DESY Hbb Analysis Framework
BaseAnalyser.h
Go to the documentation of this file.
1 #ifndef Analysis_Tools_BaseAnalyser_h
2 #define Analysis_Tools_BaseAnalyser_h 1
3 
4 // -*- C++ -*-
5 //
6 // Package: Analysis/Tools
7 // Class: Analysis
8 //
16 //
17 // Original Author: Roberval Walsh
18 // Created: 6 Sep 2018
19 //
20 //
21 
22 // system include files
23 #include <memory>
24 #include <vector>
25 #include <string>
26 //
27 // user include files
28 #include "boost/program_options.hpp"
29 
32 #include "TFile.h"
33 #include "TH1.h"
34 #include "TH2.h"
35 #include "TGraphAsymmErrors.h"
36 
37 namespace po = boost::program_options;
38 
39 
40 //
41 // class declaration
42 //
43 
44 namespace analysis {
45  namespace tools {
46 
47  class BaseAnalyser {
48 
49  public:
51  BaseAnalyser();
53  BaseAnalyser(int argc, char * argv[]);
55  virtual ~BaseAnalyser();
56 
57 
58  // ----------member data ---------------------------
59  protected:
61  std::shared_ptr<Analysis> analysis_;
63  std::shared_ptr<Config> config_;
64 
66  int cutflow_;
67 
69  int seed_;
70 
72  float weight_;
73 
75  float xsection_;
76 
78  std::shared_ptr<TFile> hout_;
80  std::map<std::string, std::shared_ptr<TH1F> > h1_;
82  std::map<std::string, std::shared_ptr<TH2F> > h2_;
83 
84  std::map<std::string, std::shared_ptr<TGraphAsymmErrors> > btageff_;
85 
88 
90  std::shared_ptr<PileupWeight> puweights_;
91 
93  std::string puw_label_;
94 
96  bool istruepu_;
97 
99  float scale_;
100 
102  bool isMC_;
104  bool isData_;
105 
107  std::shared_ptr<TTree> analyser_tree_;
108 
110  std::map<std::string,bool> trg_emul_;
111 
112 
113  private:
114 
116  std::string exe_;
117 
118  public:
119  // Gets
121  std::shared_ptr<Analysis> analysis();
123  std::shared_ptr<Config> config();
124 
126  int nEvents();
127 
128 
130  std::map<std::string, std::shared_ptr<TH1F> > histograms();
132  std::shared_ptr<TH1F> histogram(const std::string &);
133 
135  int cutflow();
137  void cutflow(const int &);
139  void cutflow(const std::string & label, const bool & ok = true);
140 
141  // Actions
143  virtual bool event(const int &);
145  virtual void histograms(const std::string &, const int &);
146 
148  int seed();
150  int seed(const std::string &);
152  void seed(const int &);
153 
155  float weight();
157  void weight(const float &);
158 
160  void generatorWeight();
161 
163  float crossSection() const;
164 
166  std::shared_ptr<TFile> output();
167 
169  bool genParticlesAnalysis() const;
171  bool genJetsAnalysis() const;
172 
174  std::shared_ptr<PileupWeight> pileupWeights() const;
176  float pileupWeight(const float & truepu, const int & var) const;
178  float trueInteractions() const;
179 
181  void pileupHistogram();
183  void fillPileupHistogram();
184 
186  void scale(const float &);
187 
189  std::string basename(const std::string &);
190 
192  void actionApplyPileupWeight(const int & var = 0);
193 
199  std::map<std::string, std::shared_ptr<TGraphAsymmErrors> > btagEfficiencies() const;
200 
202  void analyserTree();
204  void fillAnalyserTree();
205 
207  virtual bool triggerEmulation(const std::string &, const int &, const float &, const float &, const std::string & );
208 
210  std::map<std::string, bool> triggersEmulated();
211 
213  bool triggerEmulated(const std::string &);
214 
215 
216  };
217  }
218 }
219 
220 #endif // Analysis_Tools_BaseAnalyser_h
bool isData_
flag for DATA sample
Definition: BaseAnalyser.h:104
void analyserTree()
root tree
virtual bool event(const int &)
event entry to be readout and processed
float crossSection() const
returns cross section
int cutflow()
get cutflow index
std::string exe_
name of the executable
Definition: BaseAnalyser.h:116
virtual ~BaseAnalyser()
desctructor
std::shared_ptr< TH1F > histogram(const std::string &)
returns a given 1D histogram
std::shared_ptr< Config > config()
returns pointer to Config object
void actionApplyPileupWeight(const int &var=0)
apply pileup weight given a systematic variation
void pileupHistogram()
creates pileup histogram
std::shared_ptr< TFile > output()
returns pointer to output root file
std::shared_ptr< PileupWeight > pileupWeights() const
returns pointer to pileup weights (MC-only)
std::map< std::string, bool > trg_emul_
emulated triggers
Definition: BaseAnalyser.h:110
void fillPileupHistogram()
fills pileup histogram
bool genParticlesAnalysis() const
returns whether analysis of gen particles can be done
std::shared_ptr< PileupWeight > puweights_
pileup weight
Definition: BaseAnalyser.h:90
std::map< std::string, std::shared_ptr< TGraphAsymmErrors > > btagEfficiencies() const
bool isMC_
flag for MC sample
Definition: BaseAnalyser.h:102
bool istruepu_
true pileup
Definition: BaseAnalyser.h:96
bool genJetsAnalysis() const
returns whether analysis of gen jets can be done
std::shared_ptr< TTree > analyser_tree_
output tree
Definition: BaseAnalyser.h:107
std::string basename(const std::string &)
returns the basename of a path
std::shared_ptr< Config > config_
Config objects.
Definition: BaseAnalyser.h:63
std::shared_ptr< TFile > hout_
output root file
Definition: BaseAnalyser.h:78
void generatorWeight()
generator weight
std::shared_ptr< Analysis > analysis_
Analysis objects.
Definition: BaseAnalyser.h:61
float pileupWeight(const float &truepu, const int &var) const
returns pileup weight given the true pileup and uncertainty variation in values of sigma ...
void fillAnalyserTree()
fill root tree
std::map< std::string, std::shared_ptr< TGraphAsymmErrors > > btageff_
Definition: BaseAnalyser.h:84
int seed()
returns a seed for random number generator
std::string puw_label_
pileup weight label
Definition: BaseAnalyser.h:93
std::map< std::string, std::shared_ptr< TH1F > > histograms()
returns all 1D histograms
float trueInteractions() const
returns true number of interactions
float weight_
event weight
Definition: BaseAnalyser.h:72
std::map< std::string, bool > triggersEmulated()
return status of all emulated l1 triggers
void scale(const float &)
sets a scale
bool triggerEmulated(const std::string &)
return status of an emulated l1 trigger
std::map< std::string, std::shared_ptr< TH1F > > h1_
1D histograms mapping
Definition: BaseAnalyser.h:80
float xsection_
cross section
Definition: BaseAnalyser.h:75
int cutflow_
Cutflow index.
Definition: BaseAnalyser.h:66
float scale_
overall scaling
Definition: BaseAnalyser.h:99
std::shared_ptr< Analysis > analysis()
returns pointer to Analysis object
int nEvents()
number of events to be processed
virtual bool triggerEmulation(const std::string &, const int &, const float &, const float &, const std::string &)
emulate l1 trigger
float weight()
returns event weight
std::map< std::string, std::shared_ptr< TH2F > > h2_
2D histograms mapping
Definition: BaseAnalyser.h:82