19#include "BinGeneration.hh"
20#include "HistogramDef.hh"
21#include "HistogramDef1D.hh"
22#include "HistogramDef2D.hh"
23#include "HistogramDef3D.hh"
24#include "HistogramDef4D.hh"
25#include "HistogramFactory.hh"
34#include "BDSBH4DBase.hh"
35#include "BDSBH4DTypeDefs.hh"
37#include "RBDSException.hh"
46HistogramFactory::HistogramFactory()
49HistogramFactory::~HistogramFactory()
53 const std::string& overRideName,
54 const std::string& overRideTitle)
56 TH1* result =
nullptr;
57 const int nDimensions = definition->nDimensions;
88 throw RBDSException(
"HistogramFactory::CreateHistogram>",
"Not compiled with BOOST libraries - no 4D histograms.");
100 const std::string& overRideName,
101 const std::string& overRideTitle)
103 if (!overRideName.empty())
104 {name = overRideName;}
105 if (!overRideTitle.empty())
106 {title = overRideTitle;}
110 const std::string& overRideName,
111 const std::string& overRideTitle)
113 TH1D* result =
nullptr;
114 std::string name = d->histName;
115 std::string title = name;
119 {result =
new TH1D(name.c_str(), title.c_str(), xbs.n, xbs.edges->data());}
121 {result =
new TH1D(name.c_str(), title.c_str(), xbs.n, xbs.low, xbs.high);}
126 const std::string& overRideName,
127 const std::string& overRideTitle)
129 TH2D* result =
nullptr;
130 std::string name = d->histName;
131 std::string title = name;
136 if (xbs.edges && ybs.edges)
138 result =
new TH2D(name.c_str(), title.c_str(),
139 xbs.n, xbs.edges->data(),
140 ybs.n, ybs.edges->data());
144 result =
new TH2D(name.c_str(), title.c_str(),
145 xbs.n, xbs.edges->data(),
146 ybs.n, ybs.low, ybs.high);
150 result =
new TH2D(name.c_str(), title.c_str(),
151 xbs.n, xbs.low, xbs.high,
152 ybs.n, ybs.edges->data());
156 result =
new TH2D(name.c_str(), title.c_str(),
157 xbs.n, xbs.low, xbs.high,
158 ybs.n, ybs.low, ybs.high);
164 const std::string& overRideName,
165 const std::string& overRideTitle)
167 TH3D* result =
nullptr;
168 std::string name = d->histName;
169 std::string title = name;
176 if (xbs.edges || ybs.edges || zbs.edges)
178 std::vector<double> binEdgesX = xbs.edges ? *(xbs.edges) :
RBDS::LinSpace(xbs.low, xbs.high, xbs.n);
179 std::vector<double> binEdgesY = ybs.edges ? *(ybs.edges) :
RBDS::LinSpace(ybs.low, ybs.high, ybs.n);
180 std::vector<double> binEdgesZ = zbs.edges ? *(zbs.edges) :
RBDS::LinSpace(zbs.low, zbs.high, zbs.n);
181 result =
new TH3D(name.c_str(), title.c_str(),
182 xbs.n, binEdgesX.data(),
183 ybs.n, binEdgesY.data(),
184 zbs.n, binEdgesZ.data());
188 result =
new TH3D(name.c_str(), title.c_str(),
189 xbs.n, xbs.low, xbs.high,
190 ybs.n, ybs.low, ybs.high,
191 zbs.n, zbs.low, zbs.high);
199 const std::string& overRideName,
200 const std::string& overRideTitle)
204 std::string name = d->histName;
205 std::string title = name;
213 std::vector<double> binEdgesE = ebs.edges ? *(ebs.edges) :
RBDS::LinSpace(ebs.low, ebs.high, ebs.n);
215 if(d->eScale ==
"linear")
218 xbs.n, xbs.low, xbs.high,
219 ybs.n, ybs.low, ybs.high,
220 zbs.n, zbs.low, zbs.high,
221 ebs.n, ebs.low, ebs.high);
223 else if(d->eScale ==
"log")
226 xbs.n, xbs.low, xbs.high,
227 ybs.n, ybs.low, ybs.high,
228 zbs.n, zbs.low, zbs.high,
229 ebs.n, ebs.low, ebs.high);
231 else if(d->eScale ==
"user")
234 xbs.n, xbs.low, xbs.high,
235 ybs.n, ybs.low, ybs.high,
236 zbs.n, zbs.low, zbs.high);
Base class for the 4D histogram classes.
4D histogram classes with linear, logarithmic and user-defined energy binning.
Binning specification for a single dimension.
Specification for 1D histogram.
Specification for 2D histogram.
Specification for 3D Histogram.
Specification for 4D Histogram.
Common specification for a histogram.
Class to manufacture histograms.
void CheckNameAndTitle(std::string &name, std::string &title, const std::string &overRideName="", const std::string &overRideTitle="")
Whether name is set or not.
TH3D * CreateHistogram3D(const HistogramDef3D *d, const std::string &overRideName="", const std::string &overRideTitle="")
Create 3D histogram.
TH2D * CreateHistogram2D(const HistogramDef2D *d, const std::string &overRideName="", const std::string &overRideTitle="")
Create 2D histogram.
BDSBH4DBase * CreateHistogram4D(const HistogramDef4D *d, const std::string &overRideName="", const std::string &overRideTitle="")
Create 4D histogram.
TH1D * CreateHistogram1D(const HistogramDef1D *d, const std::string &overRideName="", const std::string &overRideTitle="")
Create 1D histogram.
TH1 * CreateHistogram(const HistogramDef *definition, const std::string &overRideName="", const std::string &overRideTitle="")
General exception with possible name of object and message.
std::vector< double > LinSpace(double start, double stop, int nBins, bool includeLastPoint=true)
Linear range of values.