Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
spdp::DetectorPropertiesServiceProtoDUNEsp Class Reference

#include <DetectorPropertiesServiceProtoDUNEsp.h>

Inheritance diagram for spdp::DetectorPropertiesServiceProtoDUNEsp:
detinfo::DetectorPropertiesService

Classes

struct  ServiceConfiguration_t
 

Public Types

using Parameters = art::ServiceTable< ServiceConfiguration_t >
 
- Public Types inherited from detinfo::DetectorPropertiesService
using provider_type = detinfo::DetectorProperties
 

Public Member Functions

 DetectorPropertiesServiceProtoDUNEsp (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void preProcessEvent (const art::Event &evt, art::ScheduleContext)
 
void postOpenFile (const std::string &filename)
 
void preOpenFile (const std::string &filename)
 
void preBeginRun (const art::Run &run)
 
- Public Member Functions inherited from detinfo::DetectorPropertiesService
virtual ~DetectorPropertiesService ()=default
 
DetectorPropertiesData DataForJob () const
 
DetectorPropertiesData DataForJob (detinfo::DetectorClocksData const &clockData) const
 
DetectorPropertiesData DataFor (art::Event const &e) const
 
DetectorPropertiesData DataFor (art::Event const &e, detinfo::DetectorClocksData const &clockData) const
 

Private Member Functions

bool isDetectorPropertiesServiceProtoDUNEsp (const fhicl::ParameterSet &ps) const
 
detinfo::DetectorPropertiesData getDataForJob (detinfo::DetectorClocksData const &clockData) const override
 
detinfo::DetectorPropertiesData getDataFor (art::Event const &, detinfo::DetectorClocksData const &clockData) const override
 

Private Attributes

std::unique_ptr< spdp::DetectorPropertiesProtoDUNEspfProp
 
fhicl::ParameterSet fPS
 Original parameter set. More...
 
bool isNewRun
 
bool fInheritNumberTimeSamples
 Flag saying whether to inherit NumberTimeSamples. More...
 

Detailed Description

Configuration parameters

This service passes the whole configuration down to its service provider, but it also reacts to:

Definition at line 42 of file DetectorPropertiesServiceProtoDUNEsp.h.

Member Typedef Documentation

Definition at line 63 of file DetectorPropertiesServiceProtoDUNEsp.h.

Constructor & Destructor Documentation

spdp::DetectorPropertiesServiceProtoDUNEsp::DetectorPropertiesServiceProtoDUNEsp ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)

Definition at line 31 of file DetectorPropertiesServiceProtoDUNEsp_service.cc.

32  : fInheritNumberTimeSamples(pset.get<bool>("InheritNumberTimeSamples", false))
33  {
34  // Dummy handle to ensure that the DetectorClocksService callbacks are invoked first
36 
37  // Register for callbacks.
40 
41 
42  isNewRun=true;
43 /*
44  // obtain the required dependency service providers and create our own
45  const geo::GeometryCore* geo = lar::providerFrom<geo::Geometry>();
46 
47  const detinfo::LArProperties* lp = lar::providerFrom<detinfo::LArPropertiesService>();
48 
49  const detinfo::DetectorClocks* clks = art::ServiceHandle<detinfo::DetectorClocksService const>()->;
50 
51  fProp = std::make_unique<detinfo::DetectorPropertiesStandard>(pset,geo,lp,clks);
52  */
53  fProp = std::make_unique<spdp::DetectorPropertiesProtoDUNEsp>(pset,
57  >(),
58  std::set<std::string>({ "InheritNumberTimeSamples" })
59  );
60 
61  // at this point we need and expect the provider to be fully configured
62  fProp->CheckIfConfigured();
63 
64  // Save the parameter set.
65  fPS = pset;
66 
67 
68  }
ProviderPackFromServices< Services... > extractProviders()
Returns a provider pack with providers from specified services.
Definition: ServicePack.h:54
bool fInheritNumberTimeSamples
Flag saying whether to inherit NumberTimeSamples.
fhicl::ParameterSet fPS
Original parameter set.
The geometry of one entire detector, as served by art.
Definition: Geometry.h:196
GlobalSignal< detail::SignalResponseType::FIFO, void(Run const &)> sPreBeginRun
GlobalSignal< detail::SignalResponseType::LIFO, void(std::string const &)> sPostOpenFile
std::unique_ptr< spdp::DetectorPropertiesProtoDUNEsp > fProp

Member Function Documentation

detinfo::DetectorPropertiesData spdp::DetectorPropertiesServiceProtoDUNEsp::getDataFor ( art::Event const &  ,
detinfo::DetectorClocksData const &  clockData 
) const
inlineoverrideprivatevirtual

Implements detinfo::DetectorPropertiesService.

Definition at line 88 of file DetectorPropertiesServiceProtoDUNEsp.h.

89  {
90  return fProp->DataFor(clockData);
91  }
std::unique_ptr< spdp::DetectorPropertiesProtoDUNEsp > fProp
detinfo::DetectorPropertiesData spdp::DetectorPropertiesServiceProtoDUNEsp::getDataForJob ( detinfo::DetectorClocksData const &  clockData) const
inlineoverrideprivatevirtual

Implements detinfo::DetectorPropertiesService.

Definition at line 82 of file DetectorPropertiesServiceProtoDUNEsp.h.

83  {
84  return fProp->DataFor(clockData);
85  }
std::unique_ptr< spdp::DetectorPropertiesProtoDUNEsp > fProp
bool spdp::DetectorPropertiesServiceProtoDUNEsp::isDetectorPropertiesServiceProtoDUNEsp ( const fhicl::ParameterSet ps) const
private

Definition at line 214 of file DetectorPropertiesServiceProtoDUNEsp_service.cc.

215  {
216  // This method uses heuristics to determine whether the parameter
217  // set passed as argument is a DetectorPropertiesService configuration
218  // parameter set.
219 
220  return
221  (ps.get<std::string>("service_type", "") == "DetectorPropertiesService")
222  && (ps.get<std::string>("service_provider", "") == "DetectorPropertiesServiceProtoDUNEsp")
223  ;
224 #if 0
225  // old heuristics here:
226  std::string s;
227  double d;
228  int i;
229  unsigned int u;
230 
231  bool result = !ps.get_if_present("module_label", s);
232  result = result && ps.get_if_present("TriggerOffset", i);
233  result = result && ps.get_if_present("SamplingRate", d);
234  result = result && ps.get_if_present("NumberTimeSamples", u);
235  result = result && ps.get_if_present("ReadOutWindowSize", u);
236 
237  return result;
238 #endif // 0
239  }
static QCString result
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:224
static QCString * s
Definition: config.cpp:1042
void spdp::DetectorPropertiesServiceProtoDUNEsp::postOpenFile ( const std::string filename)

Definition at line 96 of file DetectorPropertiesServiceProtoDUNEsp_service.cc.

97  {
98 
99 
100 
101 
102 
103 
104 
105 
106  // std::cout<<"new run?"<<isNewRun<<std::endl;
107  if(isNewRun){
108 
109  auto start = filename.rfind("/"); //finds the final "/"
110  if (start == std::string::npos)
111  {
112  start = 0;
113  }
114  else
115  {
116  start += 1;
117  }
118 
119  int end = filename.length(); //last postion
120  std::string filename_s=(filename.substr(start, end-start)); //creates string of just file name, not path
121  // std::cout<<"filename:"<<filename_s<<std::endl;
123  fProp->UpdateHV(filename_s); //pass file name to be able update HV value from MetaData (if requested)
125  fProp->UpdateReadoutWindowSize(clockData, filename_s); //update Readout window value from filename
126  isNewRun=false;
127 
128  }
129 
130 
131  // Use this method to figure out whether to inherit configuration
132  // parameters from previous jobs.
133  // There is no way currently to correlate parameter sets saved in
134  // sqlite RootFileDB with process history (from MetaData tree).
135  // Therefore, we use the approach of scanning every historical
136  // parameter set in RootFileDB, and finding all parameter sets
137  // that appear to be DetectorPropertiesService configurations. If all
138  // historical parameter sets are in agreement about the value of
139  // an inherited parameter, then we accept the historical value,
140  // print a message, and override the configuration parameter. In
141  // cases where the historical configurations are not in agreement
142  // about the value of an inherited parameter, we ignore any
143  // historical parameter values that are the same as the current
144  // configured value of the parameter (that is, we resolve the
145  // conflict in favor of parameters values that are different than
146  // the current configuration). If two or more historical values
147  // differ from the current configuration, throw an exception.
148  // Note that it is possible to give precendence to the current
149  // configuration by disabling inheritance for that configuration
150  // parameter.
151  // Don't do anything if no parameters are supposed to be inherited.
152  if(!fInheritNumberTimeSamples) return;
153  // The only way to access art service metadata from the input file
154  // is to open it as a separate TFile object. Do that now.
155  if(filename.size() != 0) {
156  TFile* file = TFile::Open(filename.c_str(), "READ");
157  if(file != 0 && !file->IsZombie() && file->IsOpen()) {
158  // Open the sqlite datatabase.
159  art::SQLite3Wrapper sqliteDB(file, "RootFileDB");
160  // Loop over all stored ParameterSets.
161  unsigned int iNumberTimeSamples = 0; // Combined value of NumberTimeSamples.
162  unsigned int nNumberTimeSamples = 0; // Number of NumberTimeSamples parameters seen.
163  sqlite3_stmt * stmt = 0;
164  sqlite3_prepare_v2(sqliteDB, "SELECT PSetBlob from ParameterSets;", -1, &stmt, NULL);
165  while (sqlite3_step(stmt) == SQLITE_ROW) {
166  auto ps = fhicl::ParameterSet::make(reinterpret_cast<char const *>(sqlite3_column_text(stmt, 0)));
167  // Is this a DetectorPropertiesService parameter set?
169  if(psok) {
170  // Check NumberTimeSamples
171  // if(fInheritNumberTimeSamples) {
172  unsigned int newNumberTimeSamples = ps.get<unsigned int>("NumberTimeSamples");
173 
174  // Ignore parameter values that match the current configuration.
175 
176  if(newNumberTimeSamples != fPS.get<unsigned int>("NumberTimeSamples")) {
177  if(nNumberTimeSamples == 0)
178  iNumberTimeSamples = newNumberTimeSamples;
179  else if(newNumberTimeSamples != iNumberTimeSamples) {
180  throw cet::exception(__FUNCTION__)
181  << "Historical values of NumberTimeSamples do not agree: "
182  << iNumberTimeSamples << " " << newNumberTimeSamples << "\n" ;
183  }
184  ++nNumberTimeSamples;
185  // }
186  }
187  }
188  }
189  // Done looping over parameter sets.
190  // Now decide which parameters we will actually override.
191  if(// fInheritNumberTimeSamples &&
192  nNumberTimeSamples != 0 &&
193  iNumberTimeSamples != fProp->NumberTimeSamples()) {
194  mf::LogInfo("DetectorPropertiesServiceProtoDUNEsp")
195  << "Overriding configuration parameter NumberTimeSamples using historical value.\n"
196  << " Configured value: " << fProp->NumberTimeSamples() << "\n"
197  << " Historical (used) value: " << iNumberTimeSamples << "\n";
198  fProp->SetNumberTimeSamples(iNumberTimeSamples);
199  }
200  }
201  // Close file.
202  if(file != 0) {
203  if(file->IsOpen())
204  file->Close();
205  delete file;
206  }
207  }
208 
209  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::string string
Definition: nybbler.cc:12
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
struct sqlite3_stmt sqlite3_stmt
string filename
Definition: train.py:213
bool fInheritNumberTimeSamples
Flag saying whether to inherit NumberTimeSamples.
fhicl::ParameterSet fPS
Original parameter set.
T get(std::string const &key) const
Definition: ParameterSet.h:271
DetectorPropertiesData DataForJob() const
static constexpr double ps
Definition: Units.h:99
bool isDetectorPropertiesServiceProtoDUNEsp(const fhicl::ParameterSet &ps) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::unique_ptr< spdp::DetectorPropertiesProtoDUNEsp > fProp
void spdp::DetectorPropertiesServiceProtoDUNEsp::preBeginRun ( const art::Run run)

Definition at line 79 of file DetectorPropertiesServiceProtoDUNEsp_service.cc.

80  {
81  isNewRun=true;
82  std::cout<<"New run, Num is: "<<run.run()<<" Updating DetectorProperties."<<std::endl;
83  // make it into a TTimeStamp
84 
85  //Get run dependent temperature correction
86 
87  // Before 11/17/18, temperature = 87.68 and is stable
88  // Between 11/17/18 and 3/1/19, temperature = 87.36 and has a rather large fluctuation. first run in this period 5903
89  // After 3/1/19, temperature = 87.65 and is stable. first run 6930
90  fProp->UpdateTemp(run.run());
91  }
RunNumber_t run() const
Definition: DataViewImpl.cc:71
QTextStream & endl(QTextStream &s)
std::unique_ptr< spdp::DetectorPropertiesProtoDUNEsp > fProp
void spdp::DetectorPropertiesServiceProtoDUNEsp::preOpenFile ( const std::string filename)
void spdp::DetectorPropertiesServiceProtoDUNEsp::preProcessEvent ( const art::Event evt,
art::ScheduleContext   
)
void spdp::DetectorPropertiesServiceProtoDUNEsp::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 70 of file DetectorPropertiesServiceProtoDUNEsp_service.cc.

71  {
72  fProp->ValidateAndConfigure(p, { "InheritNumberTimeSamples" });
73 
74  // Save the parameter set.
75  fPS = p;
76  return;
77  }
fhicl::ParameterSet fPS
Original parameter set.
p
Definition: test.py:223
std::unique_ptr< spdp::DetectorPropertiesProtoDUNEsp > fProp

Member Data Documentation

bool spdp::DetectorPropertiesServiceProtoDUNEsp::fInheritNumberTimeSamples
private

Flag saying whether to inherit NumberTimeSamples.

Definition at line 77 of file DetectorPropertiesServiceProtoDUNEsp.h.

std::unique_ptr<spdp::DetectorPropertiesProtoDUNEsp> spdp::DetectorPropertiesServiceProtoDUNEsp::fProp
private

Definition at line 74 of file DetectorPropertiesServiceProtoDUNEsp.h.

fhicl::ParameterSet spdp::DetectorPropertiesServiceProtoDUNEsp::fPS
private

Original parameter set.

Definition at line 75 of file DetectorPropertiesServiceProtoDUNEsp.h.

bool spdp::DetectorPropertiesServiceProtoDUNEsp::isNewRun
private

Definition at line 76 of file DetectorPropertiesServiceProtoDUNEsp.h.


The documentation for this class was generated from the following files: