3 #include <pdbcalbase/PdbBankManager.h>
4 #include <pdbcalbase/PdbApplication.h>
5 #include <pdbcalbase/PdbBankList.h>
6 #include <pdbcalbase/PdbCalBank.h>
7 #include <pdbcalbase/PdbParameterMap.h>
8 #include <pdbcalbase/PdbParameterMapContainer.h>
15 #include <TBufferXML.h>
18 #include <TBufferFile.h>
21 #include <boost/foreach.hpp>
22 #include <boost/tokenizer.hpp>
23 #include <boost/functional/hash.hpp>
28 #include <boost/version.hpp>
29 #if (__GNUC__ == 4 && __GNUC_MINOR__ == 4 && BOOST_VERSION == 105700 )
30 #pragma GCC diagnostic ignored "-Wuninitialized"
31 #pragma message "ignoring bogus gcc warning in boost header lexical_cast.hpp"
32 #include <boost/lexical_cast.hpp>
33 #pragma GCC diagnostic warning "-Wuninitialized"
35 #include <boost/lexical_cast.hpp>
56 intparams[name] = ival;
62 if (intparams.find(name) != intparams.end())
64 return intparams.find(name)->second;
66 cout <<
PHWHERE <<
" integer parameter " << name
67 <<
" does not exist (forgot to set?)" << endl;
75 if (intparams.find(name) != intparams.end())
85 cout <<
"int parameters: " << endl;
86 for (map<const string, int>::const_iterator iter = intparams.begin();
87 iter != intparams.end(); ++iter)
89 cout << iter->first <<
": " << iter->second << endl;
97 doubleparams[name] = dval;
103 if (doubleparams.find(name) != doubleparams.end())
105 return doubleparams.find(name)->second;
107 cout <<
PHWHERE <<
" double parameter " << name
108 <<
" does not exist (forgot to set?)" << endl;
116 if (doubleparams.find(name) != doubleparams.end())
127 cout <<
"Parameters for " << detname << endl;
139 for (dMap::const_iterator iter = doubleparams.begin();
140 iter != doubleparams.end(); ++iter)
143 boost::hash_combine(seed, iter->first );
144 boost::hash_combine(seed, iter->second );
148 for (iMap::const_iterator iter = intparams.begin();
149 iter != intparams.end(); ++iter)
152 boost::hash_combine(seed, iter->first );
153 boost::hash_combine(seed, iter->second );
157 for (strMap::const_iterator iter = stringparams.begin();
158 iter != stringparams.end(); ++iter)
161 boost::hash_combine(seed, iter->first );
162 boost::hash_combine(seed, iter->second );
174 cout <<
"double parameters: " << endl;
175 for (map<const string, double>::const_iterator iter = doubleparams.begin();
176 iter != doubleparams.end(); ++iter)
178 cout << iter->first <<
": " << iter->second << endl;
186 stringparams[name] = str;
192 if (stringparams.find(name) != stringparams.end())
194 return stringparams.find(name)->second;
196 cout <<
PHWHERE <<
" string parameter " << name
197 <<
" does not exist (forgot to set?)" << endl;
205 if (stringparams.find(name) != stringparams.end())
215 cout <<
"string parameters: " << endl;
216 for (map<const string, string>::const_iterator iter = stringparams.begin();
217 iter != stringparams.end(); ++iter)
219 cout << iter->first <<
": " << iter->second << endl;
229 pair<std::map<const std::string, double>::const_iterator,
230 std::map<const std::string, double>::const_iterator> begin_end_d =
232 for (map<const std::string, double>::const_iterator iter = begin_end_d.first;
233 iter != begin_end_d.second; ++iter)
235 doubleparams[iter->first] = iter->second;
237 pair<std::map<const std::string, int>::const_iterator,
238 std::map<const std::string, int>::const_iterator> begin_end_i =
240 for (map<const std::string, int>::const_iterator iter = begin_end_i.first;
241 iter != begin_end_i.second; ++iter)
243 intparams[iter->first] = iter->second;
245 pair<std::map<const std::string, string>::const_iterator,
246 std::map<const std::string, string>::const_iterator> begin_end_s =
248 for (map<const std::string, string>::const_iterator iter = begin_end_s.first;
249 iter != begin_end_s.second; ++iter)
251 stringparams[iter->first] = iter->second;
267 pair<std::map<const std::string, double>::const_iterator,
268 std::map<const std::string, double>::const_iterator> begin_end_d =
270 for (map<const std::string, double>::const_iterator iter = begin_end_d.first;
271 iter != begin_end_d.second; ++iter)
273 doubleparams[iter->first] = iter->second;
275 pair<std::map<const std::string, int>::const_iterator,
276 std::map<const std::string, int>::const_iterator> begin_end_i =
278 for (map<const std::string, int>::const_iterator iter = begin_end_i.first;
279 iter != begin_end_i.second; ++iter)
281 intparams[iter->first] = iter->second;
283 pair<std::map<const std::string, string>::const_iterator,
284 std::map<const std::string, string>::const_iterator> begin_end_s =
286 for (map<const std::string, string>::const_iterator iter = begin_end_s.first;
287 iter != begin_end_s.second; ++iter)
289 stringparams[iter->first] = iter->second;
300 for (dMap::const_iterator iter = saveparams->
doubleparams.begin();
302 doubleparams[iter->first] = iter->second;
304 for (iMap::const_iterator iter = saveparams->
intparams.begin();
305 iter != saveparams->
intparams.end(); ++iter)
306 intparams[iter->first] = iter->second;
308 for (strMap::const_iterator iter = saveparams->
stringparams.begin();
310 stringparams[iter->first] = iter->second;
319 PdbParameterMap *nodeparams = findNode::getClass<PdbParameterMap>(topNode,
332 CopyToPdbParameterMap(nodeparams);
341 if (!nodeparamcontainer)
358 CopyToPdbParameterMap(nodeparams);
369 cout <<
PHWHERE <<
" Aborting, Database not writable" << endl;
370 application->
abort();
379 string tablename = detname +
"_geoparams";
380 std::transform(tablename.begin(), tablename.end(), tablename.begin(),
383 "Geometry Parameters", TStart, TStop, tablename);
388 CopyToPdbParameterMap(myparm);
389 application->
commit(NewBank);
394 cout <<
PHWHERE " Committing to DB failed" << endl;
407 cout <<
PHWHERE <<
" Aborting, Database not readable" << endl;
408 application->
abort();
416 string tablename = name +
"_geoparams";
417 std::transform(tablename.begin(), tablename.end(), tablename.begin(),
424 FillFrom(myparm,layer);
429 cout <<
PHWHERE " Reading from DB failed" << endl;
442 cout <<
PHWHERE <<
" Aborting, Database not readable" << endl;
443 application->
abort();
451 string tablename = detname +
"_geoparams";
452 std::transform(tablename.begin(), tablename.end(), tablename.begin(),
464 cout <<
PHWHERE " Reading from DB failed" << endl;
605 for (map<const string, double>::const_iterator iter = doubleparams.begin();
606 iter != doubleparams.end(); ++iter)
610 for (map<const string, int>::const_iterator iter = intparams.begin();
611 iter != intparams.end(); ++iter)
615 for (map<const string, string>::const_iterator iter = stringparams.begin();
616 iter != stringparams.end(); ++iter)
628 tics = boost::lexical_cast<unsigned int>(str);
630 catch (boost::bad_lexical_cast
const&)
632 cout <<
"Cannot extract timestamp from " << str << endl;
PHBoolean addNode(PHNode *)
PHG4Parameters(const std::string &name)
void set_double_param(const std::string &name, const double dval)
size_t get_hash() const
hash of binary information for checking purpose
bool exist_string_param(const std::string &name) const
std::string get_string_param(const std::string &name) const
void SaveToNodeTree(PHCompositeNode *topNode, const std::string &nodename)
void set_int_param(const std::string &name, const int ival)
void CopyToPdbParameterMap(PdbParameterMap *myparm)
double get_double_param(const std::string &name) const
bool exist_int_param(const std::string &name) const
void FillFrom(const PdbParameterMap *saveparams)
void set_string_param(const std::string &name, const std::string &str)
bool exist_double_param(const std::string &name) const
int get_int_param(const std::string &name) const
unsigned int ConvertStringToUint(const std::string &str) const
virtual PdbStatus startRead()=0
virtual PdbStatus abort()=0
virtual PdbStatus commit()=0
virtual PdbStatus startUpdate()=0
virtual PdbCalBank * fetchBank(const std::string &, PdbBankID, const std::string &, const int)=0
static PdbBankManager * instance()
virtual PdbApplication * getApplication()=0
virtual PdbCalBank * createBank(const std::string &, PdbBankID, const std::string &, PHTimeStamp &, PHTimeStamp &, const std::string &)=0
virtual void setLength(size_t val)=0
virtual PdbCalChan & getEntry(size_t)=0
void AddPdbParameterMap(const int layer, PdbParameterMap *params)
PdbParameterMap * GetParametersToModify(const int layer)
const PdbParameterMap * GetParameters(const int layer) const
iConstRange get_iparam_iters() const
dConstRange get_dparam_iters() const
strConstRange get_cparam_iters() const
void set_double_param(const std::string &name, const double dval)
void set_int_param(const std::string &name, const int ival)
void set_string_param(const std::string &name, const std::string &str)