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())
126 vdoubleparams[name] = dval;
132 if (vdoubleparams.find(name) != vdoubleparams.end())
134 return vdoubleparams.find(name)->second;
136 cout <<
PHWHERE <<
" vdouble parameter " << name
137 <<
" does not exist (forgot to set?)" << endl;
145 if (vdoubleparams.find(name) != vdoubleparams.end())
156 cout <<
"Parameters for " << detname << endl;
168 for (dMap::const_iterator iter = doubleparams.begin();
169 iter != doubleparams.end(); ++iter)
172 boost::hash_combine(seed, iter->first );
173 boost::hash_combine(seed, iter->second );
177 for (iMap::const_iterator iter = intparams.begin();
178 iter != intparams.end(); ++iter)
181 boost::hash_combine(seed, iter->first );
182 boost::hash_combine(seed, iter->second );
186 for (strMap::const_iterator iter = stringparams.begin();
187 iter != stringparams.end(); ++iter)
190 boost::hash_combine(seed, iter->first );
191 boost::hash_combine(seed, iter->second );
203 cout <<
"double parameters: " << endl;
204 for (map<const string, double>::const_iterator iter = doubleparams.begin();
205 iter != doubleparams.end(); ++iter)
207 cout << iter->first <<
": " << iter->second << endl;
215 stringparams[name] = str;
221 if (stringparams.find(name) != stringparams.end())
223 return stringparams.find(name)->second;
225 cout <<
PHWHERE <<
" string parameter " << name
226 <<
" does not exist (forgot to set?)" << endl;
234 if (stringparams.find(name) != stringparams.end())
244 cout <<
"string parameters: " << endl;
245 for (map<const string, string>::const_iterator iter = stringparams.begin();
246 iter != stringparams.end(); ++iter)
248 cout << iter->first <<
": " << iter->second << endl;
258 pair<std::map<const std::string, double>::const_iterator,
259 std::map<const std::string, double>::const_iterator> begin_end_d =
261 for (map<const std::string, double>::const_iterator iter = begin_end_d.first;
262 iter != begin_end_d.second; ++iter)
264 doubleparams[iter->first] = iter->second;
266 pair<std::map<const std::string, int>::const_iterator,
267 std::map<const std::string, int>::const_iterator> begin_end_i =
269 for (map<const std::string, int>::const_iterator iter = begin_end_i.first;
270 iter != begin_end_i.second; ++iter)
272 intparams[iter->first] = iter->second;
274 pair<std::map<const std::string, string>::const_iterator,
275 std::map<const std::string, string>::const_iterator> begin_end_s =
277 for (map<const std::string, string>::const_iterator iter = begin_end_s.first;
278 iter != begin_end_s.second; ++iter)
280 stringparams[iter->first] = iter->second;
296 pair<std::map<const std::string, double>::const_iterator,
297 std::map<const std::string, double>::const_iterator> begin_end_d =
299 for (map<const std::string, double>::const_iterator iter = begin_end_d.first;
300 iter != begin_end_d.second; ++iter)
302 doubleparams[iter->first] = iter->second;
304 pair<std::map<const std::string, int>::const_iterator,
305 std::map<const std::string, int>::const_iterator> begin_end_i =
307 for (map<const std::string, int>::const_iterator iter = begin_end_i.first;
308 iter != begin_end_i.second; ++iter)
310 intparams[iter->first] = iter->second;
312 pair<std::map<const std::string, string>::const_iterator,
313 std::map<const std::string, string>::const_iterator> begin_end_s =
315 for (map<const std::string, string>::const_iterator iter = begin_end_s.first;
316 iter != begin_end_s.second; ++iter)
318 stringparams[iter->first] = iter->second;
329 for (dMap::const_iterator iter = saveparams->
doubleparams.begin();
331 doubleparams[iter->first] = iter->second;
333 for (iMap::const_iterator iter = saveparams->
intparams.begin();
334 iter != saveparams->
intparams.end(); ++iter)
335 intparams[iter->first] = iter->second;
337 for (strMap::const_iterator iter = saveparams->
stringparams.begin();
339 stringparams[iter->first] = iter->second;
348 PdbParameterMap *nodeparams = findNode::getClass<PdbParameterMap>(topNode,
361 CopyToPdbParameterMap(nodeparams);
370 if (!nodeparamcontainer)
387 CopyToPdbParameterMap(nodeparams);
398 cout <<
PHWHERE <<
" Aborting, Database not writable" << endl;
399 application->
abort();
408 string tablename = detname +
"_geoparams";
409 std::transform(tablename.begin(), tablename.end(), tablename.begin(),
412 "Geometry Parameters", TStart, TStop, tablename);
417 CopyToPdbParameterMap(myparm);
418 application->
commit(NewBank);
423 cout <<
PHWHERE " Committing to DB failed" << endl;
436 cout <<
PHWHERE <<
" Aborting, Database not readable" << endl;
437 application->
abort();
445 string tablename = name +
"_geoparams";
446 std::transform(tablename.begin(), tablename.end(), tablename.begin(),
453 FillFrom(myparm,layer);
458 cout <<
PHWHERE " Reading from DB failed" << endl;
471 cout <<
PHWHERE <<
" Aborting, Database not readable" << endl;
472 application->
abort();
480 string tablename = detname +
"_geoparams";
481 std::transform(tablename.begin(), tablename.end(), tablename.begin(),
493 cout <<
PHWHERE " Reading from DB failed" << endl;
634 for (map<const string, double>::const_iterator iter = doubleparams.begin();
635 iter != doubleparams.end(); ++iter)
639 for (map<const string, int>::const_iterator iter = intparams.begin();
640 iter != intparams.end(); ++iter)
644 for (map<const string, string>::const_iterator iter = stringparams.begin();
645 iter != stringparams.end(); ++iter)
657 tics = boost::lexical_cast<unsigned int>(str);
659 catch (boost::bad_lexical_cast
const&)
661 cout <<
"Cannot extract timestamp from " << str << endl;
PHBoolean addNode(PHNode *)
bool exist_vdouble_param(const std::string &name) const
void set_string_param(const std::string &name, const std::string &str)
double get_double_param(const std::string &name) const
void CopyToPdbParameterMap(PdbParameterMap *myparm)
int get_int_param(const std::string &name) const
void FillFrom(const PdbParameterMap *saveparams)
void set_int_param(const std::string &name, const int ival)
void set_double_param(const std::string &name, const double dval)
PHParameters(const std::string &name)
void SaveToNodeTree(PHCompositeNode *topNode, const std::string &nodename)
std::string get_string_param(const std::string &name) const
unsigned int ConvertStringToUint(const std::string &str) const
bool exist_int_param(const std::string &name) const
std::vector< double > vdouble
void set_vdouble_param(const std::string &name, const vdouble vdval)
size_t get_hash() const
hash of binary information for checking purpose
bool exist_string_param(const std::string &name) const
vdouble get_vdouble_param(const std::string &name) const
bool exist_double_param(const std::string &name) 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)