#include <HLTMuonPlotter.h>
Classes | |
struct | matchesByDescendingPt |
struct | MatchStruct |
Public Member Functions | |
void | analyze (const edm::Event &, const edm::EventSetup &) |
void | beginJob () |
void | beginRun (const edm::Run &, const edm::EventSetup &) |
HLTMuonPlotter (const edm::ParameterSet &, std::string, std::vector< std::string >, std::vector< std::string >) | |
Private Member Functions | |
void | analyzePath (const edm::Event &, const std::string &, const std::string &, const std::vector< MatchStruct >, edm::Handle< trigger::TriggerEventWithRefs >) |
void | bookHist (std::string, std::string, std::string, std::string) |
void | findMatches (std::vector< MatchStruct > &, std::vector< l1extra::L1MuonParticleRef >, std::vector< std::vector< const reco::RecoChargedCandidate * > >) |
Private Attributes | |
double | cutMaxEta_ |
double | cutMinPt_ |
unsigned int | cutMotherId_ |
std::vector< double > | cutsDr_ |
DQMStore * | dbe_ |
std::map< std::string, MonitorElement * > | elements_ |
std::string | genMuonCut_ |
StringCutObjectSelector < reco::GenParticle > * | genMuonSelector_ |
std::string | genParticleLabel_ |
std::string | hltPath_ |
std::string | hltProcessName_ |
L1MuonMatcherAlgo | l1Matcher_ |
std::vector< std::string > | moduleLabels_ |
std::vector< double > | parametersEta_ |
std::vector< double > | parametersPhi_ |
std::vector< double > | parametersTurnOn_ |
std::string | recMuonCut_ |
std::string | recMuonLabel_ |
StringCutObjectSelector < reco::Muon > * | recMuonSelector_ |
std::vector< std::string > | stepLabels_ |
Generate histograms for muon trigger efficiencies Documentation available on the CMS TWiki: https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLTOfflinePerformance
Definition at line 58 of file HLTMuonPlotter.h.
HLTMuonPlotter::HLTMuonPlotter | ( | const edm::ParameterSet & | , |
std::string | , | ||
std::vector< std::string > | , | ||
std::vector< std::string > | |||
) |
Definition at line 38 of file HLTMuonPlotter.cc.
References cutsDr_, dbe_, genMuonCut_, genMuonSelector_, genParticleLabel_, edm::ParameterSet::getParameter(), hltPath_, hltProcessName_, moduleLabels_, cppFunctionSkipper::operator, parametersEta_, parametersPhi_, parametersTurnOn_, recMuonCut_, recMuonLabel_, recMuonSelector_, DQMStore::setVerbose(), and stepLabels_.
: l1Matcher_(pset) { hltPath_ = hltPath; moduleLabels_ = moduleLabels; stepLabels_ = stepLabels; hltProcessName_ = pset.getParameter<string>("hltProcessName"); genParticleLabel_ = pset.getParameter<string>("genParticleLabel"); recMuonLabel_ = pset.getParameter<string>( "recMuonLabel"); cutsDr_ = pset.getParameter< vector<double> >("cutsDr" ); parametersEta_ = pset.getParameter< vector<double> >("parametersEta"); parametersPhi_ = pset.getParameter< vector<double> >("parametersPhi"); parametersTurnOn_ = pset.getParameter< vector<double> >("parametersTurnOn"); genMuonCut_ = pset.getParameter<string>("genMuonCut"); recMuonCut_ = pset.getParameter<string>("recMuonCut"); genMuonSelector_ = 0; recMuonSelector_ = 0; dbe_ = Service<DQMStore>().operator->(); dbe_->setVerbose(0); }
void HLTMuonPlotter::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) |
Definition at line 136 of file HLTMuonPlotter.cc.
References prof2calltree::count, cutMaxEta_, cutMinPt_, elements_, eta(), edm::HandleBase::failedToGet(), HcalObjRepresent::Fill(), spr::find(), findMatches(), genMuonCut_, genMuonSelector_, genParticleLabel_, genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByLabel(), hltPath_, hltProcessName_, i, edm::HandleBase::isValid(), j, testEve_cfg::level, LogTrace, moduleLabels_, phi, recMuonCut_, recMuonLabel_, recMuonSelector_, findQualityFiles::size, python::multivaluedict::sort(), LaserTracksInput_cfi::source, relval_parameters_module::step, stepLabels_, GlobalPosition_Frontier_DevDB_cff::tag, trigger::TriggerL1Mu, and trigger::TriggerMuon.
{ static int eventNumber = 0; eventNumber++; LogTrace("HLTMuonVal") << "In HLTMuonPlotter::analyze, " << "Event: " << eventNumber; // cout << hltPath_ << endl; // for (size_t i = 0; i < moduleLabels_.size(); i++) // cout << " " << moduleLabels_[i] << endl; Handle< TriggerEventWithRefs> rawTriggerEvent; Handle< MuonCollection> recMuons; Handle< GenParticleCollection> genParticles; iEvent.getByLabel("hltTriggerSummaryRAW", rawTriggerEvent); if (rawTriggerEvent.failedToGet()) {LogError("HLTMuonVal") << "No trigger summary found"; return;} iEvent.getByLabel( recMuonLabel_, recMuons ); iEvent.getByLabel(genParticleLabel_, genParticles ); vector<string> sources; if (genParticles.isValid()) sources.push_back("gen"); if ( recMuons.isValid()) sources.push_back("rec"); for (size_t sourceNo = 0; sourceNo < sources.size(); sourceNo++) { string source = sources[sourceNo]; // If this is the first event, initialize selectors if (!genMuonSelector_) genMuonSelector_ = new StringCutObjectSelector<reco::GenParticle>(genMuonCut_); if (!recMuonSelector_) recMuonSelector_ = new StringCutObjectSelector<reco::Muon >(recMuonCut_); // Make each good gen/rec muon into the base cand for a MatchStruct vector<MatchStruct> matches; if (source == "gen" && genParticles.isValid()) for (size_t i = 0; i < genParticles->size(); i++) if ((*genMuonSelector_)(genParticles->at(i))) matches.push_back(MatchStruct(& genParticles->at(i))); if (source == "rec" && recMuons.isValid()) for (size_t i = 0; i < recMuons->size(); i++) if ((*recMuonSelector_)(recMuons->at(i))) matches.push_back(MatchStruct(& recMuons->at(i))); // Sort the MatchStructs by pT for later filling of turn-on curve sort(matches.begin(), matches.end(), matchesByDescendingPt()); const bool isDoubleMuonPath = (hltPath_.find("Double") != string::npos); const size_t nFilters = moduleLabels_.size(); const size_t nSteps = stepLabels_.size(); const size_t nStepsHlt = nSteps - 2; const int nObjectsToPassPath = (isDoubleMuonPath) ? 2 : 1; vector< L1MuonParticleRef > candsL1; vector< vector< RecoChargedCandidateRef > > refsHlt(nStepsHlt); vector< vector< const RecoChargedCandidate * > > candsHlt(nStepsHlt); for (size_t i = 0; i < nFilters; i++) { const int hltStep = i - 1; InputTag tag = InputTag(moduleLabels_[i], "", hltProcessName_); size_t iFilter = rawTriggerEvent->filterIndex(tag); if (iFilter < rawTriggerEvent->size()) { if (i == 0) rawTriggerEvent->getObjects(iFilter, TriggerL1Mu, candsL1); else rawTriggerEvent->getObjects(iFilter, TriggerMuon, refsHlt[hltStep]); } else LogTrace("HLTMuonVal") << "No collection with label " << tag; } for (size_t i = 0; i < nStepsHlt; i++) for (size_t j = 0; j < refsHlt[i].size(); j++) if (refsHlt[i][j].isAvailable()) { candsHlt[i].push_back(& * refsHlt[i][j]); } else { LogWarning("HLTMuonPlotter") << "Ref refsHlt[i][j]: product not available " << i << " " << j; } // Add trigger objects to the MatchStructs findMatches(matches, candsL1, candsHlt); vector<size_t> matchesInEtaRange; vector<bool> hasMatch(matches.size(), true); for (size_t step = 0; step < nSteps; step++) { const size_t hltStep = (step >= 2) ? step - 2 : 0; size_t level = 0; if (stepLabels_[step].find("L3") != string::npos) level = 3; else if (stepLabels_[step].find("L2") != string::npos) level = 2; else if (stepLabels_[step].find("L1") != string::npos) level = 1; for (size_t j = 0; j < matches.size(); j++) { if (level == 0) { if (fabs(matches[j].candBase->eta()) < cutMaxEta_) matchesInEtaRange.push_back(j); } else if (level == 1) { if (matches[j].candL1 == 0) hasMatch[j] = false; } else if (level >= 2) { if (matches[j].candHlt[hltStep] == 0) hasMatch[j] = false; else if (!hasMatch[j]) { LogTrace("HLTMuonVal") << "Match found for HLT step " << hltStep << " of " << nStepsHlt << " without previous match!"; break; } } } if (std::count(hasMatch.begin(), hasMatch.end(), true) < nObjectsToPassPath) break; string pre = source + "Pass"; string post = "_" + stepLabels_[step]; for (size_t j = 0; j < matches.size(); j++) { float pt = matches[j].candBase->pt(); float eta = matches[j].candBase->eta(); float phi = matches[j].candBase->phi(); if (hasMatch[j]) { if (matchesInEtaRange.size() >= 1 && j == matchesInEtaRange[0]) elements_[pre + "MaxPt1" + post]->Fill(pt); if (matchesInEtaRange.size() >= 2 && j == matchesInEtaRange[1]) elements_[pre + "MaxPt2" + post]->Fill(pt); if (pt > cutMinPt_) { elements_[pre + "Eta" + post]->Fill(eta); if (fabs(eta) < cutMaxEta_) elements_[pre + "Phi" + post]->Fill(phi); } } } } } // End loop over sources }
void HLTMuonPlotter::analyzePath | ( | const edm::Event & | , |
const std::string & | , | ||
const std::string & | , | ||
const std::vector< MatchStruct > | , | ||
edm::Handle< trigger::TriggerEventWithRefs > | |||
) | [private] |
void HLTMuonPlotter::beginJob | ( | void | ) |
Definition at line 73 of file HLTMuonPlotter.cc.
{ }
void HLTMuonPlotter::beginRun | ( | const edm::Run & | iRun, |
const edm::EventSetup & | iSetup | ||
) |
Definition at line 80 of file HLTMuonPlotter.cc.
References cmsMakeMELists::baseDir, DQMStore::bookFloat(), bookHist(), cutMaxEta_, cutMinPt_, dbe_, elements_, DQMStore::get(), hltPath_, i, L1MuonMatcherAlgo::init(), j, l1Matcher_, convertSQLiteXML::runNumber, DQMStore::setCurrentFolder(), LaserTracksInput_cfi::source, stepLabels_, and dtDQMClient_cfg::threshold.
{ static int runNumber = 0; runNumber++; l1Matcher_.init(iSetup); cutMaxEta_ = 2.4; if (hltPath_.find("eta2p1") != string::npos) cutMaxEta_ = 2.1; // Choose a pT cut for gen/rec muons based on the pT cut in the hltPath_ unsigned int threshold = 0; TPRegexp ptRegexp("Mu([0-9]+)"); TObjArray * regexArray = ptRegexp.MatchS(hltPath_); if (regexArray->GetEntriesFast() == 2) { threshold = atoi(((TObjString *)regexArray->At(1))->GetString()); } delete regexArray; // We select a whole number min pT cut slightly above the hltPath_'s final // pt threshold, then subtract a bit to let through particle gun muons with // exact integer pT: cutMinPt_ = ceil(threshold * 1.1) - 0.01; if (cutMinPt_ < 0.) cutMinPt_ = 0.; string baseDir = "HLT/Muon/Distributions/"; dbe_->setCurrentFolder(baseDir + hltPath_); vector<string> sources(2); sources[0] = "gen"; sources[1] = "rec"; if (dbe_->get(baseDir + hltPath_ + "/CutMinPt") == 0) { elements_["CutMinPt" ] = dbe_->bookFloat("CutMinPt" ); elements_["CutMaxEta"] = dbe_->bookFloat("CutMaxEta"); elements_["CutMinPt" ]->Fill(cutMinPt_); elements_["CutMaxEta"]->Fill(cutMaxEta_); for (size_t i = 0; i < sources.size(); i++) { string source = sources[i]; for (size_t j = 0; j < stepLabels_.size(); j++) { bookHist(hltPath_, stepLabels_[j], source, "Eta"); bookHist(hltPath_, stepLabels_[j], source, "Phi"); bookHist(hltPath_, stepLabels_[j], source, "MaxPt1"); bookHist(hltPath_, stepLabels_[j], source, "MaxPt2"); } } } }
void HLTMuonPlotter::bookHist | ( | std::string | , |
std::string | , | ||
std::string | , | ||
std::string | |||
) | [private] |
Referenced by beginRun().
void HLTMuonPlotter::findMatches | ( | std::vector< MatchStruct > & | , |
std::vector< l1extra::L1MuonParticleRef > | , | ||
std::vector< std::vector< const reco::RecoChargedCandidate * > > | |||
) | [private] |
Referenced by analyze().
double HLTMuonPlotter::cutMaxEta_ [private] |
Definition at line 119 of file HLTMuonPlotter.h.
Referenced by analyze(), and beginRun().
double HLTMuonPlotter::cutMinPt_ [private] |
Definition at line 118 of file HLTMuonPlotter.h.
Referenced by analyze(), and beginRun().
unsigned int HLTMuonPlotter::cutMotherId_ [private] |
Definition at line 120 of file HLTMuonPlotter.h.
std::vector<double> HLTMuonPlotter::cutsDr_ [private] |
Definition at line 121 of file HLTMuonPlotter.h.
Referenced by HLTMuonValidator::findMatches(), and HLTMuonPlotter().
DQMStore* HLTMuonPlotter::dbe_ [private] |
Definition at line 130 of file HLTMuonPlotter.h.
Referenced by beginRun(), HLTMuonValidator::bookHist(), and HLTMuonPlotter().
std::map<std::string, MonitorElement *> HLTMuonPlotter::elements_ [private] |
Definition at line 131 of file HLTMuonPlotter.h.
Referenced by analyze(), beginRun(), and HLTMuonValidator::bookHist().
std::string HLTMuonPlotter::genMuonCut_ [private] |
Definition at line 122 of file HLTMuonPlotter.h.
Referenced by analyze(), and HLTMuonPlotter().
Definition at line 125 of file HLTMuonPlotter.h.
Referenced by analyze(), and HLTMuonPlotter().
std::string HLTMuonPlotter::genParticleLabel_ [private] |
Definition at line 111 of file HLTMuonPlotter.h.
Referenced by analyze(), and HLTMuonPlotter().
std::string HLTMuonPlotter::hltPath_ [private] |
Definition at line 105 of file HLTMuonPlotter.h.
Referenced by analyze(), beginRun(), and HLTMuonPlotter().
std::string HLTMuonPlotter::hltProcessName_ [private] |
Definition at line 106 of file HLTMuonPlotter.h.
Referenced by analyze(), and HLTMuonPlotter().
L1MuonMatcherAlgo HLTMuonPlotter::l1Matcher_ [private] |
Definition at line 128 of file HLTMuonPlotter.h.
Referenced by beginRun().
std::vector<std::string> HLTMuonPlotter::moduleLabels_ [private] |
Definition at line 108 of file HLTMuonPlotter.h.
Referenced by analyze(), and HLTMuonPlotter().
std::vector<double> HLTMuonPlotter::parametersEta_ [private] |
Definition at line 114 of file HLTMuonPlotter.h.
Referenced by HLTMuonValidator::bookHist(), and HLTMuonPlotter().
std::vector<double> HLTMuonPlotter::parametersPhi_ [private] |
Definition at line 115 of file HLTMuonPlotter.h.
Referenced by HLTMuonValidator::bookHist(), and HLTMuonPlotter().
std::vector<double> HLTMuonPlotter::parametersTurnOn_ [private] |
Definition at line 116 of file HLTMuonPlotter.h.
Referenced by HLTMuonValidator::bookHist(), and HLTMuonPlotter().
std::string HLTMuonPlotter::recMuonCut_ [private] |
Definition at line 123 of file HLTMuonPlotter.h.
Referenced by analyze(), and HLTMuonPlotter().
std::string HLTMuonPlotter::recMuonLabel_ [private] |
Definition at line 112 of file HLTMuonPlotter.h.
Referenced by analyze(), and HLTMuonPlotter().
Definition at line 126 of file HLTMuonPlotter.h.
Referenced by analyze(), and HLTMuonPlotter().
std::vector<std::string> HLTMuonPlotter::stepLabels_ [private] |
Definition at line 109 of file HLTMuonPlotter.h.
Referenced by analyze(), beginRun(), and HLTMuonPlotter().