1#ifndef __FRAMEWORK_HISTOGRAM_POOL_H__
2#define __FRAMEWORK_HISTOGRAM_POOL_H__
9#include <unordered_map>
63 TH1*
get(
const std::string& name);
105 void create(
const std::string& name,
const std::string& xLabel,
106 const double& bins,
const double& xmin,
const double& xmax);
118 void create(
const std::string& name,
const std::string& xLabel,
119 const std::vector<double>& bins);
137 void create(
const std::string& name,
const std::string& xLabel,
138 const double& xbins,
const double& xmin,
const double& xmax,
139 const std::string& yLabel,
const double& ybins,
140 const double& ymin,
const double& ymax);
154 void create(
const std::string& name,
const std::string& xLabel,
155 const std::vector<double>& xbins,
const std::string& yLabel,
156 const std::vector<double>& ybins);
166 void fill(
const std::string& name,
const double& val) {
167 auto hist =
dynamic_cast<TH1F*
>(this->
get(name));
182 void fill(
const std::string& name,
const double& valx,
const double& valy) {
183 auto hist =
dynamic_cast<TH2F*
>(this->
get(name));
194 TH1*
get(
const std::string& name) {
Interface class between an EventProcessor and the HistogramPool.
TH1 * get(const std::string &name)
Get a pointer to a histogram by name.
void fill(const std::string &name, const double &val)
Fill a 1D histogram.
std::string name_
The name of the processor that this helper is assigned to.
double theWeight_
The weight to fill histograms with.
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.
HistogramHelper(const std::string &name)
Constructor.
void fill(const std::string &name, const double &valx, const double &valy)
Fill a 2D histogram.
void setWeight(double w)
Set the weight for filling the histograms.
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.
HistogramPool(HistogramPool const &)=delete
Hide copy constructor.
void insert(const std::string &name, TH1 *hist)
Insert a histogram into the pool.
void operator=(HistogramPool const &)=delete
Hide assignment operator.
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.