#include <DQM/HistoricOfflineClient/src/HistoricOfflineClient.cc>
Public Member Functions | |
HistoricOfflineClient (const edm::ParameterSet &) | |
~HistoricOfflineClient () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob (const edm::EventSetup &) |
virtual void | beginRun (const edm::Run &, const edm::EventSetup &) |
float | CalculatePercentOver (MonitorElement *me) const |
virtual void | endJob () |
virtual void | endRun (const edm::Run &, const edm::EventSetup &) |
void | fillSummaryObjects (const edm::Run &run) const |
void | retrievePointersToModuleMEs (const edm::EventSetup &) |
void | writeToDB (const edm::Run &run) const |
void | writeToDB (edm::EventID evid, edm::Timestamp evtime) const |
Private Attributes | |
std::map< uint32_t, std::vector< MonitorElement * > > | ClientPointersToModuleMEs |
DQMStore * | dqmStore_ |
bool | firstEventInRun |
int | nevents |
edm::ParameterSet | parameters |
SiStripPerformanceSummary * | pSummary_ |
Definition at line 33 of file HistoricOfflineClient.h.
HistoricOfflineClient::HistoricOfflineClient | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 17 of file HistoricOfflineClient.cc.
References dqmStore_, and DQMStore::setVerbose().
00017 { dqmStore_ = edm::Service<DQMStore>().operator->(); dqmStore_->setVerbose(0); }
HistoricOfflineClient::~HistoricOfflineClient | ( | ) |
void HistoricOfflineClient::analyze | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 21 of file HistoricOfflineClient.cc.
References firstEventInRun, nevents, pSummary_, SiStripPerformanceSummary::setTimeValue(), and edm::Event::time().
00021 { 00022 00023 if(firstEventInRun){ 00024 firstEventInRun=false; 00025 pSummary_->setTimeValue(iEvent.time().value()); 00026 } 00027 ++nevents; 00028 }
void HistoricOfflineClient::beginJob | ( | const edm::EventSetup & | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 50 of file HistoricOfflineClient.cc.
References nevents.
00050 { 00051 nevents = 0; 00052 }
void HistoricOfflineClient::beginRun | ( | const edm::Run & | run, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 31 of file HistoricOfflineClient.cc.
References SiStripPerformanceSummary::clear(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), firstEventInRun, nevents, pSummary_, edm::Run::run(), and SiStripPerformanceSummary::setRunNr().
00031 { 00032 pSummary_ = new SiStripPerformanceSummary(); 00033 std::cout<<"HistoricOfflineClient::beginRun() nevents = "<<nevents<<std::endl; 00034 pSummary_->clear(); // just in case 00035 pSummary_->setRunNr(run.run()); 00036 firstEventInRun=true; 00037 }
float HistoricOfflineClient::CalculatePercentOver | ( | MonitorElement * | me | ) | const [private] |
Definition at line 143 of file HistoricOfflineClient.cc.
References MonitorElement::DQM_KIND_TH1F, MonitorElement::getTH1F(), and MonitorElement::kind().
Referenced by fillSummaryObjects().
00143 { 00144 if (me->kind() == MonitorElement::DQM_KIND_TH1F) { 00145 TH1F * root_ob = me->getTH1F(); 00146 if(root_ob){ 00147 float percsum=0.; 00148 TAxis * ta = root_ob->GetXaxis(); 00149 unsigned int maxbins = ta->GetNbins(); 00150 unsigned int upperbin = root_ob->FindBin(root_ob->GetMean()+3.*root_ob->GetRMS()); // bin where +3 RMS from mean ends 00151 if(upperbin<=maxbins){ 00152 percsum = root_ob->Integral(upperbin,maxbins) / root_ob->Integral(); 00153 return percsum; 00154 } 00155 } 00156 } 00157 return -199.; // nonsense value 00158 }
Reimplemented from edm::EDAnalyzer.
Definition at line 55 of file HistoricOfflineClient.cc.
References GenMuonPlsPt100GeV_cfg::cout, dqmStore_, lat::endl(), edm::ParameterSet::getUntrackedParameter(), parameters, and DQMStore::save().
00055 { 00056 if ( parameters.getUntrackedParameter<bool>("writeHisto", true) ){ 00057 std::string outputfile = parameters.getUntrackedParameter<std::string>("outputFile", "historicOffline.root"); 00058 std::cout<<"HistoricOfflineClient::endJob() outputFile = "<<outputfile<<std::endl; 00059 dqmStore_->save(outputfile); 00060 } 00061 }
void HistoricOfflineClient::endRun | ( | const edm::Run & | run, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 40 of file HistoricOfflineClient.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fillSummaryObjects(), firstEventInRun, nevents, SiStripPerformanceSummary::print(), pSummary_, retrievePointersToModuleMEs(), and writeToDB().
00040 { 00041 firstEventInRun=false; 00042 retrievePointersToModuleMEs(iSetup); 00043 fillSummaryObjects(run); 00044 std::cout<<"HistoricOfflineClient::endRun() nevents = "<<nevents<<std::endl; 00045 pSummary_->print(); 00046 writeToDB(run); 00047 }
Definition at line 82 of file HistoricOfflineClient.cc.
References CalculatePercentOver(), ClientPointersToModuleMEs, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), python::multivaluedict::map(), pSummary_, edm::Run::run(), SiStripPerformanceSummary::setClusterCharge(), SiStripPerformanceSummary::setClusterSize(), SiStripPerformanceSummary::setOccupancy(), and SiStripPerformanceSummary::setPercentNoisyStrips().
Referenced by endRun().
00082 { 00083 std::cout<<"HistoricOfflineClient::fillSummaryObjects() called. ClientPointersToModuleMEs.size()="<<ClientPointersToModuleMEs.size()<<" runnr="<<run.run()<<std::endl; 00084 for(std::map<uint32_t , std::vector<MonitorElement *> >::const_iterator imapmes = ClientPointersToModuleMEs.begin(); imapmes != ClientPointersToModuleMEs.end(); imapmes++){ 00085 uint32_t local_detid = imapmes->first; 00086 std::vector<MonitorElement*> locvec = imapmes->second; 00087 // std::cout<<"HistoricOfflineClient::fillSummaryObjects() detailed. detid="<<local_detid<<" histos.size()="<<locvec.size()<<std::endl; 00088 for(std::vector<MonitorElement*>::const_iterator imep = locvec.begin(); imep != locvec.end() ; imep++){ 00089 std::string MEName = (*imep)->getName(); 00090 //std::cout<<"HistoricOfflineClient::fillSummaryObjects() //detailed. detid="<<local_detid<<" MEName="<<MEName<<std::endl; 00091 if( MEName.find("ClusterWidth__") != std::string::npos){ //std::cout<<"ClusterWidth "<<(*imep)->getMean()<<std::endl; 00092 pSummary_->setClusterSize(local_detid, (*imep)->getMean(), (*imep)->getRMS()); 00093 } 00094 if( MEName.find("ClusterCharge__") != std::string::npos){ //std::cout<<"ClusterCharge "<<(*imep)->getMean()<<std::endl; 00095 pSummary_->setClusterCharge(local_detid, (*imep)->getMean(), (*imep)->getRMS()); 00096 } 00097 if( MEName.find("ModuleLocalOccupancy__") != std::string::npos){ 00098 pSummary_->setOccupancy(local_detid, (*imep)->getMean(), (*imep)->getRMS()); 00099 float percover = CalculatePercentOver(*imep); 00100 if (percover>-198.) pSummary_->setPercentNoisyStrips(local_detid, CalculatePercentOver(*imep)); // set percentage only if sensible value 00101 } 00102 } 00103 } 00104 }
void HistoricOfflineClient::retrievePointersToModuleMEs | ( | const edm::EventSetup & | iSetup | ) | [private] |
get all MonitorElements tagged as <tag>
Definition at line 64 of file HistoricOfflineClient.cc.
References ClientPointersToModuleMEs, GenMuonPlsPt100GeV_cfg::cout, dqmStore_, lat::endl(), edm::EventSetup::get(), and DQMStore::get().
Referenced by endRun().
00064 { 00065 // take from eventSetup the SiStripDetCabling object 00066 edm::ESHandle<SiStripDetCabling> tkmechstruct; 00067 iSetup.get<SiStripDetCablingRcd>().get(tkmechstruct); 00068 // get list of active detectors from SiStripDetCabling - this will change and be taken from a SiStripDetControl object 00069 std::vector<uint32_t> activeDets; 00070 activeDets.clear(); // just in case 00071 tkmechstruct->addActiveDetectorsRawIds(activeDets); 00073 ClientPointersToModuleMEs.clear(); 00074 for(std::vector<uint32_t>::const_iterator idet = activeDets.begin(); idet != activeDets.end(); ++idet){ 00075 std::vector<MonitorElement *> local_mes = dqmStore_->get(*idet); // get tagged MEs 00076 ClientPointersToModuleMEs.insert(std::make_pair(*idet, local_mes)); 00077 } 00078 std::cout<<"HistoricOfflineClient::retrievePointersToModuleMEs() ClientPointersToModuleMEs.size()="<<ClientPointersToModuleMEs.size()<<std::endl; 00079 }
Definition at line 107 of file HistoricOfflineClient.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), edm::Service< T >::isAvailable(), pSummary_, and edm::Run::run().
00107 { 00108 unsigned int l_run = run.run(); 00109 std::cout<<"HistoricOfflineClient::writeToDB() run="<<l_run<<std::endl; 00110 //now write SiStripPerformanceSummary data in DB 00111 edm::Service<cond::service::PoolDBOutputService> mydbservice; 00112 if( mydbservice.isAvailable() ){ 00113 if( mydbservice->isNewTagRequest("SiStripPerformanceSummaryRcd") ){ 00114 mydbservice->createNewIOV<SiStripPerformanceSummary>(pSummary_,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripPerformanceSummaryRcd"); 00115 } else { 00116 mydbservice->appendSinceTime<SiStripPerformanceSummary>(pSummary_,mydbservice->currentTime(),"SiStripPerformanceSummaryRcd"); 00117 } 00118 }else{ 00119 edm::LogError("writeToDB")<<"Service is unavailable"<<std::endl; 00120 } 00121 }
void HistoricOfflineClient::writeToDB | ( | edm::EventID | evid, | |
edm::Timestamp | evtime | |||
) | const [private] |
Definition at line 124 of file HistoricOfflineClient.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), edm::EventID::event(), edm::Service< T >::isAvailable(), pSummary_, edm::EventID::run(), and edm::Timestamp::value().
Referenced by endRun().
00124 { 00125 unsigned int l_run = evid.run(); 00126 unsigned int l_event = evid.event(); 00127 unsigned long long l_tval = evtime.value(); 00128 std::cout<<"HistoricOfflineClient::writeToDB() run="<<l_run<<" event="<<l_event<<" time="<<l_tval<<std::endl; 00129 //now write SiStripPerformanceSummary data in DB 00130 edm::Service<cond::service::PoolDBOutputService> mydbservice; 00131 if( mydbservice.isAvailable() ){ 00132 if( mydbservice->isNewTagRequest("SiStripPerformanceSummaryRcd") ){ 00133 mydbservice->createNewIOV<SiStripPerformanceSummary>(pSummary_,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripPerformanceSummaryRcd"); 00134 } else { 00135 mydbservice->appendSinceTime<SiStripPerformanceSummary>(pSummary_,mydbservice->currentTime(),"SiStripPerformanceSummaryRcd"); 00136 } 00137 }else{ 00138 edm::LogError("writeToDB")<<"Service is unavailable"<<std::endl; 00139 } 00140 }
std::map<uint32_t, std::vector<MonitorElement *> > HistoricOfflineClient::ClientPointersToModuleMEs [private] |
Definition at line 53 of file HistoricOfflineClient.h.
Referenced by fillSummaryObjects(), and retrievePointersToModuleMEs().
DQMStore* HistoricOfflineClient::dqmStore_ [private] |
Definition at line 52 of file HistoricOfflineClient.h.
Referenced by endJob(), HistoricOfflineClient(), and retrievePointersToModuleMEs().
bool HistoricOfflineClient::firstEventInRun [private] |
Definition at line 50 of file HistoricOfflineClient.h.
Referenced by analyze(), beginRun(), and endRun().
int HistoricOfflineClient::nevents [private] |
Definition at line 49 of file HistoricOfflineClient.h.
Referenced by analyze(), beginJob(), beginRun(), and endRun().
Definition at line 54 of file HistoricOfflineClient.h.
Referenced by analyze(), beginRun(), endRun(), fillSummaryObjects(), and writeToDB().