CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TopSingleLeptonHLTValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTriggerOffline/Top
4 // Class: TopSingleLeptonHLTValidation
5 //
15 //
16 // Original Author: Elvire Bouvier
17 // Created: Thu, 16 Jan 2014 16:27:35 GMT
18 //
19 //
21 
22 // system include files
23 #include <memory>
24 
25 // user include files
27 
30 
33 
37 #include "TString.h"
39 //
40 // member functions
41 //
42 
43 // ------------ method called for each event ------------
44  void
46 {
47  using namespace edm;
48 
49  isAll_ = false; isSel_ = false;
50 
51  // Electrons
53  if (!iEvent.getByToken(tokElectrons_,electrons))
54  edm::LogWarning("TopSingleLeptonHLTValidation") << "Electrons collection not found \n";
55  unsigned int nGoodE = 0;
57  if (e->pt() < ptElectrons_) continue;
58  if (fabs(e->eta()) > etaElectrons_) continue;
59  if ((e->dr03TkSumPt()+e->dr03EcalRecHitSumEt()+e->dr03HcalTowerSumEt())/e->pt() > isoElectrons_ ) continue;
60  nGoodE++;
61  if (nGoodE == 1) elec_ = &(*e);
62  }
63  // Muons
65  if (!iEvent.getByToken(tokMuons_,muons))
66  edm::LogWarning("TopSingleLeptonHLTValidation") << "Muons collection not found \n";
67  unsigned int nGoodM = 0;
68  for(edm::View<reco::Muon>::const_iterator m = muons->begin(); m != muons->end(); ++m){
69  if (!m->isPFMuon() || !m->isGlobalMuon()) continue;
70  if (m->pt() < ptMuons_) continue;
71  if (fabs(m->eta()) > etaMuons_) continue;
72  if (((m->pfIsolationR04()).sumChargedHadronPt+(m->pfIsolationR04()).sumPhotonEt+(m->pfIsolationR04()).sumNeutralHadronEt)/m->pt() > isoMuons_ ) continue;
73  nGoodM++;
74  if (nGoodM == 1) mu_ = &(*m);
75  }
76  // Jets
78  if (!iEvent.getByToken(tokJets_,jets))
79  edm::LogWarning("TopSingleLeptonHLTValidation") << "Jets collection not found \n";
80  unsigned int nGoodJ = 0;
81  if (minJets_ == 4) {
82  for(edm::View<reco::Jet>::const_iterator j = jets->begin(); j != jets->end(); ++j){
83  if (nGoodJ < 1 && j->pt() < 55) continue;
84  if (nGoodJ < 2 && j->pt() < 45) continue;
85  if (nGoodJ < 3 && j->pt() < 35) continue;
86  if (nGoodJ >= 3 && j->pt() < 20) continue;
87  if (fabs(j->eta()) > etaJets_) continue;
88  nGoodJ++;
89  if (nGoodJ == minJets_) jet_ = &(*j);
90  }
91  }
92  else {
93  for(edm::View<reco::Jet>::const_iterator j = jets->begin(); j != jets->end(); ++j){
94  if (j->pt() < ptJets_) continue;
95  if (fabs(j->eta()) > etaJets_) continue;
96  nGoodJ++;
97  if (nGoodJ == minJets_) jet_ = &(*j);
98  }
99  }
100 
101  if (nGoodE >= minElectrons_ && nGoodM >= minMuons_ && nGoodJ >= minJets_) isAll_ = true;
102 
103 
104  //Trigger
105  Handle<edm::TriggerResults> triggerTable;
106  if (!iEvent.getByToken(tokTrigger_,triggerTable))
107  edm::LogWarning("TopSingleLeptonHLTValidation") << "Trigger collection not found \n";
108  const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerTable);
109  unsigned int isInteresting = 0;
110  for (unsigned int i=0; i<triggerNames.triggerNames().size(); ++i) {
111 
112  TString name = triggerNames.triggerNames()[i].c_str();
113  for (unsigned int j=0; j<vsPaths_.size(); j++) {
114  if (name.Contains(TString(vsPaths_[j]), TString::kIgnoreCase)) {
115  if (triggerTable->accept(i)){
116  isInteresting++;
117  if (isAll_) hNumTriggerMon->Fill(j+0.5 );
118  }
119  }
120  }
121  }
122 
123  if (isAll_ && isInteresting > 0) isSel_ = true;
124  else isSel_ = false;
125 
126  //Histos
127  if (isAll_) {
128  if (minElectrons_ > 0) {
129  hDenLeptonPt->Fill(elec_->pt());
131  }
132  if (minMuons_ > 0) {
133  hDenLeptonPt->Fill(mu_->pt());
134  hDenLeptonEta->Fill(mu_->eta());
135  }
136  hDenJetPt->Fill(jet_->pt());
137  hDenJetEta->Fill(jet_->eta());
138  for(unsigned int idx=0; idx<vsPaths_.size(); ++idx){
139  hDenTriggerMon->Fill(idx+0.5);
140  }
141 
142  }
143  if (isSel_) {
144  if (minElectrons_ > 0) {
145  hNumLeptonPt->Fill(elec_->pt());
147  }
148  if (minMuons_ > 0) {
149  hNumLeptonPt->Fill(mu_->pt());
150  hNumLeptonEta->Fill(mu_->eta());
151  }
152  hNumJetPt->Fill(jet_->pt());
153  hNumJetEta->Fill(jet_->eta());
154  }
155 }
156 
157 
158 // ------------ booking histograms -----------
159  void
161 {
162  dbe.setCurrentFolder(sDir_);
163  hDenLeptonPt = dbe.book1D("PtLeptonAll", "PtLeptonAll", 50, 0., 250.);
164  hDenLeptonEta = dbe.book1D("EtaLeptonAll", "EtaLeptonAll", 30, -3. , 3.);
165  hDenJetPt = dbe.book1D("PtLastJetAll", "PtLastJetAll", 60, 0., 300.);
166  hDenJetEta = dbe.book1D("EtaLastJetAll", "EtaLastJetAll", 30, -3., 3.);
167  hNumLeptonPt = dbe.book1D("PtLeptonSel", "PtLeptonSel", 50, 0., 250.);
168  hNumLeptonEta = dbe.book1D("EtaLeptonSel", "EtaLeptonSel", 30, -3. , 3.);
169  hNumJetPt = dbe.book1D("PtLastJetSel", "PtLastJetSel", 60, 0., 300.);
170  hNumJetEta = dbe.book1D("EtaLastJetSel", "EtaLastJetSel", 30, -3., 3.);
171  // determine number of bins for trigger monitoring
172  unsigned int nPaths = vsPaths_.size();
173  // monitored trigger occupancy for single lepton triggers
174  hNumTriggerMon = dbe.book1D("TriggerMonSel" , "TriggerMonSel", nPaths, 0., nPaths);
175  hDenTriggerMon = dbe.book1D("TriggerMonAll" , "TriggerMonAll", nPaths, 0., nPaths);
176  // set bin labels for trigger monitoring
178 }
179 
180 
181 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
182 void
184  //The following says we do not know what parameters are allowed so do no validation
185  // Please change this to state exactly what you do use, even if it is no parameters
187  desc.setUnknown();
188  descriptions.addDefault(desc);
189 }
190 
int i
Definition: DBlmapReader.cc:9
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:208
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
edm::EDGetTokenT< edm::View< reco::Jet > > tokJets_
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
void Fill(long long x)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::TriggerResults > tokTrigger_
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
vector< PseudoJet > jets
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
void triggerBinLabels(const std::vector< std::string > &labels)
set configurable labels for trigger monitoring histograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
edm::EDGetTokenT< edm::View< reco::Muon > > tokMuons_
tuple muons
Definition: patZpeak.py:38
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tokElectrons_
Definition: Run.h:41