CMS 3D CMS Logo

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