ATLAS Offline Software
GenAnalysis.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GENERATORMODULES_GENANALYSIS_H
6 #define GENERATORMODULES_GENANALYSIS_H
7 
9 #include "GaudiKernel/ITHistSvc.h"
10 #include "TH1D.h"
11 #include "TH2D.h"
12 #include "TProfile.h"
13 
14 
27 class GenAnalysis : public GenBase {
28 public:
29 
30  GenAnalysis(const std::string& name, ISvcLocator* pSvcLocator);
31  virtual ~GenAnalysis() { }
32 
37 
39 
40  virtual StatusCode init() { return StatusCode::SUCCESS; }
41  virtual StatusCode analyze() = 0;
42  virtual StatusCode finalize() { return StatusCode::SUCCESS; }
44 
45 
46 protected:
47 
49 
50 
52 
53  TH1D* bookHisto1D(const std::string& name, const std::string& title, const std::vector<double>& binedges,
54  const std::string& xtitle="", const std::string& ytitle="");
55  TH1D* bookHisto1D(const std::string& name, const std::string& title, size_t numbins, double low, double high,
56  const std::string& xtitle="", const std::string& ytitle="");
57 
58  TProfile* bookProfile1D(const std::string& name, const std::string& title, const std::vector<double>& binedges,
59  const std::string& xtitle="", const std::string& ytitle="");
60  TProfile* bookProfile1D(const std::string& name, const std::string& title, size_t numbins, double low, double high,
61  const std::string& xtitle="", const std::string& ytitle="");
62 
63  TH2D* bookHisto2D(const std::string& name, const std::string& title,
64  const std::vector<double>& binedgesx, const std::vector<double>& binedgesy,
65  const std::string& xtitle="", const std::string& ytitle="", const std::string& ztitle="");
66  TH2D* bookHisto2D(const std::string& name, const std::string& title,
67  size_t numbinsx, double xlow, double xhigh,
68  size_t numbinsy, double ylow, double yhigh,
69  const std::string& xtitle="", const std::string& ytitle="", const std::string& ztitle="");
70 
72  std::string fullhistopath(const std::string& localpath) {
73  return "/" + m_histkey + "/" + name() + "/" + localpath;
74  }
75 
77  TH1* histo(const std::string& key);
78 
80  TProfile* profile(const std::string& key);
81 
84  return m_histSvc;
85  }
86 
88 
89 
90 private:
91 
93  std::string m_histkey;
95 
96 };
97 
98 
99 #endif
GenAnalysis::histSvc
const ServiceHandle< ITHistSvc > histSvc() const
Directly access the histogram service.
Definition: GenAnalysis.h:83
GenAnalysis::profile
TProfile * profile(const std::string &key)
Retrieve a profile histogram.
Definition: GenAnalysis.cxx:121
TH1D
Definition: rootspy.cxx:342
GenAnalysis::bookProfile1D
TProfile * bookProfile1D(const std::string &name, const std::string &title, const std::vector< double > &binedges, const std::string &xtitle="", const std::string &ytitle="")
Definition: GenAnalysis.cxx:62
plotting.yearwise_luminosity.ytitle
string ytitle
Definition: yearwise_luminosity.py:76
GenAnalysis::analyze
virtual StatusCode analyze()=0
GenAnalysis::GenAnalysis
GenAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GenAnalysis.cxx:11
GenAnalysis::fullhistopath
std::string fullhistopath(const std::string &localpath)
Get a histogram's full path, given the name local to the analysis.
Definition: GenAnalysis.h:72
GenAnalysis::finalize
virtual StatusCode finalize()
Definition: GenAnalysis.h:42
GenBase
Base class for common behaviour of MC truth algorithms.
Definition: GenBase.h:47
GenAnalysis::initialize
StatusCode initialize()
Setup analysis tools and call user-supplied init()
Definition: GenAnalysis.cxx:20
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
covarianceTool.title
title
Definition: covarianceTool.py:542
GenAnalysis::histo
TH1 * histo(const std::string &key)
Retrieve a histogram (as TH1* base class pointer)
Definition: GenAnalysis.cxx:114
TH2D
Definition: rootspy.cxx:430
GenAnalysis::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: GenAnalysis.h:94
GenAnalysis::bookHisto1D
TH1D * bookHisto1D(const std::string &name, const std::string &title, const std::vector< double > &binedges, const std::string &xtitle="", const std::string &ytitle="")
Definition: GenAnalysis.cxx:39
GenBase.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TProfile
Definition: rootspy.cxx:515
TH1
Definition: rootspy.cxx:268
plotting.yearwise_efficiency.xtitle
string xtitle
Definition: yearwise_efficiency.py:38
GenAnalysis
Base class for evgen-level analyses.
Definition: GenAnalysis.h:27
GenAnalysis::m_histkey
std::string m_histkey
Container name for the MC event collection to be analysed.
Definition: GenAnalysis.h:93
GenAnalysis::init
virtual StatusCode init()
Definition: GenAnalysis.h:40
GenAnalysis::~GenAnalysis
virtual ~GenAnalysis()
Definition: GenAnalysis.h:31
GenAnalysis::execute
StatusCode execute()
Per-event analysis routine: calls user-supplied analyze()
Definition: GenAnalysis.cxx:27
GenAnalysis::bookHisto2D
TH2D * bookHisto2D(const std::string &name, const std::string &title, const std::vector< double > &binedgesx, const std::vector< double > &binedgesy, const std::string &xtitle="", const std::string &ytitle="", const std::string &ztitle="")
Definition: GenAnalysis.cxx:85
ServiceHandle< ITHistSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37