ATLAS Offline Software
PlotBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // -------------------------------------------------------------
6 // Base class for Plot Collections
7 //
8 // author: Felix Socher <felix.socher@cern.ch>
9 // -------------------------------------------------------------
10 #ifndef TRKVALHISTUTILS_PLOTBASE_H
11 #define TRKVALHISTUTILS_PLOTBASE_H
12 
13 #include <string>
14 #include <utility> //for std::pair
15 #include <vector>
16 //should be possible to fwd-declare TH1F, TH2F, TH3F, TProfile, TProfile2D TTree .. why isn't this done?
17 #include "TH1F.h"
18 #include "TH1D.h"
19 #include "TH2F.h"
20 #include "TH3F.h"
21 #include "TProfile.h"
22 #include "TProfile2D.h"
23 #include "TTree.h"
24 #include "TEfficiency.h"
25 
26 
27 //fwd-declares
28 class TEfficiency;
29 
30 typedef std::pair<TH1*, std::string> HistData;
31 typedef std::pair<TTree*, std::string> TreeData;
32 typedef std::pair<TEfficiency*, std::string> EfficiencyData;
33 
34 class PlotBase {
35 public:
36  PlotBase(PlotBase *parent, const std::string & sDir);
37  virtual ~PlotBase(){}
38  void initialize();
39  void finalize();
40  void setDetailLevel(int iDetailLevel);
41  void RegisterSubPlot(PlotBase* pPlotBase){m_vSubNodes.push_back(pPlotBase);}
42 
44  std::vector<HistData> retrieveBookedHistograms();
46  std::vector<TreeData> retrieveBookedTrees();
48  std::vector<EfficiencyData> retrieveBookedEfficiencies();
52 
54  TH1D* Book1D(const std::string & name, const std::string & labels, int nBins, float start, float end, bool prependDir = true);
56  TH1D* Book1D(const std::string & name, TH1* refHist, const std::string & labels, bool prependDir = true);
57 
59  TH2F* Book2D(const std::string & name, const std::string & labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, bool prependDir = true);
61  TH2F* Book2D(const std::string & name, TH2* refHist, const std::string & labels, bool prependDir = true);
63  TH2F* Book2D(const std::string & name, const std::string & labels, int nBinsX, Double_t* binsX, int nBinsY, Double_t startY, Double_t endY, bool prependDir = true);
64 
66  TH3F* Book3D(const std::string & name, const std::string & labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, int nBinsZ, float startZ, float endZ, bool prependDir = true);
68  TH3F* Book3D(const std::string & name, TH3* refHist, const std::string & labels, bool prependDir = true);
69 
71  TProfile* BookTProfile(const std::string &name, const std::string & labels, int nBinsX, float startX, float endX, float startY=-1, float endY=-1, bool prependDir = true, bool useRMS=false);
73  TProfile* BookTProfile(const std::string &name, const std::string & labels, int nBinsX, float* binsX, bool prependDir = true);
75  TProfile* BookTProfileRangeY(const std::string &name, const std::string & labels, int nBinsX, double* binsX, double startY, double endY, bool prependDir = true); //cannot overload, conflicts with previous definitions
77  TProfile2D * BookTProfile2D(const std::string &name, const std::string & labels, const int nBinsX, const double xlo, const double xhi, const int nBinsY, const double ylo, const double yhi, bool prependDir=true, bool useRMS=false);
79  TProfile2D * BookTProfile2D(const std::string &name, const std::string &labels, const int nBinsX, double* binsX, const int nBinsY, double* binsY, bool prependDir=true, bool useRMS=false);
81  TEfficiency * BookTEfficiency(const std::string &name, const std::string & labels, const int nBinsX, const float xlo, const float xhi, const bool prependDir = true);
83  TEfficiency * BookTEfficiency(const std::string &name, const std::string & labels, const int nBinsX, const float xlo, const float xhi, const int nBinsy, const float ylo, const float yhi, const bool prependDir = true);
86  TTree* BookTree(const std::string & name, bool prependDir = true);
87 
88  const std::string& getDirectory(){return m_sDirectory;}
89 
90 private:
91  virtual void initializePlots(){;}
92  virtual void finalizePlots(){;}
93  static std::string constructPrefix(std::string dir, bool prependDir);
94 
95 protected:
96  std::vector<PlotBase*> m_vSubNodes;
97  std::vector<HistData> m_vBookedHistograms;
98  std::vector<TreeData> m_vBookedTrees;
99  std::vector<EfficiencyData> m_vBookedEfficiencies;
100  std::string m_sDirectory;
102 };
103 
104 #endif
PlotBase::constructPrefix
static std::string constructPrefix(std::string dir, bool prependDir)
Definition: PlotBase.cxx:293
WritePulseShapeToCool.yhi
yhi
Definition: WritePulseShapeToCool.py:153
PlotBase::m_iDetailLevel
int m_iDetailLevel
Definition: PlotBase.h:101
PlotBase::m_vBookedHistograms
std::vector< HistData > m_vBookedHistograms
Definition: PlotBase.h:97
PlotBase::getDirectory
const std::string & getDirectory()
Definition: PlotBase.h:88
PlotBase::BookTree
TTree * BookTree(const std::string &name, bool prependDir=true)
Book a TTree.
Definition: PlotBase.cxx:281
PlotBase::retrieveBookedTrees
std::vector< TreeData > retrieveBookedTrees()
Retrieve all booked trees.
Definition: PlotBase.cxx:73
PlotBase
Definition: PlotBase.h:34
python.copyTCTOutput.sDir
sDir
Definition: copyTCTOutput.py:60
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
PlotBase::initializePlots
virtual void initializePlots()
Definition: PlotBase.h:91
PlotBase::m_sDirectory
std::string m_sDirectory
Definition: PlotBase.h:100
PlotBase::m_vBookedEfficiencies
std::vector< EfficiencyData > m_vBookedEfficiencies
Definition: PlotBase.h:99
PlotBase::BookTEfficiency
TEfficiency * BookTEfficiency(const std::string &name, const std::string &labels, const int nBinsX, const float xlo, const float xhi, const bool prependDir=true)
Book a (1-D) TEfficiency histogram.
Definition: PlotBase.cxx:257
PlotBase::Book2D
TH2F * Book2D(const std::string &name, const std::string &labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, bool prependDir=true)
Book a TH2F histogram.
Definition: PlotBase.cxx:123
PlotBase::~PlotBase
virtual ~PlotBase()
Definition: PlotBase.h:37
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
PlotBase::retrieveBookedEfficiencies
std::vector< EfficiencyData > retrieveBookedEfficiencies()
Retrieve all booked efficiency objects.
Definition: PlotBase.cxx:83
PlotBase::BookTProfile2D
TProfile2D * BookTProfile2D(const std::string &name, const std::string &labels, const int nBinsX, const double xlo, const double xhi, const int nBinsY, const double ylo, const double yhi, bool prependDir=true, bool useRMS=false)
Book a TProfile 2D histogram with variable binning in x-axis and limits in y-values.
Definition: PlotBase.cxx:231
PlotBase::PlotBase
PlotBase(PlotBase *parent, const std::string &sDir)
Definition: PlotBase.cxx:29
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
PlotBase::BookTProfileRangeY
TProfile * BookTProfileRangeY(const std::string &name, const std::string &labels, int nBinsX, double *binsX, double startY, double endY, bool prependDir=true)
Book a TProfile histogram with variable binning in x-axis and limits in y-values.
Definition: PlotBase.cxx:217
PlotBase::RegisterSubPlot
void RegisterSubPlot(PlotBase *pPlotBase)
Definition: PlotBase.h:41
PlotBase::Book1D
TH1D * Book1D(const std::string &name, const std::string &labels, int nBins, float start, float end, bool prependDir=true)
Book a TH1D histogram.
Definition: PlotBase.cxx:94
HistData
std::pair< TH1 *, std::string > HistData
Definition: PlotBase.h:28
beamspotnt.labels
list labels
Definition: bin/beamspotnt.py:1447
PlotBase::m_vSubNodes
std::vector< PlotBase * > m_vSubNodes
Definition: PlotBase.h:96
PlotBase::retrieveBookedHistograms
std::vector< HistData > retrieveBookedHistograms()
Retrieve all booked histograms.
Definition: PlotBase.cxx:63
PlotBase::finalize
void finalize()
Definition: PlotBase.cxx:47
WritePulseShapeToCool.xhi
xhi
Definition: WritePulseShapeToCool.py:152
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition: TrigEgammaMonitorHelper.py:81
PlotBase::initialize
void initialize()
Definition: PlotBase.cxx:39
ChangeHistoRange.binsY
list binsY
Definition: ChangeHistoRange.py:59
test_pyathena.parent
parent
Definition: test_pyathena.py:15
WritePulseShapeToCool.xlo
xlo
Definition: WritePulseShapeToCool.py:133
WritePulseShapeToCool.ylo
ylo
Definition: WritePulseShapeToCool.py:134
PlotBase::Book3D
TH3F * Book3D(const std::string &name, const std::string &labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, int nBinsZ, float startZ, float endZ, bool prependDir=true)
Book a TH3F histogram.
Definition: PlotBase.cxx:157
beamspotman.dir
string dir
Definition: beamspotman.py:623
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
EfficiencyData
std::pair< TEfficiency *, std::string > EfficiencyData
Definition: PlotBase.h:32
TreeData
std::pair< TTree *, std::string > TreeData
Definition: PlotBase.h:31
PlotBase::BookTProfile
TProfile * BookTProfile(const std::string &name, const std::string &labels, int nBinsX, float startX, float endX, float startY=-1, float endY=-1, bool prependDir=true, bool useRMS=false)
Book a TProfile histogram.
Definition: PlotBase.cxx:186
ChangeHistoRange.binsX
list binsX
Definition: ChangeHistoRange.py:56
PlotBase::finalizePlots
virtual void finalizePlots()
Definition: PlotBase.h:92
PlotBase::m_vBookedTrees
std::vector< TreeData > m_vBookedTrees
Definition: PlotBase.h:98
PlotBase::setDetailLevel
void setDetailLevel(int iDetailLevel)
Definition: PlotBase.cxx:55