CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
B2GDoubleLeptonHLTValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTriggerOffline/B2G
4 // Class: B2GDoubleLeptonHLTValidation
5 //
15 //
16 // Original Author: Clint Richardson (copy of B2GSingleLeptonHLTValidation)
17 // Created: Tue, 05 Apr 2016 14:27:00 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("B2GDoubleLeptonHLTValidation") << "Electrons collection not found \n";
55  unsigned int nGoodE = 0;
57  if (e->pt() < ptElectrons_) continue;
58  if (fabs(e->eta()) > etaElectrons_) continue;
59  nGoodE++;
60  //leptons come sorted so use only 2nd
61  if (nGoodE == 2) elec_ = electrons->ptrAt( e - electrons->begin());
62  }
63  // Muons
65  if (!iEvent.getByToken(tokMuons_,muons))
66  edm::LogWarning("B2GDoubleLeptonHLTValidation") << "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  nGoodM++;
73  //leptons come sorted so use only 2nd
74  if (nGoodM == 2) mu_ = muons->ptrAt( m - muons->begin() );
75  }
76 
77  if (nGoodE >= minElectrons_ && nGoodM >= minMuons_ && nGoodE + nGoodM >= minLeptons_) isAll_ = true;
78 
79 
80  //Trigger
81  Handle<edm::TriggerResults> triggerTable;
82  if (!iEvent.getByToken(tokTrigger_,triggerTable))
83  edm::LogWarning("B2GDoubleLeptonHLTValidation") << "Trigger collection not found \n";
84  const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerTable);
85  bool isInteresting = false;
86  for (unsigned int i=0; i<triggerNames.triggerNames().size(); ++i) {
87 
88  for (unsigned int j=0; j<vsPaths_.size(); j++) {
89  if (triggerNames.triggerNames()[i].find(vsPaths_[j]) != std::string::npos) {
90  isInteresting = true;
91  break;
92  }
93  }
94  if (isInteresting) break;
95  }
96 
97  if (isAll_ && isInteresting) isSel_ = true;
98  else isSel_ = false;
99 
100  //Histos
101  if (isAll_) {
102  //here and below, change to nGoodE/M instead of min since we are taking subleading
103  if (nGoodE > 1 && elec_.isNonnull() ) {
104  hDenLeptonPt->Fill(elec_->pt());
105  hDenLeptonEta->Fill(elec_->eta());
106  }
107  if (nGoodM > 1 && mu_.isNonnull() ) {
108  hDenLeptonPt->Fill(mu_->pt());
109  hDenLeptonEta->Fill(mu_->eta());
110  }
111  for(unsigned int idx=0; idx<vsPaths_.size(); ++idx){
112  hDenTriggerMon->Fill(idx+0.5);
113  }
114 
115  }
116  if (isSel_) {
117  if (nGoodE > 1 && elec_.isNonnull() ) {
118  hNumLeptonPt->Fill(elec_->pt());
119  hNumLeptonEta->Fill(elec_->eta());
120  }
121  if (nGoodM > 1 && mu_.isNonnull() ) {
122  hNumLeptonPt->Fill(mu_->pt());
123  hNumLeptonEta->Fill(mu_->eta());
124  }
125 
126  for (unsigned int i=0; i<triggerNames.triggerNames().size(); ++i) {
127  for (unsigned int j=0; j<vsPaths_.size(); j++) {
128  if (triggerNames.triggerNames()[i].find(vsPaths_[j]) != std::string::npos) {
129  hNumTriggerMon->Fill(j+0.5 );
130  }
131  }
132  }
133  }
134 }
135 
136 
137 // ------------ booking histograms -----------
138  void
140 {
141  dbe.setCurrentFolder(sDir_);
142  hDenLeptonPt = dbe.book1D("PtLeptonAll", "PtLeptonAll", 50, 0., 2500.);
143  hDenLeptonEta = dbe.book1D("EtaLeptonAll", "EtaLeptonAll", 30, -3. , 3.);
144  hNumLeptonPt = dbe.book1D("PtLeptonSel", "PtLeptonSel", 50, 0., 2500.);
145  hNumLeptonEta = dbe.book1D("EtaLeptonSel", "EtaLeptonSel", 30, -3. , 3.);
146  // determine number of bins for trigger monitoring
147  unsigned int nPaths = vsPaths_.size();
148  // monitored trigger occupancy for single lepton triggers
149  hNumTriggerMon = dbe.book1D("TriggerMonSel" , "TriggerMonSel", nPaths, 0., nPaths);
150  hDenTriggerMon = dbe.book1D("TriggerMonAll" , "TriggerMonAll", nPaths, 0., nPaths);
151  // set bin labels for trigger monitoring
153 }
154 
155 
156 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
157 void
159  //The following says we do not know what parameters are allowed so do no validation
160  // Please change this to state exactly what you do use, even if it is no parameters
162  desc.setUnknown();
163  descriptions.addDefault(desc);
164 }
165 
int i
Definition: DBlmapReader.cc:9
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:215
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void triggerBinLabels(const std::vector< std::string > &labels)
set configurable labels for trigger monitoring histograms
edm::EDGetTokenT< edm::View< reco::Muon > > tokMuons_
edm::EDGetTokenT< edm::TriggerResults > tokTrigger_
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
edm::Ptr< reco::GsfElectron > elec_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:169
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tokElectrons_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
tuple muons
Definition: patZpeak.py:38
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: Run.h:43