CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTEfficiencyCalculator.h
Go to the documentation of this file.
1 
2 #ifndef HLTriggerOffline_HLTEffCalculator_H
3 #define HLTriggerOffline_HLTEffCalculator_H
4 
5 
6 // system include files
7 #include <memory>
8 #include <string>
9 
10 // user include files
16 
24 
27 
36 
42 
44 
46 
47 
48 #include "TDirectory.h"
49 #include "TH1F.h"
50 #include "TVector3.h"
51 #include "TLorentzVector.h"
52 #include <string>
53 #include <vector>
54 #include <sstream>
55 #include <iostream>
56 #include <TMath.h>
57 #include "TFile.h"
58 #include "TH1.h"
59 
61 public:
62  EfficiencyHandler(std::string Name, const std::vector<std::string>& pathnames, int verb = 0):name(Name),verbosity(verb){
63  int nPaths = (int)pathnames.size();
64  efficiencies= new TH1D(name.c_str(),"efficiencies per path",nPaths,-0.5,(double)nPaths-0.5);
65  std::stringstream s;
66  for(int i = 0; i < nPaths; i++){
67  pathNames.push_back(pathnames.at(i));
68  efficiencies->GetXaxis()->SetBinLabel(i+1,pathnames.at(i).c_str());
69  s.str("");
70  s<<"path_"<<i+1;
71  numerator.push_back(new TH1D((s.str()+"_num").c_str(),(s.str()+"_num").c_str(),1,-0.5,0.5));
72  denominator.push_back(new TH1D((s.str()+"_den").c_str(),(s.str()+"_den").c_str(),1,-0.5,0.5));
73  }
74  }
76  void Fill(const edm::Event& event, const edm::TriggerResults& triggerTable){
77  for(unsigned int i = 0; i< pathNames.size(); i++){
78  denominator.at(i)->Fill(0);
79  if(verbosity > 0)
80  std::cout<<pathNames.at(i)<<std::endl;
81  if(acceptHLT(event, triggerTable,pathNames.at(i)))
82  numerator.at(i)->Fill(0);
83  }
84  }
85  void WriteAll(TDirectory * d){
86  if(d == NULL){
87  std::cout<<"NULL directory! Cannot write!"<<std::endl;
88  return;
89  }
90  if((int)efficiencies->GetXaxis()->GetNbins() != (int)denominator.size()){
91  std::cout<<"HLT path numbers mismatch!"<<std::endl;
92  return;
93  }
94  for(unsigned int s = 0; s < pathNames.size(); s++){
95  double eff = (double)numerator.at(s)->GetEntries();
96  eff= eff/(double)denominator.at(s)->GetEntries();
97  efficiencies->SetBinContent(s+1, eff);
98  }
99  (d->mkdir(std::string(name+"_BareNumberHists").c_str()))->cd();
100  for(unsigned int s = 0; s < pathNames.size(); s++){
101  numerator.at(s)->Write();
102  denominator.at(s)->Write();
103  }
104  d->cd();
105  efficiencies->Write();
106  d->cd();
107  }
108 private:
110  std::vector<TH1*> numerator; //now just a number holder. for possible extention in future
111  std::vector<TH1*> denominator; //now just a number holder. for possible extention in future
113  std::vector<std::string> pathNames;
115 };
116 
117 //
118 // class decleration
119 //
120 
122 public:
123  explicit HLTEffCalculator(const edm::ParameterSet&);
125 
126 
127 private:
128  virtual void beginJob() ;
129  virtual void analyze(const edm::Event&, const edm::EventSetup&);
130  virtual void endJob() ;
131 
132  // edm::Service<TFileService> fs;
133 
134 
135  // ----------member data ---------------------------
136 
140  int verbosity ;
141 
142 };
143 
144 
145 #endif
int i
Definition: DBlmapReader.cc:9
bool acceptHLT(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
EfficiencyHandler * myEffHandler
#define NULL
Definition: scimark2.h:8
std::vector< TH1 * > denominator
std::vector< TH1 * > numerator
HLTEffCalculator(const edm::ParameterSet &)
std::vector< std::string > pathNames
tuple pathnames
Definition: lumiPlot.py:411
void Fill(const edm::Event &event, const edm::TriggerResults &triggerTable)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void WriteAll(TDirectory *d)
EfficiencyHandler(std::string Name, const std::vector< std::string > &pathnames, int verb=0)
edm::InputTag HLTresCollection
tuple cout
Definition: gather_cfg.py:121