ATLAS Offline Software
Loading...
Searching...
No Matches
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
28class TEfficiency;
29
30typedef std::pair<TH1*, std::string> HistData;
31typedef std::pair<TTree*, std::string> TreeData;
32typedef std::pair<TEfficiency*, std::string> EfficiencyData;
33
34class PlotBase {
35public:
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
90private:
91 virtual void initializePlots(){;}
92 virtual void finalizePlots(){;}
93 static std::string constructPrefix(std::string dir, bool prependDir);
94
95protected:
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
std::pair< TEfficiency *, std::string > EfficiencyData
Definition PlotBase.h:32
std::pair< TH1 *, std::string > HistData
Definition PlotBase.h:30
std::pair< TTree *, std::string > TreeData
Definition PlotBase.h:31
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
std::vector< EfficiencyData > retrieveBookedEfficiencies()
Retrieve all booked efficiency objects.
Definition PlotBase.cxx:83
std::vector< PlotBase * > m_vSubNodes
Definition PlotBase.h:96
static std::string constructPrefix(std::string dir, bool prependDir)
Definition PlotBase.cxx:293
void finalize()
Definition PlotBase.cxx:47
std::vector< HistData > retrieveBookedHistograms()
Retrieve all booked histograms.
Definition PlotBase.cxx:63
virtual ~PlotBase()
Definition PlotBase.h:37
std::vector< EfficiencyData > m_vBookedEfficiencies
Definition PlotBase.h:99
void initialize()
Definition PlotBase.cxx:39
void setDetailLevel(int iDetailLevel)
Definition PlotBase.cxx:55
const std::string & getDirectory()
Definition PlotBase.h:88
PlotBase(PlotBase *parent, const std::string &sDir)
Definition PlotBase.cxx:29
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
virtual void initializePlots()
Definition PlotBase.h:91
std::vector< HistData > m_vBookedHistograms
Definition PlotBase.h:97
virtual void finalizePlots()
Definition PlotBase.h:92
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
std::vector< TreeData > retrieveBookedTrees()
Retrieve all booked trees.
Definition PlotBase.cxx:73
void RegisterSubPlot(PlotBase *pPlotBase)
Definition PlotBase.h:41
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
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
TTree * BookTree(const std::string &name, bool prependDir=true)
Book a TTree.
Definition PlotBase.cxx:281
std::string m_sDirectory
Definition PlotBase.h:100
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
int m_iDetailLevel
Definition PlotBase.h:101
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
std::vector< TreeData > m_vBookedTrees
Definition PlotBase.h:98