From e3f918c1a63f41ad891c0c49157a0f42a884e2aa Mon Sep 17 00:00:00 2001 From: bpf6qc Date: Thu, 29 Jun 2017 15:52:04 -0400 Subject: [PATCH 1/6] Add offline DQM for MET plus track EXO triggers --- .../Trigger/plugins/METplusTrackMonitor.cc | 461 ++++++++++++++++++ .../Trigger/plugins/METplusTrackMonitor.h | 145 ++++++ .../python/ExoticaMonitoring_Client_cff.py | 20 + .../Trigger/python/ExoticaMonitoring_cff.py | 2 + .../Trigger/python/METplusTrackMonitor_cff.py | 23 + .../Trigger/python/METplusTrackMonitor_cfi.py | 65 +++ 6 files changed, 716 insertions(+) create mode 100644 DQMOffline/Trigger/plugins/METplusTrackMonitor.cc create mode 100644 DQMOffline/Trigger/plugins/METplusTrackMonitor.h create mode 100644 DQMOffline/Trigger/python/METplusTrackMonitor_cff.py create mode 100644 DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc new file mode 100644 index 0000000000000..10fbb4214680f --- /dev/null +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc @@ -0,0 +1,461 @@ +#include "DQMOffline/Trigger/plugins/METplusTrackMonitor.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "DQM/TrackingMonitor/interface/GetLumi.h" + +#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h" + +#include "DataFormats/Math/interface/deltaPhi.h" +#include "DataFormats/Math/interface/deltaR.h" + +// ----------------------------- +// constructors and destructor +// ----------------------------- + +METplusTrackMonitor::METplusTrackMonitor( const edm::ParameterSet& iConfig ) : + folderName_ ( iConfig.getParameter("FolderName") ) + , metToken_ ( consumes (iConfig.getParameter("met") ) ) + , hltMetToken_ ( consumes (iConfig.getParameter("onlineMet") ) ) + , hltMetCleanToken_ ( consumes (iConfig.getParameter("onlineMetClean") ) ) + , muonToken_ ( consumes (iConfig.getParameter("muons") ) ) + , jetToken_ ( consumes (iConfig.getParameter("jets") ) ) + , vtxToken_ ( consumes (iConfig.getParameter("vertices") ) ) + , theTrigSummary_ ( consumes (iConfig.getParameter("trigSummary") ) ) + , hltTrk50FilterTag_ ( iConfig.getParameter("isoTrkFilter") ) + , met_variable_binning_ ( iConfig.getParameter("histoPSet").getParameter >("metBinning") ) + , muonPt_variable_binning_ ( iConfig.getParameter("histoPSet").getParameter >("ptBinning") ) + , met_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("metPSet") ) ) + , ls_binning_ ( getHistoLSPSet (iConfig.getParameter("histoPSet").getParameter("lsPSet") ) ) + , pt_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("ptPSet") ) ) + , eta_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("etaPSet") ) ) + , phi_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("phiPSet") ) ) + , num_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter("numGenericTriggerEventPSet"), consumesCollector(), *this)) + , den_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter("denGenericTriggerEventPSet"), consumesCollector(), *this)) + , metSelection_ ( iConfig.getParameter("metSelection") ) + , hltMetSelection_ ( iConfig.getParameter("hltMetSelection") ) + , hltMetCleanSelection_ ( iConfig.getParameter("hltMetCleanSelection") ) + , muonSelection_ ( iConfig.getParameter("muonSelection") ) + , jetSelection_ ( iConfig.getParameter("jetSelection") ) + , vtxSelection_ ( iConfig.getParameter("vtxSelection") ) + , nmuons_ ( iConfig.getParameter("nmuons") ) + , njets_ ( iConfig.getParameter("njets") ) + , leadJetEtaCut_ ( iConfig.getParameter("leadJetEtaCut") ) + , hltMetCut_ ( iConfig.getParameter("hltMetCut") ) + , hltMetCleanCut_ ( iConfig.getParameter("hltMetCleanCut") ) +{ + + metME_.numerator = nullptr; + metME_.denominator = nullptr; + metME_variableBinning_.numerator = nullptr; + metME_variableBinning_.denominator = nullptr; + metVsLS_.numerator = nullptr; + metVsLS_.denominator = nullptr; + metPhiME_.numerator = nullptr; + metPhiME_.denominator = nullptr; + deltaphimetj1ME_.numerator = nullptr; + deltaphimetj1ME_.denominator = nullptr; + + muonPtME_.numerator = nullptr; + muonPtME_.denominator = nullptr; + muonPtME_variableBinning_.numerator = nullptr; + muonPtME_variableBinning_.denominator = nullptr; + muonPtVsLS_.numerator = nullptr; + muonPtVsLS_.denominator = nullptr; + deltaphimetmuonME_.numerator = nullptr; + deltaphimetmuonME_.denominator = nullptr; + +} + +METplusTrackMonitor::~METplusTrackMonitor() +{ +} + +METplusTrackMonitor::MEbinning METplusTrackMonitor::getHistoPSet(edm::ParameterSet pset) +{ + return METplusTrackMonitor::MEbinning { + pset.getParameter("nbins"), + pset.getParameter("xmin"), + pset.getParameter("xmax") + }; +} + +METplusTrackMonitor::MEbinning METplusTrackMonitor::getHistoLSPSet(edm::ParameterSet pset) +{ + return METplusTrackMonitor::MEbinning { + pset.getParameter("nbins"), + 0.0, + double(pset.getParameter("nbins")) + }; +} + +void METplusTrackMonitor::setMETitle(METplusTrackME& me, std::string titleX, std::string titleY, bool bookNumerator = true) +{ + if(bookNumerator) { + me.numerator->setAxisTitle(titleX, 1); + me.numerator->setAxisTitle(titleY, 2); + } + me.denominator->setAxisTitle(titleX, 1); + me.denominator->setAxisTitle(titleY, 2); +} + +void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbins, double min, double max) +{ + me.numerator = ibooker.book1D(histname + "_numerator", histtitle + " (numerator)", nbins, min, max); + me.denominator = ibooker.book1D(histname + "_denominator", histtitle + " (denominator)", nbins, min, max); +} + +void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, const std::vector& binning) +{ + int nbins = binning.size() - 1; + std::vector fbinning(binning.begin(), binning.end()); + float * arr = &fbinning[0]; + me.numerator = ibooker.book1D(histname + "_numerator", histtitle + " (numerator)", nbins, arr); + me.denominator = ibooker.book1D(histname + "_denominator", histtitle + " (denominator)", nbins, arr); +} + +void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, double ymin, double ymax) +{ + me.numerator = ibooker.bookProfile(histname + "_numerator", histtitle + " (numerator)", nbinsX, xmin, xmax, ymin, ymax); + me.denominator = ibooker.bookProfile(histname + "_denominator", histtitle + " (denominator)", nbinsX, xmin, xmax, ymin, ymax); +} + +void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, int nbinsY, double ymin, double ymax, bool bookNumerator = true) +{ + if(bookNumerator) me.numerator = ibooker.book2D(histname + "_numerator", histtitle + " (numerator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax); + me.denominator = ibooker.book2D(histname + "_denominator", histtitle + " (denominator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax); +} + +void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, const std::vector& binningX, const std::vector& binningY) +{ + int nbinsX = binningX.size() - 1; + std::vector fbinningX(binningX.begin(), binningX.end()); + float * arrX = &fbinningX[0]; + int nbinsY = binningY.size() - 1; + std::vector fbinningY(binningY.begin(), binningY.end()); + float * arrY = &fbinningY[0]; + + me.numerator = ibooker.book2D(histname+"_numerator", histtitle+" (numerator)", nbinsX, arrX, nbinsY, arrY); + me.denominator = ibooker.book2D(histname+"_denominator", histtitle+" (denominator)", nbinsX, arrX, nbinsY, arrY); +} + +void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, + edm::Run const &iRun, + edm::EventSetup const &iSetup) + { + std::string histname, histtitle; + + std::string currentFolder = folderName_; + ibooker.setCurrentFolder(currentFolder.c_str()); + + // MET leg histograms + + histname = "met"; histtitle = "CaloMET"; + bookME(ibooker, metME_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax); + setMETitle(metME_, "CaloMET [GeV]", "events / [GeV]"); + + histname = "met_variable"; histtitle = "CaloMET"; + bookME(ibooker, metME_variableBinning_, histname, histtitle, met_variable_binning_); + setMETitle(metME_variableBinning_, "CaloMET [GeV]", "events / [GeV]"); + + histname = "metVsLS"; histtitle = "CaloMET vs LS"; + bookME(ibooker, metVsLS_, histname, histtitle, ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax, met_binning_.xmin, met_binning_.xmax); + setMETitle(metVsLS_, "LS", "CaloMET [GeV]"); + + histname = "metPhi"; histtitle = "CaloMET phi"; + bookME(ibooker, metPhiME_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax); + setMETitle(metPhiME_, "CaloMET #phi","events / 0.1 rad"); + + histname = "deltaphi_metjet1"; histtitle = "dPhi(CaloMET, jet1)"; + bookME(ibooker, deltaphimetj1ME_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax); + setMETitle(deltaphimetj1ME_, "#Delta#phi (CaloMET, j1)", "events / 0.1 rad"); + + histname = "metVsHltMet"; histtitle = "CaloMET vs hltMet"; + bool bookDenominator = false; + bookME(ibooker, metVsHltMet_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, bookDenominator); + setMETitle(metVsHltMet_, "hltMet (online) [GeV]", "CaloMET (offline) [GeV]", bookDenominator); + + histname = "metVsHltMetClean"; histtitle = "CaloMET vs hltMetClean"; + bookDenominator = false; + bookME(ibooker, metVsHltMetClean_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, bookDenominator); + setMETitle(metVsHltMetClean_, "hltMetClean (online) [GeV]", "CaloMET (offline) [GeV]", bookDenominator); + + // Track leg histograms + + histname = "muonPt"; histtitle = "Muon PT"; + bookME(ibooker, muonPtME_, histname, histtitle, pt_binning_.nbins, pt_binning_.xmin, pt_binning_.xmax); + setMETitle(muonPtME_, "Muon p_{T} [GeV]", "events / [GeV]"); + + histname = "muonPt_variable"; histtitle = "Muon PT"; + bookME(ibooker, muonPtME_variableBinning_, histname, histtitle, muonPt_variable_binning_); + setMETitle(muonPtME_variableBinning_, "Muon p_{T} [GeV]", "events / [GeV]"); + + histname = "muonEta"; histtitle = "Muon eta"; + bookME(ibooker, muonEtaME_, histname, histtitle, eta_binning_.nbins, eta_binning_.xmin, eta_binning_.xmax); + setMETitle(muonEtaME_, "Muon #eta", "events / 0.2"); + + histname = "deltaphi_muonmet"; histtitle = "dPhi(Muon, CaloMET)"; + bookME(ibooker, deltaphimetmuonME_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax); + setMETitle(deltaphimetmuonME_, "#Delta#phi (Muon, CaloMET)", "events / 0.1 rad"); + + histname = "mT_muonMet"; histtitle = "Transverse mass of muon-CaloMET system"; + bookME(ibooker, mTmuonMetME_, histname, histtitle, pt_binning_.nbins, pt_binning_.xmin, pt_binning_.xmax); + setMETitle(mTmuonMetME_, "mT(Muon, CaloMET) [GeV]", "events / [GeV]"); + + histname = "muonPtVsLS"; histtitle = "Muon PT vs LS"; + bookME(ibooker, muonPtVsLS_, histname, histtitle, ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax, pt_binning_.xmin, pt_binning_.xmax); + setMETitle(muonPtVsLS_, "LS", "Muon p_{T} [GeV]"); + + // Initialize the GenericTriggerEventFlag + if(num_genTriggerEventFlag_ && num_genTriggerEventFlag_->on()) num_genTriggerEventFlag_->initRun(iRun, iSetup); + if(den_genTriggerEventFlag_ && den_genTriggerEventFlag_->on()) den_genTriggerEventFlag_->initRun(iRun, iSetup); + + } + + void METplusTrackMonitor::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) + { + + // Filter out events if Trigger Filtering is requested + if(den_genTriggerEventFlag_->on() && !den_genTriggerEventFlag_->accept(iEvent, iSetup)) return; + + edm::Handle metHandle; + iEvent.getByToken(metToken_, metHandle); + reco::CaloMET caloMet = metHandle->front(); + if(!metSelection_(caloMet)) return; + + float met = caloMet.pt(); + float metPhi = caloMet.phi(); + + edm::Handle jetsHandle; + iEvent.getByToken(jetToken_, jetsHandle); + if(jetsHandle->size() < njets_) return; + std::vector jets; + jets.clear(); + for(auto const & j : *jetsHandle) { + if(jetSelection_(j)) jets.push_back(j); + } + if(jets.size() < njets_) return; + if(njets_ > 0 && jets.size() > 0 && fabs(jets[0].eta()) > leadJetEtaCut_) return; + float deltaphi_metjet1 = (jets.size() > 0) ? fabs(deltaPhi(caloMet.phi(), jets[0].phi())) : 10.0; + + edm::Handle primaryVertices; + iEvent.getByToken(vtxToken_, primaryVertices); + if(!primaryVertices->size()) return; + const reco::Vertex* pv = nullptr; + for(auto const& v: *primaryVertices) { + if (!vtxSelection_(v)) continue; + pv = &v; + break; + } + if(pv == nullptr) return; + + edm::Handle muonHandle; + iEvent.getByToken(muonToken_, muonHandle); + if(muonHandle->size() < nmuons_) return; + std::vector muons; + muons.clear(); + for(auto const & m : *muonHandle) { + bool pass = m.isGlobalMuon() && + m.isPFMuon() && + m.globalTrack()->normalizedChi2() < 10. && + m.globalTrack()->hitPattern().numberOfValidMuonHits() > 0 && + m.numberOfMatchedStations() > 1 && + fabs(m.muonBestTrack()->dxy(pv->position())) < 0.2 && + fabs(m.muonBestTrack()->dz(pv->position())) < 0.5 && + m.innerTrack()->hitPattern().numberOfValidPixelHits() > 0 && + m.innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5; + bool passMissHits = m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::MISSING_INNER_HITS) == 0 && + m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::TRACK_HITS) == 0; + if(muonSelection_(m) && pass && passMissHits) muons.push_back(m); + } + if(muons.size() < nmuons_) return; + + edm::Handle hltMetHandle; + iEvent.getByToken(hltMetToken_, hltMetHandle); + if(!hltMetHandle.isValid()) { + edm::LogError("METplusTrackMonitor") << "Invalid collection: hltMet" << "\n"; + return; + } + reco::CaloMET hltMet = hltMetHandle->front(); + + edm::Handle hltMetCleanHandle; + iEvent.getByToken(hltMetCleanToken_, hltMetCleanHandle); + if(!hltMetCleanHandle.isValid()) { + edm::LogError("METplusTrackMonitor") << "Invalid collection: hltMetClean" << "\n"; + return; + } + reco::CaloMET hltMetClean = hltMetCleanHandle->front(); + + // Filling MET leg histograms (denominator) + metME_.denominator->Fill(met); + metME_variableBinning_.denominator->Fill(met); + metPhiME_.denominator->Fill(metPhi); + deltaphimetj1ME_.denominator->Fill(deltaphi_metjet1); + metVsHltMet_.denominator->Fill(hltMet.pt(), met); + metVsHltMetClean_.denominator->Fill(hltMetClean.pt(), met); + + int ls = iEvent.id().luminosityBlock(); + metVsLS_.denominator->Fill(ls, met); + + // Apply the selection for the MET leg numerator + if(hltMet.pt() <= hltMetCut_ || hltMetClean.pt() <= hltMetCleanCut_) return; + + // Filling MET leg histograms (numerator) + metME_.numerator->Fill(met); + metME_variableBinning_.numerator->Fill(met); + metPhiME_.numerator->Fill(metPhi); + deltaphimetj1ME_.numerator->Fill(deltaphi_metjet1); + metVsLS_.numerator->Fill(ls, met); + + // Filling track leg histograms (denominator) + double leadMuonPt = muons.size() ? muons[0].pt() : -1.0; + double leadMuonEta = muons.size() ? muons[0].eta() : 10.0; + float deltaphi_metmuon = fabs(deltaPhi(caloMet.phi(), muons[0].phi())); + float mT_metmuon = sqrt( 2.0 * met * muons[0].pt() * (1.0 - cos(deltaPhi(muons[0].phi(), caloMet.phi())))); + + muonPtME_.denominator->Fill(leadMuonPt); + muonPtME_variableBinning_.denominator->Fill(leadMuonPt); + muonPtVsLS_.denominator->Fill(ls, leadMuonPt); + muonEtaME_.denominator->Fill(leadMuonEta); + deltaphimetmuonME_.denominator->Fill(deltaphi_metmuon); + mTmuonMetME_.denominator->Fill(mT_metmuon); + + // Apply the selection for the track leg numerator + edm::Handle triggerSummary; + iEvent.getByToken(theTrigSummary_, triggerSummary); + if(!triggerSummary.isValid()) { + edm::LogError("METplusTrackMonitor") << "Invalid collection: TriggerSummary" << "\n"; + return; + } + trigger::TriggerObject isoTrk; + bool passesHLTTrk50Filter = getHLTObj(triggerSummary, hltTrk50FilterTag_, isoTrk); + + bool leadMuonMatchToHLTTrack = muons.size() > 0 && + passesHLTTrk50Filter && + deltaR(muons[0], isoTrk) < 0.1; + if(!leadMuonMatchToHLTTrack) return; + + if(num_genTriggerEventFlag_->on() && !num_genTriggerEventFlag_->accept(iEvent, iSetup)) return; + + // Filling track leg histograms (denominator) + muonPtME_.numerator->Fill(leadMuonPt); + muonPtME_variableBinning_.numerator->Fill(leadMuonPt); + muonPtVsLS_.numerator->Fill(ls, leadMuonPt); + muonEtaME_.numerator->Fill(leadMuonEta); + deltaphimetmuonME_.numerator->Fill(deltaphi_metmuon); + mTmuonMetME_.numerator->Fill(mT_metmuon); + +} + +void METplusTrackMonitor::fillHistoPSetDescription(edm::ParameterSetDescription & pset) +{ + pset.add ("nbins"); + pset.add ("xmin"); + pset.add ("xmax"); +} + +void METplusTrackMonitor::fillHistoLSPSetDescription(edm::ParameterSetDescription & pset) +{ + pset.add("nbins", 2500); +} + +void METplusTrackMonitor::fillDescriptions(edm::ConfigurationDescriptions & descriptions) +{ + edm::ParameterSetDescription desc; + desc.add ( "FolderName", "HLT/MET" ); + + desc.add( "met", edm::InputTag("caloMet") ); + desc.add( "jets", edm::InputTag("ak4PFJetsCHS") ); + desc.add( "electrons", edm::InputTag("gedGsfElectrons") ); + desc.add( "muons", edm::InputTag("muons") ); + desc.add( "vertices", edm::InputTag("offlinePrimaryVertices") ); + desc.add( "trigSummary", edm::InputTag("hltTriggerSummaryAOD") ); + desc.add( "onlineMet", edm::InputTag("hltMet", "", "HLT") ); + desc.add( "onlineMetClean", edm::InputTag("hltMetClean", "", "HLT") ); + desc.add( "isoTrkFilter", edm::InputTag("hltTrk50Filter", "", "HLT") ); + + desc.add("metSelection", "pt > 0"); + desc.add("hltMetSelection", "pt > 0"); + desc.add("hltMetCleanSelection", "pt > 0"); + desc.add("jetSelection", "pt > 0"); + desc.add("muonSelection", "pt > 0"); + desc.add("vtxSelection", "!isFake"); + desc.add("njets", 0); + desc.add("nmuons", 0); + desc.add("leadJetEtaCut", 2.4); + desc.add("hltMetCut", 105.0); + desc.add("hltMetCleanCut", 65.0); + + edm::ParameterSetDescription genericTriggerEventPSet; + genericTriggerEventPSet.add("andOr"); + genericTriggerEventPSet.add("dcsInputTag", edm::InputTag("scalersRawToDigi") ); + genericTriggerEventPSet.add >("dcsPartitions", {}); + genericTriggerEventPSet.add("andOrDcs", false); + genericTriggerEventPSet.add("errorReplyDcs", true); + genericTriggerEventPSet.add("dbLabel", ""); + genericTriggerEventPSet.add("andOrHlt", true); + genericTriggerEventPSet.add("hltInputTag", edm::InputTag("TriggerResults::HLT") ); + genericTriggerEventPSet.add >("hltPaths", {}); + genericTriggerEventPSet.add("hltDBKey", ""); + genericTriggerEventPSet.add("errorReplyHlt", false); + genericTriggerEventPSet.add("verbosityLevel", 1); + + desc.add("numGenericTriggerEventPSet", genericTriggerEventPSet); + desc.add("denGenericTriggerEventPSet", genericTriggerEventPSet); + + edm::ParameterSetDescription histoPSet; + edm::ParameterSetDescription metPSet; + edm::ParameterSetDescription phiPSet; + edm::ParameterSetDescription ptPSet; + edm::ParameterSetDescription etaPSet; + + fillHistoPSetDescription(metPSet); + fillHistoPSetDescription(phiPSet); + fillHistoPSetDescription(ptPSet); + fillHistoPSetDescription(etaPSet); + + histoPSet.add("metPSet", metPSet); + histoPSet.add("phiPSet", phiPSet); + histoPSet.add("ptPSet", ptPSet); + histoPSet.add("etaPSet", etaPSet); + + std::vector bins = {0.,20.,40.,60.,80.,90.,100.,110.,120.,130.,140.,150.,160.,170.,180.,190.,200.,220.,240.,260.,280.,300.,350.,400.,450.,1000.}; + + histoPSet.add >("metBinning", bins); + histoPSet.add >("ptBinning", bins); + + edm::ParameterSetDescription lsPSet; + fillHistoLSPSetDescription(lsPSet); + histoPSet.add("lsPSet", lsPSet); + + desc.add("histoPSet", histoPSet); + + descriptions.add("metPlusTrackMonitoring", desc); +} + +bool METplusTrackMonitor::getHLTObj(const edm::Handle &trigSummary, const edm::InputTag filterTag, trigger::TriggerObject &obj) const +{ + + double leadingPt = -1.0; + + size_t filterIndex = trigSummary->filterIndex( filterTag ); + trigger::TriggerObjectCollection triggerObjects = trigSummary->getObjects(); + + if( !(filterIndex >= trigSummary->sizeFilters()) ) { + const trigger::Keys& keys = trigSummary->filterKeys( filterIndex ); + for(size_t j = 0; j < keys.size(); ++j) { + trigger::TriggerObject foundObject = triggerObjects[keys[j]]; + if(foundObject.pt() > leadingPt) { + obj = foundObject; + leadingPt = obj.pt(); + } + } + } + + return (leadingPt > 0.0); +} + +// Define this as a plug-in +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(METplusTrackMonitor); + diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.h b/DQMOffline/Trigger/plugins/METplusTrackMonitor.h new file mode 100644 index 0000000000000..2d9f2be9f9749 --- /dev/null +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.h @@ -0,0 +1,145 @@ +#ifndef DQMOFFLINE_TRIGGER_METPLUSTRACKMONITOR_H +#define DQMOFFLINE_TRIGGER_METPLUSTRACKMONITOR_H + +#include +#include +#include + +#include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/Registry.h" + +#include "DQMServices/Core/interface/MonitorElement.h" +#include +#include "DQM/TrackingMonitor/interface/GetLumi.h" + +#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h" +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" + +// DataFormats +#include "DataFormats/METReco/interface/CaloMET.h" +#include "DataFormats/METReco/interface/CaloMETCollection.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "DataFormats/JetReco/interface/PFJet.h" +#include "DataFormats/JetReco/interface/PFJetCollection.h" +#include "DataFormats/HLTReco/interface/TriggerObject.h" +#include "DataFormats/HLTReco/interface/TriggerEvent.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" + + +class GenericTriggerEventFlag; + +// +// class declaration +// + +class METplusTrackMonitor : public DQMEDAnalyzer +{ +public: + + struct MEbinning { + unsigned int nbins; + double xmin; + double xmax; + }; + + struct METplusTrackME { + MonitorElement * numerator; + MonitorElement * denominator; + }; + + METplusTrackMonitor( const edm::ParameterSet& ); + ~METplusTrackMonitor(); + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + static void fillHistoPSetDescription(edm::ParameterSetDescription & pset); + static void fillHistoLSPSetDescription(edm::ParameterSetDescription & pset); + +protected: + + void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; + void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbins, double xmin, double xmax); + void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, const std::vector& binningX); + void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, double ymin, double ymax); + void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, int nbinsY, double ymin, double ymax, bool bookNumerator); + void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, const std::vector& binningX, const std::vector& binningY); + void setMETitle(METplusTrackME& me, std::string titleX, std::string titleY, bool bookNumerator); + + void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override; + +private: + + static MEbinning getHistoPSet (edm::ParameterSet pset); + static MEbinning getHistoLSPSet (edm::ParameterSet pset); + + bool getHLTObj(const edm::Handle &trigSummary, const edm::InputTag filterTag, trigger::TriggerObject &obj) const; + + std::string folderName_; + std::string histoSuffix_; + + edm::EDGetTokenT metToken_; + edm::EDGetTokenT hltMetToken_; + edm::EDGetTokenT hltMetCleanToken_; + edm::EDGetTokenT muonToken_; + edm::EDGetTokenT jetToken_; + edm::EDGetTokenT vtxToken_; + edm::EDGetTokenT theTrigSummary_; + + edm::InputTag hltTrk50FilterTag_; + + std::vector met_variable_binning_; + std::vector muonPt_variable_binning_; + + MEbinning met_binning_; + MEbinning ls_binning_; + MEbinning pt_binning_; + MEbinning eta_binning_; + MEbinning phi_binning_; + + METplusTrackME metME_; + METplusTrackME metME_variableBinning_; + METplusTrackME metVsLS_; + METplusTrackME metPhiME_; + METplusTrackME deltaphimetj1ME_; + METplusTrackME metVsHltMet_; + METplusTrackME metVsHltMetClean_; + + METplusTrackME muonPtME_; + METplusTrackME muonPtME_variableBinning_; + METplusTrackME muonPtVsLS_; + METplusTrackME muonEtaME_; + METplusTrackME deltaphimetmuonME_; + METplusTrackME mTmuonMetME_; + + std::unique_ptr num_genTriggerEventFlag_; + std::unique_ptr den_genTriggerEventFlag_; + + StringCutObjectSelector metSelection_; + StringCutObjectSelector hltMetSelection_; + StringCutObjectSelector hltMetCleanSelection_; + + StringCutObjectSelector muonSelection_; + StringCutObjectSelector jetSelection_; + StringCutObjectSelector vtxSelection_; + unsigned nmuons_; + unsigned njets_; + + double leadJetEtaCut_; + double hltMetCut_; + double hltMetCleanCut_; + +}; + + +#endif // DQMOFFLINE_TRIGGER_METPLUSTRACKMONITOR_H + diff --git a/DQMOffline/Trigger/python/ExoticaMonitoring_Client_cff.py b/DQMOffline/Trigger/python/ExoticaMonitoring_Client_cff.py index 95a2f8520b7c4..2025c6fdfc605 100644 --- a/DQMOffline/Trigger/python/ExoticaMonitoring_Client_cff.py +++ b/DQMOffline/Trigger/python/ExoticaMonitoring_Client_cff.py @@ -35,7 +35,27 @@ ), ) +METplusTrackEfficiency = DQMEDHarvester("DQMGenericClient", + subDirs = cms.untracked.vstring("HLT/MET/MET105_IsoTrk50/", "HLT/MET/MET120_IsoTrk50/"), + verbose = cms.untracked.uint32(0), # Set to 2 for all messages + resolution = cms.vstring(), + efficiency = cms.vstring( + "effic_met 'MET leg turnON; CaloMET [GeV]; efficiency' met_numerator met_denominator", + "effic_met_variable 'MET leg turnON; CaloMET [GeV]; efficiency' met_variable_numerator met_variable_denominator", + "effic_metPhi 'MET leg efficiency vs phi; CaloMET phi [rad]; efficiency' metPhi_numerator metPhi_denominator", + "effic_muonPt 'Track leg turnON; Muon p_{T} [GeV]; efficiency' muonPt_numerator muonPt_denominator", + "effic_muonPt_variable 'Track leg turnON; Muon p_{T} [GeV]; efficiency' muonPt_variable_numerator muonPt_variable_denominator", + "effic_muonEta 'Track leg efficiency vs eta; Muon #eta; efficiency' muonEta_numerator muonEta_denominator", + ), + efficiencyProfile = cms.untracked.vstring( + "effic_met_vs_LS 'MET leg efficiency vs LS; LS; CaloMET leg efficiency' metVsLS_numerator metVsLS_denominator", + "effic_muonPt_vs_LS 'Track leg efficiency vs LS; LS; Track leg efficiency' muonPtVsLS_numerator muonPtVsLS_denominator", + ), + +) + exoticaClient = cms.Sequence( metEfficiency + NoBPTXEfficiency + + METplusTrackEfficiency ) diff --git a/DQMOffline/Trigger/python/ExoticaMonitoring_cff.py b/DQMOffline/Trigger/python/ExoticaMonitoring_cff.py index c5b593a0af1f1..3a5897f24f0cc 100644 --- a/DQMOffline/Trigger/python/ExoticaMonitoring_cff.py +++ b/DQMOffline/Trigger/python/ExoticaMonitoring_cff.py @@ -2,8 +2,10 @@ from DQMOffline.Trigger.METMonitor_cff import * from DQMOffline.Trigger.NoBPTXMonitor_cff import * +from DQMOffline.Trigger.METplusTrackMonitor_cff import * exoticaMonitorHLT = cms.Sequence( exoHLTMETmonitoring + exoHLTNoBPTXmonitoring + + exoHLTMETplusTrackMonitoring ) diff --git a/DQMOffline/Trigger/python/METplusTrackMonitor_cff.py b/DQMOffline/Trigger/python/METplusTrackMonitor_cff.py new file mode 100644 index 0000000000000..c40c2c0118740 --- /dev/null +++ b/DQMOffline/Trigger/python/METplusTrackMonitor_cff.py @@ -0,0 +1,23 @@ +import FWCore.ParameterSet.Config as cms + +from DQMOffline.Trigger.METplusTrackMonitor_cfi import hltMETplusTrackMonitoring + +# HLT_MET105_IsoTrk50 +MET105_IsoTrk50monitoring = hltMETplusTrackMonitoring.clone() +MET105_IsoTrk50monitoring.FolderName = cms.string('HLT/MET/MET105_IsoTrk50/') +MET105_IsoTrk50monitoring.numGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_MET105_IsoTrk50_v") +MET105_IsoTrk50monitoring.hltMetSelection = cms.string("pt > 105") +MET105_IsoTrk50monitoring.hltMetCleanSelection = cms.string("pt > 65") + +# HLT_MET120_IsoTrk50 +MET120_IsoTrk50monitoring = hltMETplusTrackMonitoring.clone() +MET120_IsoTrk50monitoring.FolderName = cms.string('HLT/MET/MET120_IsoTrk50/') +MET120_IsoTrk50monitoring.numGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_MET120_IsoTrk50_v") +MET105_IsoTrk50monitoring.hltMetSelection = cms.string("pt > 120") +MET105_IsoTrk50monitoring.hltMetCleanSelection = cms.string("pt > 65") + +exoHLTMETplusTrackMonitoring = cms.Sequence( + MET105_IsoTrk50monitoring + + MET120_IsoTrk50monitoring +) + diff --git a/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py b/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py new file mode 100644 index 0000000000000..f338ae7227168 --- /dev/null +++ b/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py @@ -0,0 +1,65 @@ +import FWCore.ParameterSet.Config as cms + +from DQMOffline.Trigger.metPlusTrackMonitoring_cfi import metPlusTrackMonitoring + +hltMETplusTrackMonitoring = metPlusTrackMonitoring.clone() +hltMETplusTrackMonitoring.FolderName = cms.string('HLT/MET/MET105_IsoTrk50/') +hltMETplusTrackMonitoring.histoPSet.metPSet = cms.PSet( + nbins = cms.uint32 (200), + xmin = cms.double(-0.5), + xmax = cms.double(999.5), +) +hltMETplusTrackMonitoring.histoPSet.ptPSet = cms.PSet( + nbins = cms.uint32 (200), + xmin = cms.double(-0.5), + xmax = cms.double(999.5), +) +hltMETplusTrackMonitoring.histoPSet.etaPSet = cms.PSet( + nbins = cms.uint32 (24), + xmin = cms.double(-2.4), + xmax = cms.double(2.4), +) +hltMETplusTrackMonitoring.histoPSet.phiPSet = cms.PSet( + nbins = cms.uint32(32), + xmin = cms.double(-3.2), + xmax = cms.double(3.2), +) + +# Define 100 logarithmic bins from 10^0 to 10^3 GeV +binsLogX_METplusTrack = [] +nBinsLogX_METplusTrack = 100 +powerLo_METplusTrack = 0.0 +powerHi_METplusTrack = 3.0 +binPowerWidth_METplusTrack = (powerHi_METplusTrack - powerLo_METplusTrack) / nBinsLogX_METplusTrack +for ibin in range(nBinsLogX_METplusTrack + 1): + binsLogX_METplusTrack.append( pow(10, powerLo_METplusTrack + ibin * binPowerWidth_METplusTrack) ) + +hltMETplusTrackMonitoring.histoPSet.metBinning = cms.vdouble(binsLogX_METplusTrack) +hltMETplusTrackMonitoring.histoPSet.ptBinning = cms.vdouble(binsLogX_METplusTrack) + +hltMETplusTrackMonitoring.met = cms.InputTag("caloMet") # caloMet +hltMETplusTrackMonitoring.jets = cms.InputTag("pfJetsEI") # ak4PFJets, ak4PFJetsCHS +hltMETplusTrackMonitoring.muons = cms.InputTag("muons") # while pfIsolatedMuonsEI are reco::PFCandidate ! + +hltMETplusTrackMonitoring.muonSelection = cms.string('pt>26 && abs(eta)<2.1') +hltMETplusTrackMonitoring.vtxSelection = cms.string('ndof>=4 && abs(z)<24.0 && position.Rho<2.0') +hltMETplusTrackMonitoring.njets = cms.uint32(1) +hltMETplusTrackMonitoring.nmuons = cms.uint32(1) +hltMETplusTrackMonitoring.leadJetEtaCut = cms.double(2.4) + +hltMETplusTrackMonitoring.numGenericTriggerEventPSet.andOr = cms.bool( False ) +#hltMETplusTrackMonitoring.numGenericTriggerEventPSet.dbLabel = cms.string("ExoDQMTrigger") # it does not exist yet, we should consider the possibility of using the DB, but as it is now it will need a label per path ! +hltMETplusTrackMonitoring.numGenericTriggerEventPSet.andOrHlt = cms.bool(True)# True:=OR; False:=AND +hltMETplusTrackMonitoring.numGenericTriggerEventPSet.hltInputTag = cms.InputTag( "TriggerResults::HLT" ) +hltMETplusTrackMonitoring.numGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_MET105_IsoTrk50_v") # HLT_ZeroBias_v +#hltMETplusTrackMonitoring.numGenericTriggerEventPSet.hltDBKey = cms.string("EXO_HLT_MET") +hltMETplusTrackMonitoring.numGenericTriggerEventPSet.errorReplyHlt = cms.bool( False ) +hltMETplusTrackMonitoring.numGenericTriggerEventPSet.verbosityLevel = cms.uint32(0) + +hltMETplusTrackMonitoring.denGenericTriggerEventPSet.andOr = cms.bool( False ) +hltMETplusTrackMonitoring.denGenericTriggerEventPSet.dcsInputTag = cms.InputTag( "scalersRawToDigi" ) +hltMETplusTrackMonitoring.denGenericTriggerEventPSet.dcsPartitions = cms.vint32 ( 24, 25, 26, 27, 28, 29 ) # 24-27: strip, 28-29: pixel, we should add all other detectors ! +hltMETplusTrackMonitoring.denGenericTriggerEventPSet.andOrDcs = cms.bool( False ) +hltMETplusTrackMonitoring.denGenericTriggerEventPSet.errorReplyDcs = cms.bool( True ) +hltMETplusTrackMonitoring.denGenericTriggerEventPSet.verbosityLevel = cms.uint32(1) +hltMETplusTrackMonitoring.denGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_IsoMu27_v", "HLT_IsoTkMu27_v") From 19135006fe6518405862902988f7e718939d01ca Mon Sep 17 00:00:00 2001 From: bpf6qc Date: Sat, 1 Jul 2017 14:55:31 -0400 Subject: [PATCH 2/6] Adjust binning, histograms, and some variable names as requested. --- .../Trigger/plugins/METplusTrackMonitor.cc | 74 +++++++------------ .../Trigger/plugins/METplusTrackMonitor.h | 7 +- .../python/ExoticaMonitoring_Client_cff.py | 7 +- .../Trigger/python/METplusTrackMonitor_cfi.py | 6 +- 4 files changed, 36 insertions(+), 58 deletions(-) diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc index 10fbb4214680f..4941b5c0fd13d 100644 --- a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc @@ -22,14 +22,14 @@ METplusTrackMonitor::METplusTrackMonitor( const edm::ParameterSet& iConfig ) : , jetToken_ ( consumes (iConfig.getParameter("jets") ) ) , vtxToken_ ( consumes (iConfig.getParameter("vertices") ) ) , theTrigSummary_ ( consumes (iConfig.getParameter("trigSummary") ) ) - , hltTrk50FilterTag_ ( iConfig.getParameter("isoTrkFilter") ) + , trackLegFilterTag_ ( iConfig.getParameter("trackLegFilter") ) , met_variable_binning_ ( iConfig.getParameter("histoPSet").getParameter >("metBinning") ) , muonPt_variable_binning_ ( iConfig.getParameter("histoPSet").getParameter >("ptBinning") ) , met_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("metPSet") ) ) , ls_binning_ ( getHistoLSPSet (iConfig.getParameter("histoPSet").getParameter("lsPSet") ) ) , pt_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("ptPSet") ) ) - , eta_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("etaPSet") ) ) - , phi_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("phiPSet") ) ) + , eta_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("etaPSet") ) ) + , phi_binning_ ( getHistoPSet (iConfig.getParameter("histoPSet").getParameter("phiPSet") ) ) , num_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter("numGenericTriggerEventPSet"), consumesCollector(), *this)) , den_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter("denGenericTriggerEventPSet"), consumesCollector(), *this)) , metSelection_ ( iConfig.getParameter("metSelection") ) @@ -45,8 +45,6 @@ METplusTrackMonitor::METplusTrackMonitor( const edm::ParameterSet& iConfig ) : , hltMetCleanCut_ ( iConfig.getParameter("hltMetCleanCut") ) { - metME_.numerator = nullptr; - metME_.denominator = nullptr; metME_variableBinning_.numerator = nullptr; metME_variableBinning_.denominator = nullptr; metVsLS_.numerator = nullptr; @@ -55,15 +53,17 @@ METplusTrackMonitor::METplusTrackMonitor( const edm::ParameterSet& iConfig ) : metPhiME_.denominator = nullptr; deltaphimetj1ME_.numerator = nullptr; deltaphimetj1ME_.denominator = nullptr; + metVsHltMet_.denominator = nullptr; + metVsHltMetClean_.denominator = nullptr; - muonPtME_.numerator = nullptr; - muonPtME_.denominator = nullptr; muonPtME_variableBinning_.numerator = nullptr; muonPtME_variableBinning_.denominator = nullptr; muonPtVsLS_.numerator = nullptr; muonPtVsLS_.denominator = nullptr; deltaphimetmuonME_.numerator = nullptr; deltaphimetmuonME_.denominator = nullptr; + muonEtaVsPhi_.numerator = nullptr; + muonEtaVsPhi_.denominator = nullptr; } @@ -150,10 +150,6 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, // MET leg histograms - histname = "met"; histtitle = "CaloMET"; - bookME(ibooker, metME_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax); - setMETitle(metME_, "CaloMET [GeV]", "events / [GeV]"); - histname = "met_variable"; histtitle = "CaloMET"; bookME(ibooker, metME_variableBinning_, histname, histtitle, met_variable_binning_); setMETitle(metME_variableBinning_, "CaloMET [GeV]", "events / [GeV]"); @@ -164,28 +160,24 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, histname = "metPhi"; histtitle = "CaloMET phi"; bookME(ibooker, metPhiME_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax); - setMETitle(metPhiME_, "CaloMET #phi","events / 0.1 rad"); + setMETitle(metPhiME_, "CaloMET #phi","events / 0.2 rad"); histname = "deltaphi_metjet1"; histtitle = "dPhi(CaloMET, jet1)"; bookME(ibooker, deltaphimetj1ME_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax); - setMETitle(deltaphimetj1ME_, "#Delta#phi (CaloMET, j1)", "events / 0.1 rad"); + setMETitle(deltaphimetj1ME_, "#Delta#phi (CaloMET, j1)", "events / 0.2 rad"); histname = "metVsHltMet"; histtitle = "CaloMET vs hltMet"; - bool bookDenominator = false; - bookME(ibooker, metVsHltMet_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, bookDenominator); - setMETitle(metVsHltMet_, "hltMet (online) [GeV]", "CaloMET (offline) [GeV]", bookDenominator); + bool bookNumerator = false; + bookME(ibooker, metVsHltMet_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, bookNumerator); + setMETitle(metVsHltMet_, "hltMet (online) [GeV]", "CaloMET (offline) [GeV]", bookNumerator); histname = "metVsHltMetClean"; histtitle = "CaloMET vs hltMetClean"; - bookDenominator = false; - bookME(ibooker, metVsHltMetClean_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, bookDenominator); - setMETitle(metVsHltMetClean_, "hltMetClean (online) [GeV]", "CaloMET (offline) [GeV]", bookDenominator); + bookNumerator = false; + bookME(ibooker, metVsHltMetClean_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, bookNumerator); + setMETitle(metVsHltMetClean_, "hltMetClean (online) [GeV]", "CaloMET (offline) [GeV]", bookNumerator); // Track leg histograms - histname = "muonPt"; histtitle = "Muon PT"; - bookME(ibooker, muonPtME_, histname, histtitle, pt_binning_.nbins, pt_binning_.xmin, pt_binning_.xmax); - setMETitle(muonPtME_, "Muon p_{T} [GeV]", "events / [GeV]"); - histname = "muonPt_variable"; histtitle = "Muon PT"; bookME(ibooker, muonPtME_variableBinning_, histname, histtitle, muonPt_variable_binning_); setMETitle(muonPtME_variableBinning_, "Muon p_{T} [GeV]", "events / [GeV]"); @@ -196,11 +188,11 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, histname = "deltaphi_muonmet"; histtitle = "dPhi(Muon, CaloMET)"; bookME(ibooker, deltaphimetmuonME_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax); - setMETitle(deltaphimetmuonME_, "#Delta#phi (Muon, CaloMET)", "events / 0.1 rad"); + setMETitle(deltaphimetmuonME_, "#Delta#phi (Muon, CaloMET)", "events / 0.2 rad"); - histname = "mT_muonMet"; histtitle = "Transverse mass of muon-CaloMET system"; - bookME(ibooker, mTmuonMetME_, histname, histtitle, pt_binning_.nbins, pt_binning_.xmin, pt_binning_.xmax); - setMETitle(mTmuonMetME_, "mT(Muon, CaloMET) [GeV]", "events / [GeV]"); + histname = "muonEtaVsPhi"; histtitle = "Muon eta vs phi"; + bookME(ibooker, muonEtaVsPhi_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax, eta_binning_.nbins, eta_binning_.xmin, eta_binning_.xmax); + setMETitle(muonEtaVsPhi_, "Muon #phi", "Muon #eta"); histname = "muonPtVsLS"; histtitle = "Muon PT vs LS"; bookME(ibooker, muonPtVsLS_, histname, histtitle, ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax, pt_binning_.xmin, pt_binning_.xmax); @@ -255,18 +247,10 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, std::vector muons; muons.clear(); for(auto const & m : *muonHandle) { - bool pass = m.isGlobalMuon() && - m.isPFMuon() && - m.globalTrack()->normalizedChi2() < 10. && - m.globalTrack()->hitPattern().numberOfValidMuonHits() > 0 && - m.numberOfMatchedStations() > 1 && - fabs(m.muonBestTrack()->dxy(pv->position())) < 0.2 && - fabs(m.muonBestTrack()->dz(pv->position())) < 0.5 && - m.innerTrack()->hitPattern().numberOfValidPixelHits() > 0 && - m.innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5; + bool passTightID = muon::isTightMuon(m, *pv); bool passMissHits = m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::MISSING_INNER_HITS) == 0 && m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::TRACK_HITS) == 0; - if(muonSelection_(m) && pass && passMissHits) muons.push_back(m); + if(muonSelection_(m) && passTightID && passMissHits) muons.push_back(m); } if(muons.size() < nmuons_) return; @@ -287,7 +271,6 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, reco::CaloMET hltMetClean = hltMetCleanHandle->front(); // Filling MET leg histograms (denominator) - metME_.denominator->Fill(met); metME_variableBinning_.denominator->Fill(met); metPhiME_.denominator->Fill(metPhi); deltaphimetj1ME_.denominator->Fill(deltaphi_metjet1); @@ -301,7 +284,6 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, if(hltMet.pt() <= hltMetCut_ || hltMetClean.pt() <= hltMetCleanCut_) return; // Filling MET leg histograms (numerator) - metME_.numerator->Fill(met); metME_variableBinning_.numerator->Fill(met); metPhiME_.numerator->Fill(metPhi); deltaphimetj1ME_.numerator->Fill(deltaphi_metjet1); @@ -310,15 +292,14 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, // Filling track leg histograms (denominator) double leadMuonPt = muons.size() ? muons[0].pt() : -1.0; double leadMuonEta = muons.size() ? muons[0].eta() : 10.0; + double leadMuonPhi = muons.size() ? muons[0].phi() : 10.0; float deltaphi_metmuon = fabs(deltaPhi(caloMet.phi(), muons[0].phi())); - float mT_metmuon = sqrt( 2.0 * met * muons[0].pt() * (1.0 - cos(deltaPhi(muons[0].phi(), caloMet.phi())))); - muonPtME_.denominator->Fill(leadMuonPt); muonPtME_variableBinning_.denominator->Fill(leadMuonPt); muonPtVsLS_.denominator->Fill(ls, leadMuonPt); muonEtaME_.denominator->Fill(leadMuonEta); deltaphimetmuonME_.denominator->Fill(deltaphi_metmuon); - mTmuonMetME_.denominator->Fill(mT_metmuon); + muonEtaVsPhi_.denominator->Fill(leadMuonPhi, leadMuonEta); // Apply the selection for the track leg numerator edm::Handle triggerSummary; @@ -328,22 +309,21 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, return; } trigger::TriggerObject isoTrk; - bool passesHLTTrk50Filter = getHLTObj(triggerSummary, hltTrk50FilterTag_, isoTrk); + bool passesTrackLegFilter = getHLTObj(triggerSummary, trackLegFilterTag_, isoTrk); bool leadMuonMatchToHLTTrack = muons.size() > 0 && - passesHLTTrk50Filter && + passesTrackLegFilter && deltaR(muons[0], isoTrk) < 0.1; if(!leadMuonMatchToHLTTrack) return; if(num_genTriggerEventFlag_->on() && !num_genTriggerEventFlag_->accept(iEvent, iSetup)) return; // Filling track leg histograms (denominator) - muonPtME_.numerator->Fill(leadMuonPt); muonPtME_variableBinning_.numerator->Fill(leadMuonPt); muonPtVsLS_.numerator->Fill(ls, leadMuonPt); muonEtaME_.numerator->Fill(leadMuonEta); deltaphimetmuonME_.numerator->Fill(deltaphi_metmuon); - mTmuonMetME_.numerator->Fill(mT_metmuon); + muonEtaVsPhi_.numerator->Fill(leadMuonPhi, leadMuonEta); } @@ -372,7 +352,7 @@ void METplusTrackMonitor::fillDescriptions(edm::ConfigurationDescriptions & desc desc.add( "trigSummary", edm::InputTag("hltTriggerSummaryAOD") ); desc.add( "onlineMet", edm::InputTag("hltMet", "", "HLT") ); desc.add( "onlineMetClean", edm::InputTag("hltMetClean", "", "HLT") ); - desc.add( "isoTrkFilter", edm::InputTag("hltTrk50Filter", "", "HLT") ); + desc.add( "trackLegFilter", edm::InputTag("hltTrk50Filter", "", "HLT") ); desc.add("metSelection", "pt > 0"); desc.add("hltMetSelection", "pt > 0"); diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.h b/DQMOffline/Trigger/plugins/METplusTrackMonitor.h index 2d9f2be9f9749..4c10ea217f322 100644 --- a/DQMOffline/Trigger/plugins/METplusTrackMonitor.h +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.h @@ -30,6 +30,7 @@ #include "DataFormats/METReco/interface/CaloMETCollection.h" #include "DataFormats/MuonReco/interface/Muon.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "DataFormats/MuonReco/interface/MuonSelectors.h" #include "DataFormats/JetReco/interface/PFJet.h" #include "DataFormats/JetReco/interface/PFJetCollection.h" #include "DataFormats/HLTReco/interface/TriggerObject.h" @@ -95,7 +96,7 @@ class METplusTrackMonitor : public DQMEDAnalyzer edm::EDGetTokenT vtxToken_; edm::EDGetTokenT theTrigSummary_; - edm::InputTag hltTrk50FilterTag_; + edm::InputTag trackLegFilterTag_; std::vector met_variable_binning_; std::vector muonPt_variable_binning_; @@ -106,7 +107,6 @@ class METplusTrackMonitor : public DQMEDAnalyzer MEbinning eta_binning_; MEbinning phi_binning_; - METplusTrackME metME_; METplusTrackME metME_variableBinning_; METplusTrackME metVsLS_; METplusTrackME metPhiME_; @@ -114,12 +114,11 @@ class METplusTrackMonitor : public DQMEDAnalyzer METplusTrackME metVsHltMet_; METplusTrackME metVsHltMetClean_; - METplusTrackME muonPtME_; METplusTrackME muonPtME_variableBinning_; METplusTrackME muonPtVsLS_; METplusTrackME muonEtaME_; METplusTrackME deltaphimetmuonME_; - METplusTrackME mTmuonMetME_; + METplusTrackME muonEtaVsPhi_; std::unique_ptr num_genTriggerEventFlag_; std::unique_ptr den_genTriggerEventFlag_; diff --git a/DQMOffline/Trigger/python/ExoticaMonitoring_Client_cff.py b/DQMOffline/Trigger/python/ExoticaMonitoring_Client_cff.py index 2025c6fdfc605..46b402e599bae 100644 --- a/DQMOffline/Trigger/python/ExoticaMonitoring_Client_cff.py +++ b/DQMOffline/Trigger/python/ExoticaMonitoring_Client_cff.py @@ -13,7 +13,7 @@ efficiencyProfile = cms.untracked.vstring( "effic_met_vs_LS 'MET efficiency vs LS; LS; PF MET efficiency' metVsLS_numerator metVsLS_denominator" ), - + ) NoBPTXEfficiency = DQMEDHarvester("DQMGenericClient", @@ -32,7 +32,7 @@ ), efficiencyProfile = cms.untracked.vstring( "effic_jetE_vs_LS 'Calo jet energy efficiency vs LS; LS; Jet p_{T} Efficiency' jetEVsLS_numerator jetEVsLS_denominator", - ), + ), ) METplusTrackEfficiency = DQMEDHarvester("DQMGenericClient", @@ -40,10 +40,8 @@ verbose = cms.untracked.uint32(0), # Set to 2 for all messages resolution = cms.vstring(), efficiency = cms.vstring( - "effic_met 'MET leg turnON; CaloMET [GeV]; efficiency' met_numerator met_denominator", "effic_met_variable 'MET leg turnON; CaloMET [GeV]; efficiency' met_variable_numerator met_variable_denominator", "effic_metPhi 'MET leg efficiency vs phi; CaloMET phi [rad]; efficiency' metPhi_numerator metPhi_denominator", - "effic_muonPt 'Track leg turnON; Muon p_{T} [GeV]; efficiency' muonPt_numerator muonPt_denominator", "effic_muonPt_variable 'Track leg turnON; Muon p_{T} [GeV]; efficiency' muonPt_variable_numerator muonPt_variable_denominator", "effic_muonEta 'Track leg efficiency vs eta; Muon #eta; efficiency' muonEta_numerator muonEta_denominator", ), @@ -59,3 +57,4 @@ + NoBPTXEfficiency + METplusTrackEfficiency ) + diff --git a/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py b/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py index f338ae7227168..0a5a69ed87c70 100644 --- a/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py +++ b/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py @@ -5,12 +5,12 @@ hltMETplusTrackMonitoring = metPlusTrackMonitoring.clone() hltMETplusTrackMonitoring.FolderName = cms.string('HLT/MET/MET105_IsoTrk50/') hltMETplusTrackMonitoring.histoPSet.metPSet = cms.PSet( - nbins = cms.uint32 (200), + nbins = cms.uint32 (100), xmin = cms.double(-0.5), xmax = cms.double(999.5), ) hltMETplusTrackMonitoring.histoPSet.ptPSet = cms.PSet( - nbins = cms.uint32 (200), + nbins = cms.uint32 (100), xmin = cms.double(-0.5), xmax = cms.double(999.5), ) @@ -41,7 +41,7 @@ hltMETplusTrackMonitoring.jets = cms.InputTag("pfJetsEI") # ak4PFJets, ak4PFJetsCHS hltMETplusTrackMonitoring.muons = cms.InputTag("muons") # while pfIsolatedMuonsEI are reco::PFCandidate ! -hltMETplusTrackMonitoring.muonSelection = cms.string('pt>26 && abs(eta)<2.1') +hltMETplusTrackMonitoring.muonSelection = cms.string('pt>26 && abs(eta)<2.1 && (pfIsolationR04.sumChargedHadronPt+pfIsolationR04.sumPhotonEt+pfIsolationR04.sumNeutralHadronEt-0.5*pfIsolationR04.sumPUPt)/pt<0.12') hltMETplusTrackMonitoring.vtxSelection = cms.string('ndof>=4 && abs(z)<24.0 && position.Rho<2.0') hltMETplusTrackMonitoring.njets = cms.uint32(1) hltMETplusTrackMonitoring.nmuons = cms.uint32(1) From 09f2c7de89e5a3d02384231a147a1fc72f0b5540 Mon Sep 17 00:00:00 2001 From: bpf6qc Date: Tue, 4 Jul 2017 19:48:06 -0400 Subject: [PATCH 3/6] Remove possible invalid reference for muons without innerTrack() --- DQMOffline/Trigger/plugins/METplusTrackMonitor.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc index 4941b5c0fd13d..071901c2c9792 100644 --- a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc @@ -247,10 +247,10 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, std::vector muons; muons.clear(); for(auto const & m : *muonHandle) { - bool passTightID = muon::isTightMuon(m, *pv); - bool passMissHits = m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::MISSING_INNER_HITS) == 0 && - m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::TRACK_HITS) == 0; - if(muonSelection_(m) && passTightID && passMissHits) muons.push_back(m); + bool passTightID = muon::isTightMuon(m, *pv) && + m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::MISSING_INNER_HITS) == 0 && + m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::TRACK_HITS) == 0; + if(muonSelection_(m) && passTightID) muons.push_back(m); } if(muons.size() < nmuons_) return; From 8d5f74478d7d624ea5c0b4ebfb5fcee713189fae Mon Sep 17 00:00:00 2001 From: bpf6qc Date: Mon, 10 Jul 2017 17:39:16 -0400 Subject: [PATCH 4/6] Get online MET from TriggerEvent instead of transient collections, use TriggerDQMBase --- .../Trigger/plugins/METplusTrackMonitor.cc | 179 ++++-------------- .../Trigger/plugins/METplusTrackMonitor.h | 68 ++----- .../Trigger/python/METplusTrackMonitor_cff.py | 12 +- .../Trigger/python/METplusTrackMonitor_cfi.py | 5 +- 4 files changed, 67 insertions(+), 197 deletions(-) diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc index 071901c2c9792..3da0bc572d3f4 100644 --- a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc @@ -16,12 +16,12 @@ METplusTrackMonitor::METplusTrackMonitor( const edm::ParameterSet& iConfig ) : folderName_ ( iConfig.getParameter("FolderName") ) , metToken_ ( consumes (iConfig.getParameter("met") ) ) - , hltMetToken_ ( consumes (iConfig.getParameter("onlineMet") ) ) - , hltMetCleanToken_ ( consumes (iConfig.getParameter("onlineMetClean") ) ) , muonToken_ ( consumes (iConfig.getParameter("muons") ) ) , jetToken_ ( consumes (iConfig.getParameter("jets") ) ) , vtxToken_ ( consumes (iConfig.getParameter("vertices") ) ) , theTrigSummary_ ( consumes (iConfig.getParameter("trigSummary") ) ) + , hltMetTag_ ( iConfig.getParameter("hltMetFilter") ) + , hltMetCleanTag_ ( iConfig.getParameter("hltMetCleanFilter") ) , trackLegFilterTag_ ( iConfig.getParameter("trackLegFilter") ) , met_variable_binning_ ( iConfig.getParameter("histoPSet").getParameter >("metBinning") ) , muonPt_variable_binning_ ( iConfig.getParameter("histoPSet").getParameter >("ptBinning") ) @@ -33,16 +33,12 @@ METplusTrackMonitor::METplusTrackMonitor( const edm::ParameterSet& iConfig ) : , num_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter("numGenericTriggerEventPSet"), consumesCollector(), *this)) , den_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter("denGenericTriggerEventPSet"), consumesCollector(), *this)) , metSelection_ ( iConfig.getParameter("metSelection") ) - , hltMetSelection_ ( iConfig.getParameter("hltMetSelection") ) - , hltMetCleanSelection_ ( iConfig.getParameter("hltMetCleanSelection") ) , muonSelection_ ( iConfig.getParameter("muonSelection") ) , jetSelection_ ( iConfig.getParameter("jetSelection") ) , vtxSelection_ ( iConfig.getParameter("vtxSelection") ) , nmuons_ ( iConfig.getParameter("nmuons") ) , njets_ ( iConfig.getParameter("njets") ) , leadJetEtaCut_ ( iConfig.getParameter("leadJetEtaCut") ) - , hltMetCut_ ( iConfig.getParameter("hltMetCut") ) - , hltMetCleanCut_ ( iConfig.getParameter("hltMetCleanCut") ) { metME_variableBinning_.numerator = nullptr; @@ -53,8 +49,8 @@ METplusTrackMonitor::METplusTrackMonitor( const edm::ParameterSet& iConfig ) : metPhiME_.denominator = nullptr; deltaphimetj1ME_.numerator = nullptr; deltaphimetj1ME_.denominator = nullptr; - metVsHltMet_.denominator = nullptr; - metVsHltMetClean_.denominator = nullptr; + metVsHltMet_.numerator = nullptr; // numerator only, only available from passed filter + metVsHltMetClean_.numerator = nullptr; // numerator only, only available from passed filter muonPtME_variableBinning_.numerator = nullptr; muonPtME_variableBinning_.denominator = nullptr; @@ -67,78 +63,6 @@ METplusTrackMonitor::METplusTrackMonitor( const edm::ParameterSet& iConfig ) : } -METplusTrackMonitor::~METplusTrackMonitor() -{ -} - -METplusTrackMonitor::MEbinning METplusTrackMonitor::getHistoPSet(edm::ParameterSet pset) -{ - return METplusTrackMonitor::MEbinning { - pset.getParameter("nbins"), - pset.getParameter("xmin"), - pset.getParameter("xmax") - }; -} - -METplusTrackMonitor::MEbinning METplusTrackMonitor::getHistoLSPSet(edm::ParameterSet pset) -{ - return METplusTrackMonitor::MEbinning { - pset.getParameter("nbins"), - 0.0, - double(pset.getParameter("nbins")) - }; -} - -void METplusTrackMonitor::setMETitle(METplusTrackME& me, std::string titleX, std::string titleY, bool bookNumerator = true) -{ - if(bookNumerator) { - me.numerator->setAxisTitle(titleX, 1); - me.numerator->setAxisTitle(titleY, 2); - } - me.denominator->setAxisTitle(titleX, 1); - me.denominator->setAxisTitle(titleY, 2); -} - -void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbins, double min, double max) -{ - me.numerator = ibooker.book1D(histname + "_numerator", histtitle + " (numerator)", nbins, min, max); - me.denominator = ibooker.book1D(histname + "_denominator", histtitle + " (denominator)", nbins, min, max); -} - -void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, const std::vector& binning) -{ - int nbins = binning.size() - 1; - std::vector fbinning(binning.begin(), binning.end()); - float * arr = &fbinning[0]; - me.numerator = ibooker.book1D(histname + "_numerator", histtitle + " (numerator)", nbins, arr); - me.denominator = ibooker.book1D(histname + "_denominator", histtitle + " (denominator)", nbins, arr); -} - -void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, double ymin, double ymax) -{ - me.numerator = ibooker.bookProfile(histname + "_numerator", histtitle + " (numerator)", nbinsX, xmin, xmax, ymin, ymax); - me.denominator = ibooker.bookProfile(histname + "_denominator", histtitle + " (denominator)", nbinsX, xmin, xmax, ymin, ymax); -} - -void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, int nbinsY, double ymin, double ymax, bool bookNumerator = true) -{ - if(bookNumerator) me.numerator = ibooker.book2D(histname + "_numerator", histtitle + " (numerator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax); - me.denominator = ibooker.book2D(histname + "_denominator", histtitle + " (denominator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax); -} - -void METplusTrackMonitor::bookME(DQMStore::IBooker &ibooker, METplusTrackME& me, const std::string& histname, const std::string& histtitle, const std::vector& binningX, const std::vector& binningY) -{ - int nbinsX = binningX.size() - 1; - std::vector fbinningX(binningX.begin(), binningX.end()); - float * arrX = &fbinningX[0]; - int nbinsY = binningY.size() - 1; - std::vector fbinningY(binningY.begin(), binningY.end()); - float * arrY = &fbinningY[0]; - - me.numerator = ibooker.book2D(histname+"_numerator", histtitle+" (numerator)", nbinsX, arrX, nbinsY, arrY); - me.denominator = ibooker.book2D(histname+"_denominator", histtitle+" (denominator)", nbinsX, arrX, nbinsY, arrY); -} - void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &iSetup) @@ -163,18 +87,16 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, setMETitle(metPhiME_, "CaloMET #phi","events / 0.2 rad"); histname = "deltaphi_metjet1"; histtitle = "dPhi(CaloMET, jet1)"; - bookME(ibooker, deltaphimetj1ME_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax); - setMETitle(deltaphimetj1ME_, "#Delta#phi (CaloMET, j1)", "events / 0.2 rad"); + bookME(ibooker, deltaphimetj1ME_, histname, histtitle, phi_binning_.nbins, 0, phi_binning_.xmax); + setMETitle(deltaphimetj1ME_, "#Delta#phi (CaloMET, j1)", "events / 0.1 rad"); histname = "metVsHltMet"; histtitle = "CaloMET vs hltMet"; - bool bookNumerator = false; - bookME(ibooker, metVsHltMet_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, bookNumerator); - setMETitle(metVsHltMet_, "hltMet (online) [GeV]", "CaloMET (offline) [GeV]", bookNumerator); + bookME(ibooker, metVsHltMet_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax); + setMETitle(metVsHltMet_, "hltMet (online) [GeV]", "CaloMET (offline) [GeV]"); histname = "metVsHltMetClean"; histtitle = "CaloMET vs hltMetClean"; - bookNumerator = false; - bookME(ibooker, metVsHltMetClean_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, bookNumerator); - setMETitle(metVsHltMetClean_, "hltMetClean (online) [GeV]", "CaloMET (offline) [GeV]", bookNumerator); + bookME(ibooker, metVsHltMetClean_, histname, histtitle, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax, met_binning_.nbins, met_binning_.xmin, met_binning_.xmax); + setMETitle(metVsHltMetClean_, "hltMetClean (online) [GeV]", "CaloMET (offline) [GeV]"); // Track leg histograms @@ -187,8 +109,8 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, setMETitle(muonEtaME_, "Muon #eta", "events / 0.2"); histname = "deltaphi_muonmet"; histtitle = "dPhi(Muon, CaloMET)"; - bookME(ibooker, deltaphimetmuonME_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax); - setMETitle(deltaphimetmuonME_, "#Delta#phi (Muon, CaloMET)", "events / 0.2 rad"); + bookME(ibooker, deltaphimetmuonME_, histname, histtitle, phi_binning_.nbins, 0, phi_binning_.xmax); + setMETitle(deltaphimetmuonME_, "#Delta#phi (Muon, CaloMET)", "events / 0.1 rad"); histname = "muonEtaVsPhi"; histtitle = "Muon eta vs phi"; bookME(ibooker, muonEtaVsPhi_, histname, histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax, eta_binning_.nbins, eta_binning_.xmin, eta_binning_.xmax); @@ -248,46 +170,41 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, muons.clear(); for(auto const & m : *muonHandle) { bool passTightID = muon::isTightMuon(m, *pv) && - m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::MISSING_INNER_HITS) == 0 && + m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::MISSING_INNER_HITS) == 0 && m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::TRACK_HITS) == 0; if(muonSelection_(m) && passTightID) muons.push_back(m); } if(muons.size() < nmuons_) return; - edm::Handle hltMetHandle; - iEvent.getByToken(hltMetToken_, hltMetHandle); - if(!hltMetHandle.isValid()) { - edm::LogError("METplusTrackMonitor") << "Invalid collection: hltMet" << "\n"; - return; - } - reco::CaloMET hltMet = hltMetHandle->front(); - - edm::Handle hltMetCleanHandle; - iEvent.getByToken(hltMetCleanToken_, hltMetCleanHandle); - if(!hltMetCleanHandle.isValid()) { - edm::LogError("METplusTrackMonitor") << "Invalid collection: hltMetClean" << "\n"; - return; - } - reco::CaloMET hltMetClean = hltMetCleanHandle->front(); - // Filling MET leg histograms (denominator) metME_variableBinning_.denominator->Fill(met); metPhiME_.denominator->Fill(metPhi); deltaphimetj1ME_.denominator->Fill(deltaphi_metjet1); - metVsHltMet_.denominator->Fill(hltMet.pt(), met); - metVsHltMetClean_.denominator->Fill(hltMetClean.pt(), met); int ls = iEvent.id().luminosityBlock(); metVsLS_.denominator->Fill(ls, met); // Apply the selection for the MET leg numerator - if(hltMet.pt() <= hltMetCut_ || hltMetClean.pt() <= hltMetCleanCut_) return; + edm::Handle triggerSummary; + iEvent.getByToken(theTrigSummary_, triggerSummary); + if(!triggerSummary.isValid()) { + edm::LogError("METplusTrackMonitor") << "Invalid collection: TriggerSummary" << "\n"; + return; + } + + trigger::TriggerObject hltMet, hltMetClean; + bool passesHltMetFilter = getHLTObj(triggerSummary, hltMetTag_, hltMet); + bool passesHltMetCleanFilter = getHLTObj(triggerSummary, hltMetCleanTag_, hltMetClean); + + if(!passesHltMetFilter || !passesHltMetCleanFilter) return; // Filling MET leg histograms (numerator) metME_variableBinning_.numerator->Fill(met); metPhiME_.numerator->Fill(metPhi); deltaphimetj1ME_.numerator->Fill(deltaphi_metjet1); metVsLS_.numerator->Fill(ls, met); + metVsHltMet_.numerator->Fill(hltMet.pt(), met); + metVsHltMetClean_.numerator->Fill(hltMetClean.pt(), met); // Filling track leg histograms (denominator) double leadMuonPt = muons.size() ? muons[0].pt() : -1.0; @@ -302,12 +219,6 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, muonEtaVsPhi_.denominator->Fill(leadMuonPhi, leadMuonEta); // Apply the selection for the track leg numerator - edm::Handle triggerSummary; - iEvent.getByToken(theTrigSummary_, triggerSummary); - if(!triggerSummary.isValid()) { - edm::LogError("METplusTrackMonitor") << "Invalid collection: TriggerSummary" << "\n"; - return; - } trigger::TriggerObject isoTrk; bool passesTrackLegFilter = getHLTObj(triggerSummary, trackLegFilterTag_, isoTrk); @@ -327,44 +238,28 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, } -void METplusTrackMonitor::fillHistoPSetDescription(edm::ParameterSetDescription & pset) -{ - pset.add ("nbins"); - pset.add ("xmin"); - pset.add ("xmax"); -} - -void METplusTrackMonitor::fillHistoLSPSetDescription(edm::ParameterSetDescription & pset) -{ - pset.add("nbins", 2500); -} - void METplusTrackMonitor::fillDescriptions(edm::ConfigurationDescriptions & descriptions) { edm::ParameterSetDescription desc; desc.add ( "FolderName", "HLT/MET" ); - desc.add( "met", edm::InputTag("caloMet") ); - desc.add( "jets", edm::InputTag("ak4PFJetsCHS") ); - desc.add( "electrons", edm::InputTag("gedGsfElectrons") ); - desc.add( "muons", edm::InputTag("muons") ); - desc.add( "vertices", edm::InputTag("offlinePrimaryVertices") ); - desc.add( "trigSummary", edm::InputTag("hltTriggerSummaryAOD") ); - desc.add( "onlineMet", edm::InputTag("hltMet", "", "HLT") ); - desc.add( "onlineMetClean", edm::InputTag("hltMetClean", "", "HLT") ); - desc.add( "trackLegFilter", edm::InputTag("hltTrk50Filter", "", "HLT") ); + desc.add( "met", edm::InputTag("caloMet") ); + desc.add( "jets", edm::InputTag("ak4PFJetsCHS") ); + desc.add( "electrons", edm::InputTag("gedGsfElectrons") ); + desc.add( "muons", edm::InputTag("muons") ); + desc.add( "vertices", edm::InputTag("offlinePrimaryVertices") ); + desc.add( "trigSummary", edm::InputTag("hltTriggerSummaryAOD") ); + desc.add( "hltMetFilter", edm::InputTag("hltMET105", "", "HLT") ); + desc.add( "hltMetCleanFilter", edm::InputTag("hltMETClean65", "", "HLT") ); + desc.add( "trackLegFilter", edm::InputTag("hltTrk50Filter", "", "HLT") ); desc.add("metSelection", "pt > 0"); - desc.add("hltMetSelection", "pt > 0"); - desc.add("hltMetCleanSelection", "pt > 0"); desc.add("jetSelection", "pt > 0"); desc.add("muonSelection", "pt > 0"); desc.add("vtxSelection", "!isFake"); desc.add("njets", 0); desc.add("nmuons", 0); desc.add("leadJetEtaCut", 2.4); - desc.add("hltMetCut", 105.0); - desc.add("hltMetCleanCut", 65.0); edm::ParameterSetDescription genericTriggerEventPSet; genericTriggerEventPSet.add("andOr"); @@ -423,7 +318,7 @@ bool METplusTrackMonitor::getHLTObj(const edm::Handle &tr if( !(filterIndex >= trigSummary->sizeFilters()) ) { const trigger::Keys& keys = trigSummary->filterKeys( filterIndex ); - for(size_t j = 0; j < keys.size(); ++j) { + for(size_t j = 0; j < keys.size(); j++) { trigger::TriggerObject foundObject = triggerObjects[keys[j]]; if(foundObject.pt() > leadingPt) { obj = foundObject; diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.h b/DQMOffline/Trigger/plugins/METplusTrackMonitor.h index 4c10ea217f322..d94dd89adab83 100644 --- a/DQMOffline/Trigger/plugins/METplusTrackMonitor.h +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.h @@ -22,6 +22,8 @@ #include #include "DQM/TrackingMonitor/interface/GetLumi.h" +#include "DQMOffline/Trigger/plugins/TriggerDQMBase.h" + #include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" @@ -45,57 +47,34 @@ class GenericTriggerEventFlag; // class declaration // -class METplusTrackMonitor : public DQMEDAnalyzer +class METplusTrackMonitor : public DQMEDAnalyzer, public TriggerDQMBase { public: - struct MEbinning { - unsigned int nbins; - double xmin; - double xmax; - }; - - struct METplusTrackME { - MonitorElement * numerator; - MonitorElement * denominator; - }; - METplusTrackMonitor( const edm::ParameterSet& ); - ~METplusTrackMonitor(); + virtual ~METplusTrackMonitor() noexcept(true) {}; static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); - static void fillHistoPSetDescription(edm::ParameterSetDescription & pset); - static void fillHistoLSPSetDescription(edm::ParameterSetDescription & pset); protected: void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; - void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbins, double xmin, double xmax); - void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, const std::vector& binningX); - void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, double ymin, double ymax); - void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, int nbinsY, double ymin, double ymax, bool bookNumerator); - void bookME(DQMStore::IBooker &, METplusTrackME& me, const std::string& histname, const std::string& histtitle, const std::vector& binningX, const std::vector& binningY); - void setMETitle(METplusTrackME& me, std::string titleX, std::string titleY, bool bookNumerator); - void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override; private: - static MEbinning getHistoPSet (edm::ParameterSet pset); - static MEbinning getHistoLSPSet (edm::ParameterSet pset); - bool getHLTObj(const edm::Handle &trigSummary, const edm::InputTag filterTag, trigger::TriggerObject &obj) const; std::string folderName_; std::string histoSuffix_; edm::EDGetTokenT metToken_; - edm::EDGetTokenT hltMetToken_; - edm::EDGetTokenT hltMetCleanToken_; edm::EDGetTokenT muonToken_; edm::EDGetTokenT jetToken_; edm::EDGetTokenT vtxToken_; edm::EDGetTokenT theTrigSummary_; + edm::InputTag hltMetTag_; + edm::InputTag hltMetCleanTag_; edm::InputTag trackLegFilterTag_; std::vector met_variable_binning_; @@ -107,38 +86,33 @@ class METplusTrackMonitor : public DQMEDAnalyzer MEbinning eta_binning_; MEbinning phi_binning_; - METplusTrackME metME_variableBinning_; - METplusTrackME metVsLS_; - METplusTrackME metPhiME_; - METplusTrackME deltaphimetj1ME_; - METplusTrackME metVsHltMet_; - METplusTrackME metVsHltMetClean_; + ObjME metME_variableBinning_; + ObjME metVsLS_; + ObjME metPhiME_; + ObjME deltaphimetj1ME_; + ObjME metVsHltMet_; + ObjME metVsHltMetClean_; - METplusTrackME muonPtME_variableBinning_; - METplusTrackME muonPtVsLS_; - METplusTrackME muonEtaME_; - METplusTrackME deltaphimetmuonME_; - METplusTrackME muonEtaVsPhi_; + ObjME muonPtME_variableBinning_; + ObjME muonPtVsLS_; + ObjME muonEtaME_; + ObjME deltaphimetmuonME_; + ObjME muonEtaVsPhi_; std::unique_ptr num_genTriggerEventFlag_; std::unique_ptr den_genTriggerEventFlag_; - StringCutObjectSelector metSelection_; - StringCutObjectSelector hltMetSelection_; - StringCutObjectSelector hltMetCleanSelection_; + StringCutObjectSelector metSelection_; + StringCutObjectSelector muonSelection_; + StringCutObjectSelector jetSelection_; + StringCutObjectSelector vtxSelection_; - StringCutObjectSelector muonSelection_; - StringCutObjectSelector jetSelection_; - StringCutObjectSelector vtxSelection_; unsigned nmuons_; unsigned njets_; double leadJetEtaCut_; - double hltMetCut_; - double hltMetCleanCut_; }; - #endif // DQMOFFLINE_TRIGGER_METPLUSTRACKMONITOR_H diff --git a/DQMOffline/Trigger/python/METplusTrackMonitor_cff.py b/DQMOffline/Trigger/python/METplusTrackMonitor_cff.py index c40c2c0118740..89193f2ce0bd5 100644 --- a/DQMOffline/Trigger/python/METplusTrackMonitor_cff.py +++ b/DQMOffline/Trigger/python/METplusTrackMonitor_cff.py @@ -5,16 +5,16 @@ # HLT_MET105_IsoTrk50 MET105_IsoTrk50monitoring = hltMETplusTrackMonitoring.clone() MET105_IsoTrk50monitoring.FolderName = cms.string('HLT/MET/MET105_IsoTrk50/') -MET105_IsoTrk50monitoring.numGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_MET105_IsoTrk50_v") -MET105_IsoTrk50monitoring.hltMetSelection = cms.string("pt > 105") -MET105_IsoTrk50monitoring.hltMetCleanSelection = cms.string("pt > 65") +MET105_IsoTrk50monitoring.numGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_MET105_IsoTrk50_v*") +MET105_IsoTrk50monitoring.hltMetFilter = cms.InputTag('hltMET105', '', 'HLT') +MET105_IsoTrk50monitoring.hltMetCleanFilter = cms.InputTag('hltMETClean65', '', 'HLT') # HLT_MET120_IsoTrk50 MET120_IsoTrk50monitoring = hltMETplusTrackMonitoring.clone() MET120_IsoTrk50monitoring.FolderName = cms.string('HLT/MET/MET120_IsoTrk50/') -MET120_IsoTrk50monitoring.numGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_MET120_IsoTrk50_v") -MET105_IsoTrk50monitoring.hltMetSelection = cms.string("pt > 120") -MET105_IsoTrk50monitoring.hltMetCleanSelection = cms.string("pt > 65") +MET120_IsoTrk50monitoring.numGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_MET120_IsoTrk50_v*") +MET120_IsoTrk50monitoring.hltMetFilter = cms.InputTag('hltMET120', '', 'HLT') +MET120_IsoTrk50monitoring.hltMetCleanFilter = cms.InputTag('hltMETClean65', '', 'HLT') exoHLTMETplusTrackMonitoring = cms.Sequence( MET105_IsoTrk50monitoring diff --git a/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py b/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py index 0a5a69ed87c70..1bfef07d75c73 100644 --- a/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py +++ b/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py @@ -51,7 +51,7 @@ #hltMETplusTrackMonitoring.numGenericTriggerEventPSet.dbLabel = cms.string("ExoDQMTrigger") # it does not exist yet, we should consider the possibility of using the DB, but as it is now it will need a label per path ! hltMETplusTrackMonitoring.numGenericTriggerEventPSet.andOrHlt = cms.bool(True)# True:=OR; False:=AND hltMETplusTrackMonitoring.numGenericTriggerEventPSet.hltInputTag = cms.InputTag( "TriggerResults::HLT" ) -hltMETplusTrackMonitoring.numGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_MET105_IsoTrk50_v") # HLT_ZeroBias_v +hltMETplusTrackMonitoring.numGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_MET105_IsoTrk50_v*") # HLT_ZeroBias_v #hltMETplusTrackMonitoring.numGenericTriggerEventPSet.hltDBKey = cms.string("EXO_HLT_MET") hltMETplusTrackMonitoring.numGenericTriggerEventPSet.errorReplyHlt = cms.bool( False ) hltMETplusTrackMonitoring.numGenericTriggerEventPSet.verbosityLevel = cms.uint32(0) @@ -62,4 +62,5 @@ hltMETplusTrackMonitoring.denGenericTriggerEventPSet.andOrDcs = cms.bool( False ) hltMETplusTrackMonitoring.denGenericTriggerEventPSet.errorReplyDcs = cms.bool( True ) hltMETplusTrackMonitoring.denGenericTriggerEventPSet.verbosityLevel = cms.uint32(1) -hltMETplusTrackMonitoring.denGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_IsoMu27_v", "HLT_IsoTkMu27_v") +hltMETplusTrackMonitoring.denGenericTriggerEventPSet.hltPaths = cms.vstring("HLT_IsoMu27_v*", "HLT_IsoTkMu27_v*") + From 3adc7c39226fc4348cb84428cc20342155d36092 Mon Sep 17 00:00:00 2001 From: bpf6qc Date: Tue, 11 Jul 2017 10:50:07 -0400 Subject: [PATCH 5/6] Make muon-matching configurable, and remove njet requirement --- DQMOffline/Trigger/plugins/METplusTrackMonitor.cc | 14 ++++++++++---- DQMOffline/Trigger/plugins/METplusTrackMonitor.h | 3 +++ .../Trigger/python/METplusTrackMonitor_cfi.py | 1 - 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc index 3da0bc572d3f4..7d1fd38c5dcb1 100644 --- a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc @@ -39,6 +39,8 @@ METplusTrackMonitor::METplusTrackMonitor( const edm::ParameterSet& iConfig ) : , nmuons_ ( iConfig.getParameter("nmuons") ) , njets_ ( iConfig.getParameter("njets") ) , leadJetEtaCut_ ( iConfig.getParameter("leadJetEtaCut") ) + , requireLeadMatched_ ( iConfig.getParameter("requireLeadMatched") ) + , maxMatchDeltaR_ ( iConfig.getParameter("maxMatchDeltaR") ) { metME_variableBinning_.numerator = nullptr; @@ -222,11 +224,13 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, trigger::TriggerObject isoTrk; bool passesTrackLegFilter = getHLTObj(triggerSummary, trackLegFilterTag_, isoTrk); - bool leadMuonMatchToHLTTrack = muons.size() > 0 && - passesTrackLegFilter && - deltaR(muons[0], isoTrk) < 0.1; - if(!leadMuonMatchToHLTTrack) return; + // require track leg filter + if(!passesTrackLegFilter) return; + // if requested, require lead selected muon is matched to the track leg filter object + if(requireLeadMatched_ && muons.size() && deltaR(muons[0], isoTrk) < maxMatchDeltaR_) return; + + // require the full HLT path is fired if(num_genTriggerEventFlag_->on() && !num_genTriggerEventFlag_->accept(iEvent, iSetup)) return; // Filling track leg histograms (denominator) @@ -260,6 +264,8 @@ void METplusTrackMonitor::fillDescriptions(edm::ConfigurationDescriptions & desc desc.add("njets", 0); desc.add("nmuons", 0); desc.add("leadJetEtaCut", 2.4); + desc.add("requireLeadMatched", true); + desc.add("maxMatchDeltaR", 0.1); edm::ParameterSetDescription genericTriggerEventPSet; genericTriggerEventPSet.add("andOr"); diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.h b/DQMOffline/Trigger/plugins/METplusTrackMonitor.h index d94dd89adab83..5f3ad6020ca4c 100644 --- a/DQMOffline/Trigger/plugins/METplusTrackMonitor.h +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.h @@ -112,6 +112,9 @@ class METplusTrackMonitor : public DQMEDAnalyzer, public TriggerDQMBase double leadJetEtaCut_; + bool requireLeadMatched_; + double maxMatchDeltaR_; + }; #endif // DQMOFFLINE_TRIGGER_METPLUSTRACKMONITOR_H diff --git a/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py b/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py index 1bfef07d75c73..850ab9e3ee8df 100644 --- a/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py +++ b/DQMOffline/Trigger/python/METplusTrackMonitor_cfi.py @@ -43,7 +43,6 @@ hltMETplusTrackMonitoring.muonSelection = cms.string('pt>26 && abs(eta)<2.1 && (pfIsolationR04.sumChargedHadronPt+pfIsolationR04.sumPhotonEt+pfIsolationR04.sumNeutralHadronEt-0.5*pfIsolationR04.sumPUPt)/pt<0.12') hltMETplusTrackMonitoring.vtxSelection = cms.string('ndof>=4 && abs(z)<24.0 && position.Rho<2.0') -hltMETplusTrackMonitoring.njets = cms.uint32(1) hltMETplusTrackMonitoring.nmuons = cms.uint32(1) hltMETplusTrackMonitoring.leadJetEtaCut = cms.double(2.4) From 38afbc3163a1494adc914fb8d6b506465467e6b4 Mon Sep 17 00:00:00 2001 From: bpf6qc Date: Tue, 25 Jul 2017 09:17:58 -0400 Subject: [PATCH 6/6] Resolving comments about vector clear() and size() --- .../Trigger/plugins/METplusTrackMonitor.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc index 7d1fd38c5dcb1..0dd9305705b06 100644 --- a/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc +++ b/DQMOffline/Trigger/plugins/METplusTrackMonitor.cc @@ -146,13 +146,12 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, iEvent.getByToken(jetToken_, jetsHandle); if(jetsHandle->size() < njets_) return; std::vector jets; - jets.clear(); for(auto const & j : *jetsHandle) { if(jetSelection_(j)) jets.push_back(j); } if(jets.size() < njets_) return; - if(njets_ > 0 && jets.size() > 0 && fabs(jets[0].eta()) > leadJetEtaCut_) return; - float deltaphi_metjet1 = (jets.size() > 0) ? fabs(deltaPhi(caloMet.phi(), jets[0].phi())) : 10.0; + if(njets_ > 0 && !(jets.empty()) && fabs(jets[0].eta()) > leadJetEtaCut_) return; + float deltaphi_metjet1 = !(jets.empty()) ? fabs(deltaPhi(caloMet.phi(), jets[0].phi())) : 10.0; edm::Handle primaryVertices; iEvent.getByToken(vtxToken_, primaryVertices); @@ -169,7 +168,6 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, iEvent.getByToken(muonToken_, muonHandle); if(muonHandle->size() < nmuons_) return; std::vector muons; - muons.clear(); for(auto const & m : *muonHandle) { bool passTightID = muon::isTightMuon(m, *pv) && m.innerTrack()->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::MISSING_INNER_HITS) == 0 && @@ -209,10 +207,10 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, metVsHltMetClean_.numerator->Fill(hltMetClean.pt(), met); // Filling track leg histograms (denominator) - double leadMuonPt = muons.size() ? muons[0].pt() : -1.0; - double leadMuonEta = muons.size() ? muons[0].eta() : 10.0; - double leadMuonPhi = muons.size() ? muons[0].phi() : 10.0; - float deltaphi_metmuon = fabs(deltaPhi(caloMet.phi(), muons[0].phi())); + double leadMuonPt = !(muons.empty()) ? muons[0].pt() : -1.0; + double leadMuonEta = !(muons.empty()) ? muons[0].eta() : 10.0; + double leadMuonPhi = !(muons.empty()) ? muons[0].phi() : 10.0; + float deltaphi_metmuon = !(muons.empty()) ? fabs(deltaPhi(caloMet.phi(), muons[0].phi())) : 10.0; muonPtME_variableBinning_.denominator->Fill(leadMuonPt); muonPtVsLS_.denominator->Fill(ls, leadMuonPt); @@ -228,7 +226,7 @@ void METplusTrackMonitor::bookHistograms(DQMStore::IBooker &ibooker, if(!passesTrackLegFilter) return; // if requested, require lead selected muon is matched to the track leg filter object - if(requireLeadMatched_ && muons.size() && deltaR(muons[0], isoTrk) < maxMatchDeltaR_) return; + if(requireLeadMatched_ && !(muons.empty()) && deltaR(muons[0], isoTrk) < maxMatchDeltaR_) return; // require the full HLT path is fired if(num_genTriggerEventFlag_->on() && !num_genTriggerEventFlag_->accept(iEvent, iSetup)) return;