CMS 3D CMS Logo

ConditionDBWriter< T > Class Template Reference

#include <CommonTools/ConditionDBWriter/interface/ConditionDBWriter.h>

Inheritance diagram for ConditionDBWriter< T >:

edm::EDAnalyzer

List of all members.

Public Member Functions

 ConditionDBWriter (const edm::ParameterSet &iConfig)
virtual ~ConditionDBWriter ()

Protected Member Functions

void storeOnDbNow ()
cond::Time_t timeOfLastIOV ()

Private Member Functions

virtual void algoAnalyze (const edm::Event &, const edm::EventSetup &)
virtual void algoBeginJob (const edm::EventSetup &)
virtual void algoBeginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &)
virtual void algoBeginRun (const edm::Run &, const edm::EventSetup &)
virtual void algoEndJob ()
virtual void algoEndLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &)
virtual void algoEndRun (const edm::Run &, const edm::EventSetup &)
void analyze (const edm::Event &event, const edm::EventSetup &iSetup)
void beginJob (const edm::EventSetup &iSetup)
void beginLuminosityBlock (const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
void beginRun (const edm::Run &run, const edm::EventSetup &es)
void endJob ()
void endLuminosityBlock (const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &es)
void endRun (const edm::Run &run, const edm::EventSetup &es)
virtual T * getNewObject ()=0
void setTime ()
void storeOnDb (T *objPointer)

Private Attributes

bool AlgoDrivenMode_
bool doStore_
bool JobMode_
bool LumiBlockMode_
std::string Record_
bool RunMode_
bool setSinceTime_
bool SinceAppendMode_
cond::Time_t Time_


Detailed Description

template<class T>
class ConditionDBWriter< T >

Definition at line 162 of file ConditionDBWriter.h.


Constructor & Destructor Documentation

template<class T>
ConditionDBWriter< T >::ConditionDBWriter ( const edm::ParameterSet iConfig  )  [inline, explicit]

Definition at line 166 of file ConditionDBWriter.h.

00166                                                              : LumiBlockMode_(false), RunMode_(false), JobMode_(false), AlgoDrivenMode_(false), Time_(0), setSinceTime_(false) {
00167 
00168     edm::LogInfo("ConditionDBWriter::ConditionDBWriter()") << std::endl;
00169     SinceAppendMode_=iConfig.getParameter<bool>("SinceAppendMode");
00170     std::string IOVMode=iConfig.getParameter<std::string>("IOVMode");
00171     if (IOVMode==std::string("Job")) JobMode_=true;
00172     else if (IOVMode==std::string("Run")) RunMode_=true;
00173     else if (IOVMode==std::string("LumiBlock")) LumiBlockMode_=true;
00174     else if (IOVMode==std::string("AlgoDriven")) AlgoDrivenMode_=true;
00175     else  edm::LogError("ConditionDBWriter::ConditionDBWriter(): ERROR - unknown IOV interval write mode...will not store anything on the DB") << std::endl;
00176     Record_=iConfig.getParameter<std::string>("Record");
00177     doStore_=iConfig.getParameter<bool>("doStoreOnDB");
00178 
00179 
00180   }

template<class T>
virtual ConditionDBWriter< T >::~ConditionDBWriter (  )  [inline, virtual]

Definition at line 183 of file ConditionDBWriter.h.

00183                               {
00184   
00185     edm::LogInfo("ConditionDBWriter::~ConditionDBWriter()") << std::endl;
00186 
00187   }


Member Function Documentation

template<class T>
virtual void ConditionDBWriter< T >::algoAnalyze ( const edm::Event ,
const edm::EventSetup  
) [inline, private, virtual]

Reimplemented in SiStripGainCosmicCalculator, SiStripGainFromData, SiStripGainRandomCalculator, SiStripThresholdFakeOnDB, SiStripNoiseDummyCalculator, SiStripQualityHotStripIdentifier, SiStripBadChannelBuilder, SiStripBadFiberBuilder, and SiStripQualityHotStripIdentifierRoot.

Definition at line 207 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::analyze().

00207 {};

template<class T>
virtual void ConditionDBWriter< T >::algoBeginJob ( const edm::EventSetup  )  [inline, private, virtual]

Reimplemented in SiStripGainCosmicCalculator, SiStripGainFromData, SiStripCalibLorentzAngle, SiStripRandomLorentzAngle, SiStripQualityHotStripIdentifier, and SiStripQualityHotStripIdentifierRoot.

Definition at line 201 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::beginJob().

00201 {};

template<class T>
virtual void ConditionDBWriter< T >::algoBeginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup  
) [inline, private, virtual]

Reimplemented in SiStripQualityHotStripIdentifier, and SiStripQualityHotStripIdentifierRoot.

Definition at line 205 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::beginLuminosityBlock().

00205 {};

template<class T>
virtual void ConditionDBWriter< T >::algoBeginRun ( const edm::Run ,
const edm::EventSetup  
) [inline, private, virtual]

Reimplemented in SiStripQualityHotStripIdentifier, and SiStripQualityHotStripIdentifierRoot.

Definition at line 203 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::beginRun().

00203 {};

template<class T>
virtual void ConditionDBWriter< T >::algoEndJob (  )  [inline, private, virtual]

Reimplemented in SiStripGainCosmicCalculator, SiStripGainFromData, SiStripQualityHotStripIdentifier, SiStripRunSummaryWrite, and SiStripQualityHotStripIdentifierRoot.

Definition at line 211 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::endJob().

00211 {};

template<class T>
virtual void ConditionDBWriter< T >::algoEndLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup  
) [inline, private, virtual]

Definition at line 277 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::endLuminosityBlock().

00277 {};

template<class T>
virtual void ConditionDBWriter< T >::algoEndRun ( const edm::Run ,
const edm::EventSetup  
) [inline, private, virtual]

Definition at line 209 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::endRun().

00209 {};

template<class T>
void ConditionDBWriter< T >::analyze ( const edm::Event event,
const edm::EventSetup iSetup 
) [inline, private, virtual]

Implements edm::EDAnalyzer.

Definition at line 243 of file ConditionDBWriter.h.

00243                                                                   {
00244     
00245     if(SinceAppendMode_ && setSinceTime_ ){
00246       setTime(); //set new since time for possible next upload to DB  
00247       setSinceTime_=false;
00248     }
00249 
00250     algoAnalyze(event, iSetup);     
00251 
00252   }

template<class T>
void ConditionDBWriter< T >::beginJob ( const edm::EventSetup iSetup  )  [inline, private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 215 of file ConditionDBWriter.h.

00215                                             {
00216 
00217     edm::LogInfo("ConditionDBWriter::beginJob") << std::endl;
00218     if( (JobMode_ || AlgoDrivenMode_) && SinceAppendMode_) setSinceTime_=true;
00219     algoBeginJob(iSetup);
00220 
00221   }

template<class T>
void ConditionDBWriter< T >::beginLuminosityBlock ( const edm::LuminosityBlock lumiBlock,
const edm::EventSetup iSetup 
) [inline, private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 234 of file ConditionDBWriter.h.

00234                                                                                                {
00235 
00236     edm::LogInfo("ConditionDBWriter::beginLuminosityBlock") << std::endl;
00237     if(LumiBlockMode_ && SinceAppendMode_) setSinceTime_=true;
00238     algoBeginLuminosityBlock(lumiBlock, iSetup);
00239 
00240   }

template<class T>
void ConditionDBWriter< T >::beginRun ( const edm::Run run,
const edm::EventSetup es 
) [inline, private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 224 of file ConditionDBWriter.h.

00224                                                               {
00225 
00226     edm::LogInfo("ConditionDBWriter::beginRun") << std::endl;
00227     if(RunMode_ && SinceAppendMode_) setSinceTime_=true;
00228     algoBeginRun(run,es);
00229 
00230   }

template<class T>
void ConditionDBWriter< T >::endJob ( void   )  [inline, private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 303 of file ConditionDBWriter.h.

00303                {
00304 
00305     edm::LogInfo("ConditionDBWriter::endJob") << std::endl;
00306 
00307     algoEndJob();
00308 
00309     if(JobMode_){
00310 
00311       T * objPointer = getNewObject();
00312 
00313       if( objPointer ){
00314         storeOnDb(objPointer);
00315       }
00316 
00317       else {
00318 
00319         edm::LogError("ConditionDBWriter::endJob(): ERROR - requested to store on DB on a Job based interval, but received null pointer...will not store anything on the DB") << std::endl;
00320         
00321       }
00322 
00323     }
00324 
00325   }

template<class T>
void ConditionDBWriter< T >::endLuminosityBlock ( const edm::LuminosityBlock lumiBlock,
const edm::EventSetup es 
) [inline, private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 256 of file ConditionDBWriter.h.

00256                                                                                          {
00257 
00258     edm::LogInfo("ConditionDBWriter::endLuminosityBlock") << std::endl;
00259     algoEndLuminosityBlock(lumiBlock, es);
00260 
00261     if(LumiBlockMode_){
00262 
00263       T * objPointer = getNewObject();
00264       
00265       if(objPointer ){
00266         storeOnDb(objPointer);
00267       }
00268       else {
00269         edm::LogError("ConditionDBWriter::endLuminosityblock(): ERROR - requested to store on DB on a Lumi Block based interval, but received null pointer...will not store anything on the DB") << std::endl;
00270       }
00271 
00272     }
00273 
00274   }

template<class T>
void ConditionDBWriter< T >::endRun ( const edm::Run run,
const edm::EventSetup es 
) [inline, private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 280 of file ConditionDBWriter.h.

00280                                                            {
00281 
00282     edm::LogInfo("ConditionDBWriter::endRun") << std::endl;
00283 
00284     algoEndRun(run, es);
00285 
00286     if(RunMode_){
00287 
00288       T * objPointer = getNewObject();
00289 
00290       if(objPointer ){
00291         storeOnDb(objPointer);
00292       }
00293       else {
00294         edm::LogError("ConditionDBWriter::endRun(): ERROR - requested to store on DB on a Run based interval, but received null pointer...will not store anything on the DB") << std::endl;
00295       }
00296 
00297     }
00298 
00299   }

template<class T>
virtual T* ConditionDBWriter< T >::getNewObject (  )  [private, pure virtual]

Implemented in SiStripGainCosmicCalculator, SiStripGainFromAsciiFile, SiStripGainFromData, SiStripGainRandomCalculator, SiStripThresholdFakeOnDB, SiStripNoiseDummyCalculator, SiStripCalibLorentzAngle, SiStripRandomLorentzAngle, SiStripBadModuleByHandBuilder, SiStripBadStripFromASCIIFile, SiStripQualityHotStripIdentifier, SiStripRunSummaryWrite, SiStripBadChannelBuilder, SiStripBadFiberBuilder, and SiStripQualityHotStripIdentifierRoot.

Referenced by ConditionDBWriter< SiStripThreshold >::endJob(), ConditionDBWriter< SiStripThreshold >::endLuminosityBlock(), ConditionDBWriter< SiStripThreshold >::endRun(), and ConditionDBWriter< SiStripThreshold >::storeOnDbNow().

template<class T>
void ConditionDBWriter< T >::setTime (  )  [inline, private]

Definition at line 401 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::analyze(), and ConditionDBWriter< SiStripThreshold >::storeOnDb().

00401                 {
00402 
00403     edm::Service<cond::service::PoolDBOutputService> mydbservice;
00404     
00405     if( mydbservice.isAvailable() ){
00406       Time_ = mydbservice->currentTime();
00407       edm::LogInfo("ConditionDBWriter::setTime: time set to ") << Time_ << std::endl;
00408     }
00409     else{
00410       edm::LogError("ConditionDBWriter::setTime(): PoolDBOutputService is not available...cannot set current time") << std::endl;
00411     }
00412     
00413   }

template<class T>
void ConditionDBWriter< T >::storeOnDb ( T *  objPointer  )  [inline, private]

Definition at line 328 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::endJob(), ConditionDBWriter< SiStripThreshold >::endLuminosityBlock(), ConditionDBWriter< SiStripThreshold >::endRun(), and ConditionDBWriter< SiStripThreshold >::storeOnDbNow().

00328                                 {
00329 
00330     edm::LogInfo("ConditionDBWriter::storeOnDb ")  << std::endl;
00331 
00332     if(! SinceAppendMode_ ) setTime();
00333     else setSinceTime_=true;
00334 
00335     if(! objPointer) {
00336       edm::LogError("ConditionDBWriter: Pointer to object has not been set...storing no data on DB") ;
00337       return;
00338     }
00339   
00340 
00341     //And now write  data in DB
00342     edm::Service<cond::service::PoolDBOutputService> mydbservice;
00343   
00344     if( doStore_ && mydbservice.isAvailable() ){
00345 
00346       try{
00347         
00348         bool tillDone=false;
00349 
00350         //if first time tag is populated
00351         if( mydbservice->isNewTagRequest(Record_) ){
00352         
00353           edm::LogInfo("ConditionDBWriter") << "first request for storing objects with Record "<< Record_ << std::endl;
00354           
00355           if(SinceAppendMode_) {
00356             //    edm::LogInfo("ConditionDBWriter") << "appending a new DUMMY object to new tag "<<Record_<<" in since mode " << std::endl;
00357             //    mydbservice->createNewIOV<T>(new T(), mydbservice->endOfTime(), Record_);
00358             edm::LogInfo("ConditionDBWriter") << "appending a new object to existing tag " <<Record_ <<" in since mode " << std::endl;
00359             mydbservice->createNewIOV<T>(objPointer, mydbservice->beginOfTime(), mydbservice->endOfTime(), Record_);
00360 
00361             // mydbservice->appendSinceTime<T>(objPointer, Time_, Record_); 
00362           }
00363           else{
00364             edm::LogInfo("ConditionDBWriter") << "appending a new object to new tag "<<Record_<< " in till mode " << std::endl;
00365             mydbservice->createNewIOV<T>(objPointer, mydbservice->beginOfTime(),Time_, Record_);      
00366             tillDone=true;
00367           }
00368           
00369         } 
00370         else {
00371           
00372           if(SinceAppendMode_){
00373             edm::LogInfo("ConditionDBWriter") << "appending a new object to existing tag " <<Record_ <<" in since mode " << std::endl;
00374             mydbservice->appendSinceTime<T>(objPointer, Time_, Record_); 
00375           }
00376           else if(!tillDone){
00377             edm::LogInfo("ConditionDBWriter") << "appending a new object to existing tag "<<Record_ <<" in till mode." << std::endl;
00378             //    mydbservice->appendTillTime<T>(objPointer,Time_,"TRcd");      
00379             mydbservice->appendTillTime<T>(objPointer, Time_, Record_);      
00380           }
00381 
00382         }
00383 
00384       }catch(const cond::Exception& er){
00385         edm::LogError("ConditionDBWriter")<<er.what()<<std::endl;
00386       }catch(const std::exception& er){
00387         edm::LogError("ConditionDBWriter")<<"caught std::exception "<<er.what()<<std::endl;
00388       }catch(...){
00389         edm::LogError("ConditionDBWriter")<<"Funny error"<<std::endl;
00390       }
00391     }
00392     else if (!  mydbservice.isAvailable() ) {
00393       edm::LogError("ConditionDBWriter")<<"PoolDBOutputService is unavailable"<<std::endl;
00394     }
00395     
00396     
00397   }

template<class T>
void ConditionDBWriter< T >::storeOnDbNow (  )  [inline, protected]

Definition at line 420 of file ConditionDBWriter.h.

00420                      {
00421 
00422     T * objPointer = 0;
00423 
00424     if(AlgoDrivenMode_){
00425 
00426       setSinceTime_=true;
00427 
00428       objPointer = getNewObject();
00429   
00430       if (!objPointer ) {
00431         edm::LogError("ConditionDBWriter::storeOnDbNow: ERROR - requested to store on DB a new object (module configuration is algo driven based IOV), but received NULL pointer...will not store anything on the DB") << std::endl;
00432         return;
00433       }
00434       else {storeOnDb(objPointer);}
00435       
00436     }
00437     else {
00438       
00439       edm::LogError("ConditionDBWriter::storeOnDbNow(): ERROR - received a direct request from concrete algorithm to store on DB a new object, but module configuration is not to store on DB on an algo driven based interval...will not store anything on the DB") << std::endl;
00440       return;
00441     }
00442 
00443   }

template<class T>
cond::Time_t ConditionDBWriter< T >::timeOfLastIOV (  )  [inline, protected]

Definition at line 448 of file ConditionDBWriter.h.

00448 {return Time_;}


Member Data Documentation

template<class T>
bool ConditionDBWriter< T >::AlgoDrivenMode_ [private]

Definition at line 459 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::beginJob(), ConditionDBWriter< SiStripThreshold >::ConditionDBWriter(), and ConditionDBWriter< SiStripThreshold >::storeOnDbNow().

template<class T>
bool ConditionDBWriter< T >::doStore_ [private]

Definition at line 460 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::ConditionDBWriter(), and ConditionDBWriter< SiStripThreshold >::storeOnDb().

template<class T>
bool ConditionDBWriter< T >::JobMode_ [private]

Definition at line 458 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::beginJob(), ConditionDBWriter< SiStripThreshold >::ConditionDBWriter(), and ConditionDBWriter< SiStripThreshold >::endJob().

template<class T>
bool ConditionDBWriter< T >::LumiBlockMode_ [private]

Definition at line 456 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::beginLuminosityBlock(), ConditionDBWriter< SiStripThreshold >::ConditionDBWriter(), and ConditionDBWriter< SiStripThreshold >::endLuminosityBlock().

template<class T>
std::string ConditionDBWriter< T >::Record_ [private]

Definition at line 462 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::ConditionDBWriter(), and ConditionDBWriter< SiStripThreshold >::storeOnDb().

template<class T>
bool ConditionDBWriter< T >::RunMode_ [private]

Definition at line 457 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::beginRun(), ConditionDBWriter< SiStripThreshold >::ConditionDBWriter(), and ConditionDBWriter< SiStripThreshold >::endRun().

template<class T>
bool ConditionDBWriter< T >::setSinceTime_ [private]

Definition at line 465 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::analyze(), ConditionDBWriter< SiStripThreshold >::beginJob(), ConditionDBWriter< SiStripThreshold >::beginLuminosityBlock(), ConditionDBWriter< SiStripThreshold >::beginRun(), ConditionDBWriter< SiStripThreshold >::storeOnDb(), and ConditionDBWriter< SiStripThreshold >::storeOnDbNow().

template<class T>
bool ConditionDBWriter< T >::SinceAppendMode_ [private]

Definition at line 454 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::analyze(), ConditionDBWriter< SiStripThreshold >::beginJob(), ConditionDBWriter< SiStripThreshold >::beginLuminosityBlock(), ConditionDBWriter< SiStripThreshold >::beginRun(), ConditionDBWriter< SiStripThreshold >::ConditionDBWriter(), and ConditionDBWriter< SiStripThreshold >::storeOnDb().

template<class T>
cond::Time_t ConditionDBWriter< T >::Time_ [private]

Definition at line 463 of file ConditionDBWriter.h.

Referenced by ConditionDBWriter< SiStripThreshold >::setTime(), ConditionDBWriter< SiStripThreshold >::storeOnDb(), and ConditionDBWriter< SiStripThreshold >::timeOfLastIOV().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:16:38 2009 for CMSSW by  doxygen 1.5.4