DESY Hbb Analysis Framework
Public Member Functions | Protected Attributes | Private Attributes | List of all members
analysis::tools::BaseAnalyser Class Reference

#include <BaseAnalyser.h>

Inheritance diagram for analysis::tools::BaseAnalyser:
analysis::tools::JetAnalyser analysis::tools::MuonAnalyser analysis::tools::TriggerAnalyser analysis::tools::Analyser analysis::tools::Analyser analysis::tools::Analyser analysis::mssmhbb::MssmHbbAnalyser analysis::mssmhbb::MssmHbbAnalyser analysis::mssmhbb::MssmHbbAnalyser

Public Member Functions

void actionApplyPileupWeight (const int &var=0)
 apply pileup weight given a systematic variation More...
 
void analyserTree ()
 root tree More...
 
std::shared_ptr< Analysisanalysis ()
 returns pointer to Analysis object More...
 
 BaseAnalyser ()
 constructor More...
 
 BaseAnalyser (int argc, char *argv[])
 constructor More...
 
std::string basename (const std::string &)
 returns the basename of a path More...
 
std::map< std::string, std::shared_ptr< TGraphAsymmErrors > > btagEfficiencies () const
 
std::shared_ptr< Configconfig ()
 returns pointer to Config object More...
 
float crossSection () const
 returns cross section More...
 
int cutflow ()
 get cutflow index More...
 
void cutflow (const int &)
 set cutflow index More...
 
void cutflow (const std::string &label, const bool &ok=true)
 create and update cutflow entry in the cutflow histogram More...
 
virtual bool event (const int &)
 event entry to be readout and processed More...
 
void fillAnalyserTree ()
 fill root tree More...
 
void fillPileupHistogram ()
 fills pileup histogram More...
 
void generatorWeight ()
 generator weight More...
 
bool genJetsAnalysis () const
 returns whether analysis of gen jets can be done More...
 
bool genParticlesAnalysis () const
 returns whether analysis of gen particles can be done More...
 
std::shared_ptr< TH1F > histogram (const std::string &)
 returns a given 1D histogram More...
 
std::map< std::string, std::shared_ptr< TH1F > > histograms ()
 returns all 1D histograms More...
 
virtual void histograms (const std::string &, const int &)
 create n histograms of a given type More...
 
int nEvents ()
 number of events to be processed More...
 
std::shared_ptr< TFile > output ()
 returns pointer to output root file More...
 
void pileupHistogram ()
 creates pileup histogram More...
 
float pileupWeight (const float &truepu, const int &var) const
 returns pileup weight given the true pileup and uncertainty variation in values of sigma More...
 
std::shared_ptr< PileupWeightpileupWeights () const
 returns pointer to pileup weights (MC-only) More...
 
void scale (const float &)
 sets a scale More...
 
int seed ()
 returns a seed for random number generator More...
 
int seed (const std::string &)
 reads a file containing a seed and returns the seed or -1 if fails More...
 
void seed (const int &)
 sets a seed for random number generators More...
 
bool triggerEmulated (const std::string &)
 return status of an emulated l1 trigger More...
 
virtual bool triggerEmulation (const std::string &, const int &, const float &, const float &, const std::string &)
 emulate l1 trigger More...
 
std::map< std::string, bool > triggersEmulated ()
 return status of all emulated l1 triggers More...
 
float trueInteractions () const
 returns true number of interactions More...
 
float weight ()
 returns event weight More...
 
void weight (const float &)
 sets event weight More...
 
virtual ~BaseAnalyser ()
 desctructor More...
 

Protected Attributes

std::shared_ptr< TTree > analyser_tree_
 output tree More...
 
std::shared_ptr< Analysisanalysis_
 Analysis objects. More...
 
std::map< std::string, std::shared_ptr< TGraphAsymmErrors > > btageff_
 
std::shared_ptr< Configconfig_
 Config objects. More...
 
int cutflow_
 Cutflow index. More...
 
bool genjetsanalysis_
 
bool genpartsanalysis_
 
std::map< std::string, std::shared_ptr< TH1F > > h1_
 1D histograms mapping More...
 
std::map< std::string, std::shared_ptr< TH2F > > h2_
 2D histograms mapping More...
 
std::shared_ptr< TFile > hout_
 output root file More...
 
bool isData_
 flag for DATA sample More...
 
bool isMC_
 flag for MC sample More...
 
bool istruepu_
 true pileup More...
 
std::string puw_label_
 pileup weight label More...
 
std::shared_ptr< PileupWeightpuweights_
 pileup weight More...
 
float scale_
 overall scaling More...
 
int seed_
 seed value More...
 
std::map< std::string, bool > trg_emul_
 emulated triggers More...
 
float weight_
 event weight More...
 
float xsection_
 cross section More...
 

Private Attributes

std::string exe_
 name of the executable More...
 

Detailed Description

Definition at line 47 of file BaseAnalyser.h.

Constructor & Destructor Documentation

BaseAnalyser::BaseAnalyser ( )

constructor

Definition at line 24 of file BaseAnalyser.cc.

25 {
26 }
BaseAnalyser::BaseAnalyser ( int  argc,
char *  argv[] 
)

constructor

Definition at line 29 of file BaseAnalyser.cc.

References analysis_, basename(), btageff_, config_, exe_, f, genjetsanalysis_, genpartsanalysis_, h1_, hout_, isData_, isMC_, puw_label_, puweights_, scale_, seed_, weight_, and xsection_.

30 {
31  TH1::SetDefaultSumw2();
32 
33  exe_ = std::string(argv[0]);
34 
35  // some inits
36  scale_ = -1.;
37  weight_ = 1.;
38  xsection_ = -1.;
39  genpartsanalysis_ = false;
40  genjetsanalysis_ = false;
41 
42  // the heavy stuff
43  config_ = std::make_shared<Config>(argc,argv);
44  analysis_ = std::make_shared<Analysis>(config_->ntuplesList(),config_->eventInfo());
45 
46  // output file
47  if ( config_->outputRoot() != "" )
48  {
49  hout_= std::make_shared<TFile>(config_->outputRoot().c_str(),"recreate",Form("%s %s %s",argv[0],argv[1],argv[2]));
50  hout_ -> cd();
51  }
52 
53  seed_ = analysis_ ->seed(config_->seedFile());
54 
55  // Workflow
56  h1_["cutflow"] = std::make_shared<TH1F>("workflow",Form("Workflow #%d",config_->workflow()), 100,0,100);
57 
58 
59  isMC_ = analysis_->isMC();
60  isData_ = !isMC_;
61 
62  // Some MC-only stuff
63  if ( isMC_ )
64  {
65  // Cross sections
66  if ( analysis_ -> crossSections(config_->crossSectionTree()) == 0 )
67  xsection_ = analysis_->crossSection(config_->crossSectionType());
68  // Pileup weights
69  if ( config_->pileupWeights() != "" )
70  {
71  puweights_ = analysis_->pileupWeights(config_->pileupWeights());
72  puw_label_ = basename(config_->pileupWeights());
73  }
74  else
75  {
76  puw_label_ = "*** missing *** assuming puweight = 1";
77  }
78 
79  // gen part analysis
80  genpartsanalysis_ = ( analysis_->addTree<GenParticle> ("GenParticles",config_->genParticlesCollection()) != nullptr );
81  // gen jets analysis
82  genjetsanalysis_ = ( analysis_->addTree<GenJet> ("GenJets",config_->genJetsCollection()) != nullptr );
83 
84  }
85 
86  // JSON for data
87  if( isData_ && config_->json() != "" ) analysis_->processJsonFile(config_->json());
88 
89  // btag efficiencies
90  if ( config_->btagEfficiencies() != "" )
91  {
92  TFile f(config_->btagEfficiencies().c_str(),"old");
93  auto list = f.GetListOfKeys();
94  for ( int i = 0; i < list -> GetSize(); ++i)
95  {
96  TString item(list -> At(i) -> GetName());
97  if ( ! item.BeginsWith("eff_")) continue;
98  item.Remove(0,4);
99  btageff_[item.Data()] = std::shared_ptr<TGraphAsymmErrors>((TGraphAsymmErrors*)f.Get(("eff_"+item).Data()));
100  }
101  f.Close();
102  }
103 
104 }
bool isData_
flag for DATA sample
Definition: BaseAnalyser.h:104
std::string exe_
name of the executable
Definition: BaseAnalyser.h:116
std::shared_ptr< PileupWeight > puweights_
pileup weight
Definition: BaseAnalyser.h:90
bool isMC_
flag for MC sample
Definition: BaseAnalyser.h:102
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
std::shared_ptr< Analysis > analysis_
Analysis objects.
Definition: BaseAnalyser.h:61
std::map< std::string, std::shared_ptr< TGraphAsymmErrors > > btageff_
Definition: BaseAnalyser.h:84
std::string puw_label_
pileup weight label
Definition: BaseAnalyser.h:93
float weight_
event weight
Definition: BaseAnalyser.h:72
std::map< std::string, std::shared_ptr< TH1F > > h1_
1D histograms mapping
Definition: BaseAnalyser.h:80
float xsection_
cross section
Definition: BaseAnalyser.h:75
float scale_
overall scaling
Definition: BaseAnalyser.h:99
TFile * f[10]
Definition: PlotsCompare.cc:24
BaseAnalyser::~BaseAnalyser ( )
virtual

desctructor

Definition at line 106 of file BaseAnalyser.cc.

References config_, exe_, h, h1_, h2_, hout_, scale(), and scale_.

107 {
108  std::cout << std::endl;
109  // get last bin
110  int lastbin = 0;
111  for ( int i = 1; i <= h1_["cutflow"] ->GetNbinsX(); ++i )
112  {
113  std::string label = std::string(h1_["cutflow"]->GetXaxis()->GetBinLabel(i));
114  if ( label == "" )
115  {
116  lastbin = i-1;
117  break;
118  }
119  }
120  float fevts = h1_["cutflow"] -> GetBinContent(lastbin);
121  // overall scale
122  float scale = 1.;
123  bool doscale = false;
124  if ( scale_ > 0. ) // superseeds the scale from config
125  {
126  doscale = true;
127  scale = scale_;
128  }
129  else
130  {
131  // scale from config
132  if ( config_ -> scale() > 0. )
133  {
134  doscale = true;
135  scale = config_ -> scale();
136  }
137  }
138  if ( doscale )
139  {
140  if ( std::string(h1_["cutflow"] -> GetXaxis()-> GetBinLabel(lastbin+1)) == "" )
141  {
142  h1_["cutflow"] -> GetXaxis()-> SetBinLabel(lastbin+1,Form("Number of events after scaling to %10.5f",scale));
143  }
144  h1_["cutflow"] -> Fill(lastbin,fevts*scale);
145  }
146 
147 
148  for ( auto h : h1_ )
149  {
150  if ( h.first == "cutflow" || h.first == "pileup" || h.first == "pileup_w" ) continue;
151  if ( doscale ) h.second -> Scale(scale);
152  bool is_empty = ( h.second -> GetEntries() != 0 || h.second -> GetSumOfWeights() != 0 );
153  if ( is_empty )
154  continue;
155 
156  }
157  for ( auto h : h2_ )
158  {
159  if ( doscale ) h.second -> Scale(scale);
160  bool is_empty = ( h.second -> GetEntries() != 0 || h.second -> GetSumOfWeights() != 0 );
161  if ( is_empty ) continue;
162  }
163 
164  if ( hout_ )
165  {
166 // std::cout << std::endl;
167 // std::cout << "output root file: " << config_->outputRoot() << std::endl;
168  hout_ -> cd();
169  hout_ -> Write();
170  hout_->Close();
171  // print workflow using the Workflow macro
172  try
173  {
174  system(Form("Workflow %s",config_->outputRoot().c_str()));
175  }
176  catch(...)
177  {
178  std::cout << "Problems with Workflow macro or the output file, no summary printed" << std::endl;
179  }
180  }
181 
182  std::cout << std::endl;
183  std::cout << exe_ << " finished!" << std::endl;
184  printf("%s\n", std::string(100,'_').c_str());
185  std::cout << std::endl;
186 
187  std::ofstream finished;
188  finished.open("finished.txt");
189  finished << exe_ << "\n";
190  finished.close();
191 
192 }
std::string exe_
name of the executable
Definition: BaseAnalyser.h:116
TH1F * h[10]
Definition: PlotsCompare.cc:25
std::shared_ptr< Config > config_
Config objects.
Definition: BaseAnalyser.h:63
std::shared_ptr< TFile > hout_
output root file
Definition: BaseAnalyser.h:78
void scale(const float &)
sets a scale
std::map< std::string, std::shared_ptr< TH1F > > h1_
1D histograms mapping
Definition: BaseAnalyser.h:80
float scale_
overall scaling
Definition: BaseAnalyser.h:99
std::map< std::string, std::shared_ptr< TH2F > > h2_
2D histograms mapping
Definition: BaseAnalyser.h:82

Member Function Documentation

void BaseAnalyser::actionApplyPileupWeight ( const int &  var = 0)

apply pileup weight given a systematic variation

Definition at line 301 of file BaseAnalyser.cc.

References analysis_, config_, cutflow(), fillPileupHistogram(), pileupWeight(), puw_label_, puweights_, and weight_.

Referenced by analysis::tools::Analyser::event(), and main().

302 {
303  if ( ! config_->isMC() ) return;
304 
305  if ( puweights_ )
306  weight_ *= this->pileupWeight(analysis_->nTruePileup(),var);
307  else
308  weight_ *= 1;
309 
311 
312  this -> fillPileupHistogram();
313 }
int cutflow()
get cutflow index
void fillPileupHistogram()
fills pileup histogram
std::shared_ptr< PileupWeight > puweights_
pileup weight
Definition: BaseAnalyser.h:90
std::shared_ptr< Config > config_
Config objects.
Definition: BaseAnalyser.h:63
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 ...
std::string puw_label_
pileup weight label
Definition: BaseAnalyser.h:93
float weight_
event weight
Definition: BaseAnalyser.h:72
void analysis::tools::BaseAnalyser::analyserTree ( )

root tree

std::shared_ptr< Analysis > BaseAnalyser::analysis ( )

returns pointer to Analysis object

Definition at line 203 of file BaseAnalyser.cc.

References analysis_.

Referenced by main().

204 {
205  return analysis_;
206 }
std::shared_ptr< Analysis > analysis_
Analysis objects.
Definition: BaseAnalyser.h:61
std::string BaseAnalyser::basename ( const std::string &  name)

returns the basename of a path

Definition at line 363 of file BaseAnalyser.cc.

Referenced by analysis::tools::JetAnalyser::actionApplyJER(), BaseAnalyser(), and analysis::tools::Analyser::event().

364 {
365  std::string bn = "";
366  std::vector<std::string> paths;
367  if ( name != "" )
368  {
369  boost::split(paths, name, boost::is_any_of("/"));
370  bn = paths.back();
371  }
372  return bn;
373 
374 
375 }
std::map< std::string, std::shared_ptr< TGraphAsymmErrors > > BaseAnalyser::btagEfficiencies ( ) const

btag efficiencies

Given as TGraphAsymmErrors for each flavour

Definition at line 377 of file BaseAnalyser.cc.

References btageff_.

378 {
379  return btageff_;
380 }
std::map< std::string, std::shared_ptr< TGraphAsymmErrors > > btageff_
Definition: BaseAnalyser.h:84
std::shared_ptr< Config > BaseAnalyser::config ( )

returns pointer to Config object

Definition at line 208 of file BaseAnalyser.cc.

References config_.

Referenced by analysis::tools::JetAnalyser::jetCorrections(), and main().

209 {
210  return config_;
211 }
std::shared_ptr< Config > config_
Config objects.
Definition: BaseAnalyser.h:63
float BaseAnalyser::crossSection ( ) const

returns cross section

Definition at line 278 of file BaseAnalyser.cc.

References xsection_.

279 {
280  return xsection_;
281 }
float xsection_
cross section
Definition: BaseAnalyser.h:75
int BaseAnalyser::cutflow ( )
void BaseAnalyser::cutflow ( const int &  c)

set cutflow index

Definition at line 342 of file BaseAnalyser.cc.

References cutflow_.

343 {
344  cutflow_ = c;
345 }
int cutflow_
Cutflow index.
Definition: BaseAnalyser.h:66
void BaseAnalyser::cutflow ( const std::string &  label,
const bool &  ok = true 
)

create and update cutflow entry in the cutflow histogram

Definition at line 347 of file BaseAnalyser.cc.

References cutflow_, h1_, and weight_.

348 {
349  ++cutflow_;
350  if ( std::string(h1_["cutflow"] -> GetXaxis()-> GetBinLabel(cutflow_+1)) == "" )
351  {
352  h1_["cutflow"] -> GetXaxis()-> SetBinLabel(cutflow_+1,label.c_str());
353  }
354  if ( ok ) h1_["cutflow"] -> Fill(cutflow_,weight_);
355 
356 }
float weight_
event weight
Definition: BaseAnalyser.h:72
std::map< std::string, std::shared_ptr< TH1F > > h1_
1D histograms mapping
Definition: BaseAnalyser.h:80
int cutflow_
Cutflow index.
Definition: BaseAnalyser.h:66
bool BaseAnalyser::event ( const int &  i)
virtual

event entry to be readout and processed

Reimplemented in analysis::tools::Analyser, and analysis::mssmhbb::MssmHbbAnalyser.

Definition at line 200 of file BaseAnalyser.cc.

200 { return true; }
void analysis::tools::BaseAnalyser::fillAnalyserTree ( )

fill root tree

void BaseAnalyser::fillPileupHistogram ( )

fills pileup histogram

Definition at line 330 of file BaseAnalyser.cc.

References analysis_, h1_, and pileupWeight().

Referenced by actionApplyPileupWeight(), and main().

331 {
332 
333  h1_["pileup"] -> Fill(analysis_->nTruePileup());
334  h1_["pileup_w"] -> Fill(analysis_->nTruePileup(),this->pileupWeight(analysis_->nTruePileup(),0));
335 }
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 ...
std::map< std::string, std::shared_ptr< TH1F > > h1_
1D histograms mapping
Definition: BaseAnalyser.h:80
void BaseAnalyser::generatorWeight ( )

generator weight

Definition at line 383 of file BaseAnalyser.cc.

References analysis_, config_, weight(), and weight_.

Referenced by analysis::tools::Analyser::event().

384 {
385  if ( ! config_->isMC() ) return;
386 
387  float weight = analysis_->genWeight();
388  if ( config_->fullGenWeight() )
389  {
390  weight_ *= weight;
391  }
392  else
393  {
394  float sign = (weight > 0) ? 1 : ((weight < 0) ? -1 : 0);
395  weight_ *= sign;
396  }
397 
398 }
std::shared_ptr< Config > config_
Config objects.
Definition: BaseAnalyser.h:63
std::shared_ptr< Analysis > analysis_
Analysis objects.
Definition: BaseAnalyser.h:61
float weight_
event weight
Definition: BaseAnalyser.h:72
float weight()
returns event weight
bool BaseAnalyser::genJetsAnalysis ( ) const

returns whether analysis of gen jets can be done

Definition at line 273 of file BaseAnalyser.cc.

References genjetsanalysis_.

Referenced by analysis::tools::JetAnalyser::analysisWithJets(), analysis::tools::Analyser::event(), and analysis::tools::JetAnalyser::JetAnalyser().

274 {
275  return genjetsanalysis_;
276 }
bool BaseAnalyser::genParticlesAnalysis ( ) const

returns whether analysis of gen particles can be done

Definition at line 268 of file BaseAnalyser.cc.

References genpartsanalysis_.

Referenced by analysis::tools::JetAnalyser::analysisWithJets(), and analysis::tools::Analyser::event().

269 {
270  return genpartsanalysis_;
271 }
std::shared_ptr< TH1F > BaseAnalyser::histogram ( const std::string &  hname)

returns a given 1D histogram

Definition at line 220 of file BaseAnalyser.cc.

References h1_.

221 {
222  if ( h1_.find(hname) == h1_.end() )
223  {
224  std::cout << "-e- BaseAnalyser::H1F(const string & hname) -> no histogram with hname = " << hname << std::endl;
225  return nullptr;
226  }
227 
228  return h1_[hname];
229 }
std::map< std::string, std::shared_ptr< TH1F > > h1_
1D histograms mapping
Definition: BaseAnalyser.h:80
std::map< std::string, std::shared_ptr< TH1F > > BaseAnalyser::histograms ( )

returns all 1D histograms

Definition at line 231 of file BaseAnalyser.cc.

References h1_.

232 {
233  return h1_;
234 }
std::map< std::string, std::shared_ptr< TH1F > > h1_
1D histograms mapping
Definition: BaseAnalyser.h:80
void BaseAnalyser::histograms ( const std::string &  s,
const int &  i 
)
virtual

create n histograms of a given type

Definition at line 201 of file BaseAnalyser.cc.

201 { }
int BaseAnalyser::nEvents ( )

number of events to be processed

Definition at line 213 of file BaseAnalyser.cc.

References analysis_, and config_.

Referenced by main().

214 {
215  int maxevt = config_->nEventsMax();
216  if ( maxevt < 0 || maxevt > analysis_->size() ) maxevt = analysis_->size();
217  return maxevt;
218 }
std::shared_ptr< Config > config_
Config objects.
Definition: BaseAnalyser.h:63
std::shared_ptr< Analysis > analysis_
Analysis objects.
Definition: BaseAnalyser.h:61
std::shared_ptr< TFile > BaseAnalyser::output ( )

returns pointer to output root file

Definition at line 263 of file BaseAnalyser.cc.

References hout_.

Referenced by analysis::tools::JetAnalyser::fillJetHistograms(), analysis::tools::JetAnalyser::jetHistograms(), analysis::mssmhbb::MssmHbbAnalyser::mssmHbbTree(), and pileupHistogram().

264 {
265  return hout_;
266 }
std::shared_ptr< TFile > hout_
output root file
Definition: BaseAnalyser.h:78
void BaseAnalyser::pileupHistogram ( )

creates pileup histogram

Definition at line 315 of file BaseAnalyser.cc.

References config_, h1_, and output().

Referenced by analysis::tools::Analyser::Analyser().

316 {
317  this->output()->cd();
318  if ( config_->min() > 0 && config_->max() > 0 )
319  {
320  h1_["pileup"] = std::make_shared<TH1F>("pileup" , "pileup" , config_->n() , config_->min() , config_->max() );
321  h1_["pileup_w"] = std::make_shared<TH1F>("pileup_w" , "weighted pileup" , config_->n() , config_->min() , config_->max() );
322  }
323  else
324  {
325  h1_["pileup"] = std::make_shared<TH1F>("pileup" , "pileup" , 100 , 0 , 100 );
326  h1_["pileup_w"] = std::make_shared<TH1F>("pileup_w" , "weighted pileup" , 100 , 0 , 100 );
327  }
328 
329 }
std::shared_ptr< TFile > output()
returns pointer to output root file
std::shared_ptr< Config > config_
Config objects.
Definition: BaseAnalyser.h:63
std::map< std::string, std::shared_ptr< TH1F > > h1_
1D histograms mapping
Definition: BaseAnalyser.h:80
float BaseAnalyser::pileupWeight ( const float &  truepu,
const int &  var 
) const

returns pileup weight given the true pileup and uncertainty variation in values of sigma

Definition at line 288 of file BaseAnalyser.cc.

References puweights_.

Referenced by actionApplyPileupWeight(), and fillPileupHistogram().

289 {
290  if ( ! puweights_ ) return 1.;
291  return puweights_->weight(truepu,var);
292 }
std::shared_ptr< PileupWeight > puweights_
pileup weight
Definition: BaseAnalyser.h:90
std::shared_ptr< PileupWeight > BaseAnalyser::pileupWeights ( ) const

returns pointer to pileup weights (MC-only)

Definition at line 283 of file BaseAnalyser.cc.

References puweights_.

284 {
285  return puweights_;
286 }
std::shared_ptr< PileupWeight > puweights_
pileup weight
Definition: BaseAnalyser.h:90
void BaseAnalyser::scale ( const float &  scale)

sets a scale

Definition at line 358 of file BaseAnalyser.cc.

References scale_.

Referenced by ~BaseAnalyser().

359 {
360  scale_ = scale;
361 }
void scale(const float &)
sets a scale
float scale_
overall scaling
Definition: BaseAnalyser.h:99
int BaseAnalyser::seed ( )

returns a seed for random number generator

Definition at line 237 of file BaseAnalyser.cc.

References seed_.

Referenced by seed().

238 {
239  return seed_;
240 }
int BaseAnalyser::seed ( const std::string &  f)

reads a file containing a seed and returns the seed or -1 if fails

Definition at line 242 of file BaseAnalyser.cc.

References analysis_, and seed_.

243 {
244  seed_ = analysis_ ->seed(f);
245  return seed_;
246 }
std::shared_ptr< Analysis > analysis_
Analysis objects.
Definition: BaseAnalyser.h:61
TFile * f[10]
Definition: PlotsCompare.cc:24
void BaseAnalyser::seed ( const int &  seed)

sets a seed for random number generators

Definition at line 248 of file BaseAnalyser.cc.

References seed(), and seed_.

249 {
250  seed_ = seed;
251 }
int seed()
returns a seed for random number generator
bool BaseAnalyser::triggerEmulated ( const std::string &  name)

return status of an emulated l1 trigger

Definition at line 476 of file BaseAnalyser.cc.

References nano_94X_2017_rereco31Mar18-v1::name, and trg_emul_.

Referenced by analysis::tools::TriggerAnalyser::selectionTriggerEmulated().

477 {
478  return trg_emul_[name];
479 }
std::map< std::string, bool > trg_emul_
emulated triggers
Definition: BaseAnalyser.h:110
bool BaseAnalyser::triggerEmulation ( const std::string &  name,
const int &  nmin,
const float &  ptmin,
const float &  etamax,
const std::string &  newname 
)
virtual

emulate l1 trigger

Definition at line 400 of file BaseAnalyser.cc.

References analysis_, analysis::tools::Candidate::e(), analysis::tools::Candidate::eta(), naf_mult_submit::int, nano_94X_2017_rereco31Mar18-v1::name, analysis::tools::Candidate::phi(), analysis::tools::Candidate::pt(), and trg_emul_.

Referenced by analysis::tools::JetAnalyser::analysisWithJets(), and analysis::tools::MuonAnalyser::analysisWithMuons().

401 {
402  trg_emul_[newname] = true;
403  std::vector<TriggerObject> new_objects;
404 
405 
406  if ( name != "l1tJets" && name != "l1tMuons" )
407  {
408  std::shared_ptr< Collection<TriggerObject> > objects = analysis_->collection<TriggerObject>(name);
409 
410  for ( int i = 0 ; i < objects->size() ; ++i )
411  {
412  TriggerObject obj = objects->at(i);
413  if ( obj.pt() >= ptmin && fabs(obj.eta()) <= etamax )
414  {
415  new_objects.push_back(obj);
416  }
417  }
418 
419  }
420 
421  if ( name == "l1tJets" )
422  {
423  std::shared_ptr< Collection<L1TJet> > l1tjets = analysis_->collection<L1TJet>(name);
424 
425  for ( int i = 0 ; i < l1tjets->size() ; ++i )
426  {
427  L1TJet l1tjet = l1tjets -> at(i);
428  float pt = l1tjet.pt();
429  float eta = l1tjet.eta();
430  float phi = l1tjet.phi();
431  float e = l1tjet.e();
432  TriggerObject obj(pt,eta,phi,e);
433  if ( obj.pt() >= ptmin && fabs(obj.eta()) <= etamax )
434  {
435  new_objects.push_back(obj);
436  }
437  }
438 
439  }
440  if ( name == "l1tMuons" )
441  {
442  std::shared_ptr< Collection<L1TMuon> > l1tmuons = analysis_->collection<L1TMuon>(name);
443 
444  for ( int i = 0 ; i < l1tmuons->size() ; ++i )
445  {
446  L1TMuon l1tmuon = l1tmuons -> at(i);
447  float pt = l1tmuon.pt();
448  float eta = l1tmuon.eta();
449  float phi = l1tmuon.phi();
450  float e = l1tmuon.e();
451  TriggerObject obj(pt,eta,phi,e);
452  if ( obj.pt() >= ptmin && fabs(obj.eta()) <= etamax )
453  {
454  new_objects.push_back(obj);
455  }
456  }
457 
458  }
459  trg_emul_[newname] = ( (int)new_objects.size() >= nmin );
460 
461  Collection<TriggerObject> new_collection(new_objects,newname);
462  analysis_->addCollection(new_collection);
463 
464  return trg_emul_[newname];
465 
466 
467 
468 }
float eta() const
returns the pseudorapidity
Definition: Candidate.cc:134
std::map< std::string, bool > trg_emul_
emulated triggers
Definition: BaseAnalyser.h:110
float e() const
returns the energy
Definition: Candidate.cc:136
float phi() const
returns the azimuthal angle
Definition: Candidate.cc:135
std::shared_ptr< Analysis > analysis_
Analysis objects.
Definition: BaseAnalyser.h:61
float pt() const
returns the transverse momentum
Definition: Candidate.cc:133
std::map< std::string, bool > BaseAnalyser::triggersEmulated ( )

return status of all emulated l1 triggers

Definition at line 471 of file BaseAnalyser.cc.

References trg_emul_.

472 {
473  return trg_emul_;
474 }
std::map< std::string, bool > trg_emul_
emulated triggers
Definition: BaseAnalyser.h:110
float BaseAnalyser::trueInteractions ( ) const

returns true number of interactions

Definition at line 294 of file BaseAnalyser.cc.

References analysis_, and config_.

295 {
296  if ( ! config_->isMC() ) return -1;
297 
298  return float(analysis_->nTruePileup());
299 }
std::shared_ptr< Config > config_
Config objects.
Definition: BaseAnalyser.h:63
std::shared_ptr< Analysis > analysis_
Analysis objects.
Definition: BaseAnalyser.h:61
float BaseAnalyser::weight ( )

returns event weight

Definition at line 258 of file BaseAnalyser.cc.

References weight_.

Referenced by generatorWeight().

259 {
260  return weight_;
261 }
float weight_
event weight
Definition: BaseAnalyser.h:72
void BaseAnalyser::weight ( const float &  w)

sets event weight

Definition at line 253 of file BaseAnalyser.cc.

References weight_.

254 {
255  weight_ = w;
256 }
float weight_
event weight
Definition: BaseAnalyser.h:72

Member Data Documentation

std::shared_ptr<TTree> analysis::tools::BaseAnalyser::analyser_tree_
protected

output tree

Definition at line 107 of file BaseAnalyser.h.

std::shared_ptr<Analysis> analysis::tools::BaseAnalyser::analysis_
protected
std::map<std::string, std::shared_ptr<TGraphAsymmErrors> > analysis::tools::BaseAnalyser::btageff_
protected

Definition at line 84 of file BaseAnalyser.h.

Referenced by BaseAnalyser(), and btagEfficiencies().

std::shared_ptr<Config> analysis::tools::BaseAnalyser::config_
protected

Config objects.

Definition at line 63 of file BaseAnalyser.h.

Referenced by analysis::tools::JetAnalyser::actionApplyBjetRegression(), analysis::tools::JetAnalyser::actionApplyBtagSF(), analysis::tools::JetAnalyser::actionApplyJER(), actionApplyPileupWeight(), analysis::tools::JetAnalyser::analysisWithJets(), analysis::tools::MuonAnalyser::analysisWithMuons(), BaseAnalyser(), analysis::tools::JetAnalyser::btag(), analysis::mssmhbb::MssmHbbAnalyser::btagSelection(), config(), analysis::tools::Analyser::event(), analysis::tools::JetAnalyser::fillJetHistograms(), analysis::mssmhbb::MssmHbbAnalyser::fillMssmHbbHistograms(), analysis::mssmhbb::MssmHbbAnalyser::fillMssmHbbTree(), analysis::tools::MuonAnalyser::fillMuonHistograms(), generatorWeight(), analysis::tools::JetAnalyser::getBtagSF(), analysis::tools::JetAnalyser::JetAnalyser(), analysis::tools::JetAnalyser::jetHistograms(), analysis::mssmhbb::MssmHbbAnalyser::jetSelection(), analysis::mssmhbb::MssmHbbAnalyser::MssmHbbAnalyser(), analysis::tools::MuonAnalyser::MuonAnalyser(), nEvents(), analysis::tools::JetAnalyser::onlineBJetMatching(), analysis::tools::JetAnalyser::onlineJetMatching(), analysis::tools::MuonAnalyser::onlineL1MuonMatching(), analysis::tools::MuonAnalyser::onlineL3MuonMatching(), analysis::tools::MuonAnalyser::onlineMuonMatching(), pileupHistogram(), analysis::tools::JetAnalyser::selectionBJet(), analysis::tools::JetAnalyser::selectionBJetProbB(), analysis::tools::JetAnalyser::selectionBJetProbBB(), analysis::tools::JetAnalyser::selectionBJetProbC(), analysis::tools::JetAnalyser::selectionBJetProbG(), analysis::tools::JetAnalyser::selectionBJetProbLepB(), analysis::tools::JetAnalyser::selectionBJetProbLight(), analysis::tools::JetAnalyser::selectionDiJetMass(), analysis::tools::TriggerAnalyser::selectionHLT(), analysis::tools::JetAnalyser::selectionJet(), analysis::tools::JetAnalyser::selectionJetDeta(), analysis::tools::JetAnalyser::selectionJetDphi(), analysis::tools::JetAnalyser::selectionJetDr(), analysis::tools::JetAnalyser::selectionJetId(), analysis::tools::JetAnalyser::selectionJetPileupId(), analysis::tools::JetAnalyser::selectionJetPtImbalance(), analysis::tools::JetAnalyser::selectionJetQGlikelihood(), analysis::tools::TriggerAnalyser::selectionL1(), analysis::tools::MuonAnalyser::selectionMuon(), analysis::tools::MuonAnalyser::selectionMuonDr(), analysis::tools::MuonAnalyser::selectionMuonId(), analysis::tools::MuonAnalyser::selectionMuons(), analysis::tools::JetAnalyser::selectionNJets(), analysis::tools::MuonAnalyser::selectionNMuons(), analysis::tools::JetAnalyser::selectionNonBJet(), analysis::tools::TriggerAnalyser::selectionTrigger(), analysis::tools::TriggerAnalyser::TriggerAnalyser(), analysis::tools::TriggerAnalyser::triggerObjectsCaloJets(), analysis::tools::TriggerAnalyser::triggerObjectsL1Jets(), analysis::tools::TriggerAnalyser::triggerObjectsL1Muons(), analysis::tools::TriggerAnalyser::triggerObjectsL3Muons(), analysis::tools::TriggerAnalyser::triggerObjectsPFJets(), trueInteractions(), and ~BaseAnalyser().

int analysis::tools::BaseAnalyser::cutflow_
protected
std::string analysis::tools::BaseAnalyser::exe_
private

name of the executable

Definition at line 116 of file BaseAnalyser.h.

Referenced by BaseAnalyser(), and ~BaseAnalyser().

bool analysis::tools::BaseAnalyser::genjetsanalysis_
protected

Definition at line 87 of file BaseAnalyser.h.

Referenced by BaseAnalyser(), and genJetsAnalysis().

bool analysis::tools::BaseAnalyser::genpartsanalysis_
protected

Definition at line 86 of file BaseAnalyser.h.

Referenced by BaseAnalyser(), and genParticlesAnalysis().

std::map<std::string, std::shared_ptr<TH1F> > analysis::tools::BaseAnalyser::h1_
protected

1D histograms mapping

Definition at line 80 of file BaseAnalyser.h.

Referenced by analysis::tools::MuonAnalyser::analysisWithMuons(), BaseAnalyser(), cutflow(), analysis::tools::JetAnalyser::fillJetHistograms(), analysis::mssmhbb::MssmHbbAnalyser::fillMssmHbbHistograms(), analysis::mssmhbb::MssmHbbAnalyser::fillMssmHbbTree(), analysis::tools::MuonAnalyser::fillMuonHistograms(), fillPileupHistogram(), histogram(), histograms(), analysis::tools::JetAnalyser::jetHistograms(), analysis::mssmhbb::MssmHbbAnalyser::MssmHbbAnalyser(), analysis::tools::MuonAnalyser::muonHistograms(), analysis::mssmhbb::MssmHbbAnalyser::muonJet(), analysis::tools::MuonAnalyser::onlineL1MuonMatching(), analysis::tools::MuonAnalyser::onlineL3MuonMatching(), analysis::tools::MuonAnalyser::onlineMuonMatching(), pileupHistogram(), analysis::tools::JetAnalyser::selectionBJetProbB(), analysis::tools::JetAnalyser::selectionBJetProbBB(), analysis::tools::JetAnalyser::selectionBJetProbC(), analysis::tools::JetAnalyser::selectionBJetProbG(), analysis::tools::JetAnalyser::selectionBJetProbLepB(), analysis::tools::JetAnalyser::selectionBJetProbLight(), analysis::tools::JetAnalyser::selectionDiJetMass(), analysis::tools::TriggerAnalyser::selectionHLT(), analysis::tools::TriggerAnalyser::selectionL1(), analysis::tools::MuonAnalyser::selectionMuon(), analysis::tools::MuonAnalyser::selectionMuonId(), analysis::tools::MuonAnalyser::selectionMuons(), analysis::tools::MuonAnalyser::selectionNMuons(), analysis::tools::TriggerAnalyser::selectionTriggerEmulated(), and ~BaseAnalyser().

std::map<std::string, std::shared_ptr<TH2F> > analysis::tools::BaseAnalyser::h2_
protected
std::shared_ptr<TFile> analysis::tools::BaseAnalyser::hout_
protected

output root file

Definition at line 78 of file BaseAnalyser.h.

Referenced by BaseAnalyser(), output(), and ~BaseAnalyser().

bool analysis::tools::BaseAnalyser::isData_
protected

flag for DATA sample

Definition at line 104 of file BaseAnalyser.h.

Referenced by BaseAnalyser().

bool analysis::tools::BaseAnalyser::isMC_
protected

flag for MC sample

Definition at line 102 of file BaseAnalyser.h.

Referenced by analysis::tools::JetAnalyser::actionApplyJER(), BaseAnalyser(), and analysis::tools::Analyser::event().

bool analysis::tools::BaseAnalyser::istruepu_
protected

true pileup

Definition at line 96 of file BaseAnalyser.h.

std::string analysis::tools::BaseAnalyser::puw_label_
protected

pileup weight label

Definition at line 93 of file BaseAnalyser.h.

Referenced by actionApplyPileupWeight(), and BaseAnalyser().

std::shared_ptr<PileupWeight> analysis::tools::BaseAnalyser::puweights_
protected

pileup weight

Definition at line 90 of file BaseAnalyser.h.

Referenced by actionApplyPileupWeight(), BaseAnalyser(), pileupWeight(), and pileupWeights().

float analysis::tools::BaseAnalyser::scale_
protected

overall scaling

Definition at line 99 of file BaseAnalyser.h.

Referenced by BaseAnalyser(), scale(), and ~BaseAnalyser().

int analysis::tools::BaseAnalyser::seed_
protected

seed value

Definition at line 69 of file BaseAnalyser.h.

Referenced by BaseAnalyser(), and seed().

std::map<std::string,bool> analysis::tools::BaseAnalyser::trg_emul_
protected

emulated triggers

Definition at line 110 of file BaseAnalyser.h.

Referenced by triggerEmulated(), triggerEmulation(), and triggersEmulated().

float analysis::tools::BaseAnalyser::weight_
protected
float analysis::tools::BaseAnalyser::xsection_
protected

cross section

Definition at line 75 of file BaseAnalyser.h.

Referenced by BaseAnalyser(), and crossSection().


The documentation for this class was generated from the following files: