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