3 #include <pdbcalbase/PdbApplication.h>
4 #include <pdbcalbase/PdbBankID.h>
5 #include <pdbcalbase/PdbBankManager.h>
6 #include <pdbcalbase/PdbCalBank.h>
7 #include <pdbcalbase/PdbParameterMap.h>
8 #include <pdbcalbase/PdbParameterMapContainer.h>
18 #include <TBufferXML.h>
22 #include <boost/foreach.hpp>
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
25 #include <boost/functional/hash.hpp>
26 #pragma GCC diagnostic pop
27 #include <boost/lexical_cast.hpp>
28 #include <boost/tokenizer.hpp>
30 #pragma GCC diagnostic push
31 #pragma GCC diagnostic ignored "-Wshadow"
32 #include <boost/stacktrace.hpp>
33 #pragma GCC diagnostic pop
77 std::cout <<
PHWHERE <<
" integer parameter " << name
78 <<
" does not exist (forgot to set?)" << std::endl;
79 std::cout <<
"Here is the stacktrace: " << std::endl;
80 std::cout << boost::stacktrace::stacktrace();
81 std::cout << std::endl
82 <<
"DO NOT PANIC - this is not a segfault" << std::endl;
83 std::cout <<
"Check the stacktrace for the guilty party (typically #2)" << std::endl;
99 std::cout <<
"int parameters: " << std::endl;
102 std::cout << iter.first <<
": " << iter.second << std::endl;
119 std::cout <<
PHWHERE <<
" double parameter " << name
120 <<
" does not exist (forgot to set?)" << std::endl;
121 std::cout <<
"Here is the stacktrace: " << std::endl;
122 std::cout << boost::stacktrace::stacktrace();
123 std::cout << std::endl
124 <<
"DO NOT PANIC - this is not a segfault" << std::endl;
125 std::cout <<
"Check the stacktrace for the guilty party (typically #2)" << std::endl;
142 std::cout <<
"Parameters for " <<
m_Detector << std::endl;
157 boost::hash_combine(seed, iter.first);
158 boost::hash_combine(seed, iter.second);
165 boost::hash_combine(seed, iter.first);
166 boost::hash_combine(seed, iter.second);
173 boost::hash_combine(seed, iter.first);
174 boost::hash_combine(seed, iter.second);
183 std::cout <<
"double parameters: " << std::endl;
186 std::cout << iter.first <<
": " << iter.second << std::endl;
203 std::cout <<
PHWHERE <<
" string parameter " << name
204 <<
" does not exist (forgot to set?)" << std::endl;
205 std::cout <<
"Here is the stacktrace: " << std::endl;
206 std::cout << boost::stacktrace::stacktrace();
207 std::cout << std::endl
208 <<
"DO NOT PANIC - this is not a segfault" << std::endl;
209 std::cout <<
"Check the stacktrace for the guilty party (typically #2)" << std::endl;
225 std::cout <<
"string parameters: " << std::endl;
228 std::cout << iter.first <<
": " << iter.second << std::endl;
237 std::pair<std::map<const std::string, double>::const_iterator,
238 std::map<const std::string, double>::const_iterator>
240 for (std::map<const std::string, double>::const_iterator iter = begin_end_d.first;
241 iter != begin_end_d.second; ++iter)
245 std::pair<std::map<const std::string, int>::const_iterator,
246 std::map<const std::string, int>::const_iterator>
248 for (std::map<const std::string, int>::const_iterator iter = begin_end_i.first;
249 iter != begin_end_i.second; ++iter)
253 std::pair<std::map<const std::string, std::string>::const_iterator,
254 std::map<const std::string, std::string>::const_iterator>
256 for (std::map<const std::string, std::string>::const_iterator iter = begin_end_s.first;
257 iter != begin_end_s.second; ++iter)
274 std::pair<std::map<const std::string, double>::const_iterator,
275 std::map<const std::string, double>::const_iterator>
277 for (std::map<const std::string, double>::const_iterator iter = begin_end_d.first;
278 iter != begin_end_d.second; ++iter)
282 std::pair<std::map<const std::string, int>::const_iterator,
283 std::map<const std::string, int>::const_iterator>
285 for (std::map<const std::string, int>::const_iterator iter = begin_end_i.first;
286 iter != begin_end_i.second; ++iter)
290 std::pair<std::map<const std::string, std::string>::const_iterator,
291 std::map<const std::string, std::string>::const_iterator>
293 for (std::map<const std::string, std::string>::const_iterator iter = begin_end_s.first;
294 iter != begin_end_s.second; ++iter)
326 PdbParameterMap *nodeparams = findNode::getClass<PdbParameterMap>(topNode, nodename);
331 topNode->addNode(newnode);
343 PdbParameterMap *nodeparams = findNode::getClass<PdbParameterMap>(topNode, nodename);
346 std::cout <<
PHWHERE <<
" could not find PdbParameterMap " << nodename
347 <<
" which must exist" << std::endl;
358 if (!nodeparamcontainer)
363 topNode->addNode(newnode);
382 if (!nodeparamcontainer)
384 std::cout <<
PHWHERE <<
" could not find PdbParameterMapContainer " << nodename
385 <<
" which must exist" << std::endl;
391 std::cout <<
PHWHERE <<
" could not find PdbParameterMap for detector " << detid
392 <<
" which must exist" << std::endl;
405 std::cout <<
PHWHERE <<
" Aborting, Database not writable" << std::endl;
406 application->
abort();
417 std::transform(tablename.begin(), tablename.end(), tablename.begin(), ::tolower);
419 "Geometry Parameters", TStart, TStop, tablename);
425 application->
commit(NewBank);
430 std::cout <<
PHWHERE " Committing to DB failed" << std::endl;
442 std::cout <<
PHWHERE <<
" Aborting, Database not readable" << std::endl;
443 application->
abort();
453 std::transform(tablename.begin(), tablename.end(), tablename.begin(), ::tolower);
454 PdbCalBank *NewBank = bankManager->
fetchBank(
"PdbParameterMapContainerBank", bankID, tablename, TSearch);
463 std::cout <<
PHWHERE " Reading from DB failed" << std::endl;
475 std::cout <<
PHWHERE <<
" Aborting, Database not readable" << std::endl;
476 application->
abort();
486 std::transform(tablename.begin(), tablename.end(), tablename.begin(), ::tolower);
497 std::cout <<
PHWHERE " Reading from DB failed" << std::endl;
506 TFile *
f = TFile::Open(url.c_str());
509 std::cout <<
"could not open " << url
510 <<
" for domain " << domain << std::endl;
516 std::cout <<
"could not get PdbParameterMap from " << url << std::endl;
529 TFile *
f = TFile::Open(filename.c_str(),
"recreate");
538 std::ostringstream fullpath;
539 std::ostringstream fnamestream;
545 if (*(dir.rbegin()) !=
'/')
554 std::transform(fname.begin(), fname.end(), fname.begin(), ::tolower);
557 std::cout <<
"PHParameters::WriteToFile - save to " << fullpath.str() << std::endl;
561 TFile *
f = TFile::Open(fullpath.str().c_str(),
"recreate");
564 std::string floatformat = TBufferXML::GetFloatFormat();
565 TBufferXML::SetFloatFormat(
"%.17g");
569 TBufferXML::SetFloatFormat(floatformat.c_str());
570 std::cout <<
"sleeping 1 second to prevent duplicate inserttimes" << std::endl;
579 std::ostringstream fnamestream;
580 fnamestream << name <<
"_geoparams"
583 std::transform(fileprefix.begin(), fileprefix.end(), fileprefix.begin(),
587 std::filesystem::recursive_directory_iterator diriter(targetDir), eod;
588 boost::char_separator<char> sep(
"-.");
589 std::map<unsigned int, std::string> calibfiles;
592 if (is_regular_file(i))
598 if (basename.compare(0, fileprefix.size(), fileprefix) != 0)
605 if (i.extension().string().find(extension) == std::string::npos || i.extension().string().size() != extension.size() + 1)
609 boost::tokenizer<boost::char_separator<char> > tok(basename, sep);
610 boost::tokenizer<boost::char_separator<char> >::iterator iter =
615 if (TSearch < TStart)
621 if (TSearch >= TStop)
629 if (calibfiles.empty())
631 std::cout <<
"No calibration file like " << dir <<
"/" << fileprefix <<
" found" << std::endl;
635 std::cout <<
"PHParameters::ReadFromFile - Reading from File: " << (calibfiles.rbegin())->second <<
" ... ";
637 TFile *
f = TFile::Open(fname.c_str());
645 std::cout <<
"Missing PdbParameterMapContainer Detector Id " << detid << std::endl;
649 std::cout <<
"Received PdbParameterMapContainer Detector Id " << detid <<
" with (Hash = 0x" << std::hex << myparm->
GetParameters(detid)->
get_hash() << std::dec <<
")" << std::endl;
658 std::cout <<
"Received PdbParameterMap with (Hash = 0x" << std::hex << myparm->
get_hash() << std::dec <<
")" << std::endl;
670 TFile *
f = TFile::Open(url.c_str());
680 for (std::map<const std::string, double>::const_iterator iter =
m_DoubleParMap.begin();
685 for (std::map<const std::string, int>::const_iterator iter =
m_IntParMap.begin();
690 for (std::map<const std::string, std::string>::const_iterator iter =
m_StringParMap.begin();
703 tics = boost::lexical_cast<
unsigned int>(
str);
705 catch (boost::bad_lexical_cast
const &)
707 std::cout <<
"Cannot extract timestamp from " << str << std::endl;