CMS 3D CMS Logo

B2GDoubleLeptonHLTValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTriggerOffline/B2G
4 // Class: B2GDoubleLeptonHLTValidation
5 //
17 //
18 // Original Author: Clint Richardson (copy of B2GSingleLeptonHLTValidation)
19 // Created: Tue, 05 Apr 2016 14:27:00 GMT
20 //
21 //
23 
24 // system include files
25 #include <memory>
26 
27 // user include files
29 
32 
35 
40 #include "TString.h"
41 //
42 // member functions
43 //
44 
45 // ------------ method called for each event ------------
47  using namespace edm;
48 
49  isAll_ = false;
50  isSel_ = false;
51 
52  // Electrons
54  if (!iEvent.getByToken(tokElectrons_, electrons))
55  edm::LogWarning("B2GDoubleLeptonHLTValidation") << "Electrons collection not found \n";
56  unsigned int nGoodE = 0;
57  for (edm::View<reco::GsfElectron>::const_iterator e = electrons->begin(); e != electrons->end(); ++e) {
58  if (e->pt() < ptElectrons_)
59  continue;
60  if (fabs(e->eta()) > etaElectrons_)
61  continue;
62  nGoodE++;
63  // leptons come sorted so use only 2nd
64  if (nGoodE == 2)
65  elec_ = electrons->ptrAt(e - electrons->begin());
66  }
67  // Muons
69  if (!iEvent.getByToken(tokMuons_, muons))
70  edm::LogWarning("B2GDoubleLeptonHLTValidation") << "Muons collection not found \n";
71  unsigned int nGoodM = 0;
72  for (edm::View<reco::Muon>::const_iterator m = muons->begin(); m != muons->end(); ++m) {
73  if (!m->isPFMuon() || !m->isGlobalMuon())
74  continue;
75  if (m->pt() < ptMuons_)
76  continue;
77  if (fabs(m->eta()) > etaMuons_)
78  continue;
79  nGoodM++;
80  // leptons come sorted so use only 2nd
81  if (nGoodM == 2)
82  mu_ = muons->ptrAt(m - muons->begin());
83  }
84 
85  if (nGoodE >= minElectrons_ && nGoodM >= minMuons_ && nGoodE + nGoodM >= minLeptons_)
86  isAll_ = true;
87 
88  // Trigger
89  Handle<edm::TriggerResults> triggerTable;
90  if (!iEvent.getByToken(tokTrigger_, triggerTable))
91  edm::LogWarning("B2GDoubleLeptonHLTValidation") << "Trigger collection not found \n";
92  const edm::TriggerNames &triggerNames = iEvent.triggerNames(*triggerTable);
93  bool isInteresting = false;
94  for (unsigned int i = 0; i < triggerNames.triggerNames().size(); ++i) {
95  for (unsigned int j = 0; j < vsPaths_.size(); j++) {
96  if (triggerNames.triggerNames()[i].find(vsPaths_[j]) != std::string::npos) {
97  isInteresting = true;
98  break;
99  }
100  }
101  if (isInteresting)
102  break;
103  }
104 
105  if (isAll_ && isInteresting)
106  isSel_ = true;
107  else
108  isSel_ = false;
109 
110  // Histos
111  if (isAll_) {
112  // here and below, change to nGoodE/M instead of min since we are taking
113  // subleading
114  if (nGoodE > 1 && elec_.isNonnull()) {
115  hDenLeptonPt->Fill(elec_->pt());
117  }
118  if (nGoodM > 1 && mu_.isNonnull()) {
119  hDenLeptonPt->Fill(mu_->pt());
120  hDenLeptonEta->Fill(mu_->eta());
121  }
122  for (unsigned int idx = 0; idx < vsPaths_.size(); ++idx) {
123  hDenTriggerMon->Fill(idx + 0.5);
124  }
125  }
126  if (isSel_) {
127  if (nGoodE > 1 && elec_.isNonnull()) {
128  hNumLeptonPt->Fill(elec_->pt());
130  }
131  if (nGoodM > 1 && mu_.isNonnull()) {
132  hNumLeptonPt->Fill(mu_->pt());
133  hNumLeptonEta->Fill(mu_->eta());
134  }
135 
136  for (unsigned int i = 0; i < triggerNames.triggerNames().size(); ++i) {
137  for (unsigned int j = 0; j < vsPaths_.size(); j++) {
138  if (triggerNames.triggerNames()[i].find(vsPaths_[j]) != std::string::npos) {
139  hNumTriggerMon->Fill(j + 0.5);
140  }
141  }
142  }
143  }
144 }
145 
146 // ------------ booking histograms -----------
148  dbe.setCurrentFolder(sDir_);
149  hDenLeptonPt = dbe.book1D("PtLeptonAll", "PtLeptonAll", 50, 0., 2500.);
150  hDenLeptonEta = dbe.book1D("EtaLeptonAll", "EtaLeptonAll", 30, -3., 3.);
151  hNumLeptonPt = dbe.book1D("PtLeptonSel", "PtLeptonSel", 50, 0., 2500.);
152  hNumLeptonEta = dbe.book1D("EtaLeptonSel", "EtaLeptonSel", 30, -3., 3.);
153  // determine number of bins for trigger monitoring
154  unsigned int nPaths = vsPaths_.size();
155  // monitored trigger occupancy for single lepton triggers
156  hNumTriggerMon = dbe.book1D("TriggerMonSel", "TriggerMonSel", nPaths, 0., nPaths);
157  hDenTriggerMon = dbe.book1D("TriggerMonAll", "TriggerMonAll", nPaths, 0., nPaths);
158  // set bin labels for trigger monitoring
160 }
161 
162 // ------------ method fills 'descriptions' with the allowed parameters for the
163 // module ------------
165  // The following says we do not know what parameters are allowed so do no
166  // validation
167  // Please change this to state exactly what you do use, even if it is no
168  // parameters
170  desc.setUnknown();
171  descriptions.addDefault(desc);
172 }
double pt() const final
transverse momentum
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void triggerBinLabels(const std::vector< std::string > &labels)
set configurable labels for trigger monitoring histograms
edm::EDGetTokenT< edm::TriggerResults > tokTrigger_
edm::EDGetTokenT< edm::View< reco::Muon > > tokMuons_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:212
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tokElectrons_
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
edm::Ptr< reco::GsfElectron > elec_
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
void analyze(const edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: Run.h:45
double eta() const final
momentum pseudorapidity