2#include "Framework/Histograms.h"
4#include "Framework/Exception/Exception.h"
20 gStyle->SetOptStat(1);
21 gStyle->SetGridColor(17);
22 gStyle->SetFrameBorderMode(0);
23 gStyle->SetTitleOffset(1.2,
"yx");
24 gStyle->SetTitleFontSize(25);
26 gStyle->SetPadBottomMargin(0.1);
27 gStyle->SetPadTopMargin(0.01);
28 gStyle->SetPadLeftMargin(0.1);
29 gStyle->SetPadRightMargin(0.09);
30 gStyle->SetPadGridX(1);
31 gStyle->SetPadGridY(1);
32 gStyle->SetPadTickX(1);
33 gStyle->SetPadTickY(1);
35 gStyle->SetHistLineWidth(2);
49 EXCEPTION_RAISE(
"InvalidArg",
"Histogram " + name +
" not found in pool.");
56 const double& bins,
const double& xmin,
58 std::string fullName =
name_ +
"_" + name;
61 auto hist =
new TH1F(fullName.c_str(), fullName.c_str(), bins, xmin, xmax);
67 hist->GetXaxis()->SetTitle(xLabel.c_str());
68 hist->GetXaxis()->CenterTitle();
75 const std::vector<double>& bins) {
76 std::string fullName =
name_ +
"_" + name;
79 int nbins = bins.size() - 1;
80 double* binEdges =
new double[bins.size()];
81 for (
unsigned int iBin = 0; iBin < bins.size(); iBin++)
82 binEdges[iBin] = bins.at(iBin);
84 auto hist =
new TH1F(fullName.c_str(), fullName.c_str(), nbins, binEdges);
92 hist->GetXaxis()->SetTitle(xLabel.c_str());
93 hist->GetXaxis()->CenterTitle();
100 const double& xbins,
const double& xmin,
101 const double& xmax,
const std::string& yLabel,
102 const double& ybins,
const double& ymin,
103 const double& ymax) {
104 std::string fullName =
name_ +
"_" + name;
107 auto hist =
new TH2F(fullName.c_str(), fullName.c_str(), xbins, xmin, xmax,
114 hist->GetXaxis()->SetTitle(xLabel.c_str());
115 hist->GetXaxis()->CenterTitle();
118 hist->GetYaxis()->SetTitle(yLabel.c_str());
119 hist->GetYaxis()->CenterTitle();
126 const std::vector<double>& xbins,
127 const std::string& yLabel,
128 const std::vector<double>& ybins) {
129 std::string fullName =
name_ +
"_" + name;
132 int xNBins = xbins.size() - 1;
133 double* xBinEdges =
new double[xbins.size()];
134 for (
unsigned int iBin = 0; iBin < xbins.size(); iBin++)
135 xBinEdges[iBin] = xbins.at(iBin);
137 int yNBins = ybins.size() - 1;
138 double* yBinEdges =
new double[ybins.size()];
139 for (
unsigned int iBin = 0; iBin < ybins.size(); iBin++)
140 yBinEdges[iBin] = ybins.at(iBin);
142 auto hist =
new TH2F(fullName.c_str(), fullName.c_str(), xNBins, xBinEdges,
152 hist->GetXaxis()->SetTitle(xLabel.c_str());
153 hist->GetXaxis()->CenterTitle();
156 hist->GetYaxis()->SetTitle(yLabel.c_str());
157 hist->GetYaxis()->CenterTitle();
std::string name_
The name of the processor that this helper is assigned to.
void create(const std::string &name, const std::string &xLabel, const double &bins, const double &xmin, const double &xmax)
Create a ROOT 1D histogram of type TH1F and pool it for later use.
Singleton class used to create and pool histograms.
static HistogramPool & getInstance()
Access the single instance of HistogramPool by reference.
HistogramPool()
Private constructor to prevent instantiation.
void insert(const std::string &name, TH1 *hist)
Insert a histogram into the pool.
TH1 * get(const std::string &name)
Get a histogram using its name.
std::unordered_map< std::string, TH1 * > histograms_
Container for all histograms.
All classes in the ldmx-sw project use this namespace.