Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
DQMHistNormalizer (const edm::ParameterSet &) | |
virtual void | endJob () |
virtual void | endRun (const edm::Run &r, const edm::EventSetup &c) |
virtual | ~DQMHistNormalizer () |
Private Member Functions | |
lat::Regexp * | buildRegex (const string &expr) |
Private Attributes | |
vector< string > | plotNamesToNormalize_ |
string | reference_ |
Class to produce efficiency histograms by dividing nominator by denominator histograms
Definition at line 38 of file DQMHistNormalizer.cc.
DQMHistNormalizer::DQMHistNormalizer | ( | const edm::ParameterSet & | cfg | ) | [explicit] |
Definition at line 54 of file DQMHistNormalizer.cc.
: plotNamesToNormalize_(cfg.getParameter< std::vector<string> >("plotNamesToNormalize")), reference_(cfg.getParameter< string >("reference")) { //std::cout << "<DQMHistNormalizer::DQMHistNormalizer>:" << std::endl; }
DQMHistNormalizer::~DQMHistNormalizer | ( | ) | [virtual] |
Definition at line 61 of file DQMHistNormalizer.cc.
{
//--- nothing to be done yet
}
void DQMHistNormalizer::analyze | ( | const edm::Event & | , |
const edm::EventSetup & | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 66 of file DQMHistNormalizer.cc.
{
//--- nothing to be done yet
}
lat::Regexp * DQMHistNormalizer::buildRegex | ( | const string & | expr | ) | [private] |
Definition at line 71 of file DQMHistNormalizer.cc.
References alignCSCRings::e, raiseDQMError(), and corrVsCorr::rx.
Referenced by endRun().
{ lat::Regexp* rx = 0; try { rx = new lat::Regexp(expr, 0, lat::Regexp::Wildcard); rx->study(); } catch (lat::Error &e) { raiseDQMError("DQMStore", "Invalid regular expression '%s': %s", expr.c_str(), e.explain().c_str()); } return rx; }
virtual void DQMHistNormalizer::endJob | ( | void | ) | [inline, virtual] |
void DQMHistNormalizer::endRun | ( | const edm::Run & | r, |
const edm::EventSetup & | c | ||
) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 87 of file DQMHistNormalizer.cc.
References buildRegex(), dir, DQMStore::getAllContents(), estimatePileup::hist, timingPdfMaker::pathname, plotNamesToNormalize_, and reference_.
{ //std::cout << "<DQMHistNormalizer::endJob>:" << std::endl; //--- check that DQMStore service is available if ( !edm::Service<DQMStore>().isAvailable() ) { edm::LogError ("endJob") << " Failed to access dqmStore --> histograms will NOT be plotted !!"; return; } DQMStore& dqmStore = (*edm::Service<DQMStore>()); vector<MonitorElement *> allOurMEs = dqmStore.getAllContents("RecoTauV/"); lat::Regexp* refregex = buildRegex("*RecoTauV/*/" + reference_); vector<lat::Regexp*> toNormRegex; for ( std::vector<string>::const_iterator toNorm = plotNamesToNormalize_.begin(); toNorm != plotNamesToNormalize_.end(); ++toNorm ) toNormRegex.push_back( buildRegex("*RecoTauV/*/" + *toNorm) ); map<string, MonitorElement *> refsMap; vector<MonitorElement *> toNormElements; for(vector<MonitorElement *>::const_iterator element = allOurMEs.begin(); element != allOurMEs.end(); ++element){ string pathname = (*element)->getFullname(); //cout << pathname << endl; //Matches reference if(refregex->match(pathname)){ //cout << "Matched to ref" << endl; string dir = pathname.substr(0, pathname.rfind("/")); if(refsMap.find(dir) != refsMap.end()){ edm::LogInfo("DQMHistNormalizer")<<"DQMHistNormalizer::endRun: Warning! found multiple normalizing references for dir: "<<dir<<"!"; edm::LogInfo("DQMHistNormalizer")<<" " << (refsMap[dir])->getFullname(); edm::LogInfo("DQMHistNormalizer")<<" " << pathname; } else{ refsMap[dir] = *element; } } //Matches targets for(vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg){ if((*reg)->match(pathname)){ //cout << "Matched to target" << endl; toNormElements.push_back(*element); //cout << "Filled the collection" << endl; } } } delete refregex; for(vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg) delete *reg; for(vector<MonitorElement *>::const_iterator matchingElement = toNormElements.begin(); matchingElement != toNormElements.end(); ++matchingElement){ string meName = (*matchingElement)->getFullname(); string dir = meName.substr(0, meName.rfind("/")); if(refsMap.find(dir) == refsMap.end()){ edm::LogInfo("DQMHistNormalizer")<<"DQMHistNormalizer::endRun: Error! normalizing references for "<<meName<<" not found! Skipping..."; continue; } float norm = refsMap[dir]->getTH1()->GetEntries(); TH1* hist = (*matchingElement)->getTH1(); if ( norm != 0. ) { if( !hist->GetSumw2N() ) hist->Sumw2(); hist->Scale(1/norm);//use option "width" to divide the bin contents and errors by the bin width? }else{ edm::LogInfo("DQMHistNormalizer")<<"DQMHistNormalizer::endRun: Error! Normalization failed in "<<hist->GetTitle()<<"!"; } }// for(vector<MonitorElement *>::const_iterator matchingElement = matchingElemts.begin(); matchingElement = matchingElemts.end(); ++matchingElement) }
vector<string> DQMHistNormalizer::plotNamesToNormalize_ [private] |
Definition at line 50 of file DQMHistNormalizer.cc.
Referenced by endRun().
string DQMHistNormalizer::reference_ [private] |
Definition at line 51 of file DQMHistNormalizer.cc.
Referenced by endRun().