CMS 3D CMS Logo

TopDiLeptonHLTValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTriggerOffline/Top
4 // Class: TopDiLeptonHLTValidation
5 //
18 //
19 // Original Author: Elvire Bouvier
20 // Created: Thu, 16 Jan 2014 16:27:35 GMT
21 //
22 //
24 
25 // system include files
26 #include <memory>
27 
28 // user include files
30 
33 
36 
41 #include "TString.h"
42 //
43 // member functions
44 //
45 
46 // ------------ method called for each event ------------
48  using namespace edm;
49 
50  isAll_ = false;
51  isSel_ = false;
52 
53  // Electrons
55  if (!iEvent.getByToken(tokElectrons_, electrons))
56  edm::LogWarning("TopDiLeptonHLTValidation") << "Electrons collection not found \n";
57  unsigned int nGoodE = 0;
58  for (edm::View<reco::GsfElectron>::const_iterator e = electrons->begin(); e != electrons->end(); ++e) {
59  if (e->pt() < ptElectrons_)
60  continue;
61  if (fabs(e->eta()) > etaElectrons_)
62  continue;
63  if ((e->dr03TkSumPt() + e->dr03EcalRecHitSumEt() + e->dr03HcalTowerSumEt()) / e->pt() > isoElectrons_)
64  continue;
65  nGoodE++;
66  if (nGoodE == 1)
67  elec1_ = &(*e);
68  if (nGoodE == 2)
69  elec2_ = &(*e);
70  }
71  // Muons
73  if (!iEvent.getByToken(tokMuons_, muons))
74  edm::LogWarning("TopDiLeptonHLTValidation") << "Muons collection not found \n";
75  unsigned int nGoodM = 0;
76  for (edm::View<reco::Muon>::const_iterator m = muons->begin(); m != muons->end(); ++m) {
77  if (!m->isPFMuon() || (!m->isGlobalMuon() && !m->isTrackerMuon()))
78  continue;
79  if (m->pt() < ptMuons_)
80  continue;
81  if (fabs(m->eta()) > etaMuons_)
82  continue;
83  if (((m->pfIsolationR04()).sumChargedHadronPt + (m->pfIsolationR04()).sumPhotonEt +
84  (m->pfIsolationR04()).sumNeutralHadronEt) /
85  m->pt() >
86  isoMuons_)
87  continue;
88  nGoodM++;
89  if (nGoodM == 1)
90  mu1_ = &(*m);
91  if (nGoodM == 2)
92  mu2_ = &(*m);
93  }
94  // Jets
96  if (!iEvent.getByToken(tokJets_, jets))
97  edm::LogWarning("TopDiLeptonHLTValidation") << "Jets collection not found \n";
98  unsigned int nGoodJ = 0;
99  for (edm::View<reco::Jet>::const_iterator j = jets->begin(); j != jets->end(); ++j) {
100  if (j->pt() < ptJets_)
101  continue;
102  if (fabs(j->eta()) > etaJets_)
103  continue;
104  nGoodJ++;
105  if (nGoodJ == minJets_)
106  jet_ = &(*j);
107  }
108 
109  if (nGoodE >= minElectrons_ && nGoodM >= minMuons_ && nGoodJ >= minJets_)
110  isAll_ = true;
111 
112  // Trigger
113  Handle<edm::TriggerResults> triggerTable;
114  if (!iEvent.getByToken(tokTrigger_, triggerTable))
115  edm::LogWarning("TopDiLeptonHLTValidation") << "Trigger collection not found \n";
116  const edm::TriggerNames &triggerNames = iEvent.triggerNames(*triggerTable);
117  unsigned int isInteresting = 0;
118  for (unsigned int i = 0; i < triggerNames.triggerNames().size(); ++i) {
119  TString name = triggerNames.triggerNames()[i].c_str();
120  for (unsigned int j = 0; j < vsPaths_.size(); j++) {
121  if (name.Contains(TString(vsPaths_[j]), TString::kIgnoreCase)) {
122  if (triggerTable->accept(i)) {
123  isInteresting++;
124  if (isAll_)
125  hNumTriggerMon->Fill(j + 0.5);
126  }
127  }
128  }
129  }
130 
131  if (isAll_ && isInteresting > 0)
132  isSel_ = true;
133  else
134  isSel_ = false;
135 
136  // Histos
137  if (isAll_) {
138  if (minElectrons_ > 0) {
139  hDenLeptonPt->Fill(elec1_->pt());
141  }
142  if (minElectrons_ > 1) {
143  hDenLeptonPt->Fill(elec2_->pt());
145  }
146  if (minMuons_ > 0) {
147  hDenLeptonPt->Fill(mu1_->pt());
148  hDenLeptonEta->Fill(mu1_->eta());
149  }
150  if (minMuons_ > 1) {
151  hDenLeptonPt->Fill(mu2_->pt());
152  hDenLeptonEta->Fill(mu2_->eta());
153  }
154  hDenJetPt->Fill(jet_->pt());
155  hDenJetEta->Fill(jet_->eta());
156  for (unsigned int idx = 0; idx < vsPaths_.size(); ++idx) {
157  hDenTriggerMon->Fill(idx + 0.5);
158  }
159  }
160  if (isSel_) {
161  if (minElectrons_ > 0) {
162  hNumLeptonPt->Fill(elec1_->pt());
164  }
165  if (minElectrons_ > 1) {
166  hNumLeptonPt->Fill(elec2_->pt());
168  }
169  if (minMuons_ > 0) {
170  hNumLeptonPt->Fill(mu1_->pt());
171  hNumLeptonEta->Fill(mu1_->eta());
172  }
173  if (minMuons_ > 1) {
174  hNumLeptonPt->Fill(mu2_->pt());
175  hNumLeptonEta->Fill(mu2_->eta());
176  }
177  hNumJetPt->Fill(jet_->pt());
178  hNumJetEta->Fill(jet_->eta());
179  }
180 }
181 
182 // ------------ booking histograms -----------
184  dbe.setCurrentFolder(sDir_);
185  hDenLeptonPt = dbe.book1D("PtLeptonAll", "PtLeptonAll", 50, 0., 250.);
186  hDenLeptonEta = dbe.book1D("EtaLeptonAll", "EtaLeptonAll", 30, -3., 3.);
187  hDenJetPt = dbe.book1D("PtLastJetAll", "PtLastJetAll", 60, 0., 300.);
188  hDenJetEta = dbe.book1D("EtaLastJetAll", "EtaLastJetAll", 30, -3., 3.);
189  hNumLeptonPt = dbe.book1D("PtLeptonSel", "PtLeptonSel", 50, 0., 250.);
190  hNumLeptonEta = dbe.book1D("EtaLeptonSel", "EtaLeptonSel", 30, -3., 3.);
191  hNumJetPt = dbe.book1D("PtLastJetSel", "PtLastJetSel", 60, 0., 300.);
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 }
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
double eta() const final
momentum pseudorapidity
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tokElectrons_
const reco::GsfElectron * elec2_
bool accept() const
Has at least one path accepted the event?
edm::EDGetTokenT< edm::TriggerResults > tokTrigger_
double pt() const final
transverse momentum
Strings const & triggerNames() const
Definition: TriggerNames.cc:20
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::View< reco::Muon > > tokMuons_
void addDefault(ParameterSetDescription const &psetDescription)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
const reco::GsfElectron * elec1_
vector< PseudoJet > jets
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
std::vector< std::string > vsPaths_
void triggerBinLabels(const std::vector< std::string > &labels)
set configurable labels for trigger monitoring histograms
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::View< reco::Jet > > tokJets_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:256
Definition: Run.h:45