ATLAS Offline Software
Loading...
Searching...
No Matches
PlotBase.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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 <string_view>
15#include <utility> //for std::pair
16#include <vector>
17//should be possible to fwd-declare TH1F, TH2F, TH3F, TProfile, TProfile2D TTree .. why isn't this done?
18#include "TH1F.h"
19#include "TH1D.h"
20#include "TH2F.h"
21#include "TH3F.h"
22#include "TProfile.h"
23#include "TProfile2D.h"
24#include "TTree.h"
25#include "TEfficiency.h"
26
27
28//fwd-declares
29class TEfficiency;
30
31typedef std::pair<TH1*, std::string> HistData;
32typedef std::pair<TTree*, std::string> TreeData;
33typedef std::pair<TEfficiency*, std::string> EfficiencyData;
34
35class PlotBase {
36public:
37 PlotBase(PlotBase *parent, std::string_view sDir);
38 virtual ~PlotBase(){}
39 void initialize();
40 void finalize();
41 void setDetailLevel(int iDetailLevel);
42 void RegisterSubPlot(PlotBase* pPlotBase){m_vSubNodes.push_back(pPlotBase);}
43
45 std::vector<HistData> retrieveBookedHistograms();
47 std::vector<TreeData> retrieveBookedTrees();
49 std::vector<EfficiencyData> retrieveBookedEfficiencies();
53
55 TH1D* Book1D(std::string_view name, std::string_view labels, int nBins, float start, float end, bool prependDir = true);
57 TH1D* Book1D(std::string_view name, TH1* refHist, std::string_view labels, bool prependDir = true);
58
60 TH2F* Book2D(std::string_view name, std::string_view labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, bool prependDir = true);
62 TH2F* Book2D(std::string_view name, TH2* refHist, std::string_view labels, bool prependDir = true);
64 TH2F* Book2D(std::string_view name, std::string_view labels, int nBinsX, Double_t* binsX, int nBinsY, Double_t startY, Double_t endY, bool prependDir = true);
65
67 TH3F* Book3D(std::string_view name, std::string_view labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, int nBinsZ, float startZ, float endZ, bool prependDir = true);
69 TH3F* Book3D(std::string_view name, TH3* refHist, std::string_view labels, bool prependDir = true);
70
72 TProfile* BookTProfile(std::string_view name, std::string_view labels, int nBinsX, float startX, float endX, float startY=-1, float endY=-1, bool prependDir = true, bool useRMS=false);
74 TProfile* BookTProfile(std::string_view name, std::string_view labels, int nBinsX, float* binsX, bool prependDir = true);
76 TProfile* BookTProfileRangeY(std::string_view name, std::string_view labels, int nBinsX, double* binsX, double startY, double endY, bool prependDir = true); //cannot overload, conflicts with previous definitions
78 TProfile2D * BookTProfile2D(std::string_view name, std::string_view 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);
80 TProfile2D * BookTProfile2D(std::string_view name, std::string_view labels, const int nBinsX, double* binsX, const int nBinsY, double* binsY, bool prependDir=true, bool useRMS=false);
82 TEfficiency * BookTEfficiency(std::string_view name, std::string_view labels, const int nBinsX, const float xlo, const float xhi, const bool prependDir = true);
84 TEfficiency * BookTEfficiency(std::string_view name, std::string_view labels, const int nBinsX, const float xlo, const float xhi, const int nBinsy, const float ylo, const float yhi, const bool prependDir = true);
87 TTree* BookTree(std::string_view name, bool prependDir = true);
88
89 const std::string& getDirectory(){return m_sDirectory;}
90
91private:
92 virtual void initializePlots(){;}
93 virtual void finalizePlots(){;}
94 static std::string constructPrefix(std::string dir, bool prependDir);
95
96protected:
97 std::vector<PlotBase*> m_vSubNodes;
98 std::vector<HistData> m_vBookedHistograms;
99 std::vector<TreeData> m_vBookedTrees;
100 std::vector<EfficiencyData> m_vBookedEfficiencies;
101 std::string m_sDirectory;
103};
104
105#endif
std::pair< TEfficiency *, std::string > EfficiencyData
Definition PlotBase.h:33
std::pair< TH1 *, std::string > HistData
Definition PlotBase.h:31
std::pair< TTree *, std::string > TreeData
Definition PlotBase.h:32
std::vector< EfficiencyData > retrieveBookedEfficiencies()
Retrieve all booked efficiency objects.
Definition PlotBase.cxx:83
std::vector< PlotBase * > m_vSubNodes
Definition PlotBase.h:97
static std::string constructPrefix(std::string dir, bool prependDir)
Definition PlotBase.cxx:289
void finalize()
Definition PlotBase.cxx:47
std::vector< HistData > retrieveBookedHistograms()
Retrieve all booked histograms.
Definition PlotBase.cxx:63
virtual ~PlotBase()
Definition PlotBase.h:38
std::vector< EfficiencyData > m_vBookedEfficiencies
Definition PlotBase.h:100
void initialize()
Definition PlotBase.cxx:39
void setDetailLevel(int iDetailLevel)
Definition PlotBase.cxx:55
const std::string & getDirectory()
Definition PlotBase.h:89
TH1D * Book1D(std::string_view name, std::string_view labels, int nBins, float start, float end, bool prependDir=true)
Book a TH1D histogram.
Definition PlotBase.cxx:94
TProfile * BookTProfile(std::string_view name, std::string_view 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
PlotBase(PlotBase *parent, std::string_view sDir)
Definition PlotBase.cxx:29
TEfficiency * BookTEfficiency(std::string_view name, std::string_view labels, const int nBinsX, const float xlo, const float xhi, const bool prependDir=true)
Book a (1-D) TEfficiency histogram.
Definition PlotBase.cxx:257
TH2F * Book2D(std::string_view name, std::string_view labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, bool prependDir=true)
Book a TH2F histogram.
Definition PlotBase.cxx:123
virtual void initializePlots()
Definition PlotBase.h:92
TH3F * Book3D(std::string_view name, std::string_view 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
std::vector< HistData > m_vBookedHistograms
Definition PlotBase.h:98
virtual void finalizePlots()
Definition PlotBase.h:93
std::vector< TreeData > retrieveBookedTrees()
Retrieve all booked trees.
Definition PlotBase.cxx:73
void RegisterSubPlot(PlotBase *pPlotBase)
Definition PlotBase.h:42
std::string m_sDirectory
Definition PlotBase.h:101
TTree * BookTree(std::string_view name, bool prependDir=true)
Book a TTree.
Definition PlotBase.cxx:277
TProfile * BookTProfileRangeY(std::string_view name, std::string_view 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
int m_iDetailLevel
Definition PlotBase.h:102
std::vector< TreeData > m_vBookedTrees
Definition PlotBase.h:99
TProfile2D * BookTProfile2D(std::string_view name, std::string_view 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