1#ifndef __FRAMEWORK_HISTOGRAM_POOL_H__
2#define __FRAMEWORK_HISTOGRAM_POOL_H__
8#include <unordered_map>
13#include "Framework/Configure/Parameters.h"
14#include "Framework/Exception/Exception.h"
15#include "TDirectory.h"
142 void insert(
const std::string& name, std::function<TH1*()> factory,
158 TH1*
get(
const std::string& name);
175 void create(
const std::string& name,
const std::string& x_label,
176 const int& bins,
const double& xmin,
const double& xmax,
177 bool weighted =
false);
187 void create(
const std::string& name,
const std::string& x_label,
188 const std::vector<double>& bins,
bool weighted =
false);
198 void create(
const std::string& name,
const std::string& x_label,
199 const std::vector<std::string>& categories,
200 bool weighted =
false);
216 void create(
const std::string& name,
const std::string& x_label,
217 const int& xbins,
const double& xmin,
const double& xmax,
218 const std::string& y_label,
const int& ybins,
const double& ymin,
219 const double& ymax,
bool weighted =
false);
234 void create(
const std::string& name,
const std::string& x_label,
235 const std::vector<double>& xbins,
const std::string& y_label,
236 const int& ybins,
const double& ymin,
const double& ymax,
237 bool weighted =
false);
252 void create(
const std::string& name,
const std::string& x_label,
253 const std::vector<std::string>& xcategories,
254 const std::string& y_label,
const int& ybins,
const double& ymin,
255 const double& ymax,
bool weighted =
false);
270 void create(
const std::string& name,
const std::string& x_label,
271 const int& xbins,
const double& xmin,
const double& xmax,
272 const std::string& y_label,
const std::vector<double>& ybins,
273 bool weighted =
false);
286 void create(
const std::string& name,
const std::string& x_label,
287 const std::vector<double>& xbins,
const std::string& y_label,
288 const std::vector<double>& ybins,
bool weighted =
false);
301 void create(
const std::string& name,
const std::string& x_label,
302 const std::vector<std::string>& xcategories,
303 const std::string& y_label,
const std::vector<double>& ybins,
304 bool weighted =
false);
319 void create(
const std::string& name,
const std::string& x_label,
320 const int& xbins,
const double& xmin,
const double& xmax,
321 const std::string& y_label,
322 const std::vector<std::string>& ycategories,
323 bool weighted =
false);
336 void create(
const std::string& name,
const std::string& x_label,
337 const std::vector<double>& xbins,
const std::string& y_label,
338 const std::vector<std::string>& ycategories,
339 bool weighted =
false);
352 void create(
const std::string& name,
const std::string& x_label,
353 const std::vector<std::string>& xcategories,
354 const std::string& y_label,
355 const std::vector<std::string>& ycategories,
356 bool weighted =
false);
366 template <
typename T>
367 void fill(
const std::string& name,
const T& val) {
368 auto hist =
dynamic_cast<TH1F*
>(this->
get(name));
376 "Attempting to 1D fill a histogram that is not actually 1D.");
389 template <
typename T>
390 void fillw(
const std::string& name,
const T& val,
double w) {
391 auto hist =
dynamic_cast<TH1F*
>(this->
get(name));
399 "Attempting to 1D fill a histogram that is not actually 1D.");
412 template <
typename Tx,
typename Ty>
413 void fill(
const std::string& name,
const Tx& valx,
const Ty& valy) {
414 auto hist =
dynamic_cast<TH2F*
>(this->
get(name));
422 "Attempting to 2D fill a histogram that is not actually 2D.");
436 template <
typename Tx,
typename Ty>
437 void fillw(
const std::string& name,
const Tx& valx,
const Ty& valy,
439 auto hist =
dynamic_cast<TH2F*
>(this->
get(name));
441 hist->Fill(valx, valy, w);
447 "Attempting to 2D fill a histogram that is not actually 2D.");
Class for holding an EventProcessor's histogram pointers and making sure that they all end up in the ...
void insert(const std::string &name, std::function< TH1 *()> factory, bool weighted)
insert a histogram into this pool by name
void fillw(const std::string &name, const Tx &valx, const Ty &valy, double w)
Fill a 2D histogram.
std::function< TDirectory *()> get_directory_
the callback to get the directory these histograms should go in
void setWeight(double w)
Set the weight for filling the histograms.
void fillw(const std::string &name, const T &val, double w)
Fill a 1D histogram.
HistogramPool(std::function< TDirectory *()> get_directory)
define how we can get the directory we need
void create(const config::Parameters &p)
Create a histogram from the input configuration parameters.
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
void fill(const std::string &name, const Tx &valx, const Ty &valy)
Fill a 2D histogram.
TH1 * get(const std::string &name)
get a histogram from this pool by name
std::unordered_map< std::string, TH1 * > histograms_
the pool of histogram pointers
double the_weight_
The weight to fill histograms with.
Class encapsulating parameters for configuring a processor.
All classes in the ldmx-sw project use this namespace.