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