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  for (unsigned int i=0; i<triggerNames.triggerNames().size(); ++i) {
99 
100  TString name = triggerNames.triggerNames()[i].c_str();
101  bool isInteresting = false;
102  for (unsigned int j=0; j<vsPaths_.size(); j++) {
103  if (name.Contains(TString(vsPaths_[j]), TString::kIgnoreCase)) isInteresting = true;
104  }
105 
106  if (isAll_ && isInteresting) isSel_ = true;
107  else isSel_ = false;
108 
109  //Histos
110  if (isAll_) {
111  if (minElectrons_ > 0) {
112  hDenLeptonPt->Fill(elec1_->pt());
114  }
115  if (minElectrons_ > 1) {
116  hDenLeptonPt->Fill(elec2_->pt());
118  }
119  if (minMuons_ > 0) {
120  hDenLeptonPt->Fill(mu1_->pt());
121  hDenLeptonEta->Fill(mu1_->eta());
122  }
123  if (minMuons_ > 1) {
124  hDenLeptonPt->Fill(mu2_->pt());
125  hDenLeptonEta->Fill(mu2_->eta());
126  }
127  hDenJetPt->Fill(jet_->pt());
128  hDenJetEta->Fill(jet_->eta());
129  }
130  if (isSel_) {
131  if (minElectrons_ > 0) {
132  hNumLeptonPt->Fill(elec1_->pt());
134  }
135  if (minElectrons_ > 1) {
136  hNumLeptonPt->Fill(elec2_->pt());
138  }
139  if (minMuons_ > 0) {
140  hNumLeptonPt->Fill(mu1_->pt());
141  hNumLeptonEta->Fill(mu1_->eta());
142  }
143  if (minMuons_ > 1) {
144  hNumLeptonPt->Fill(mu2_->pt());
145  hNumLeptonEta->Fill(mu2_->eta());
146  }
147  hNumJetPt->Fill(jet_->pt());
148  hNumJetEta->Fill(jet_->eta());
149  }
150  }
151 }
152 
153 // ------------ booking histograms -----------
154  void
156 {
157  dbe.setCurrentFolder(sDir_);
158  hDenLeptonPt = dbe.book1D("PtLeptonAll", "PtLeptonAll", 50, 0., 250.);
159  hDenLeptonEta = dbe.book1D("EtaLeptonAll", "EtaLeptonAll", 30, -3. , 3.);
160  hDenJetPt = dbe.book1D("PtLastJetAll", "PtLastJetAll", 60, 0., 300.);
161  hDenJetEta = dbe.book1D("EtaLastJetAll", "EtaLastJetAll", 30, -3., 3.);
162  hNumLeptonPt = dbe.book1D("PtLeptonSel", "PtLeptonSel", 50, 0., 250.);
163  hNumLeptonEta = dbe.book1D("EtaLeptonSel", "EtaLeptonSel", 30, -3. , 3.);
164  hNumJetPt = dbe.book1D("PtLastJetSel", "PtLastJetSel", 60, 0., 300.);
165  hNumJetEta = dbe.book1D("EtaLastJetSel", "EtaLastJetSel", 30, -3., 3.);
166 }
167 
168 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
169 void
171  //The following says we do not know what parameters are allowed so do no validation
172  // Please change this to state exactly what you do use, even if it is no parameters
174  desc.setUnknown();
175  descriptions.addDefault(desc);
176 }
177 
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:204
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual float pt() const
transverse momentum
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
const reco::GsfElectron * elec2_
edm::EDGetTokenT< edm::TriggerResults > tokTrigger_
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
virtual float eta() const
momentum pseudorapidity
const reco::GsfElectron * elec1_
vector< PseudoJet > jets
edm::EDGetTokenT< edm::View< reco::Jet > > tokJets_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
int j
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::View< reco::Muon > > tokMuons_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
tuple muons
Definition: patZpeak.py:38
std::vector< std::string > vsPaths_
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tokElectrons_
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: Run.h:41