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)
124 : RHist(std::vector<RAxisVariant>{RRegularAxis(nNormalBins, 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 /// std::vector<ROOT::Experimental::RBinIndex> indices = {3, 5};
287 /// int value = /* ... */;
288 /// hist.SetBinContent(indices, 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 indices 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] indices the vector of indices for each axis
300 /// \param[in] value the new value of the bin content
301 /// \par See also
302 /// the \ref SetBinContent(const A &... args) "variadic function template overload" accepting arguments directly
303 template <typename V>
304 void SetBinContent(const std::vector<RBinIndex> &indices, const V &value)
305 {
306 fEngine.SetBinContent(indices, value);
307 fStats.Taint();
308 }
309
310 /// Set the content of a single bin.
311 ///
312 /// \code
313 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
314 /// int value = /* ... */;
315 /// hist.SetBinContent(ROOT::Experimental::RBinIndex(3), ROOT::Experimental::RBinIndex(5), value);
316 /// // ... or construct the RBinIndex arguments implicitly from integers:
317 /// hist.SetBinContent(3, 5, value);
318 /// \endcode
319 ///
320 /// \note Compared to TH1 conventions, the first normal bin has index 0 and underflow and overflow bins are special
321 /// values. See also the class documentation of RBinIndex.
322 ///
323 /// Throws an exception if the number of arguments does not match the axis configuration or the bin is not found.
324 ///
325 /// \warning Setting the bin content will taint the global histogram statistics. Attempting to access its values, for
326 /// example calling GetNEntries(), will throw exceptions.
327 ///
328 /// \param[in] args the arguments for each axis and the new value of the bin content
329 /// \par See also
330 /// the function overloads accepting
331 /// \ref SetBinContent(const std::array<RBinIndex, N> &indices, const V &value) const "`std::array`" or
332 /// \ref SetBinContent(const std::vector<RBinIndex> &indices, const V &value) const "`std::vector`"
333 template <typename... A>
334 void SetBinContent(const A &...args)
335 {
336 fEngine.SetBinContent(args...);
337 fStats.Taint();
338 }
339
340 /// \}
341 /// \name Filling
342 /// \{
343
344 /// Fill an entry into the histogram.
345 ///
346 /// \code
347 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
348 /// auto args = std::make_tuple(8.5, 10.5);
349 /// hist.Fill(args);
350 /// \endcode
351 ///
352 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
353 /// discarded.
354 ///
355 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
356 /// converted for the axis type at run-time.
357 ///
358 /// \param[in] args the arguments for each axis
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, RWeight weight) "overload for weighted filling"
362 template <typename... A>
363 void Fill(const std::tuple<A...> &args)
364 {
365 fEngine.Fill(args);
366 fStats.Fill(args);
367 }
368
369 /// Fill an entry into the histogram with a weight.
370 ///
371 /// This overload is not available for integral bin content types (see \ref RHistEngine::SupportsWeightedFilling).
372 ///
373 /// \code
374 /// ROOT::Experimental::RHist<float> hist({/* two dimensions */});
375 /// auto args = std::make_tuple(8.5, 10.5);
376 /// hist.Fill(args, ROOT::Experimental::RWeight(0.8));
377 /// \endcode
378 ///
379 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
380 /// discarded.
381 ///
382 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
383 /// converted for the axis type at run-time.
384 ///
385 /// \param[in] args the arguments for each axis
386 /// \param[in] weight the weight for this entry
387 /// \par See also
388 /// the \ref Fill(const A &... args) "variadic function template overload" accepting arguments directly and the
389 /// \ref Fill(const std::tuple<A...> &args) "overload for unweighted filling"
390 template <typename... A>
391 void Fill(const std::tuple<A...> &args, RWeight weight)
392 {
393 fEngine.Fill(args, weight);
394 fStats.Fill(args, weight);
395 }
396
397 /// Fill an entry into the histogram.
398 ///
399 /// \code
400 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
401 /// hist.Fill(8.5, 10.5);
402 /// \endcode
403 ///
404 /// For weighted filling, pass an RWeight as the last argument:
405 /// \code
406 /// ROOT::Experimental::RHist<float> hist({/* two dimensions */});
407 /// hist.Fill(8.5, 10.5, ROOT::Experimental::RWeight(0.8));
408 /// \endcode
409 /// This is not available for integral bin content types (see \ref RHistEngine::SupportsWeightedFilling).
410 ///
411 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
412 /// discarded.
413 ///
414 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
415 /// converted for the axis type at run-time.
416 ///
417 /// \param[in] args the arguments for each axis
418 /// \par See also
419 /// the function overloads accepting `std::tuple` \ref Fill(const std::tuple<A...> &args) "for unweighted filling"
420 /// and \ref Fill(const std::tuple<A...> &args, RWeight) "for weighted filling"
421 template <typename... A>
422 void Fill(const A &...args)
423 {
424 static_assert(sizeof...(A) >= 1, "need at least one argument to Fill");
425 if constexpr (sizeof...(A) >= 1) {
426 fEngine.Fill(args...);
427 fStats.Fill(args...);
428 }
429 }
430
431 /// \}
432 /// \name Operations
433 /// \{
434
435 /// Add all bin contents and statistics of another histogram.
436 ///
437 /// Throws an exception if the axes configurations are not identical.
438 ///
439 /// \param[in] other another histogram
440 void Add(const RHist &other)
441 {
442 fEngine.Add(other.fEngine);
443 fStats.Add(other.fStats);
444 }
445
446 /// Add all bin contents and statistics of another histogram using atomic instructions.
447 ///
448 /// Throws an exception if the axes configurations are not identical.
449 ///
450 /// \param[in] other another histogram that must not be modified during the operation
451 void AddAtomic(const RHist &other)
452 {
453 fEngine.AddAtomic(other.fEngine);
454 fStats.AddAtomic(other.fStats);
455 }
456
457 /// Clear all bin contents and statistics.
458 void Clear()
459 {
460 fEngine.Clear();
461 fStats.Clear();
462 }
463
464 /// Clone this histogram.
465 ///
466 /// Copying all bin contents can be an expensive operation, depending on the number of bins.
467 ///
468 /// \return the cloned object
469 RHist Clone() const
470 {
471 RHist h(fEngine.Clone());
472 h.fStats = fStats;
473 return h;
474 }
475
476 /// Convert this histogram to a different bin content type.
477 ///
478 /// There is no bounds checking to make sure that the converted values can be represented. Note that it is not
479 /// possible to convert to RBinWithError since the information about individual weights has been lost since filling.
480 ///
481 /// Converting all bin contents can be an expensive operation, depending on the number of bins.
482 ///
483 /// \return the converted object
484 template <typename U>
486 {
487 RHist<U> h(fEngine.template Convert<U>());
488 h.fStats = fStats;
489 return h;
490 }
491
492 /// Scale all histogram bin contents and statistics.
493 ///
494 /// This method is not available for integral bin content types.
495 ///
496 /// \param[in] factor the scale factor
497 void Scale(double factor)
498 {
499 fEngine.Scale(factor);
500 fStats.Scale(factor);
501 }
502
503 /// Slice this histogram with an RSliceSpec per dimension.
504 ///
505 /// With a range, only the specified bins are retained. All other bin contents are transferred to the underflow and
506 /// overflow bins:
507 /// \code
508 /// ROOT::Experimental::RHist<int> hist(/* one dimension */);
509 /// // Fill the histogram with a number of entries...
510 /// auto sliced = hist.Slice({hist.GetAxes()[0].GetNormalRange(1, 5)});
511 /// // The returned histogram will have 4 normal bins, an underflow and an overflow bin.
512 /// \endcode
513 ///
514 /// Slicing can also perform operations per dimension, see RSliceSpec. RSliceSpec::ROperationRebin allows to rebin
515 /// the histogram axis, grouping a number of normal bins into a new one:
516 /// \code
517 /// ROOT::Experimental::RHist<int> hist(/* one dimension */);
518 /// // Fill the histogram with a number of entries...
519 /// auto rebinned = hist.Slice(ROOT::Experimental::RSliceSpec::ROperationRebin(2));
520 /// // The returned histogram has groups of two normal bins merged.
521 /// \endcode
522 ///
523 /// RSliceSpec::ROperationSum sums the bin contents along that axis, which allows to project to a lower-dimensional
524 /// histogram:
525 /// \code
526 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
527 /// // Fill the histogram with a number of entries...
528 /// auto projected = hist.Slice(ROOT::Experimental::RSliceSpec{}, ROOT::Experimental::RSliceSpec::ROperationSum{});
529 /// // The returned histogram has one dimension, with bin contents summed along the second axis.
530 /// \endcode
531 /// Note that it is not allowed to sum along all histogram axes because the return value would be a scalar.
532 ///
533 /// Ranges and operations can be combined. In that case, the range is applied before the operation.
534 ///
535 /// \warning Combining a range and the sum operation drops bin contents, which will taint the global histogram
536 /// statistics. Attempting to access its values, for example calling GetNEntries(), will throw exceptions.
537 ///
538 /// \param[in] sliceSpecs the slice specifications for each axis
539 /// \return the sliced histogram
540 /// \par See also
541 /// the \ref Slice(const A &... args) const "variadic function template overload" accepting arguments directly
542 RHist Slice(const std::vector<RSliceSpec> &sliceSpecs) const
543 {
544 bool dropped = false;
545 RHist sliced(fEngine.SliceImpl(sliceSpecs, dropped));
546 assert(sliced.fStats.GetNDimensions() == sliced.GetNDimensions());
547 if (dropped || fStats.IsTainted()) {
548 sliced.fStats.Taint();
549 } else {
551 sliced.fStats.fSumW = fStats.fSumW;
552 sliced.fStats.fSumW2 = fStats.fSumW2;
553 std::size_t slicedDim = 0;
554 for (std::size_t i = 0; i < sliceSpecs.size(); i++) {
555 // A sum operation makes the dimension disappear.
556 if (sliceSpecs[i].GetOperationSum() == nullptr) {
557 sliced.fStats.fDimensionStats[slicedDim] = fStats.fDimensionStats[i];
558 slicedDim++;
559 }
560 }
561 assert(slicedDim == sliced.GetNDimensions());
562 }
563 return sliced;
564 }
565
566 /// Slice this histogram with an RSliceSpec per dimension.
567 ///
568 /// With a range, only the specified bins are retained. All other bin contents are transferred to the underflow and
569 /// overflow bins:
570 /// \code
571 /// ROOT::Experimental::RHist<int> hist(/* one dimension */);
572 /// // Fill the histogram with a number of entries...
573 /// auto sliced = hist.Slice(hist.GetAxes()[0].GetNormalRange(1, 5));
574 /// // The returned histogram will have 4 normal bins, an underflow and an overflow bin.
575 /// \endcode
576 ///
577 /// Slicing can also perform operations per dimension, see RSliceSpec. RSliceSpec::ROperationRebin allows to rebin
578 /// the histogram axis, grouping a number of normal bins into a new one:
579 /// \code
580 /// ROOT::Experimental::RHist<int> hist(/* one dimension */);
581 /// // Fill the histogram with a number of entries...
582 /// auto rebinned = hist.Slice(ROOT::Experimental::RSliceSpec::ROperationRebin(2));
583 /// // The returned histogram has groups of two normal bins merged.
584 /// \endcode
585 ///
586 /// RSliceSpec::ROperationSum sums the bin contents along that axis, which allows to project to a lower-dimensional
587 /// histogram:
588 /// \code
589 /// ROOT::Experimental::RHist<int> hist({/* two dimensions */});
590 /// // Fill the histogram with a number of entries...
591 /// auto projected = hist.Slice(ROOT::Experimental::RSliceSpec{}, ROOT::Experimental::RSliceSpec::ROperationSum{});
592 /// // The returned histogram has one dimension, with bin contents summed along the second axis.
593 /// \endcode
594 /// Note that it is not allowed to sum along all histogram axes because the return value would be a scalar.
595 ///
596 /// Ranges and operations can be combined. In that case, the range is applied before the operation.
597 ///
598 /// \warning Combining a range and the sum operation drops bin contents, which will taint the global histogram
599 /// statistics. Attempting to access its values, for example calling GetNEntries(), will throw exceptions.
600 ///
601 /// \param[in] args the arguments for each axis
602 /// \return the sliced histogram
603 /// \par See also
604 /// the \ref Slice(const std::vector<RSliceSpec> &sliceSpecs) const "function overload" accepting `std::vector`
605 template <typename... A>
606 RHist Slice(const A &...args) const
607 {
608 std::vector<RSliceSpec> sliceSpecs{args...};
609 return Slice(sliceSpecs);
610 }
611
612 /// \}
613
614 /// %ROOT Streamer function to throw when trying to store an object of this class.
615 void Streamer(TBuffer &) { throw std::runtime_error("unable to store RHist"); }
616};
617
618} // namespace Experimental
619} // namespace ROOT
620
621#endif
#define h(i)
Definition RSha256.hxx:106
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 histogram data structure to bin data along multiple dimensions.
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.
std::size_t GetNDimensions() const
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.
void SetBinContent(const std::vector< RBinIndex > &indices, const V &value)
Set the content of a single bin.
Definition RHist.hxx:304
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:469
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:497
RHist Slice(const A &...args) const
Slice this histogram with an RSliceSpec per dimension.
Definition RHist.hxx:606
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:363
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:451
void Fill(const std::tuple< A... > &args, RWeight weight)
Fill an entry into the histogram with a weight.
Definition RHist.hxx:391
RHist< U > Convert() const
Convert this histogram to a different bin content type.
Definition RHist.hxx:485
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:615
void Fill(const A &...args)
Fill an entry into the histogram.
Definition RHist.hxx:422
void SetBinContent(const A &...args)
Set the content of a single bin.
Definition RHist.hxx:334
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:542
void Add(const RHist &other)
Add all bin contents and statistics of another histogram.
Definition RHist.hxx:440
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:458
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