File indexing completed on 2024-04-06 12:18:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include "HLTriggerOffline/B2G/interface/B2GDoubleLeptonHLTValidation.h"
0023
0024
0025 #include <memory>
0026
0027
0028 #include "FWCore/Framework/interface/Frameworkfwd.h"
0029
0030 #include "FWCore/Framework/interface/Event.h"
0031 #include "FWCore/Framework/interface/MakerMacros.h"
0032
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 #include "FWCore/ServiceRegistry/interface/Service.h"
0035
0036 #include "DataFormats/MuonReco/interface/MuonPFIsolation.h"
0037 #include "FWCore/Common/interface/TriggerNames.h"
0038 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0039 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0040 #include "TString.h"
0041
0042
0043
0044
0045
0046 void B2GDoubleLeptonHLTValidation::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0047 using namespace edm;
0048
0049 isAll_ = false;
0050 isSel_ = false;
0051
0052
0053 Handle<edm::View<reco::GsfElectron>> electrons;
0054 if (!iEvent.getByToken(tokElectrons_, electrons))
0055 edm::LogWarning("B2GDoubleLeptonHLTValidation") << "Electrons collection not found \n";
0056 unsigned int nGoodE = 0;
0057 for (edm::View<reco::GsfElectron>::const_iterator e = electrons->begin(); e != electrons->end(); ++e) {
0058 if (e->pt() < ptElectrons_)
0059 continue;
0060 if (fabs(e->eta()) > etaElectrons_)
0061 continue;
0062 nGoodE++;
0063
0064 if (nGoodE == 2)
0065 elec_ = electrons->ptrAt(e - electrons->begin());
0066 }
0067
0068 Handle<edm::View<reco::Muon>> muons;
0069 if (!iEvent.getByToken(tokMuons_, muons))
0070 edm::LogWarning("B2GDoubleLeptonHLTValidation") << "Muons collection not found \n";
0071 unsigned int nGoodM = 0;
0072 for (edm::View<reco::Muon>::const_iterator m = muons->begin(); m != muons->end(); ++m) {
0073 if (!m->isPFMuon() || !m->isGlobalMuon())
0074 continue;
0075 if (m->pt() < ptMuons_)
0076 continue;
0077 if (fabs(m->eta()) > etaMuons_)
0078 continue;
0079 nGoodM++;
0080
0081 if (nGoodM == 2)
0082 mu_ = muons->ptrAt(m - muons->begin());
0083 }
0084
0085 if (nGoodE >= minElectrons_ && nGoodM >= minMuons_ && nGoodE + nGoodM >= minLeptons_)
0086 isAll_ = true;
0087
0088
0089 Handle<edm::TriggerResults> triggerTable;
0090 if (!iEvent.getByToken(tokTrigger_, triggerTable))
0091 edm::LogWarning("B2GDoubleLeptonHLTValidation") << "Trigger collection not found \n";
0092 const edm::TriggerNames &triggerNames = iEvent.triggerNames(*triggerTable);
0093 bool isInteresting = false;
0094 for (unsigned int i = 0; i < triggerNames.triggerNames().size(); ++i) {
0095 for (unsigned int j = 0; j < vsPaths_.size(); j++) {
0096 if (triggerNames.triggerNames()[i].find(vsPaths_[j]) != std::string::npos) {
0097 isInteresting = true;
0098 break;
0099 }
0100 }
0101 if (isInteresting)
0102 break;
0103 }
0104
0105 if (isAll_ && isInteresting)
0106 isSel_ = true;
0107 else
0108 isSel_ = false;
0109
0110
0111 if (isAll_) {
0112
0113
0114 if (nGoodE > 1 && elec_.isNonnull()) {
0115 hDenLeptonPt->Fill(elec_->pt());
0116 hDenLeptonEta->Fill(elec_->eta());
0117 }
0118 if (nGoodM > 1 && mu_.isNonnull()) {
0119 hDenLeptonPt->Fill(mu_->pt());
0120 hDenLeptonEta->Fill(mu_->eta());
0121 }
0122 for (unsigned int idx = 0; idx < vsPaths_.size(); ++idx) {
0123 hDenTriggerMon->Fill(idx + 0.5);
0124 }
0125 }
0126 if (isSel_) {
0127 if (nGoodE > 1 && elec_.isNonnull()) {
0128 hNumLeptonPt->Fill(elec_->pt());
0129 hNumLeptonEta->Fill(elec_->eta());
0130 }
0131 if (nGoodM > 1 && mu_.isNonnull()) {
0132 hNumLeptonPt->Fill(mu_->pt());
0133 hNumLeptonEta->Fill(mu_->eta());
0134 }
0135
0136 for (unsigned int i = 0; i < triggerNames.triggerNames().size(); ++i) {
0137 for (unsigned int j = 0; j < vsPaths_.size(); j++) {
0138 if (triggerNames.triggerNames()[i].find(vsPaths_[j]) != std::string::npos) {
0139 hNumTriggerMon->Fill(j + 0.5);
0140 }
0141 }
0142 }
0143 }
0144 }
0145
0146
0147 void B2GDoubleLeptonHLTValidation::bookHistograms(DQMStore::IBooker &dbe, edm::Run const &, edm::EventSetup const &) {
0148 dbe.setCurrentFolder(sDir_);
0149 hDenLeptonPt = dbe.book1D("PtLeptonAll", "PtLeptonAll", 50, 0., 2500.);
0150 hDenLeptonEta = dbe.book1D("EtaLeptonAll", "EtaLeptonAll", 30, -3., 3.);
0151 hNumLeptonPt = dbe.book1D("PtLeptonSel", "PtLeptonSel", 50, 0., 2500.);
0152 hNumLeptonEta = dbe.book1D("EtaLeptonSel", "EtaLeptonSel", 30, -3., 3.);
0153
0154 unsigned int nPaths = vsPaths_.size();
0155
0156 hNumTriggerMon = dbe.book1D("TriggerMonSel", "TriggerMonSel", nPaths, 0., nPaths);
0157 hDenTriggerMon = dbe.book1D("TriggerMonAll", "TriggerMonAll", nPaths, 0., nPaths);
0158
0159 triggerBinLabels(vsPaths_);
0160 }
0161
0162
0163
0164 void B2GDoubleLeptonHLTValidation::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0165
0166
0167
0168
0169 edm::ParameterSetDescription desc;
0170 desc.setUnknown();
0171 descriptions.addDefault(desc);
0172 }