CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
B2GSingleLeptonHLTValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTriggerOffline/B2G
4 // Class: B2GSingleLeptonHLTValidation
5 //
17 //
18 // Original Author: Elvire Bouvier
19 // Created: Thu, 16 Jan 2014 16:27:35 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("B2GSingleLeptonHLTValidation") << "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  if (nGoodE == 1)
64  elec_ = electrons->ptrAt(e - electrons->begin());
65  }
66  // Muons
68  if (!iEvent.getByToken(tokMuons_, muons))
69  edm::LogWarning("B2GSingleLeptonHLTValidation") << "Muons collection not found \n";
70  unsigned int nGoodM = 0;
71  for (edm::View<reco::Muon>::const_iterator m = muons->begin(); m != muons->end(); ++m) {
72  if (!m->isPFMuon() || !m->isGlobalMuon())
73  continue;
74  if (m->pt() < ptMuons_)
75  continue;
76  if (fabs(m->eta()) > etaMuons_)
77  continue;
78  nGoodM++;
79  if (nGoodM == 1)
80  mu_ = muons->ptrAt(m - muons->begin());
81  }
82  // Jets
84  if (!iEvent.getByToken(tokJets_, jets))
85  edm::LogWarning("B2GSingleLeptonHLTValidation") << "Jets collection not found \n";
86  unsigned int nGoodJ = 0;
87 
88  // Check to see if we want asymmetric jet pt cuts
89  if (ptJets0_ > 0.0 || ptJets1_ > 0.0) {
90  if (ptJets0_ > 0.0) {
91  if (!jets->empty() && jets->at(0).pt() > ptJets0_) {
92  nGoodJ++;
93  jet_ = jets->ptrAt(0);
94  }
95  }
96  if (ptJets1_ > 0.0) {
97  if (jets->size() > 1 && jets->at(1).pt() > ptJets1_) {
98  nGoodJ++;
99  jet_ = jets->ptrAt(1);
100  }
101  }
102  } else {
103  for (edm::View<reco::Jet>::const_iterator j = jets->begin(); j != jets->end(); ++j) {
104  if (j->pt() < ptJets_)
105  continue;
106  if (fabs(j->eta()) > etaJets_)
107  continue;
108  nGoodJ++;
109  if (nGoodJ == minJets_)
110  jet_ = jets->ptrAt(j - jets->begin());
111  }
112  }
113 
114  if (nGoodE >= minElectrons_ && nGoodM >= minMuons_ && nGoodJ >= minJets_)
115  isAll_ = true;
116 
117  // Trigger
118  Handle<edm::TriggerResults> triggerTable;
119  if (!iEvent.getByToken(tokTrigger_, triggerTable))
120  edm::LogWarning("B2GSingleLeptonHLTValidation") << "Trigger collection not found \n";
121  const edm::TriggerNames &triggerNames = iEvent.triggerNames(*triggerTable);
122  bool isInteresting = false;
123  for (unsigned int i = 0; i < triggerNames.triggerNames().size(); ++i) {
124  TString name = triggerNames.triggerNames()[i].c_str();
125  for (unsigned int j = 0; j < vsPaths_.size(); j++) {
126  if (name.Contains(TString(vsPaths_[j]), TString::kIgnoreCase)) {
127  isInteresting = true;
128  break;
129  }
130  }
131  if (isInteresting)
132  break;
133  }
134 
135  if (isAll_ && isInteresting)
136  isSel_ = true;
137  else
138  isSel_ = false;
139 
140  // Histos
141  if (isAll_) {
142  if (minElectrons_ > 0 && elec_.isNonnull()) {
143  hDenLeptonPt->Fill(elec_->pt());
144  hDenLeptonEta->Fill(elec_->eta());
145  }
146  if (minMuons_ > 0 && mu_.isNonnull()) {
147  hDenLeptonPt->Fill(mu_->pt());
148  hDenLeptonEta->Fill(mu_->eta());
149  }
150  if (jet_.isNonnull()) {
151  hDenJetPt->Fill(jet_->pt());
152  hDenJetEta->Fill(jet_->eta());
153  }
154  for (unsigned int idx = 0; idx < vsPaths_.size(); ++idx) {
155  hDenTriggerMon->Fill(idx + 0.5);
156  }
157  }
158  if (isSel_) {
159  if (minElectrons_ > 0 && elec_.isNonnull()) {
160  hNumLeptonPt->Fill(elec_->pt());
161  hNumLeptonEta->Fill(elec_->eta());
162  }
163  if (minMuons_ > 0 && mu_.isNonnull()) {
164  hNumLeptonPt->Fill(mu_->pt());
165  hNumLeptonEta->Fill(mu_->eta());
166  }
167  if (jet_.isNonnull()) {
168  hNumJetPt->Fill(jet_->pt());
169  hNumJetEta->Fill(jet_->eta());
170  }
171  for (unsigned int i = 0; i < triggerNames.triggerNames().size(); ++i) {
172  TString name = triggerNames.triggerNames()[i].c_str();
173  for (unsigned int j = 0; j < vsPaths_.size(); j++) {
174  if (name.Contains(TString(vsPaths_[j]), TString::kIgnoreCase)) {
175  hNumTriggerMon->Fill(j + 0.5);
176  }
177  }
178  }
179  }
180 }
181 
182 // ------------ booking histograms -----------
184  dbe.setCurrentFolder(sDir_);
185  hDenLeptonPt = dbe.book1D("PtLeptonAll", "PtLeptonAll", 50, 0., 2500.);
186  hDenLeptonEta = dbe.book1D("EtaLeptonAll", "EtaLeptonAll", 30, -3., 3.);
187  hDenJetPt = dbe.book1D("PtLastJetAll", "PtLastJetAll", 60, 0., 3000.);
188  hDenJetEta = dbe.book1D("EtaLastJetAll", "EtaLastJetAll", 30, -3., 3.);
189  hNumLeptonPt = dbe.book1D("PtLeptonSel", "PtLeptonSel", 50, 0., 2500.);
190  hNumLeptonEta = dbe.book1D("EtaLeptonSel", "EtaLeptonSel", 30, -3., 3.);
191  hNumJetPt = dbe.book1D("PtLastJetSel", "PtLastJetSel", 60, 0., 3000.);
192  hNumJetEta = dbe.book1D("EtaLastJetSel", "EtaLastJetSel", 30, -3., 3.);
193  // determine number of bins for trigger monitoring
194  unsigned int nPaths = vsPaths_.size();
195  // monitored trigger occupancy for single lepton triggers
196  hNumTriggerMon = dbe.book1D("TriggerMonSel", "TriggerMonSel", nPaths, 0., nPaths);
197  hDenTriggerMon = dbe.book1D("TriggerMonAll", "TriggerMonAll", nPaths, 0., nPaths);
198  // set bin labels for trigger monitoring
200 }
201 
202 // ------------ method fills 'descriptions' with the allowed parameters for the
203 // module ------------
205  // The following says we do not know what parameters are allowed so do no
206  // validation
207  // Please change this to state exactly what you do use, even if it is no
208  // parameters
210  desc.setUnknown();
211  descriptions.addDefault(desc);
212 }
edm::EDGetTokenT< edm::View< reco::Muon > > tokMuons_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< edm::View< reco::Jet > > tokJets_
edm::Ptr< reco::GsfElectron > elec_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:275
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::TriggerResults > tokTrigger_
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
vector< PseudoJet > jets
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tokElectrons_
void analyze(const edm::Event &, const edm::EventSetup &) override
tuple muons
Definition: patZpeak.py:39
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void triggerBinLabels(const std::vector< std::string > &labels)
set configurable labels for trigger monitoring histograms
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