00001 #ifndef __EMCDB_H__ 00002 #define __EMCDB_H__ 00003 00004 #include <string> 00005 #include <vector> 00006 #ifndef __PHTIMESTAMP_H__ 00007 #include "PHTimeStamp.h" 00008 #endif 00009 #ifndef __EMCMANAGEABLE_H__ 00010 #include "emcManageable.h" 00011 #endif 00012 00013 class emcTracedFEM; 00014 class PdbCalBank; 00015 class PdbBankManager; 00016 00225 class emcDB { 00226 00227 public: 00229 emcDB(const char* dbms="Pg", 00230 const char* dbname="calibrations", 00231 bool interactive=false, PHTimeStamp* ts=0, 00232 PHTimeStamp* tsend=0); 00233 00235 ~emcDB(); 00236 00238 void Debug(bool value=true) { fDebug = value; } 00239 00241 bool Dump(const std::string fulldbname); 00243 bool Dump(const char* fulldbname) { return Dump(std::string(fulldbname)); } 00244 00245 #ifndef __CINT__ 00246 00247 int Compare(PdbCalBank& bank, const std::string& directory, 00248 const std::string& flavour); 00249 #endif 00250 00252 void MakeRunTimes(int minrunnumber); 00253 00255 void SetBankID(int bankid) { fBankID = bankid; } 00256 00258 void SetConfigurationFile(const std::string& filename) { 00259 fConfigurationFile = filename; } 00260 00262 void SetConfigurationFile(const char* filename) { 00263 SetConfigurationFile(std::string(filename)); 00264 } 00265 00267 void SetDirectories(std::vector<std::string>& directories) { 00268 fDirectories = directories; 00269 } 00270 00272 void SetEndInterval(const PHTimeStamp& endAfter, 00273 const PHTimeStamp& endBefore); 00274 00276 void SetInsertInterval(const PHTimeStamp& insertAfter, 00277 const PHTimeStamp& insertBefore); 00278 00280 void SetStartInterval(const PHTimeStamp& startAfter, 00281 const PHTimeStamp& startBefore); 00282 00284 bool Update(const std::string directory); 00285 00288 bool UpdatePbGlGains(const std::string top_directory); 00289 00291 bool UpdateInitialCalibration(const std::string top_directory); 00292 00294 bool UpdateRejectList(const std::string top_directory); 00295 00297 bool UpdateTofSectorOffset(const std::string dir, int runnumber); 00298 00300 static std::string Version(void); 00301 00302 #ifndef __CINT__ 00303 private: 00304 00305 int AbsolutePosition(const std::string& femName); 00306 00307 void Abort(const std::string& method, const std::string& message); 00308 00309 PdbBankManager* BankManager(); 00310 00311 emcManageable::EStorage destination() const; 00312 00313 void DumpContent(PdbCalBank&, int nchannels); 00314 00315 void CompareToDirectories(PdbCalBank&,const std::string&); 00316 00317 PHTimeStamp EndOfValidity(void) const; 00318 bool Error(const std::string method, const std::string message); 00319 int GetPinNumber(int absPosition); 00320 void initDBMS(const char* dbms); 00321 void ParseFileName(const std::string filename, size_t& ifem, size_t& pin); 00322 int PedestalVersion(const std::string cdir); 00323 bool Quit(void); 00324 bool ReadConfiguration(bool debug); 00325 void Split(const std::string& str, std::vector<std::string>& split); 00326 void UpdateXValue(emcTracedFEM& fem, int value); 00327 #endif 00328 00329 private: 00330 std::string fDBMS; 00331 std::string fDbname; 00332 bool fInteractive; 00333 PHTimeStamp* fForceDate; 00334 PHTimeStamp* fForceEndDate; 00335 int fBankID; 00336 bool fDebug; 00337 PHTimeStamp fInsertAfter; 00338 PHTimeStamp fInsertBefore; 00339 PHTimeStamp fStartAfter; 00340 PHTimeStamp fStartBefore; 00341 PHTimeStamp fEndAfter; 00342 PHTimeStamp fEndBefore; 00343 bool fStartIntervalGiven; 00344 bool fEndIntervalGiven; 00345 bool fInsertIntervalGiven; 00346 std::vector<std::string> fDirectories; 00347 std::string fConfigurationFile; 00348 std::vector<int> fPinNumbers; 00349 }; 00350 00351 #endif