24#include "BDSBH4DTypeDefs.hh"
25#include <boost/format.hpp>
26#include <boost/histogram.hpp>
39 BDSBH4DBase(3,3,3,3, 0,1, 0,1, 0,1, 0.1,0.230,
"BDSBH4D",
"BDSBH4D",
"linear")
41 h = boost::histogram::make_histogram_with(std::vector<double>(),
42 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
43 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
44 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
45 boost::histogram::axis::regular<double> {3, 1.0, 230.0,
"energy"});
47 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
48 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
49 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
50 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
51 boost::histogram::axis::regular<double> {3, 1.0, 230.0,
"energy"});
56 BDSBH4DBase(3,3,3,3, 0,1, 0,1, 0,1, 0.1,0.230,
"BDSBH4D",
"BDSBH4D",
"log")
58 h = boost::histogram::make_histogram_with(std::vector<double>(),
59 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
60 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
61 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
62 boost::histogram::axis::regular<double, boost::histogram::axis::transform::log> {3, 1.0, 230.0,
"energy"});
64 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
65 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
66 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
67 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
68 boost::histogram::axis::regular<double, boost::histogram::axis::transform::log> {3, 1.0, 230.0,
"energy"});
73 BDSBH4DBase(3,3,3,0,1, 0,1, 0,1,
"BDSBH4D",
"BDSBH4D",
"user",std::vector<double>{0.001,0.1,0.230})
75 h = boost::histogram::make_histogram_with(std::vector<double>(),
76 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
77 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
78 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
79 boost::histogram::axis::variable<double> {std::vector<double>{0.001,0.230},
"energy"});
81 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
82 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"x"},
83 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"y"},
84 boost::histogram::axis::regular<double> {3, 0.0, 1.0,
"z"},
85 boost::histogram::axis::variable<double> {std::vector<double>{0.001,0.1,0.230},
"energy"});
90 unsigned int nxbins,
double xmin,
double xmax,
91 unsigned int nybins,
double ymin,
double ymax,
92 unsigned int nzbins,
double zmin,
double zmax,
93 unsigned int nebins,
double emin,
double emax):
95 xmin, xmax, ymin, ymax, zmin, zmax, emin, emax,
98 h = boost::histogram::make_histogram_with(std::vector<double>(),
99 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
100 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
101 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
102 boost::histogram::axis::regular<double> {nebins, emin, emax,
"energy"});
104 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
105 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
106 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
107 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
108 boost::histogram::axis::regular<double> {nebins, emin, emax,
"energy"});
113 unsigned int nxbins,
double xmin,
double xmax,
114 unsigned int nybins,
double ymin,
double ymax,
115 unsigned int nzbins,
double zmin,
double zmax,
116 unsigned int nebins,
double emin,
double emax):
118 xmin, xmax, ymin, ymax, zmin, zmax, emin, emax,
121 h = boost::histogram::make_histogram_with(std::vector<double>(),
122 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
123 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
124 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
125 boost::histogram::axis::regular<double, boost::histogram::axis::transform::log> {nebins, emin, emax,
"energy"});
127 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
128 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
129 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
130 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
131 boost::histogram::axis::regular<double, boost::histogram::axis::transform::log> {nebins, emin, emax,
"energy"});
136 const std::vector<double>& eBinEdgesIn,
137 unsigned int nxbins,
double xmin,
double xmax,
138 unsigned int nybins,
double ymin,
double ymax,
139 unsigned int nzbins,
double zmin,
double zmax):
140 BDSBH4DBase(nxbins, nybins, nzbins, xmin, xmax, ymin, ymax, zmin, zmax, name, title, eScale, eBinEdgesIn)
142 h = boost::histogram::make_histogram_with(std::vector<double>(),
143 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
144 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
145 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
146 boost::histogram::axis::variable<double> {eBinEdgesIn,
"energy"});
148 h_err = boost::histogram::make_histogram_with(std::vector<double>(),
149 boost::histogram::axis::regular<double> {nxbins, xmin, xmax,
"x"},
150 boost::histogram::axis::regular<double> {nybins, ymin, ymax,
"y"},
151 boost::histogram::axis::regular<double> {nzbins, zmin, zmax,
"z"},
152 boost::histogram::axis::variable<double> {eBinEdgesIn,
"energy"});
170 clone->SetName(newname);
180 h(xValue, yValue, zValue, eValue);
190 h.at(x, y, z, e) = value;
200 h_err.at(x, y, z, e) = value;
206 auto tmp =
dynamic_cast<BDSBH4D<T>*
>(otherHistogram);
213 return h.at(x, y, z, e);
219 std::ostringstream os4;
220 for (
auto&& i : indexed(h))
222 if (i.index(0) == x and i.index(1) == y and i.index(2) == z and i.index(3) == e)
223 {
return i.bin(3).lower();}
231 std::ostringstream os4;
232 for (
auto&& i : indexed(h))
234 if (i.index(0) == x and i.index(1) == y and i.index(2) == z and i.index(3) == e)
235 {
return i.bin(3).upper();}
243 return h_err.at(x, y, z, e);
249 std::ostringstream os4;
250 for (
auto&& x : indexed(this->h))
252 if (!with_zero_values and *x != 0)
254 os4 << boost::format(
"(%i, %i, %i, %i) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) %i\n")
255 % x.index(0) % x.index(1) % x.index(2) % x.index(3)
256 % x.bin(0).lower() % x.bin(0).upper()
257 % x.bin(1).lower() % x.bin(1).upper()
258 % x.bin(2).lower() % x.bin(2).upper()
259 % x.bin(3).lower() % x.bin(3).upper()
262 else if (with_zero_values)
264 os4 << boost::format(
"(%i, %i, %i, %i) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) %i\n")
265 % x.index(0) % x.index(1) % x.index(2) % x.index(3)
266 % x.bin(0).lower() % x.bin(0).upper()
267 % x.bin(1).lower() % x.bin(1).upper()
268 % x.bin(2).lower() % x.bin(2).upper()
269 % x.bin(3).lower() % x.bin(3).upper()
273 std::cout << os4.str() << std::flush;
279 std::ostringstream os4;
280 for (
auto&& i : indexed(this->h))
282 if (i.index(0) == x and i.index(1) == y and i.index(2) ==z and i.index(3) ==e)
284 os4 << boost::format(
"(%i, %i, %i, %i) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) [%.3f, %.3f) %i\n")
285 % i.index(0) % i.index(1) % i.index(2) % i.index(3)
286 % i.bin(0).lower() % i.bin(0).upper()
287 % i.bin(1).lower() % i.bin(1).upper()
288 % i.bin(2).lower() % i.bin(2).upper()
289 % i.bin(3).lower() % i.bin(3).upper()
293 std::cout << os4.str() << std::flush;
Base class for the 4D histogram classes.
4D histogram classes with linear, logarithmic and user-defined energy binning.