CMS 3D CMS Logo

B2GHadronicHLTValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTriggerOffline/B2G
4 // Class: B2GHadronicHLTValidation
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"
38 //
39 // member functions
40 //
41 
42 // ------------ method called for each event ------------
43  void
45 {
46  using namespace edm;
47 
48  isAll_ = false; isSel_ = false;
49 
50  // Jets
52  if (!iEvent.getByToken(tokJets_,jets))
53  edm::LogWarning("B2GHadronicHLTValidation") << "Jets collection not found \n";
54  unsigned int nGoodJ = 0;
55  double ht = 0.0;
56  // Check to see if we want asymmetric jet pt cuts
57  if ( ptJets0_ > 0.0 || ptJets1_ > 0.0 ) {
58  if ( ptJets0_ > 0.0 ) {
59  if ( jets->size() > 0 && jets->at(0).pt() > ptJets0_ ) {
60  nGoodJ++;
61  jet_ = jets->ptrAt(0) ;
62  }
63  }
64  if ( ptJets1_ > 0.0 ) {
65  if ( jets->size() > 1 && jets->at(1).pt() > ptJets1_ ) {
66  nGoodJ++;
67  jet_ = jets->ptrAt(1) ;
68  }
69  }
70  } else if (minJets_ > 0 || htMin_ > 0 ) {
71  for(edm::View<reco::Jet>::const_iterator j = jets->begin(); j != jets->end(); ++j){
72  if (j->pt() < ptJets_) continue;
73  if (fabs(j->eta()) > etaJets_) continue;
74  nGoodJ++;
75  ht += j->pt();
76  if (nGoodJ == minJets_) jet_ = jets->ptrAt( j -jets->begin() );
77  }
78  }
79 
80  if ( nGoodJ >= minJets_ || ht > htMin_ ) isAll_ = true;
81 
82 
83  //Trigger
84  Handle<edm::TriggerResults> triggerTable;
85  if (!iEvent.getByToken(tokTrigger_,triggerTable))
86  edm::LogWarning("B2GHadronicHLTValidation") << "Trigger collection not found \n";
87  const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerTable);
88  bool isInteresting = false;
89  for (unsigned int i=0; i<triggerNames.triggerNames().size(); ++i) {
90 
91  TString name = triggerNames.triggerNames()[i].c_str();
92  for (unsigned int j=0; j<vsPaths_.size(); j++) {
93  if (name.Contains(TString(vsPaths_[j]), TString::kIgnoreCase)) {
94  isInteresting = true;
95  break;
96  }
97  }
98  if (isInteresting) break;
99  }
100 
101  if (isAll_ && isInteresting) isSel_ = true;
102  else isSel_ = false;
103 
104  //Histos
105  if (isAll_) {
106  if ( jet_.isNonnull() ) {
107  hDenJetPt->Fill(jet_->pt());
108  hDenJetEta->Fill(jet_->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  hNumJetPt->Fill(jet_->pt());
117  hNumJetEta->Fill(jet_->eta());
118  for (unsigned int i=0; i<triggerNames.triggerNames().size(); ++i) {
119  TString name = triggerNames.triggerNames()[i].c_str();
120  for (unsigned int j=0; j<vsPaths_.size(); j++) {
121  if (name.Contains(TString(vsPaths_[j]), TString::kIgnoreCase)) {
122  hNumTriggerMon->Fill(j+0.5 );
123  }
124  }
125  }
126  }
127 }
128 
129 
130 // ------------ booking histograms -----------
131  void
133 {
134  dbe.setCurrentFolder(sDir_);
135  hDenJetPt = dbe.book1D("PtLastJetAll", "PtLastJetAll", 60, 0., 3000.);
136  hDenJetEta = dbe.book1D("EtaLastJetAll", "EtaLastJetAll", 30, -3., 3.);
137  hNumJetPt = dbe.book1D("PtLastJetSel", "PtLastJetSel", 60, 0., 3000.);
138  hNumJetEta = dbe.book1D("EtaLastJetSel", "EtaLastJetSel", 30, -3., 3.);
139  // determine number of bins for trigger monitoring
140  unsigned int nPaths = vsPaths_.size();
141  // monitored trigger occupancy for single lepton triggers
142  hNumTriggerMon = dbe.book1D("TriggerMonSel" , "TriggerMonSel", nPaths, 0., nPaths);
143  hDenTriggerMon = dbe.book1D("TriggerMonAll" , "TriggerMonAll", nPaths, 0., nPaths);
144  // set bin labels for trigger monitoring
146 }
147 
148 
149 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
150 void
152  //The following says we do not know what parameters are allowed so do no validation
153  // Please change this to state exactly what you do use, even if it is no parameters
155  desc.setUnknown();
156  descriptions.addDefault(desc);
157 }
158 
virtual double pt() const final
transverse momentum
virtual double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
void Fill(long long x)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::TriggerResults > tokTrigger_
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
void triggerBinLabels(const std::vector< std::string > &labels)
set configurable labels for trigger monitoring histograms
vector< PseudoJet > jets
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
edm::EDGetTokenT< edm::View< reco::Jet > > tokJets_
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
std::vector< std::string > vsPaths_
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:239
Definition: Run.h:42