CMS 3D CMS Logo

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;
56  for(edm::View<reco::GsfElectron>::const_iterator e = electrons->begin(); e != electrons->end(); ++e){
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  for (unsigned int j=0; j<vsPaths_.size(); j++) {
88  if (triggerNames.triggerNames()[i].find(vsPaths_[j]) != std::string::npos) {
89  isInteresting = true;
90  break;
91  }
92  }
93  if (isInteresting) break;
94  }
95 
96  if (isAll_ && isInteresting) isSel_ = true;
97  else isSel_ = false;
98 
99  //Histos
100  if (isAll_) {
101  //here and below, change to nGoodE/M instead of min since we are taking subleading
102  if (nGoodE > 1 && elec_.isNonnull() ) {
103  hDenLeptonPt->Fill(elec_->pt());
105  }
106  if (nGoodM > 1 && mu_.isNonnull() ) {
107  hDenLeptonPt->Fill(mu_->pt());
108  hDenLeptonEta->Fill(mu_->eta());
109  }
110  for(unsigned int idx=0; idx<vsPaths_.size(); ++idx){
111  hDenTriggerMon->Fill(idx+0.5);
112  }
113 
114  }
115  if (isSel_) {
116  if (nGoodE > 1 && elec_.isNonnull() ) {
117  hNumLeptonPt->Fill(elec_->pt());
119  }
120  if (nGoodM > 1 && mu_.isNonnull() ) {
121  hNumLeptonPt->Fill(mu_->pt());
122  hNumLeptonEta->Fill(mu_->eta());
123  }
124 
125  for (unsigned int i=0; i<triggerNames.triggerNames().size(); ++i) {
126  for (unsigned int j=0; j<vsPaths_.size(); j++) {
127  if (triggerNames.triggerNames()[i].find(vsPaths_[j]) != std::string::npos) {
128  hNumTriggerMon->Fill(j+0.5 );
129  }
130  }
131  }
132  }
133 }
134 
135 
136 // ------------ booking histograms -----------
137  void
139 {
140  dbe.setCurrentFolder(sDir_);
141  hDenLeptonPt = dbe.book1D("PtLeptonAll", "PtLeptonAll", 50, 0., 2500.);
142  hDenLeptonEta = dbe.book1D("EtaLeptonAll", "EtaLeptonAll", 30, -3. , 3.);
143  hNumLeptonPt = dbe.book1D("PtLeptonSel", "PtLeptonSel", 50, 0., 2500.);
144  hNumLeptonEta = dbe.book1D("EtaLeptonSel", "EtaLeptonSel", 30, -3. , 3.);
145  // determine number of bins for trigger monitoring
146  unsigned int nPaths = vsPaths_.size();
147  // monitored trigger occupancy for single lepton triggers
148  hNumTriggerMon = dbe.book1D("TriggerMonSel" , "TriggerMonSel", nPaths, 0., nPaths);
149  hDenTriggerMon = dbe.book1D("TriggerMonAll" , "TriggerMonAll", nPaths, 0., nPaths);
150  // set bin labels for trigger monitoring
152 }
153 
154 
155 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
156 void
158  //The following says we do not know what parameters are allowed so do no validation
159  // Please change this to state exactly what you do use, even if it is no parameters
161  desc.setUnknown();
162  descriptions.addDefault(desc);
163 }
164 
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
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_
double pt() const final
transverse momentum
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
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:118
void analyze(const edm::Event &, const edm::EventSetup &) override
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tokElectrons_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
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
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:301
Definition: Run.h:44