5 #include <pdbcalbase/PdbParameterMap.h>
6 #include <pdbcalbase/PdbParameterMapContainer.h>
15 #include <boost/format.hpp>
24 , paramscontainer(nullptr)
32 , superdetector(
"NONE")
38 nam << name <<
"_" << lyr;
39 Name(nam.str().c_str());
44 savetopNode = topNode;
56 string g4geonodename =
"G4GEO_";
57 string paramnodename =
"G4GEOPARAM_";
59 int isSuperDetector = 0;
60 if (superdetector !=
"NONE")
63 paramscontainer = findNode::getClass<PHG4ParametersContainer>(parNode, g4geonodename);
76 paramnodename += superdetector;
77 calibdetname = superdetector;
83 g4geonodename += paramscontainer->
Name();
85 paramnodename += paramscontainer->
Name();
86 calibdetname = paramscontainer->
Name();
96 paramscontainer_default->
clear();
97 delete paramscontainer_default;
98 paramscontainer_default =
nullptr;
123 paramscontainer->
FillFrom(nodeparams);
131 if (superdetector !=
"NONE")
146 cout <<
Name() << endl;
149 beginrunexecuted = 1;
155 superdetector = name;
161 map<int, map<const std::string, double>>::const_iterator iter = default_double.find(detid);
162 if (iter == default_double.end())
164 cout <<
"detid " << detid <<
" not implemented" << endl;
165 cout <<
"implemented detector ids: " << endl;
166 for (map<
int, map<const std::string, double>>::const_iterator iter2 = default_double.begin(); iter2 != default_double.end(); ++iter2)
168 cout <<
"detid: " << iter2->first << endl;
172 if (iter->second.find(name) == iter->second.end())
174 cout <<
"double parameter " << name <<
" not implemented" << endl;
175 cout <<
"implemented double parameters are:" << endl;
176 for (map<const string, double>::const_iterator iter3 = iter->second.begin(); iter3 != iter->second.end(); ++iter3)
178 cout << iter3->first << endl;
184 map<int, map<const std::string, double>>::iterator dmapiter = dparams.find(detid);
185 if (dmapiter == dparams.end())
187 map<const std::string, double> newdmap;
188 newdmap[name] = dval;
189 dparams[detid] = newdmap;
193 dmapiter->second[name] = dval;
206 map<int, map<const std::string, int>>::const_iterator iter = default_int.find(detid);
207 if (iter == default_int.end())
209 cout <<
"detid " << detid <<
" not implemented" << endl;
210 cout <<
"implemented detector ids: " << endl;
211 for (map<
int, map<const std::string, int>>::const_iterator iter2 = default_int.begin(); iter2 != default_int.end(); ++iter2)
213 cout <<
"detid: " << iter2->first << endl;
217 if (iter->second.find(name) == iter->second.end())
219 cout <<
"int parameter " << name <<
" not implemented" << endl;
220 cout <<
"implemented int parameters are:" << endl;
221 for (map<const string, int>::const_iterator iter3 = iter->second.begin(); iter3 != iter->second.end(); ++iter3)
223 cout << iter3->first << endl;
229 map<int, map<const std::string, int>>::iterator imapiter = iparams.find(detid);
230 if (imapiter == iparams.end())
232 map<const std::string, int> newdmap;
233 newdmap[name] = ival;
234 iparams[detid] = newdmap;
238 imapiter->second[name] = ival;
249 map<int, map<const std::string, string>>::const_iterator iter = default_string.find(detid);
250 if (iter == default_string.end())
252 cout <<
"detid " << detid <<
" not implemented" << endl;
253 cout <<
"implemented detector ids: " << endl;
254 for (map<
int, map<const std::string, string>>::const_iterator iter2 = default_string.begin(); iter2 != default_string.end(); ++iter2)
256 cout <<
"detid: " << iter2->first << endl;
260 if (iter->second.find(name) == iter->second.end())
262 cout <<
"string parameter " << name <<
" not implemented" << endl;
263 cout <<
"implemented string parameters are:" << endl;
264 for (map<const string, string>::const_iterator iter3 = iter->second.begin(); iter3 != iter->second.end(); ++iter3)
266 cout << iter3->first << endl;
272 map<int, map<const std::string, string>>::iterator smapiter = cparams.find(detid);
273 if (smapiter == cparams.end())
275 map<const std::string, string> newdmap;
276 newdmap[name] = sval;
277 cparams[detid] = newdmap;
281 smapiter->second[name] = sval;
294 map<int, map<const std::string, double>>::const_iterator iter;
295 for (iter = dparams.begin(); iter != dparams.end(); ++iter)
297 map<const std::string, double>::const_iterator diter;
298 for (diter = iter->second.begin(); diter != iter->second.end(); ++diter)
303 map<int, map<const std::string, int>>::const_iterator iiter;
304 for (iiter = iparams.begin(); iiter != iparams.end(); ++iiter)
308 map<const std::string, int>::const_iterator iiter2;
309 for (iiter2 = iiter->second.begin(); iiter2 != iiter->second.end(); ++iiter2)
314 map<int, map<const std::string, string>>::const_iterator siter;
315 for (siter = cparams.begin(); siter != cparams.end(); ++siter)
317 map<const std::string, string>::const_iterator siter2;
318 for (siter2 = siter->second.begin(); siter2 != siter->second.end(); ++siter2)
328 map<int, map<const std::string, double>>::iterator dmapiter = default_double.find(detid);
329 if (dmapiter == default_double.end())
331 map<const std::string, double> newdmap;
332 newdmap[name] = dval;
333 default_double[detid] = newdmap;
337 if (dmapiter->second.find(name) != dmapiter->second.end())
339 cout <<
"trying to overwrite default double " << name <<
" "
340 << dmapiter->second.find(name)->second <<
" with " << dval << endl;
345 dmapiter->second[name] = dval;
353 map<int, map<const std::string, int>>::iterator imapiter = default_int.find(detid);
354 if (imapiter == default_int.end())
356 map<const std::string, int> newimap;
357 newimap[name] = ival;
358 default_int[detid] = newimap;
362 if (imapiter->second.find(name) != imapiter->second.end())
364 cout <<
"trying to overwrite default int " << name <<
" "
365 << imapiter->second.find(name)->second <<
" with " << ival << endl;
370 imapiter->second[name] = ival;
378 map<int, map<const std::string, string>>::iterator smapiter = default_string.find(detid);
379 if (smapiter == default_string.end())
381 map<const std::string, string> newsmap;
382 newsmap[name] = sval;
383 default_string[detid] = newsmap;
387 if (smapiter->second.find(name) != smapiter->second.end())
389 cout <<
"trying to overwrite default string " << name <<
" "
390 << smapiter->second.find(name)->second <<
" with " << sval << endl;
395 smapiter->second[name] = sval;
403 for (set<int>::const_iterator iter = layers.begin(); iter != layers.end(); ++iter)
411 map<int, map<const string, double>>::const_iterator diter;
412 for (diter = default_double.begin(); diter != default_double.end(); ++diter)
417 detidparams =
new PHG4Parameters(boost::str(boost::format(
"%s_%d") %
Name() % diter->first));
420 map<const string, double>::const_iterator diter2;
421 for (diter2 = diter->second.begin(); diter2 != diter->second.end(); ++diter2)
427 map<int, map<const string, int>>::const_iterator iiter;
428 for (iiter = default_int.begin(); iiter != default_int.end(); ++iiter)
433 detidparams =
new PHG4Parameters(boost::str(boost::format(
"%s_%d") %
Name() % iiter->first));
436 map<const string, int>::const_iterator iiter2;
437 for (iiter2 = iiter->second.begin(); iiter2 != iiter->second.end(); ++iiter2)
443 map<int, map<const string, string>>::const_iterator siter;
444 for (siter = default_string.begin(); siter != default_string.end(); ++siter)
449 detidparams =
new PHG4Parameters(boost::str(boost::format(
"%s_%d") %
Name() % siter->first));
452 map<const string, string>::const_iterator siter2;
453 for (siter2 = siter->second.begin(); siter2 != siter->second.end(); ++siter2)
463 assert(paramscontainer);
467 cout <<
"problem committing to DB" << endl;
485 cout <<
"problem reading from DB" << endl;
502 cout <<
PHWHERE <<
"filetype " << ftyp <<
" not implemented" << endl;
506 assert(paramscontainer);
507 iret = paramscontainer->
WriteToFile(extension, calibfiledir);
510 cout <<
"problem saving to " << extension <<
" file " << endl;
527 cout <<
PHWHERE <<
"filetype " << ftyp <<
" not implemented" << endl;
534 cout <<
"problem reading from " << extension <<
" file " << endl;
561 cout <<
"Default Parameters: " << endl;
562 cout <<
"int values: " << endl;
563 map<int, map<const std::string, int>>::const_iterator iiter;
564 for (iiter = default_int.begin(); iiter != default_int.end(); ++iiter)
566 cout <<
"Detector id: " << iiter->first << endl;
567 map<const string, int>::const_iterator iiter2;
568 for (iiter2 = iiter->second.begin(); iiter2 != iiter->second.end(); ++iiter2)
570 cout << iiter2->first <<
": " << iiter2->second << endl;
573 cout <<
"double values: " << endl;
574 map<int, map<const std::string, double>>::const_iterator diter;
575 for (diter = default_double.begin(); diter != default_double.end(); ++diter)
577 cout <<
"Detector id: " << diter->first << endl;
578 map<const string, double>::const_iterator diter2;
579 for (diter2 = diter->second.begin(); diter2 != diter->second.end(); ++diter2)
581 cout << diter2->first <<
": " << diter2->second << endl;
584 cout <<
"string values: " << endl;
585 map<int, map<const std::string, string>>::const_iterator siter;
586 for (siter = default_string.begin(); siter != default_string.end(); ++siter)
588 cout <<
"Detector id: " << siter->first << endl;
589 map<const string, string>::const_iterator siter2;
590 for (siter2 = siter->second.begin(); siter2 != siter->second.end(); ++siter2)
592 cout << siter2->first <<
": " << siter2->second << endl;
600 cout <<
"Macro Parameters: " << endl;
601 cout <<
"int values: " << endl;
602 map<int, map<const std::string, int>>::const_iterator iiter;
603 for (iiter = iparams.begin(); iiter != iparams.end(); ++iiter)
605 cout <<
"Detector id: " << iiter->first << endl;
606 map<const string, int>::const_iterator iiter2;
607 for (iiter2 = iiter->second.begin(); iiter2 != iiter->second.end(); ++iiter2)
609 cout << iiter2->first <<
": " << iiter2->second << endl;
612 cout <<
"double values: " << endl;
613 map<int, map<const std::string, double>>::const_iterator diter;
614 for (diter = dparams.begin(); diter != dparams.end(); ++diter)
616 cout <<
"Detector id: " << diter->first << endl;
617 map<const string, double>::const_iterator diter2;
618 for (diter2 = diter->second.begin(); diter2 != diter->second.end(); ++diter2)
620 cout << diter2->first <<
": " << diter2->second << endl;
623 cout <<
"string values: " << endl;
624 map<int, map<const std::string, string>>::const_iterator siter;
625 for (siter = cparams.begin(); siter != cparams.end(); ++siter)
627 cout <<
"Detector id: " << siter->first << endl;
628 map<const string, string>::const_iterator siter2;
629 for (siter2 = siter->second.begin(); siter2 != siter->second.end(); ++siter2)
631 cout << siter2->first <<
": " << siter2->second << endl;
virtual const std::string Name() const
Returns the name of this module.
virtual int Verbosity() const
Gets the verbosity of this module.
PHBoolean addNode(PHNode *)
void PrintDefaultParams() const
FILE_TYPE get_filetype() const
int ReadParamsFromDB(const std::string &name, const int issuper)
void UpdateParametersWithMacro()
void set_double_param(const int detid, const std::string &name, const double dval)
int SaveParamsToFile(const FILE_TYPE ftyp)
void BlackHole(const int detid, const int i=1)
void SetAbsorberTruth(const int detid, const int i=1)
double get_double_param(const int detid, const std::string &name) const
void set_int_param(const int detid, const std::string &name, const int ival)
void SetAbsorberActive(const int detid, const int i=1)
const std::string SuperDetector() const
virtual void SetDefaultParameters()=0
void set_default_double_param(const int detid, const std::string &name, const double dval)
PHG4DetectorGroupSubsystem(const std::string &name="GenericSubsystem", const int lyr=0)
int get_int_param(const int detid, const std::string &name) const
PHG4ParametersContainer * GetParamsContainer() const
void InitializeParameters()
int InitRun(PHCompositeNode *) final
int ReadParamsFromFile(const std::string &name, const FILE_TYPE ftyp, const int issuper)
void set_default_int_param(const int detid, const std::string &name, const int ival)
std::string get_string_param(const int detid, const std::string &name) const
virtual int InitRunSubsystem(PHCompositeNode *)
void SetActive(const int detid, const int i=1)
void set_default_string_param(const int detid, const std::string &name, const std::string &sval)
void set_string_param(const int detid, const std::string &name, const std::string &sval)
virtual int InitSubsystem(PHCompositeNode *)
int Init(PHCompositeNode *) final
void PrintMacroParams() const
Map::const_iterator ConstIterator
void set_name(const std::string &name)
int WriteToFile(const std::string &extension, const std::string &dir)
void AddPHG4Parameters(const int layer, PHG4Parameters *params)
ConstRange GetAllParameters() const
const PHG4Parameters * GetParameters(const int layer) const
std::pair< ConstIterator, ConstIterator > ConstRange
void FillFrom(const PdbParameterMapContainer *saveparamcontainer)
void SaveToNodeTree(PHCompositeNode *topNode, const std::string &nodename)
PHG4Parameters * GetParametersToModify(const int layer)
void set_double_param(const std::string &name, const double dval)
std::string get_string_param(const std::string &name) const
void set_int_param(const std::string &name, const int ival)
double get_double_param(const std::string &name) const
void set_string_param(const std::string &name, const std::string &str)
int get_int_param(const std::string &name) const
PHNode * findFirst(const std::string &, const std::string &)
void set_int_param(const std::string &name, const int ival)