23#include "TProfile2D.h"
25#include "TEfficiency.h"
30 if (pParent !=
nullptr) {
33 std::string sParentDirectory = (pParent !=
nullptr) ? pParent->
getDirectory() :
"";
41 subNode->initialize();
57 subNode->setDetailLevel(iDetailLevel);
66 std::vector<HistData> subNodeHists = subNode->retrieveBookedHistograms();
67 vBookedHistograms.insert(vBookedHistograms.end(), subNodeHists.begin(), subNodeHists.end());
69 return vBookedHistograms;
76 std::vector<TreeData> subNodeTrees = subNode->retrieveBookedTrees();
77 vBookedTrees.insert(vBookedTrees.end(), subNodeTrees.begin(), subNodeTrees.end());
82std::vector<EfficiencyData>
86 std::vector<EfficiencyData> subNodeHists = subNode->retrieveBookedEfficiencies();
87 vBookedEfficiencies.insert(vBookedEfficiencies.end(), subNodeHists.begin(), subNodeHists.end());
89 return vBookedEfficiencies;
94PlotBase::Book1D(
const std::string &name,
const std::string &labels,
int nBins,
float start,
float end,
97 Bool_t oldstat = TH1::AddDirectoryStatus();
98 TH1::AddDirectory(
false);
99 TH1D *hist =
new TH1D((prefix + name).c_str(), labels.c_str(), nBins, start, end);
100 TH1::AddDirectory(oldstat);
108PlotBase::Book1D(
const std::string &name, TH1 *refHist,
const std::string &labels,
bool prependDir) {
110 Bool_t oldstat = TH1::AddDirectoryStatus();
111 TH1::AddDirectory(
false);
112 TH1D *hist =
new TH1D((prefix + name).c_str(), labels.c_str(), refHist->GetNbinsX(),
113 refHist->GetXaxis()->GetXbins()->GetArray());
115 TH1::AddDirectory(oldstat);
123PlotBase::Book2D(
const std::string &name,
const std::string &labels,
int nBinsX,
float startX,
float endX,
int nBinsY,
124 float startY,
float endY,
bool prependDir) {
126 Bool_t oldstat = TH2::AddDirectoryStatus();
127 TH2::AddDirectory(
false);
128 TH2F *hist =
new TH2F((prefix + name).c_str(), labels.c_str(), nBinsX, startX, endX, nBinsY, startY, endY);
130 TH2::AddDirectory(oldstat);
138PlotBase::Book2D(
const std::string &name, TH2 *refHist,
const std::string &labels,
bool prependDir) {
139 return Book2D(name, labels, refHist->GetNbinsX(), refHist->GetXaxis()->GetXmin(), refHist->GetXaxis()->GetXmax(),
140 refHist->GetNbinsY(), refHist->GetYaxis()->GetXmin(), refHist->GetYaxis()->GetXmax(), prependDir);
144PlotBase::Book2D(
const std::string &name,
const std::string &labels,
int nBinsX, Double_t *binsX,
int nBinsY,
145 Double_t startY, Double_t endY,
bool prependDir) {
147 Bool_t oldstat = TH2::AddDirectoryStatus();
148 TH2::AddDirectory(
false);
149 TH2F *hist =
new TH2F((prefix + name).c_str(), labels.c_str(), nBinsX, binsX, nBinsY, startY, endY);
151 TH2::AddDirectory(oldstat);
157PlotBase::Book3D(
const std::string &name,
const std::string &labels,
int nBinsX,
float startX,
float endX,
int nBinsY,
158 float startY,
float endY,
int nBinsZ,
float startZ,
float endZ,
bool prependDir) {
160 Bool_t oldstat = TH3::AddDirectoryStatus();
161 TH3::AddDirectory(
false);
162 TH3F *hist =
new TH3F((prefix + name).c_str(),
163 labels.c_str(), nBinsX, startX, endX, nBinsY, startY, endY, nBinsZ, startZ, endZ);
165 TH3::AddDirectory(oldstat);
171PlotBase::Book3D(
const std::string &name, TH3 *refHist,
const std::string &labels,
bool prependDir) {
173 Bool_t oldstat = TH3::AddDirectoryStatus();
174 TH3::AddDirectory(
false);
175 TH3F *hist =
new TH3F((prefix + name).c_str(), labels.c_str(), refHist->GetNbinsX(),
176 refHist->GetXaxis()->GetXbins()->GetArray(), refHist->GetNbinsY(),
177 refHist->GetYaxis()->GetXbins()->GetArray(), refHist->GetNbinsZ(),
178 refHist->GetZaxis()->GetXbins()->GetArray());
179 TH3::AddDirectory(oldstat);
187 float startY,
float endY,
bool prependDir,
bool useRMS) {
189 TProfile *hist(
nullptr);
190 Bool_t oldstat = TProfile::AddDirectoryStatus();
191 TProfile::AddDirectory(
false);
192 std::string opt = useRMS ?
"S" :
"";
193 if ((startY == -1) and (endY == -1)) {
194 hist =
new TProfile((prefix + name).c_str(), labels.c_str(), nBinsX, startX, endX, opt.c_str());
196 hist =
new TProfile((prefix + name).c_str(), labels.c_str(), nBinsX, startX, endX, startY, endY, opt.c_str());
198 TProfile::AddDirectory(oldstat);
206 TProfile *hist(
nullptr);
207 Bool_t oldstat = TProfile::AddDirectoryStatus();
208 TProfile::AddDirectory(
false);
210 hist =
new TProfile((prefix + name).c_str(), labels.c_str(), nBinsX, binsX);
211 TProfile::AddDirectory(oldstat);
218 double startY,
double endY,
bool prependDir) {
220 TProfile *hist(
nullptr);
221 Bool_t oldstat = TProfile::AddDirectoryStatus();
222 TProfile::AddDirectory(
false);
224 hist =
new TProfile((prefix + name).c_str(), labels.c_str(), (Int_t) nBinsX, binsX, startY, endY);
225 TProfile::AddDirectory(oldstat);
232 const double xlo,
const double xhi,
const int nBinsY,
const double ylo,
const double yhi,
233 bool prependDir,
bool useRMS) {
235 Bool_t oldstat = TProfile2D::AddDirectoryStatus();
236 TProfile2D::AddDirectory(
false);
237 std::string opt = useRMS ?
"S" :
"";
238 TProfile2D *hist =
new TProfile2D((prefix + name).c_str(), labels.c_str(), nBinsX, xlo, xhi, nBinsY, ylo, yhi, opt.c_str());
239 TProfile2D::AddDirectory(oldstat);
245PlotBase::BookTProfile2D(
const std::string &name,
const std::string &labels,
const int nBinsX,
double* binsX,
const int nBinsY,
double* binsY,
bool prependDir,
bool useRMS) {
247 Bool_t oldstat = TProfile2D::AddDirectoryStatus();
248 TProfile2D::AddDirectory(
false);
249 std::string opt = useRMS ?
"S" :
"";
250 TProfile2D *hist =
new TProfile2D((prefix + name).c_str(), labels.c_str(), nBinsX, binsX, nBinsY, binsY, opt.c_str());
251 TProfile2D::AddDirectory(oldstat);
257PlotBase::BookTEfficiency(
const std::string &name,
const std::string & labels,
const int nBinsX,
const float xlo,
const float xhi,
const bool prependDir){
260 TEfficiency *hist =
new TEfficiency((prefix + name).c_str(), labels.c_str(), nBinsX, xlo, xhi);
263 hist->SetDirectory(
nullptr);
270PlotBase::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){
273 TEfficiency *hist =
new TEfficiency((prefix + name).c_str(), labels.c_str(), nBinsX, xlo, xhi, nBinsY, ylo, yhi);
274 hist->SetDirectory(
nullptr);
283 TTree *
tree =
new TTree((prefix + name).c_str(),
"");
285 tree->SetAutoSave(0);
286 tree->SetAutoFlush(0);
287 tree->SetDirectory(
nullptr);
297 std::replace(dir.begin(), dir.end(),
'/',
'_');
TH1D * Book1D(const std::string &name, const std::string &labels, int nBins, float start, float end, bool prependDir=true)
Book a TH1D histogram.
std::vector< EfficiencyData > retrieveBookedEfficiencies()
Retrieve all booked efficiency objects.
std::vector< PlotBase * > m_vSubNodes
static std::string constructPrefix(std::string dir, bool prependDir)
std::vector< HistData > retrieveBookedHistograms()
Retrieve all booked histograms.
std::vector< EfficiencyData > m_vBookedEfficiencies
void setDetailLevel(int iDetailLevel)
const std::string & getDirectory()
PlotBase(PlotBase *parent, const std::string &sDir)
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.
virtual void initializePlots()
std::vector< HistData > m_vBookedHistograms
virtual void finalizePlots()
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.
std::vector< TreeData > retrieveBookedTrees()
Retrieve all booked trees.
void RegisterSubPlot(PlotBase *pPlotBase)
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.
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.
TTree * BookTree(const std::string &name, bool prependDir=true)
Book a TTree.
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.
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.
std::vector< TreeData > m_vBookedTrees