23#include "BDSBH4DTypeDefs.hh"
24#include <boost/format.hpp>
25#include <boost/histogram.hpp>
38 BDSBH4DBase(3,3,3,3, 0,1, 0,1, 0,1, 0.1,0.230,
"BDSBH4D",
"BDSBH4D",
"linear")
40 h = boost::histogram::make_histogram_with(std::vector<double>(),
41 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
42 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
43 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
44 boost::histogram::axis::regular<double> {3, 1.0, 230.0,
"energy"});
46 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
47 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
48 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
49 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
50 boost::histogram::axis::regular<double> {3, 1.0, 230.0,
"energy"});
55 BDSBH4DBase(3,3,3,3, 0,1, 0,1, 0,1, 0.1,0.230,
"BDSBH4D",
"BDSBH4D",
"log")
57 h = boost::histogram::make_histogram_with(std::vector<double>(),
58 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
59 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
60 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
61 boost::histogram::axis::regular<double, boost::histogram::axis::transform::log> {3, 1.0, 230.0,
"energy"});
63 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
64 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
65 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
66 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
67 boost::histogram::axis::regular<double, boost::histogram::axis::transform::log> {3, 1.0, 230.0,
"energy"});
72 BDSBH4DBase(3,3,3,0,1, 0,1, 0,1,
"BDSBH4D",
"BDSBH4D",
"user",
std::vector<double>{0.001,0.1,0.230})
74 h = boost::histogram::make_histogram_with(std::vector<double>(),
75 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
76 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
77 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
78 boost::histogram::axis::variable<double> {std::vector<double>{0.001,0.230},
"energy"});
80 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
81 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
82 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
83 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
84 boost::histogram::axis::variable<double> {std::vector<double>{0.001,0.1,0.230},
"energy"});
89 unsigned int nxbins,
double xmin,
double xmax,
90 unsigned int nybins,
double ymin,
double ymax,
91 unsigned int nzbins,
double zmin,
double zmax,
92 unsigned int nebins,
double emin,
double emax):
94 xmin, xmax, ymin, ymax, zmin, zmax, emin, emax,
97 h = boost::histogram::make_histogram_with(std::vector<double>(),
98 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
99 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
100 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
101 boost::histogram::axis::regular<double> {nebins, emin, emax,
"energy"});
103 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
104 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
105 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
106 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
107 boost::histogram::axis::regular<double> {nebins, emin, emax,
"energy"});
112 unsigned int nxbins,
double xmin,
double xmax,
113 unsigned int nybins,
double ymin,
double ymax,
114 unsigned int nzbins,
double zmin,
double zmax,
115 unsigned int nebins,
double emin,
double emax):
117 xmin, xmax, ymin, ymax, zmin, zmax, emin, emax,
120 h = boost::histogram::make_histogram_with(std::vector<double>(),
121 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
122 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
123 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
124 boost::histogram::axis::regular<double, boost::histogram::axis::transform::log> {nebins, emin, emax,
"energy"});
126 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
127 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
128 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
129 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
130 boost::histogram::axis::regular<double, boost::histogram::axis::transform::log> {nebins, emin, emax,
"energy"});
135 const std::vector<double>& eBinEdgesIn,
136 unsigned int nxbins,
double xmin,
double xmax,
137 unsigned int nybins,
double ymin,
double ymax,
138 unsigned int nzbins,
double zmin,
double zmax):
139 BDSBH4DBase(nxbins, nybins, nzbins, xmin, xmax, ymin, ymax, zmin, zmax, name, title, eScale, eBinEdgesIn)
141 h = boost::histogram::make_histogram_with(std::vector<double>(),
142 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
143 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
144 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
145 boost::histogram::axis::variable<double> {eBinEdgesIn,
"energy"});
147 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
148 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
149 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
150 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
151 boost::histogram::axis::variable<double> {eBinEdgesIn,
"energy"});
169 clone->SetName(newname);
179 h(xValue, yValue, zValue, eValue);
189 h.at(x, y, z, e) = value;
199 h_err.at(x, y, z, e) = value;
205 auto tmp =
dynamic_cast<BDSBH4D<T>*
>(otherHistogram);
212 return h.at(x, y, z, e);
218 std::ostringstream os4;
219 for (
auto&& i : indexed(h))
221 if (i.index(0) == x and i.index(1) == y and i.index(2) == z and i.index(3) == e)
222 {
return i.bin(3).lower();}
230 std::ostringstream os4;
231 for (
auto&& i : indexed(h))
233 if (i.index(0) == x and i.index(1) == y and i.index(2) == z and i.index(3) == e)
234 {
return i.bin(3).upper();}
242 return h_err.at(x, y, z, e);
248 std::ostringstream os4;
249 for (
auto&& x : indexed(this->h))
251 if (!with_zero_values and *x != 0)
253 os4 << boost::format(
"(%i, %i, %i, %i) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) %i\n")
254 % x.index(0) % x.index(1) % x.index(2) % x.index(3)
255 % x.bin(0).lower() % x.bin(0).upper()
256 % x.bin(1).lower() % x.bin(1).upper()
257 % x.bin(2).lower() % x.bin(2).upper()
258 % x.bin(3).lower() % x.bin(3).upper()
261 else if (with_zero_values)
263 os4 << boost::format(
"(%i, %i, %i, %i) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) %i\n")
264 % x.index(0) % x.index(1) % x.index(2) % x.index(3)
265 % x.bin(0).lower() % x.bin(0).upper()
266 % x.bin(1).lower() % x.bin(1).upper()
267 % x.bin(2).lower() % x.bin(2).upper()
268 % x.bin(3).lower() % x.bin(3).upper()
272 std::cout << os4.str() << std::flush;
278 std::ostringstream os4;
279 for (
auto&& i : indexed(this->h))
281 if (i.index(0) == x and i.index(1) == y and i.index(2) ==z and i.index(3) ==e)
283 os4 << boost::format(
"(%i, %i, %i, %i) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) %i\n")
284 % i.index(0) % i.index(1) % i.index(2) % i.index(3)
285 % i.bin(0).lower() % i.bin(0).upper()
286 % i.bin(1).lower() % i.bin(1).upper()
287 % i.bin(2).lower() % i.bin(2).upper()
288 % i.bin(3).lower() % i.bin(3).upper()
292 std::cout << os4.str() << std::flush;
Base class for the 4D histogram classes.
4D histogram classes with linear, logarithmic and user-defined energy binning.