#include <DQM/HLTEvF/pulgins/HLTMonElectron.cc>
Public Member Functions | |
HLTMon (const edm::ParameterSet &) | |
~HLTMon () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | endJob () |
template<class T > | |
void | fillHistos (edm::Handle< trigger::TriggerEventWithRefs > &, const edm::Event &, unsigned int) |
Private Attributes | |
DQMStore * | dbe |
std::string | dirname_ |
std::vector< MonitorElement * > | eta_phihist |
std::vector< MonitorElement * > | etahist |
std::vector< MonitorElement * > | etahistiso |
std::vector< MonitorElement * > | ethist |
std::vector< MonitorElement * > | ethistiso |
std::string | histoTitle |
std::vector< std::vector < edm::InputTag > > | isoNames |
ofstream | logFile_ |
bool | monitorDaemon_ |
int | nev_ |
std::string | outputFile_ |
std::vector< MonitorElement * > | phihist |
std::vector< MonitorElement * > | phihistiso |
std::vector< std::pair< double, double > > | plotBounds |
std::vector< bool > | plotiso |
unsigned int | reqNum |
std::vector< edm::InputTag > | theHLTCollectionLabels |
int | theHLTOutputType |
std::vector< int > | theHLTOutputTypes |
unsigned int | theNbins |
double | thePtMax |
double | thePtMaxTemp |
double | thePtMin |
double | thePtMinTemp |
MonitorElement * | total |
Description: This is a DQM source meant to be an example for general development of HLT DQM code. Based on the general structure used for L1TMonitor DQM sources. This adaptation of HLTMonElectron was created by Ben BLOOM bbloom@gmail.com
Implementation: <Notes on="" implementation>="">
HLTMon::HLTMon | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 47 of file HLTMon.cc.
References dbe, dirname_, filters, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), isoNames, LogDebug, logFile_, NULL, cmsCodeRules::cppFunctionSkipper::operator, outputFile_, plotBounds, plotiso, reqNum, DQMStore::setCurrentFolder(), DQMStore::setVerbose(), theHLTCollectionLabels, theHLTOutputTypes, theNbins, thePtMax, and thePtMin.
{ LogDebug("HLTMon") << "constructor...." ; logFile_.open("HLTMon.log"); dbe = NULL; if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) { dbe = edm::Service < DQMStore > ().operator->(); dbe->setVerbose(0); } outputFile_ = iConfig.getUntrackedParameter < std::string > ("outputFile", ""); if (outputFile_.size() != 0) { edm::LogInfo("HLTMon") << "L1T Monitoring histograms will be saved to " << outputFile_ ; } else { outputFile_ = "L1TDQM.root"; } bool disable = iConfig.getUntrackedParameter < bool > ("disableROOToutput", false); if (disable) { outputFile_ = ""; } dirname_="HLT/HLTMon"+iConfig.getParameter<std::string>("@module_label"); if (dbe != NULL) { dbe->setCurrentFolder(dirname_); } //plotting paramters thePtMin = iConfig.getUntrackedParameter<double>("PtMin",0.); thePtMax = iConfig.getUntrackedParameter<double>("PtMax",300.); theNbins = iConfig.getUntrackedParameter<unsigned int>("Nbins",40); //info for each filter-step reqNum = iConfig.getParameter<unsigned int>("reqNum"); std::vector<edm::ParameterSet> filters = iConfig.getParameter<std::vector<edm::ParameterSet> >("filters"); for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++){ theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels")); theHLTOutputTypes.push_back(filterconf->getParameter<unsigned int>("theHLTOutputTypes")); std::vector<double> bounds = filterconf->getParameter<std::vector<double> >("PlotBounds"); assert(bounds.size() == 2); plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1])); isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >("IsoCollections")); assert(isoNames.back().size()>0); if (isoNames.back().at(0).label()=="none") plotiso.push_back(false); else{ plotiso.push_back(true); } } }
HLTMon::~HLTMon | ( | ) |
void HLTMon::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 125 of file HLTMon.cc.
References MonitorElement::Fill(), edm::Event::getByLabel(), iEvent, edm::HandleBase::isValid(), LogDebug, n, nev_, theHLTCollectionLabels, theHLTOutputTypes, and total.
{ nev_++; LogDebug("HLTMon")<< "HLTMon: analyze...." ; edm::Handle<trigger::TriggerEventWithRefs> triggerObj; iEvent.getByLabel("hltTriggerSummaryRAW",triggerObj); //Gets the data product which holds if(!triggerObj.isValid()) { //all of the information. edm::LogWarning("HLTMon") << "RAW-type HLT results not found, skipping event"; return; } // total event number total->Fill(theHLTCollectionLabels.size()+0.5); //Each individual "Collection Label" has a numbered category that can be found on doxygen for(unsigned int n=0; n < theHLTCollectionLabels.size() ; n++) { //loop over filter modules switch(theHLTOutputTypes[n]){ case 81: //L1 Muons fillHistos<l1extra::L1MuonParticleCollection>(triggerObj,iEvent,n);break; case 82: // non-iso L1 fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break; case 83: // iso L1https://slashdot.org/ fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break; case 84: // fillHistos<l1extra::L1JetParticleCollection>(triggerObj,iEvent,n);break; case 85: // fillHistos<l1extra::L1JetParticleCollection>(triggerObj,iEvent,n);break; case 91: //photon fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break; case 92: //electron fillHistos<reco::ElectronCollection>(triggerObj,iEvent,n);break; case 93: //Muon fillHistos<reco::RecoChargedCandidateCollection>(triggerObj,iEvent,n);break; case 95: //Jet fillHistos<reco::CaloJetCollection>(triggerObj,iEvent,n);break; case 97: //MET fillHistos<reco::CaloMETCollection>(triggerObj,iEvent,n);break; case 100: // TriggerCluster fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break; default: throw(cms::Exception("Release Validation Error")<< "HLT output type not implemented: theHLTOutputTypes[n]" ); } } }
void HLTMon::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 229 of file HLTMon.cc.
References DQMStore::book1D(), DQMStore::book2D(), dbe, dirname_, eta_phihist, etahist, etahistiso, ethist, ethistiso, histoTitle, i, label, nev_, NULL, cmsCodeRules::cppFunctionSkipper::operator, phihist, phihistiso, plotBounds, plotiso, DQMStore::rmdir(), MonitorElement::setAxisTitle(), MonitorElement::setBinLabel(), DQMStore::setCurrentFolder(), theHLTCollectionLabels, theNbins, thePtMax, thePtMaxTemp, thePtMin, thePtMinTemp, and total.
{ nev_ = 0; DQMStore *dbe = 0; dbe = edm::Service < DQMStore > ().operator->(); if (dbe) { dbe->setCurrentFolder(dirname_); dbe->rmdir(dirname_); } if (dbe) { dbe->setCurrentFolder(dirname_); std::string histoname="total eff"; MonitorElement* tmphisto; total = dbe->book1D(histoname.c_str(),histoname.c_str(),theHLTCollectionLabels.size()+1,0,theHLTCollectionLabels.size()+1); total->setBinLabel(theHLTCollectionLabels.size()+1,"Total",1); for (unsigned int u=0; u<theHLTCollectionLabels.size(); u++){total->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());} for(unsigned int i = 0; i< theHLTCollectionLabels.size() ; i++){ histoname = theHLTCollectionLabels[i].label()+"et"; //ability to customize histograms /* if(theHLTCollectionLabels[i].label() == "hltL1seedRelaxedSingleEt8") { thePtMinTemp = thePtMin; thePtMaxTemp = thePtMax; } else if(theHLTCollectionLabels[i].label() == "hltL1NonIsoHLTNonIsoSingleElectronLWEt12L1MatchFilterRegional") { thePtMinTemp = thePtMin; thePtMaxTemp = thePtMax; } else if(theHLTCollectionLabels[i].label() == "hltL1NonIsoHLTNonIsoSingleElectronLWEt12EtFilter") { thePtMinTemp = thePtMin; thePtMaxTemp = thePtMax; } else if(theHLTCollectionLabels[i].label() == "hltL1NonIsoHLTNonIsoSingleElectronLWEt12HOneOEMinusOneOPFilter") { thePtMinTemp = thePtMin; thePtMaxTemp = thePtMax; } else if(theHLTCollectionLabels[i].label() == "hltZMML2Filtered") { thePtMinTemp = thePtMin; thePtMaxTemp = thePtMax; } else if(theHLTCollectionLabels[i].label() == "hltEMuL1MuonFilter") { thePtMinTemp = thePtMin; thePtMaxTemp = thePtMax; } else { */ thePtMaxTemp = thePtMax; thePtMinTemp = thePtMin; //} // Formatting of various plots. histoTitle = theHLTCollectionLabels[i].label() + " Et"; tmphisto = dbe->book1D(histoname.c_str(),histoTitle.c_str(),theNbins,thePtMinTemp,thePtMaxTemp); tmphisto->setAxisTitle("Number of Events", 2); tmphisto->setAxisTitle("p_{T}", 1); ethist.push_back(tmphisto); histoname = theHLTCollectionLabels[i].label()+"eta"; histoTitle = theHLTCollectionLabels[i].label() + " #eta"; tmphisto = dbe->book1D(histoname.c_str(),histoTitle.c_str(),theNbins,-2.7,2.7); tmphisto->setAxisTitle("Number of Events", 2); tmphisto->setAxisTitle("#eta", 1); etahist.push_back(tmphisto); histoname = theHLTCollectionLabels[i].label()+"phi"; histoTitle = theHLTCollectionLabels[i].label() + " #phi"; tmphisto = dbe->book1D(histoname.c_str(),histoTitle.c_str(),theNbins,-3.14,3.14); tmphisto->setAxisTitle("Number of Events", 2); tmphisto->setAxisTitle("#phi", 1); phihist.push_back(tmphisto); histoname = theHLTCollectionLabels[i].label()+"eta_phi"; histoTitle = theHLTCollectionLabels[i].label() + " #eta vs. #phi"; tmphisto = dbe->book2D(histoname.c_str(),histoTitle.c_str(),theNbins,-2.7,2.7, theNbins, -3.14, 3.14); tmphisto->setAxisTitle("#phi", 2); tmphisto->setAxisTitle("#eta", 1); eta_phihist.push_back(tmphisto); if(plotiso[i]){ histoname = theHLTCollectionLabels[i].label()+"eta isolation"; tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-2.7,2.7,theNbins,plotBounds[i].first,plotBounds[i].second); } else{ tmphisto = NULL; } etahistiso.push_back(tmphisto); if(plotiso[i]){ histoname = theHLTCollectionLabels[i].label()+"et isolation"; tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,thePtMin,thePtMax,theNbins,plotBounds[i].first,plotBounds[i].second); } else{ tmphisto = NULL; } ethistiso.push_back(tmphisto); if(plotiso[i]){ histoname = theHLTCollectionLabels[i].label()+"phi isolation"; tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-3.14,3.14,theNbins,plotBounds[i].first,plotBounds[i].second); } else{ tmphisto = NULL; } phihistiso.push_back(tmphisto); } } // end "if(dbe)" }
void HLTMon::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 355 of file HLTMon.cc.
References dbe, nev_, outputFile_, and DQMStore::save().
{ // std::cout << "HLTMonElectron: end job...." << std::endl; edm::LogInfo("HLTMon") << "analyzed " << nev_ << " events"; if (outputFile_.size() != 0 && dbe) dbe->save(outputFile_); return; }
void HLTMon::fillHistos | ( | edm::Handle< trigger::TriggerEventWithRefs > & | triggerObj, |
const edm::Event & | iEvent, | ||
unsigned int | n | ||
) | [private] |
Definition at line 171 of file HLTMon.cc.
References asciidump::at, eta(), eta_phihist, etahist, etahistiso, ethist, ethistiso, MonitorElement::Fill(), edm::Event::getByLabel(), i, isoNames, edm::HandleBase::isValid(), j, label, n, phi, phihist, phihistiso, plotiso, reqNum, theHLTCollectionLabels, theHLTOutputTypes, and total.
{ std::vector<edm::Ref<T> > particlecands; // To keep track of what particlecands have passed a filter in TriggerEventWithRefs // it adds the name to a list of filter names. To check whether a filter got passed, // one just looks at its index in the list...if it is not there it (for some reason) // returns the size of the list. if (!( triggerObj->filterIndex(theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if availabel // retrieve saved filter objects triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),theHLTOutputTypes[n],particlecands); //Danger: special case, L1 non-isolated // needs to be merged with L1 iso if(theHLTOutputTypes[n]==82){ std::vector<edm::Ref<T> > isocands; triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),83,isocands); if(isocands.size()>0) for(unsigned int i=0; i < isocands.size(); i++) particlecands.push_back(isocands[i]); } //fill filter objects into histos if (particlecands.size()!=0){ if(particlecands.size() >= reqNum ) total->Fill(n+0.5); for (unsigned int i=0; i<particlecands.size() && particlecands[i].isAvailable(); i++) { //unmatched ethist[n]->Fill(particlecands[i]->et() ); etahist[n]->Fill(particlecands[i]->eta() ); phihist[n]->Fill(particlecands[i]->phi() ); eta_phihist[n]->Fill(particlecands[i]->eta(), particlecands[i]->phi() ); //plot isolation variables (show not yet cut iso, i.e. associated to next filter) if(n+1 < theHLTCollectionLabels.size()){ // can't plot beyond last if(plotiso[n+1]){ for(unsigned int j = 0 ; j < isoNames[n+1].size() ;j++ ){ edm::Handle<edm::AssociationMap<edm::OneToValue< T , float > > > depMap; iEvent.getByLabel(isoNames[n+1].at(j).label(),depMap); if(depMap.isValid()) { typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(particlecands[i]); if(mapi!=depMap->end()){ // found candidate in isolation map! etahistiso[n+1]->Fill(particlecands[i]->eta(),mapi->val); ethistiso[n+1]->Fill(particlecands[i]->et(),mapi->val); phihistiso[n+1]->Fill(particlecands[i]->phi(),mapi->val); break; // to avoid multiple filling we only look until we found the candidate once. } } else { edm::LogWarning("HLTMon") << "IsoName collection not found"; } } } } } } } }
DQMStore* HLTMon::dbe [private] |
Definition at line 66 of file HLTMon.h.
Referenced by beginJob(), endJob(), and HLTMon().
std::string HLTMon::dirname_ [private] |
Definition at line 88 of file HLTMon.h.
Referenced by beginJob(), and HLTMon().
std::vector<MonitorElement *> HLTMon::eta_phihist [private] |
Definition at line 70 of file HLTMon.h.
Referenced by beginJob(), and fillHistos().
std::vector<MonitorElement *> HLTMon::etahist [private] |
Definition at line 67 of file HLTMon.h.
Referenced by beginJob(), and fillHistos().
std::vector<MonitorElement *> HLTMon::etahistiso [private] |
Definition at line 71 of file HLTMon.h.
Referenced by beginJob(), and fillHistos().
std::vector<MonitorElement *> HLTMon::ethist [private] |
Definition at line 68 of file HLTMon.h.
Referenced by beginJob(), and fillHistos().
std::vector<MonitorElement *> HLTMon::ethistiso [private] |
Definition at line 72 of file HLTMon.h.
Referenced by beginJob(), and fillHistos().
std::string HLTMon::histoTitle [private] |
Definition at line 94 of file HLTMon.h.
Referenced by beginJob().
std::vector<std::vector<edm::InputTag> > HLTMon::isoNames [private] |
Definition at line 78 of file HLTMon.h.
Referenced by fillHistos(), and HLTMon().
ofstream HLTMon::logFile_ [private] |
bool HLTMon::monitorDaemon_ [private] |
int HLTMon::nev_ [private] |
Definition at line 65 of file HLTMon.h.
Referenced by analyze(), beginJob(), and endJob().
std::string HLTMon::outputFile_ [private] |
std::vector<MonitorElement *> HLTMon::phihist [private] |
Definition at line 69 of file HLTMon.h.
Referenced by beginJob(), and fillHistos().
std::vector<MonitorElement *> HLTMon::phihistiso [private] |
Definition at line 73 of file HLTMon.h.
Referenced by beginJob(), and fillHistos().
std::vector<std::pair<double,double> > HLTMon::plotBounds [private] |
Definition at line 79 of file HLTMon.h.
Referenced by beginJob(), and HLTMon().
std::vector<bool> HLTMon::plotiso [private] |
Definition at line 77 of file HLTMon.h.
Referenced by beginJob(), fillHistos(), and HLTMon().
unsigned int HLTMon::reqNum [private] |
Definition at line 80 of file HLTMon.h.
Referenced by fillHistos(), and HLTMon().
std::vector<edm::InputTag> HLTMon::theHLTCollectionLabels [private] |
Definition at line 75 of file HLTMon.h.
Referenced by analyze(), beginJob(), fillHistos(), and HLTMon().
int HLTMon::theHLTOutputType [private] |
std::vector<int> HLTMon::theHLTOutputTypes [private] |
Definition at line 76 of file HLTMon.h.
Referenced by analyze(), fillHistos(), and HLTMon().
unsigned int HLTMon::theNbins [private] |
Definition at line 86 of file HLTMon.h.
Referenced by beginJob(), and HLTMon().
double HLTMon::thePtMax [private] |
Definition at line 83 of file HLTMon.h.
Referenced by beginJob(), and HLTMon().
double HLTMon::thePtMaxTemp [private] |
Definition at line 85 of file HLTMon.h.
Referenced by beginJob().
double HLTMon::thePtMin [private] |
Definition at line 82 of file HLTMon.h.
Referenced by beginJob(), and HLTMon().
double HLTMon::thePtMinTemp [private] |
Definition at line 84 of file HLTMon.h.
Referenced by beginJob().
MonitorElement* HLTMon::total [private] |
Definition at line 74 of file HLTMon.h.
Referenced by analyze(), beginJob(), and fillHistos().