Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RHist.hxx
Go to the documentation of this file.
1/// \file
2/// \warning This is part of the %ROOT 7 prototype! It will change without notice. It might trigger earthquakes.
3/// Feedback is welcome!
4
5#ifndef ROOT_RHist
6#define ROOT_RHist
7
8#include "RAxisVariant.hxx"
9#include "RBinIndex.hxx"
11#include "RCategoricalAxis.hxx"
12#include "RHistEngine.hxx"
13#include "RHistStats.hxx"
14#include "RRegularAxis.hxx"
15#include "RWeight.hxx"
16
17#include <array>
18#include <cstddef>
19#include <cstdint>
20#include <stdexcept>
21#include <tuple>
22#include <utility>
23#include <variant>
24#include <vector>
25
26class TBuffer;
27
28namespace ROOT {
29namespace Experimental {
30
31// forward declaration for friend declaration
32template <typename BinContentType>
33class RHistFillContext;
34
35/**
36A histogram for aggregation of data along multiple dimensions.
37
38Every call to \ref Fill(const A &... args) "Fill" increments the bin content and is reflected in global statistics:
39\code
40ROOT::Experimental::RHist<int> hist(10, {5, 15});
41hist.Fill(8.5);
42// hist.GetBinContent(ROOT::Experimental::RBinIndex(3)) will return 1
43\endcode
44
45The class is templated on the bin content type. For counting, as in the example above, it may be an integral type such
46as `int` or `long`. Narrower types such as `unsigned char` or `short` are supported, but may overflow due to their
47limited range and must be used with care. For weighted filling, the bin content type must not be an integral type, but
48a floating-point type such as `float` or `double`, or the special type RBinWithError. Note that `float` has a limited
49significand precision of 24 bits.
50
51An object can have arbitrary dimensionality determined at run-time. The axis configuration is passed as a vector of
52RAxisVariant:
53\code
54std::vector<ROOT::Experimental::RAxisVariant> axes;
55axes.push_back(ROOT::Experimental::RRegularAxis(10, {5, 15}));
56axes.push_back(ROOT::Experimental::RVariableBinAxis({1, 10, 100, 1000}));
57ROOT::Experimental::RHist<int> hist(axes);
58// hist.GetNDimensions() will return 2
59\endcode
60
61\warning This is part of the %ROOT 7 prototype! It will change without notice. It might trigger earthquakes.
62Feedback is welcome!
63*/
64template <typename BinContentType>
65class RHist final {
66 // For conversion, all other template instantiations must be a friend.
67 template <typename U>
68 friend class RHist;
69
70 friend class RHistFillContext<BinContentType>;
71
72 /// The histogram engine including the bin contents.
74 /// The global histogram statistics.
76
77 /// Private constructor based off an engine.
79
80public:
81 /// Construct a histogram.
82 ///
83 /// \param[in] axes the axis objects, must have size > 0
84 explicit RHist(std::vector<RAxisVariant> axes) : fEngine(std::move(axes)), fStats(fEngine.GetNDimensions())
85 {
86 // The axes parameter was moved, use from the engine.
87 const auto &engineAxes = fEngine.GetAxes();
88 for (std::size_t i = 0; i < engineAxes.size(); i++) {
89 if (engineAxes[i].GetCategoricalAxis() != nullptr) {
91 }
92 }
93 }
94
95 /// Construct a histogram.
96 ///
97 /// Note that there is no perfect forwarding of the axis objects. If that is needed, use the
98 /// \ref RHist(std::vector<RAxisVariant> axes) "overload accepting a std::vector".
99 ///
100 /// \param[in] axes the axis objects, must have size > 0
101 explicit RHist(std::initializer_list<RAxisVariant> axes) : RHist(std::vector(axes)) {}
102
103 /// Construct a histogram.
104 ///
105 /// Note that there is no perfect forwarding of the axis objects. If that is needed, use the
106 /// \ref RHist(std::vector<RAxisVariant> axes) "overload accepting a std::vector".
107 ///
108 /// \param[in] axis1 the first axis object
109 /// \param[in] axes the remaining axis objects
110 template <typename... Axes>
111 explicit RHist(const RAxisVariant &axis1, const Axes &...axes) : RHist(std::vector<RAxisVariant>{axis1, axes...})
112 {
113 }
114
115 /// Construct a one-dimensional histogram with a regular axis.
116 ///
117 /// \param[in] nNormalBins the number of normal bins, must be > 0
118 /// \param[in] interval the axis interval (lower end inclusive, upper end exclusive)
119 /// \par See also
120 /// the \ref RRegularAxis::RRegularAxis(std::uint64_t nNormalBins, std::pair<double, double> interval, bool
121 /// enableFlowBins) "constructor of RRegularAxis"
122 RHist(std::uint64_t nNormalBins, std::pair<double, double> interval)
124 {
125 }
126
127 /// The copy constructor is deleted.
128 ///
129 /// Copying all bin contents can be an expensive operation, depending on the number of bins. If required, users can
130 /// explicitly call Clone().
131 RHist(const RHist &) = delete;
132 /// Efficiently move construct a histogram.
133 ///
134 /// After this operation, the moved-from object is invalid.
135 RHist(RHist &&) = default;
136
137 /// The copy assignment operator is deleted.
138 ///
139 /// Copying all bin contents can be an expensive operation, depending on the number of bins. If required, users can
140 /// explicitly call Clone().
141 RHist &operator=(const RHist &) = delete;
142 /// Efficiently move a histogram.
143 ///
144 /// After this operation, the moved-from object is invalid.
145 RHist &operator=(RHist &&) = default;
146
147 ~RHist() = default;
148
149 /// \name Accessors
150 /// \{
151
153 const RHistStats &GetStats() const { return fStats; }
154
155 const std::vector<RAxisVariant> &GetAxes() const { return fEngine.GetAxes(); }
156 std::size_t GetNDimensions() const { return fEngine.GetNDimensions(); }
157 std::uint64_t GetTotalNBins() const { return fEngine.GetTotalNBins(); }
158
159 std::uint64_t GetNEntries() const { return fStats.GetNEntries(); }
160
161 /// \}
162 /// \name Computations
163 /// \{
164
165 /// \copydoc RHistStats::ComputeNEffectiveEntries()
167 /// \copydoc RHistStats::ComputeMean()
168 double ComputeMean(std::size_t dim = 0) const { return fStats.ComputeMean(dim); }
169 /// \copydoc RHistStats::ComputeStdDev()
170 double ComputeStdDev(std::size_t dim = 0) const { return fStats.ComputeStdDev(dim); }
171
172 /// \}
173 /// \name Accessors
174 /// \{
175
176 /// Get the content of a single bin.
177 ///
178 /// \code
179 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
180 /// std::array<ROOT::Experimental::RBinIndex, 2> indices = {3, 5};
181 /// int content = hist.GetBinContent(indices);
182 /// \endcode
183 ///
184 /// \note Compared to TH1 conventions, the first normal bin has index 0 and underflow and overflow bins are special
185 /// values. See also the class documentation of RBinIndex.
186 ///
187 /// Throws an exception if the number of indices does not match the axis configuration or the bin is not found.
188 ///
189 /// \param[in] indices the array of indices for each axis
190 /// \return the bin content
191 /// \par See also
192 /// the \ref GetBinContent(const A &... args) const "variadic function template overload" accepting arguments
193 /// directly
194 template <std::size_t N>
195 const BinContentType &GetBinContent(const std::array<RBinIndex, N> &indices) const
196 {
197 return fEngine.GetBinContent(indices);
198 }
199
200 /// Get the content of a single bin.
201 ///
202 /// \code
203 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
204 /// std::vector<ROOT::Experimental::RBinIndex> indices = {3, 5};
205 /// int content = hist.GetBinContent(indices);
206 /// \endcode
207 ///
208 /// \note Compared to TH1 conventions, the first normal bin has index 0 and underflow and overflow bins are special
209 /// values. See also the class documentation of RBinIndex.
210 ///
211 /// Throws an exception if the number of indices does not match the axis configuration or the bin is not found.
212 ///
213 /// \param[in] indices the array of indices for each axis
214 /// \return the bin content
215 /// \par See also
216 /// the \ref GetBinContent(const A &... args) const "variadic function template overload" accepting arguments
217 /// directly
218 const BinContentType &GetBinContent(const std::vector<RBinIndex> &indices) const
219 {
220 return fEngine.GetBinContent(indices);
221 }
222
223 /// Get the content of a single bin.
224 ///
225 /// \code
226 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
227 /// int content = hist.GetBinContent(ROOT::Experimental::RBinIndex(3), ROOT::Experimental::RBinIndex(5));
228 /// // ... or construct the RBinIndex arguments implicitly from integers:
229 /// content = hist.GetBinContent(3, 5);
230 /// \endcode
231 ///
232 /// \note Compared to TH1 conventions, the first normal bin has index 0 and underflow and overflow bins are special
233 /// values. See also the class documentation of RBinIndex.
234 ///
235 /// Throws an exception if the number of arguments does not match the axis configuration or the bin is not found.
236 ///
237 /// \param[in] args the arguments for each axis
238 /// \return the bin content
239 /// \par See also
240 /// the function overloads accepting \ref GetBinContent(const std::array<RBinIndex, N> &indices) const "`std::array`"
241 /// or \ref GetBinContent(const std::vector<RBinIndex> &indices) const "`std::vector`"
242 template <typename... A>
243 const BinContentType &GetBinContent(const A &...args) const
244 {
245 return fEngine.GetBinContent(args...);
246 }
247
248 /// Get the multidimensional range of all bins.
249 ///
250 /// \return the multidimensional range
251 RBinIndexMultiDimRange GetFullMultiDimRange() const { return fEngine.GetFullMultiDimRange(); }
252
253 /// Set the content of a single bin.
254 ///
255 /// \code
256 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
257 /// std::array<ROOT::Experimental::RBinIndex, 2> indices = {3, 5};
258 /// int value = /* ... */;
259 /// hist.SetBinContent(indices, value);
260 /// \endcode
261 ///
262 /// \note Compared to TH1 conventions, the first normal bin has index 0 and underflow and overflow bins are special
263 /// values. See also the class documentation of RBinIndex.
264 ///
265 /// Throws an exception if the number of indices does not match the axis configuration or the bin is not found.
266 ///
267 /// \warning Setting the bin content will taint the global histogram statistics. Attempting to access its values, for
268 /// example calling GetNEntries(), will throw exceptions.
269 ///
270 /// \param[in] indices the array of indices for each axis
271 /// \param[in] value the new value of the bin content
272 /// \par See also
273 /// the \ref SetBinContent(const A &... args) "variadic function template overload" accepting arguments directly
274 template <std::size_t N, typename V>
275 void SetBinContent(const std::array<RBinIndex, N> &indices, const V &value)
276 {
277 fEngine.SetBinContent(indices, value);
278 fStats.Taint();
279 }
280
281 /// Set the content of a single bin.
282 ///
283 /// \code
284 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
285 /// int value = /* ... */;
286 /// hist.SetBinContent(ROOT::Experimental::RBinIndex(3), ROOT::Experimental::RBinIndex(5), value);
287 /// // ... or construct the RBinIndex arguments implicitly from integers:
288 /// hist.SetBinContent(3, 5, value);
289 /// \endcode
290 ///
291 /// \note Compared to TH1 conventions, the first normal bin has index 0 and underflow and overflow bins are special
292 /// values. See also the class documentation of RBinIndex.
293 ///
294 /// Throws an exception if the number of arguments does not match the axis configuration or the bin is not found.
295 ///
296 /// \warning Setting the bin content will taint the global histogram statistics. Attempting to access its values, for
297 /// example calling GetNEntries(), will throw exceptions.
298 ///
299 /// \param[in] args the arguments for each axis and the new value of the bin content
300 /// \par See also
301 /// the \ref SetBinContent(const std::array<RBinIndex, N> &indices, const V &value) "function overload" accepting
302 /// `std::array`
303 template <typename... A>
304 void SetBinContent(const A &...args)
305 {
306 fEngine.SetBinContent(args...);
307 fStats.Taint();
308 }
309
310 /// \}
311 /// \name Filling
312 /// \{
313
314 /// Fill an entry into the histogram.
315 ///
316 /// \code
317 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
318 /// auto args = std::make_tuple(8.5, 10.5);
319 /// hist.Fill(args);
320 /// \endcode
321 ///
322 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
323 /// discarded.
324 ///
325 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
326 /// converted for the axis type at run-time.
327 ///
328 /// \param[in] args the arguments for each axis
329 /// \par See also
330 /// the \ref Fill(const A &... args) "variadic function template overload" accepting arguments directly and the
331 /// \ref Fill(const std::tuple<A...> &args, RWeight weight) "overload for weighted filling"
332 template <typename... A>
333 void Fill(const std::tuple<A...> &args)
334 {
335 fEngine.Fill(args);
336 fStats.Fill(args);
337 }
338
339 /// Fill an entry into the histogram with a weight.
340 ///
341 /// This overload is not available for integral bin content types (see \ref RHistEngine::SupportsWeightedFilling).
342 ///
343 /// \code
344 /// ROOT::Experimental::RHist<float> hist({/* two dimensions */});
345 /// auto args = std::make_tuple(8.5, 10.5);
346 /// hist.Fill(args, ROOT::Experimental::RWeight(0.8));
347 /// \endcode
348 ///
349 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
350 /// discarded.
351 ///
352 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
353 /// converted for the axis type at run-time.
354 ///
355 /// \param[in] args the arguments for each axis
356 /// \param[in] weight the weight for this entry
357 /// \par See also
358 /// the \ref Fill(const A &... args) "variadic function template overload" accepting arguments directly and the
359 /// \ref Fill(const std::tuple<A...> &args) "overload for unweighted filling"
360 template <typename... A>
361 void Fill(const std::tuple<A...> &args, RWeight weight)
362 {
363 fEngine.Fill(args, weight);
364 fStats.Fill(args, weight);
365 }
366
367 /// Fill an entry into the histogram.
368 ///
369 /// \code
370 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
371 /// hist.Fill(8.5, 10.5);
372 /// \endcode
373 ///
374 /// For weighted filling, pass an RWeight as the last argument:
375 /// \code
376 /// ROOT::Experimental::RHist<float> hist({/* two dimensions */});
377 /// hist.Fill(8.5, 10.5, ROOT::Experimental::RWeight(0.8));
378 /// \endcode
379 /// This is not available for integral bin content types (see \ref RHistEngine::SupportsWeightedFilling).
380 ///
381 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
382 /// discarded.
383 ///
384 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
385 /// converted for the axis type at run-time.
386 ///
387 /// \param[in] args the arguments for each axis
388 /// \par See also
389 /// the function overloads accepting `std::tuple` \ref Fill(const std::tuple<A...> &args) "for unweighted filling"
390 /// and \ref Fill(const std::tuple<A...> &args, RWeight) "for weighted filling"
391 template <typename... A>
392 void Fill(const A &...args)
393 {
394 static_assert(sizeof...(A) >= 1, "need at least one argument to Fill");
395 if constexpr (sizeof...(A) >= 1) {
396 fEngine.Fill(args...);
397 fStats.Fill(args...);
398 }
399 }
400
401 /// \}
402 /// \name Operations
403 /// \{
404
405 /// Add all bin contents and statistics of another histogram.
406 ///
407 /// Throws an exception if the axes configurations are not identical.
408 ///
409 /// \param[in] other another histogram
410 void Add(const RHist &other)
411 {
412 fEngine.Add(other.fEngine);
413 fStats.Add(other.fStats);
414 }
415
416 /// Add all bin contents and statistics of another histogram using atomic instructions.
417 ///
418 /// Throws an exception if the axes configurations are not identical.
419 ///
420 /// \param[in] other another histogram that must not be modified during the operation
421 void AddAtomic(const RHist &other)
422 {
423 fEngine.AddAtomic(other.fEngine);
424 fStats.AddAtomic(other.fStats);
425 }
426
427 /// Clear all bin contents and statistics.
428 void Clear()
429 {
430 fEngine.Clear();
431 fStats.Clear();
432 }
433
434 /// Clone this histogram.
435 ///
436 /// Copying all bin contents can be an expensive operation, depending on the number of bins.
437 ///
438 /// \return the cloned object
439 RHist Clone() const
440 {
441 RHist h(fEngine.Clone());
442 h.fStats = fStats;
443 return h;
444 }
445
446 /// Convert this histogram to a different bin content type.
447 ///
448 /// There is no bounds checking to make sure that the converted values can be represented. Note that it is not
449 /// possible to convert to RBinWithError since the information about individual weights has been lost since filling.
450 ///
451 /// Converting all bin contents can be an expensive operation, depending on the number of bins.
452 ///
453 /// \return the converted object
454 template <typename U>
456 {
457 RHist<U> h(fEngine.template Convert<U>());
458 h.fStats = fStats;
459 return h;
460 }
461
462 /// Scale all histogram bin contents and statistics.
463 ///
464 /// This method is not available for integral bin content types.
465 ///
466 /// \param[in] factor the scale factor
467 void Scale(double factor)
468 {
469 fEngine.Scale(factor);
470 fStats.Scale(factor);
471 }
472
473 /// Slice this histogram with an RSliceSpec per dimension.
474 ///
475 /// With a range, only the specified bins are retained. All other bin contents are transferred to the underflow and
476 /// overflow bins:
477 /// \code
478 /// ROOT::Experimental::RHist<int> hist(/* one dimension */);
479 /// // Fill the histogram with a number of entries...
480 /// auto sliced = hist.Slice({hist.GetAxes()[0].GetNormalRange(1, 5)});
481 /// // The returned histogram will have 4 normal bins, an underflow and an overflow bin.
482 /// \endcode
483 ///
484 /// Slicing can also perform operations per dimension, see RSliceSpec. RSliceSpec::ROperationRebin allows to rebin
485 /// the histogram axis, grouping a number of normal bins into a new one:
486 /// \code
487 /// ROOT::Experimental::RHist<int> hist(/* one dimension */);
488 /// // Fill the histogram with a number of entries...
489 /// auto rebinned = hist.Slice(ROOT::Experimental::RSliceSpec::ROperationRebin(2));
490 /// // The returned histogram has groups of two normal bins merged.
491 /// \endcode
492 ///
493 /// RSliceSpec::ROperationSum sums the bin contents along that axis, which allows to project to a lower-dimensional
494 /// histogram:
495 /// \code
496 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
497 /// // Fill the histogram with a number of entries...
498 /// auto projected = hist.Slice(ROOT::Experimental::RSliceSpec{}, ROOT::Experimental::RSliceSpec::ROperationSum{});
499 /// // The returned histogram has one dimension, with bin contents summed along the second axis.
500 /// \endcode
501 /// Note that it is not allowed to sum along all histogram axes because the return value would be a scalar.
502 ///
503 /// Ranges and operations can be combined. In that case, the range is applied before the operation.
504 ///
505 /// \warning Combining a range and the sum operation drops bin contents, which will taint the global histogram
506 /// statistics. Attempting to access its values, for example calling GetNEntries(), will throw exceptions.
507 ///
508 /// \param[in] sliceSpecs the slice specifications for each axis
509 /// \return the sliced histogram
510 /// \par See also
511 /// the \ref Slice(const A &... args) const "variadic function template overload" accepting arguments directly
512 RHist Slice(const std::vector<RSliceSpec> &sliceSpecs) const
513 {
514 bool dropped = false;
516 assert(sliced.fStats.GetNDimensions() == sliced.GetNDimensions());
517 if (dropped || fStats.IsTainted()) {
518 sliced.fStats.Taint();
519 } else {
520 sliced.fStats.fNEntries = fStats.fNEntries;
521 sliced.fStats.fSumW = fStats.fSumW;
522 sliced.fStats.fSumW2 = fStats.fSumW2;
523 std::size_t slicedDim = 0;
524 for (std::size_t i = 0; i < sliceSpecs.size(); i++) {
525 // A sum operation makes the dimension disappear.
526 if (sliceSpecs[i].GetOperationSum() == nullptr) {
527 sliced.fStats.fDimensionStats[slicedDim] = fStats.fDimensionStats[i];
528 slicedDim++;
529 }
530 }
531 assert(slicedDim == sliced.GetNDimensions());
532 }
533 return sliced;
534 }
535
536 /// Slice this histogram with an RSliceSpec per dimension.
537 ///
538 /// With a range, only the specified bins are retained. All other bin contents are transferred to the underflow and
539 /// overflow bins:
540 /// \code
541 /// ROOT::Experimental::RHist<int> hist(/* one dimension */);
542 /// // Fill the histogram with a number of entries...
543 /// auto sliced = hist.Slice(hist.GetAxes()[0].GetNormalRange(1, 5));
544 /// // The returned histogram will have 4 normal bins, an underflow and an overflow bin.
545 /// \endcode
546 ///
547 /// Slicing can also perform operations per dimension, see RSliceSpec. RSliceSpec::ROperationRebin allows to rebin
548 /// the histogram axis, grouping a number of normal bins into a new one:
549 /// \code
550 /// ROOT::Experimental::RHist<int> hist(/* one dimension */);
551 /// // Fill the histogram with a number of entries...
552 /// auto rebinned = hist.Slice(ROOT::Experimental::RSliceSpec::ROperationRebin(2));
553 /// // The returned histogram has groups of two normal bins merged.
554 /// \endcode
555 ///
556 /// RSliceSpec::ROperationSum sums the bin contents along that axis, which allows to project to a lower-dimensional
557 /// histogram:
558 /// \code
559 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
560 /// // Fill the histogram with a number of entries...
561 /// auto projected = hist.Slice(ROOT::Experimental::RSliceSpec{}, ROOT::Experimental::RSliceSpec::ROperationSum{});
562 /// // The returned histogram has one dimension, with bin contents summed along the second axis.
563 /// \endcode
564 /// Note that it is not allowed to sum along all histogram axes because the return value would be a scalar.
565 ///
566 /// Ranges and operations can be combined. In that case, the range is applied before the operation.
567 ///
568 /// \warning Combining a range and the sum operation drops bin contents, which will taint the global histogram
569 /// statistics. Attempting to access its values, for example calling GetNEntries(), will throw exceptions.
570 ///
571 /// \param[in] args the arguments for each axis
572 /// \return the sliced histogram
573 /// \par See also
574 /// the \ref Slice(const std::vector<RSliceSpec> &sliceSpecs) const "function overload" accepting `std::vector`
575 template <typename... A>
576 RHist Slice(const A &...args) const
577 {
578 std::vector<RSliceSpec> sliceSpecs{args...};
579 return Slice(sliceSpecs);
580 }
581
582 /// \}
583
584 /// %ROOT Streamer function to throw when trying to store an object of this class.
585 void Streamer(TBuffer &) { throw std::runtime_error("unable to store RHist"); }
586};
587
588} // namespace Experimental
589} // namespace ROOT
590
591#endif
#define h(i)
Definition RSha256.hxx:106
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
A variant of all supported axis types.
A multidimensional range of bin indices.
A context to concurrently fill an RHist.
Histogram statistics of unbinned values.
void Add(const RHistStats &other)
Add all entries from another statistics object.
std::vector< RDimensionStats > fDimensionStats
The sums per dimension.
void Clear()
Clear this statistics object.
void Taint()
Taint this statistics object.
void AddAtomic(const RHistStats &other)
Add all entries from another statistics object using atomic instructions.
double fSumW
The sum of weights.
double fSumW2
The sum of weights squared.
void Scale(double factor)
Scale the histogram statistics.
void Fill(const std::tuple< A... > &args)
Fill an entry into this statistics object.
double ComputeNEffectiveEntries() const
Compute the number of effective entries.
void DisableDimension(std::size_t dim)
Disable one dimension of this statistics object.
std::uint64_t GetNEntries() const
double ComputeMean(std::size_t dim=0) const
Compute the arithmetic mean of unbinned values.
std::uint64_t fNEntries
The number of entries.
double ComputeStdDev(std::size_t dim=0) const
Compute the standard deviation of unbinned values.
A histogram for aggregation of data along multiple dimensions.
Definition RHist.hxx:65
RHist(const RHist &)=delete
The copy constructor is deleted.
double ComputeMean(std::size_t dim=0) const
Compute the arithmetic mean of unbinned values.
Definition RHist.hxx:168
RHist(std::uint64_t nNormalBins, std::pair< double, double > interval)
Construct a one-dimensional histogram with a regular axis.
Definition RHist.hxx:122
std::size_t GetNDimensions() const
Definition RHist.hxx:156
RHist Clone() const
Clone this histogram.
Definition RHist.hxx:439
RHist & operator=(RHist &&)=default
Efficiently move a histogram.
RHist(const RAxisVariant &axis1, const Axes &...axes)
Construct a histogram.
Definition RHist.hxx:111
void Scale(double factor)
Scale all histogram bin contents and statistics.
Definition RHist.hxx:467
RHist Slice(const A &...args) const
Slice this histogram with an RSliceSpec per dimension.
Definition RHist.hxx:576
const BinContentType & GetBinContent(const std::vector< RBinIndex > &indices) const
Get the content of a single bin.
Definition RHist.hxx:218
RHist(std::initializer_list< RAxisVariant > axes)
Construct a histogram.
Definition RHist.hxx:101
void Fill(const std::tuple< A... > &args)
Fill an entry into the histogram.
Definition RHist.hxx:333
RHist & operator=(const RHist &)=delete
The copy assignment operator is deleted.
RHistStats fStats
The global histogram statistics.
Definition RHist.hxx:75
void AddAtomic(const RHist &other)
Add all bin contents and statistics of another histogram using atomic instructions.
Definition RHist.hxx:421
void Fill(const std::tuple< A... > &args, RWeight weight)
Fill an entry into the histogram with a weight.
Definition RHist.hxx:361
RHist< U > Convert() const
Convert this histogram to a different bin content type.
Definition RHist.hxx:455
RHistEngine< BinContentType > fEngine
The histogram engine including the bin contents.
Definition RHist.hxx:73
double ComputeNEffectiveEntries() const
Compute the number of effective entries.
Definition RHist.hxx:166
std::uint64_t GetTotalNBins() const
Definition RHist.hxx:157
RHist(std::vector< RAxisVariant > axes)
Construct a histogram.
Definition RHist.hxx:84
RBinIndexMultiDimRange GetFullMultiDimRange() const
Get the multidimensional range of all bins.
Definition RHist.hxx:251
const RHistStats & GetStats() const
Definition RHist.hxx:153
const RHistEngine< BinContentType > & GetEngine() const
Definition RHist.hxx:152
void Streamer(TBuffer &)
ROOT Streamer function to throw when trying to store an object of this class.
Definition RHist.hxx:585
void Fill(const A &...args)
Fill an entry into the histogram.
Definition RHist.hxx:392
void SetBinContent(const A &...args)
Set the content of a single bin.
Definition RHist.hxx:304
double ComputeStdDev(std::size_t dim=0) const
Compute the standard deviation of unbinned values.
Definition RHist.hxx:170
RHist(RHist &&)=default
Efficiently move construct a histogram.
const BinContentType & GetBinContent(const std::array< RBinIndex, N > &indices) const
Get the content of a single bin.
Definition RHist.hxx:195
const std::vector< RAxisVariant > & GetAxes() const
Definition RHist.hxx:155
RHist Slice(const std::vector< RSliceSpec > &sliceSpecs) const
Slice this histogram with an RSliceSpec per dimension.
Definition RHist.hxx:512
void Add(const RHist &other)
Add all bin contents and statistics of another histogram.
Definition RHist.hxx:410
void SetBinContent(const std::array< RBinIndex, N > &indices, const V &value)
Set the content of a single bin.
Definition RHist.hxx:275
RHist(RHistEngine< BinContentType > engine)
Private constructor based off an engine.
Definition RHist.hxx:78
const BinContentType & GetBinContent(const A &...args) const
Get the content of a single bin.
Definition RHist.hxx:243
void Clear()
Clear all bin contents and statistics.
Definition RHist.hxx:428
std::uint64_t GetNEntries() const
Definition RHist.hxx:159
A regular axis with equidistant bins in the interval .
Buffer base class used for serializing objects.
Definition TBuffer.h:43
A weight for filling histograms.
Definition RWeight.hxx:17