Logo ROOT  
Reference Guide
RHistData.hxx
Go to the documentation of this file.
1 /// \file ROOT/RHistData.h
2 /// \ingroup Hist ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2015-06-14
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #ifndef ROOT7_RHistData
17 #define ROOT7_RHistData
18 
19 #include <cmath>
20 #include <vector>
21 #include "ROOT/RSpan.hxx"
22 #include "ROOT/RHistUtils.hxx"
23 
24 namespace ROOT {
25 namespace Experimental {
26 
27 template <int DIMENSIONS, class PRECISION, template <int D_, class P_> class... STAT>
28 class RHist;
29 
30 /**
31  \class RHistStatContent
32  Basic histogram statistics, keeping track of the bin content and the total
33  number of calls to Fill().
34  */
35 template <int DIMENSIONS, class PRECISION>
36 class RHistStatContent {
37 public:
38  /// The type of a (possibly multi-dimensional) coordinate.
39  using CoordArray_t = Hist::CoordArray_t<DIMENSIONS>;
40  /// The type of the weight and the bin content.
41  using Weight_t = PRECISION;
42  /// Type of the bin content array.
43  using Content_t = std::vector<PRECISION>;
44 
45  /**
46  \class RConstBinStat
47  Const view on a RHistStatContent for a given bin.
48  */
49  class RConstBinStat {
50  public:
51  RConstBinStat(const RHistStatContent &stat, int index): fContent(stat.GetBinContent(index)) {}
52  PRECISION GetContent() const { return fContent; }
53 
54  private:
55  PRECISION fContent; ///< The content of this bin.
56  };
57 
58  /**
59  \class RBinStat
60  Modifying view on a RHistStatContent for a given bin.
61  */
62  class RBinStat {
63  public:
64  RBinStat(RHistStatContent &stat, int index): fContent(stat.GetBinContent(index)) {}
65  PRECISION &GetContent() const { return fContent; }
66 
67  private:
68  PRECISION &fContent; ///< The content of this bin.
69  };
70 
72  using BinStat_t = RBinStat;
73 
74 private:
75  /// Number of calls to Fill().
76  int64_t fEntries = 0;
77 
78  /// Bin content.
80 
81  /// Under- and overflow bin content.
83 
84 public:
85  RHistStatContent() = default;
86  RHistStatContent(size_t bin_size, size_t overflow_size): fBinContent(bin_size), fOverflowBinContent(overflow_size) {}
87 
88  /// Get a reference to the bin corresponding to `binidx` of the correct bin
89  /// content array
90  /// i.e. depending if `binidx` is a regular bin or an under- / overflow bin.
91  Weight_t GetBinArray(int binidx) const
92  {
93  if (binidx < 0){
94  return fOverflowBinContent[-binidx - 1];
95  } else {
96  return fBinContent[binidx - 1];
97  }
98  }
99 
100  /// Get a reference to the bin corresponding to `binidx` of the correct bin
101  /// content array (non-const)
102  /// i.e. depending if `binidx` is a regular bin or an under- / overflow bin.
103  Weight_t& GetBinArray(int binidx)
104  {
105  if (binidx < 0){
106  return fOverflowBinContent[-binidx - 1];
107  } else {
108  return fBinContent[binidx - 1];
109  }
110  }
111 
112  /// Add weight to the bin content at `binidx`.
113  void Fill(const CoordArray_t & /*x*/, int binidx, Weight_t weight = 1.)
114  {
115  GetBinArray(binidx) += weight;
116  ++fEntries;
117  }
118 
119  /// Get the number of entries filled into the histogram - i.e. the number of
120  /// calls to Fill().
121  int64_t GetEntries() const { return fEntries; }
122 
123  /// Get the number of bins exluding under- and overflow.
124  size_t sizeNoOver() const noexcept { return fBinContent.size(); }
125 
126  /// Get the number of bins including under- and overflow..
127  size_t size() const noexcept { return fBinContent.size() + fOverflowBinContent.size(); }
128 
129  /// Get the number of bins including under- and overflow..
130  size_t sizeUnderOver() const noexcept { return fOverflowBinContent.size(); }
131 
132  /// Get the bin content for the given bin.
133  Weight_t operator[](int binidx) const { return GetBinArray(binidx); }
134  /// Get the bin content for the given bin (non-const).
135  Weight_t &operator[](int binidx) { return GetBinArray(binidx); }
136 
137  /// Get the bin content for the given bin.
138  Weight_t GetBinContent(int binidx) const { return GetBinArray(binidx); }
139  /// Get the bin content for the given bin (non-const).
140  Weight_t &GetBinContent(int binidx) { return GetBinArray(binidx); }
141 
142  /// Retrieve the content array.
143  const Content_t &GetContentArray() const { return fBinContent; }
144  /// Retrieve the content array (non-const).
146 
147  /// Retrieve the under-/overflow content array.
148  const Content_t &GetOverflowContentArray() const { return fOverflowBinContent; }
149  /// Retrieve the under-/overflow content array (non-const).
151 
152  /// Merge with other RHistStatContent, assuming same bin configuration.
153  void Add(const RHistStatContent& other) {
154  assert(fBinContent.size() == other.fBinContent.size()
155  && "this and other have incompatible bin configuration!");
156  assert(fOverflowBinContent.size() == other.fOverflowBinContent.size()
157  && "this and other have incompatible bin configuration!");
158  fEntries += other.fEntries;
159  for (size_t b = 0; b < fBinContent.size(); ++b)
160  fBinContent[b] += other.fBinContent[b];
161  for (size_t b = 0; b < fOverflowBinContent.size(); ++b)
162  fOverflowBinContent[b] += other.fOverflowBinContent[b];
163  }
164 };
165 
166 /**
167  \class RHistStatTotalSumOfWeights
168  Keeps track of the histogram's total sum of weights.
169  */
170 template <int DIMENSIONS, class PRECISION>
172 public:
173  /// The type of a (possibly multi-dimensional) coordinate.
175  /// The type of the weight and the bin content.
176  using Weight_t = PRECISION;
177 
178  /**
179  \class RBinStat
180  No-op; this class does not provide per-bin statistics.
181  */
182  class RBinStat {
183  public:
184  RBinStat(const RHistStatTotalSumOfWeights &, int) {}
185  };
186 
187  using ConstBinStat_t = RBinStat;
189 
190 private:
191  /// Sum of weights.
193 
194 public:
195  RHistStatTotalSumOfWeights() = default;
196  RHistStatTotalSumOfWeights(size_t, size_t) {}
197 
198  /// Add weight to the bin content at binidx.
199  void Fill(const CoordArray_t & /*x*/, int, Weight_t weight = 1.) { fSumWeights += weight; }
200 
201  /// Get the sum of weights.
202  Weight_t GetSumOfWeights() const { return fSumWeights; }
203 
204  /// Merge with other RHistStatTotalSumOfWeights data, assuming same bin configuration.
205  void Add(const RHistStatTotalSumOfWeights& other) {
206  fSumWeights += other.fSumWeights;
207  }
208 };
209 
210 /**
211  \class RHistStatTotalSumOfSquaredWeights
212  Keeps track of the histogram's total sum of squared weights.
213  */
214 template <int DIMENSIONS, class PRECISION>
216 public:
217  /// The type of a (possibly multi-dimensional) coordinate.
219  /// The type of the weight and the bin content.
220  using Weight_t = PRECISION;
221 
222  /**
223  \class RBinStat
224  No-op; this class does not provide per-bin statistics.
225  */
226  class RBinStat {
227  public:
229  };
230 
231  using ConstBinStat_t = RBinStat;
233 
234 private:
235  /// Sum of (weights^2).
237 
238 public:
241 
242  /// Add weight to the bin content at binidx.
243  void Fill(const CoordArray_t & /*x*/, int /*binidx*/, Weight_t weight = 1.) { fSumWeights2 += weight * weight; }
244 
245  /// Get the sum of weights.
246  Weight_t GetSumOfSquaredWeights() const { return fSumWeights2; }
247 
248  /// Merge with other RHistStatTotalSumOfSquaredWeights data, assuming same bin configuration.
249  void Add(const RHistStatTotalSumOfSquaredWeights& other) {
250  fSumWeights2 += other.fSumWeights2;
251  }
252 };
253 
254 /**
255  \class RHistStatUncertainty
256  Histogram statistics to keep track of the Poisson uncertainty per bin.
257  */
258 template <int DIMENSIONS, class PRECISION>
259 class RHistStatUncertainty {
260 
261 public:
262  /// The type of a (possibly multi-dimensional) coordinate.
264  /// The type of the weight and the bin content.
265  using Weight_t = PRECISION;
266  /// Type of the bin content array.
267  using Content_t = std::vector<PRECISION>;
268 
269  /**
270  \class RConstBinStat
271  Const view on a `RHistStatUncertainty` for a given bin.
272  */
273  class RConstBinStat {
274  public:
275  RConstBinStat(const RHistStatUncertainty &stat, int index): fSumW2(stat.GetSumOfSquaredWeights(index)) {}
276  PRECISION GetSumW2() const { return fSumW2; }
277 
278  double GetUncertaintyImpl() const { return std::sqrt(std::abs(fSumW2)); }
279 
280  private:
281  PRECISION fSumW2; ///< The bin's sum of square of weights.
282  };
283 
284  /**
285  \class RBinStat
286  Modifying view on a `RHistStatUncertainty` for a given bin.
287  */
288  class RBinStat {
289  public:
290  RBinStat(RHistStatUncertainty &stat, int index): fSumW2(stat.GetSumOfSquaredWeights(index)) {}
291  PRECISION &GetSumW2() const { return fSumW2; }
292  // Can never modify this. Set GetSumW2() instead.
293  double GetUncertaintyImpl() const { return std::sqrt(std::abs(fSumW2)); }
294 
295  private:
296  PRECISION &fSumW2; ///< The bin's sum of square of weights.
297  };
298 
299  using ConstBinStat_t = RConstBinStat;
301 
302 private:
303  /// Uncertainty of the content for each bin excluding under-/overflow.
304  Content_t fSumWeightsSquared; ///< Sum of squared weights.
305  /// Uncertainty of the under-/overflow content.
306  Content_t fOverflowSumWeightsSquared; ///< Sum of squared weights for under-/overflow.
307 
308 public:
309  RHistStatUncertainty() = default;
310  RHistStatUncertainty(size_t bin_size, size_t overflow_size): fSumWeightsSquared(bin_size), fOverflowSumWeightsSquared(overflow_size) {}
311 
312  /// Get a reference to the bin corresponding to `binidx` of the correct bin
313  /// content array
314  /// i.e. depending if `binidx` is a regular bin or an under- / overflow bin.
315  Weight_t GetBinArray(int binidx) const
316  {
317  if (binidx < 0){
318  return fOverflowSumWeightsSquared[-binidx - 1];
319  } else {
320  return fSumWeightsSquared[binidx - 1];
321  }
322  }
323 
324  /// Get a reference to the bin corresponding to `binidx` of the correct bin
325  /// content array (non-const)
326  /// i.e. depending if `binidx` is a regular bin or an under- / overflow bin.
327  Weight_t& GetBinArray(int binidx)
328  {
329  if (binidx < 0){
330  return fOverflowSumWeightsSquared[-binidx - 1];
331  } else {
332  return fSumWeightsSquared[binidx - 1];
333  }
334  }
335 
336  /// Add weight to the bin at `binidx`; the coordinate was `x`.
337  void Fill(const CoordArray_t & /*x*/, int binidx, Weight_t weight = 1.)
338  {
339  GetBinArray(binidx) += weight * weight;
340  }
341 
342  /// Calculate a bin's (Poisson) uncertainty of the bin content as the
343  /// square-root of the bin's sum of squared weights.
344  double GetBinUncertaintyImpl(int binidx) const { return std::sqrt(GetBinArray(binidx)); }
345 
346  /// Get a bin's sum of squared weights.
347  Weight_t GetSumOfSquaredWeights(int binidx) const { return GetBinArray(binidx); }
348  /// Get a bin's sum of squared weights.
349  Weight_t &GetSumOfSquaredWeights(int binidx) { return GetBinArray(binidx); }
350 
351  /// Get the structure holding the sum of squares of weights.
352  const std::vector<double> &GetSumOfSquaredWeights() const { return fSumWeightsSquared; }
353  /// Get the structure holding the sum of squares of weights (non-const).
354  std::vector<double> &GetSumOfSquaredWeights() { return fSumWeightsSquared; }
355 
356  /// Get the structure holding the under-/overflow sum of squares of weights.
357  const std::vector<double> &GetOverflowSumOfSquaredWeights() const { return fOverflowSumWeightsSquared; }
358  /// Get the structure holding the under-/overflow sum of squares of weights (non-const).
360 
361  /// Merge with other `RHistStatUncertainty` data, assuming same bin configuration.
362  void Add(const RHistStatUncertainty& other) {
363  assert(fSumWeightsSquared.size() == other.fSumWeightsSquared.size()
364  && "this and other have incompatible bin configuration!");
365  assert(fOverflowSumWeightsSquared.size() == other.fOverflowSumWeightsSquared.size()
366  && "this and other have incompatible bin configuration!");
367  for (size_t b = 0; b < fSumWeightsSquared.size(); ++b)
368  fSumWeightsSquared[b] += other.fSumWeightsSquared[b];
369  for (size_t b = 0; b < fOverflowSumWeightsSquared.size(); ++b)
370  fOverflowSumWeightsSquared[b] += other.fOverflowSumWeightsSquared[b];
371  }
372 };
373 
374 /** \class RHistDataMomentUncert
375  For now do as `RH1`: calculate first (xw) and second (x^2w) moment.
376 */
377 template <int DIMENSIONS, class PRECISION>
378 class RHistDataMomentUncert {
379 public:
380  /// The type of a (possibly multi-dimensional) coordinate.
382  /// The type of the weight and the bin content.
383  using Weight_t = PRECISION;
384  /// Type of the bin content array.
385  using Content_t = std::vector<PRECISION>;
386 
387  /**
388  \class RBinStat
389  No-op; this class does not provide per-bin statistics.
390  */
391  class RBinStat {
392  public:
394  };
395 
396  using ConstBinStat_t = RBinStat;
398 
399 private:
400  std::array<Weight_t, DIMENSIONS> fMomentXW;
401  std::array<Weight_t, DIMENSIONS> fMomentX2W;
402  // FIXME: Add sum(w.x.y)-style stats.
403 
404 public:
406  RHistDataMomentUncert(size_t, size_t) {}
407 
408  /// Add weight to the bin at binidx; the coordinate was x.
409  void Fill(const CoordArray_t &x, int /*binidx*/, Weight_t weight = 1.)
410  {
411  for (int idim = 0; idim < DIMENSIONS; ++idim) {
412  const PRECISION xw = x[idim] * weight;
413  fMomentXW[idim] += xw;
414  fMomentX2W[idim] += x[idim] * xw;
415  }
416  }
417 
418  // FIXME: Add a way to query the inner data
419 
420  /// Merge with other RHistDataMomentUncert data, assuming same bin configuration.
421  void Add(const RHistDataMomentUncert& other) {
422  for (size_t d = 0; d < DIMENSIONS; ++d) {
423  fMomentXW[d] += other.fMomentXW[d];
424  fMomentX2W[d] += other.fMomentX2W[d];
425  }
426  }
427 };
428 
429 /** \class RHistStatRuntime
430  Interface implementing a pure virtual functions `DoFill()`, `DoFillN()`.
431  */
432 template <int DIMENSIONS, class PRECISION>
434 public:
435  /// The type of a (possibly multi-dimensional) coordinate.
437  /// The type of the weight and the bin content.
438  using Weight_t = PRECISION;
439  /// Type of the bin content array.
440  using Content_t = std::vector<PRECISION>;
441 
442  /**
443  \class RBinStat
444  No-op; this class does not provide per-bin statistics.
445  */
446  class RBinStat {
447  public:
448  RBinStat(const RHistStatRuntime &, int) {}
449  };
450 
451  using ConstBinStat_t = RBinStat;
453 
454  RHistStatRuntime() = default;
455  RHistStatRuntime(size_t, size_t) {}
456  virtual ~RHistStatRuntime() = default;
457 
458  virtual void DoFill(const CoordArray_t &x, int binidx, Weight_t weightN) = 0;
459  void Fill(const CoordArray_t &x, int binidx, Weight_t weight = 1.) { DoFill(x, binidx, weight); }
460 };
461 
462 namespace Detail {
463 
464 /** \class RHistBinStat
465  Const view on a bin's statistical data. Combines all STATs' BinStat_t views.
466  */
467 template <class DATA, class... BASES>
468 class RHistBinStat: public BASES... {
469 private:
470  /// Check whether `double T::GetBinUncertaintyImpl(int)` can be called.
471  template <class T>
472  static auto HaveUncertainty(const T *This) -> decltype(This->GetUncertaintyImpl());
473  /// Fall-back case for check whether `double T::GetBinUncertaintyImpl(int)` can be called.
474  template <class T>
475  static char HaveUncertainty(...);
476 
477 public:
478  RHistBinStat(DATA &data, int index): BASES(data, index)... {}
479 
480  /// Whether this provides storage for uncertainties, or whether uncertainties
481  /// are determined as poisson uncertainty of the content.
482  static constexpr bool HasBinUncertainty()
483  {
484  struct AllYourBaseAreBelongToUs: public BASES... {
485  };
486  return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(nullptr)) == sizeof(double);
487  }
488  /// Calculate the bin content's uncertainty for the given bin, using base class information,
489  /// i.e. forwarding to a base's `GetUncertaintyImpl()`.
490  template <bool B = true, class = typename std::enable_if<B && HasBinUncertainty()>::type>
491  double GetUncertainty() const
492  {
493  return this->GetUncertaintyImpl();
494  }
495  /// Calculate the bin content's uncertainty for the given bin, using Poisson
496  /// statistics on the absolute bin content. Only available if no base provides
497  /// this functionality. Requires `GetContent()`.
498  template <bool B = true, class = typename std::enable_if<B && !HasBinUncertainty()>::type>
499  double GetUncertainty(...) const
500  {
501  auto content = this->GetContent();
502  return std::sqrt(std::fabs(content));
503  }
504 };
505 
506 /** \class RHistData
507  A `RHistImplBase`'s data, provides accessors to all its statistics.
508  */
509 template <int DIMENSIONS, class PRECISION, class STORAGE, template <int D_, class P_> class... STAT>
510 class RHistData: public STAT<DIMENSIONS, PRECISION>... {
511 private:
512  /// Check whether `double T::GetBinUncertaintyImpl(int)` can be called.
513  template <class T>
514  static auto HaveUncertainty(const T *This) -> decltype(This->GetBinUncertaintyImpl(12));
515  /// Fall-back case for check whether `double T::GetBinUncertaintyImpl(int)` can be called.
516  template <class T>
517  static char HaveUncertainty(...);
518 
519 public:
520  /// Matching `RHist`.
521  using Hist_t = RHist<DIMENSIONS, PRECISION, STAT...>;
522 
523  /// The type of the weight and the bin content.
524  using Weight_t = PRECISION;
525 
526  /// The type of a (possibly multi-dimensional) coordinate.
528 
529  /// The type of a non-modifying view on a bin.
530  using ConstHistBinStat_t =
532 
533  /// The type of a modifying view on a bin.
535 
536  /// Number of dimensions of the coordinates.
537  static constexpr int GetNDim() noexcept { return DIMENSIONS; }
538 
539  RHistData() = default;
540 
541  /// Constructor providing the number of bins (incl under, overflow) to the
542  /// base classes.
543  RHistData(size_t bin_size, size_t overflow_size): STAT<DIMENSIONS, PRECISION>(bin_size, overflow_size)... {}
544 
545  /// Fill weight at x to the bin content at binidx.
546  void Fill(const CoordArray_t &x, int binidx, Weight_t weight = 1.)
547  {
548  // Call `Fill()` on all base classes.
549  // This combines a couple of C++ spells:
550  // - "STAT": is a template parameter pack of template template arguments. It
551  // has multiple (or one or no) elements; each is a template name
552  // that needs to be instantiated before it can be used.
553  // - "...": template parameter pack expansion; the expression is evaluated
554  // for each `STAT`. The expression is
555  // `(STAT<DIMENSIONS, PRECISION>::Fill(x, binidx, weight), 0)`.
556  // - "trigger_base_fill{}":
557  // initialization, provides a context in which template parameter
558  // pack expansion happens.
559  // - ", 0": because `Fill()` returns void it cannot be used as initializer
560  // expression. The trailing ", 0" gives it the type of the trailing
561  // comma-separated expression - int.
562  using trigger_base_fill = int[];
563  (void)trigger_base_fill{(STAT<DIMENSIONS, PRECISION>::Fill(x, binidx, weight), 0)...};
564  }
565 
566  /// Integrate other statistical data into the current data.
567  ///
568  /// The implementation assumes that the other statistics were recorded with
569  /// the same binning configuration, and that the statistics of `OtherData`
570  /// are a superset of those recorded by the active `RHistData` instance.
571  template <typename OtherData>
572  void Add(const OtherData &other)
573  {
574  // Call `Add()` on all base classes, using the same tricks as `Fill()`.
575  using trigger_base_add = int[];
576  (void)trigger_base_add{(STAT<DIMENSIONS, PRECISION>::Add(other), 0)...};
577  }
578 
579  /// Whether this provides storage for uncertainties, or whether uncertainties
580  /// are determined as poisson uncertainty of the content.
581  static constexpr bool HasBinUncertainty()
582  {
583  struct AllYourBaseAreBelongToUs: public STAT<DIMENSIONS, PRECISION>... {
584  };
585  return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(nullptr)) == sizeof(double);
586  }
587 
588  /// Calculate the bin content's uncertainty for the given bin, using base class information,
589  /// i.e. forwarding to a base's `GetBinUncertaintyImpl(binidx)`.
590  template <bool B = true, class = typename std::enable_if<B && HasBinUncertainty()>::type>
591  double GetBinUncertainty(int binidx) const
592  {
593  return this->GetBinUncertaintyImpl(binidx);
594  }
595  /// Calculate the bin content's uncertainty for the given bin, using Poisson
596  /// statistics on the absolute bin content. Only available if no base provides
597  /// this functionality. Requires `GetContent()`.
598  template <bool B = true, class = typename std::enable_if<B && !HasBinUncertainty()>::type>
599  double GetBinUncertainty(int binidx, ...) const
600  {
601  auto content = this->GetBinContent(binidx);
602  return std::sqrt(std::fabs(content));
603  }
604 
605  /// Get a view on the statistics values of a bin.
606  ConstHistBinStat_t GetView(int idx) const { return ConstHistBinStat_t(*this, idx); }
607  /// Get a (non-const) view on the statistics values of a bin.
608  HistBinStat_t GetView(int idx) { return HistBinStat_t(*this, idx); }
609 };
610 } // namespace Detail
611 
612 } // namespace Experimental
613 } // namespace ROOT
614 
615 #endif
ROOT::Experimental::RHistStatContent::sizeUnderOver
size_t sizeUnderOver() const noexcept
Get the number of bins including under- and overflow..
Definition: RHistData.hxx:142
ROOT::Experimental::RHistDataMomentUncert::Content_t
std::vector< PRECISION > Content_t
Type of the bin content array.
Definition: RHistData.hxx:397
ROOT::Experimental::RHistStatContent::GetEntries
int64_t GetEntries() const
Get the number of entries filled into the histogram - i.e.
Definition: RHistData.hxx:133
ROOT::Experimental::RHistStatUncertainty::CoordArray_t
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
Definition: RHistData.hxx:275
ROOT::Experimental::RHistDataMomentUncert::Weight_t
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:395
ROOT::Experimental::RHistStatUncertainty::RConstBinStat::GetSumW2
PRECISION GetSumW2() const
Definition: RHistData.hxx:288
ROOT::Experimental::RHistStatContent::RBinStat::GetContent
PRECISION & GetContent() const
Definition: RHistData.hxx:77
ROOT::Experimental::Detail::RHistBinStat::HasBinUncertainty
static constexpr bool HasBinUncertainty()
Whether this provides storage for uncertainties, or whether uncertainties are determined as poisson u...
Definition: RHistData.hxx:494
ROOT::Experimental::RHistStatUncertainty::GetOverflowSumOfSquaredWeights
const std::vector< double > & GetOverflowSumOfSquaredWeights() const
Get the structure holding the under-/overflow sum of squares of weights.
Definition: RHistData.hxx:369
ROOT::Experimental::RHistStatTotalSumOfSquaredWeights::Add
void Add(const RHistStatTotalSumOfSquaredWeights &other)
Merge with other RHistStatTotalSumOfSquaredWeights data, assuming same bin configuration.
Definition: RHistData.hxx:261
ROOT::Experimental::RHistStatContent::RHistStatContent
RHistStatContent()=default
ROOT::Experimental::RHistStatTotalSumOfSquaredWeights::RHistStatTotalSumOfSquaredWeights
RHistStatTotalSumOfSquaredWeights()=default
ROOT::Experimental::RHistStatTotalSumOfWeights::RBinStat
Definition: RHistData.hxx:194
ROOT::Experimental::RHistStatUncertainty::fSumWeightsSquared
Content_t fSumWeightsSquared
Uncertainty of the content for each bin excluding under-/overflow.
Definition: RHistData.hxx:316
ROOT::Experimental::RHistStatUncertainty::Fill
void Fill(const CoordArray_t &, int binidx, Weight_t weight=1.)
Add weight to the bin at binidx; the coordinate was x.
Definition: RHistData.hxx:349
ROOT::Experimental::RHistDataMomentUncert::RHistDataMomentUncert
RHistDataMomentUncert()=default
ROOT::Experimental::RHistDataMomentUncert::fMomentX2W
std::array< Weight_t, DIMENSIONS > fMomentX2W
Definition: RHistData.hxx:413
ROOT::Experimental::RHistStatRuntime
Definition: RHistData.hxx:445
ROOT::Experimental::Detail::RHistBinStat
Definition: RHistData.hxx:480
ROOT::Experimental::RHistDataMomentUncert::Fill
void Fill(const CoordArray_t &x, int, Weight_t weight=1.)
Add weight to the bin at binidx; the coordinate was x.
Definition: RHistData.hxx:421
BASES
ROOT::Experimental::RHistStatRuntime::Fill
void Fill(const CoordArray_t &x, int binidx, Weight_t weight=1.)
Definition: RHistData.hxx:471
ROOT::Experimental::RHistStatTotalSumOfSquaredWeights::Weight_t
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:232
x
Double_t x[n]
Definition: legend1.C:17
ROOT::Experimental::Detail::RHistData::GetNDim
static constexpr int GetNDim() noexcept
Number of dimensions of the coordinates.
Definition: RHistData.hxx:549
ROOT::Experimental::RHistStatContent::RConstBinStat::fContent
PRECISION fContent
The content of this bin.
Definition: RHistData.hxx:67
ROOT::Experimental::RHistStatContent::Add
void Add(const RHistStatContent &other)
Merge with other RHistStatContent, assuming same bin configuration.
Definition: RHistData.hxx:165
ROOT::Experimental::RHistStatContent::GetOverflowContentArray
const Content_t & GetOverflowContentArray() const
Retrieve the under-/overflow content array.
Definition: RHistData.hxx:160
ROOT::Experimental::RHistStatUncertainty
Definition: RHistData.hxx:271
ROOT::Experimental::RHistStatTotalSumOfWeights::Fill
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
Definition: RHistData.hxx:211
ROOT::Experimental::RHistStatContent::RBinStat::fContent
PRECISION & fContent
The content of this bin.
Definition: RHistData.hxx:80
ROOT::Experimental::RHistStatContent::Weight_t
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:53
b
#define b(i)
Definition: RSha256.hxx:118
ROOT::Experimental::Detail::RHistData::Fill
void Fill(const CoordArray_t &x, int binidx, Weight_t weight=1.)
Fill weight at x to the bin content at binidx.
Definition: RHistData.hxx:558
ROOT::Experimental::RHistStatUncertainty::RConstBinStat::GetUncertaintyImpl
double GetUncertaintyImpl() const
Definition: RHistData.hxx:290
ROOT::Experimental::Detail::RHistData::HaveUncertainty
static auto HaveUncertainty(const T *This) -> decltype(This->GetBinUncertaintyImpl(12))
Check whether double T::GetBinUncertaintyImpl(int) can be called.
ROOT::Experimental::RHistStatUncertainty::RHistStatUncertainty
RHistStatUncertainty()=default
ROOT::Experimental::RHistStatTotalSumOfWeights::RHistStatTotalSumOfWeights
RHistStatTotalSumOfWeights()=default
ROOT::Experimental::RHistStatUncertainty::GetBinArray
Weight_t GetBinArray(int binidx) const
Get a reference to the bin corresponding to binidx of the correct bin content array i....
Definition: RHistData.hxx:327
ROOT::Experimental::RHistStatTotalSumOfSquaredWeights::Fill
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
Definition: RHistData.hxx:255
ROOT::Experimental::RHistStatTotalSumOfWeights::Weight_t
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:188
ROOT::Experimental::RHistStatTotalSumOfWeights
Definition: RHistData.hxx:183
ROOT::Experimental::RHistStatContent::fBinContent
Content_t fBinContent
Bin content.
Definition: RHistData.hxx:91
ROOT::Experimental::RHistStatUncertainty::RBinStat::GetUncertaintyImpl
double GetUncertaintyImpl() const
Definition: RHistData.hxx:305
ROOT::Experimental::Detail::RHistData::GetBinUncertainty
double GetBinUncertainty(int binidx) const
Calculate the bin content's uncertainty for the given bin, using base class information,...
Definition: RHistData.hxx:603
ROOT::Experimental::Detail::RHistData::Hist_t
RHist< DIMENSIONS, PRECISION, STAT... > Hist_t
Matching RHist.
Definition: RHistData.hxx:533
ROOT::Experimental::Detail::RHistData::Add
void Add(const OtherData &other)
Integrate other statistical data into the current data.
Definition: RHistData.hxx:584
ROOT::Experimental::RHistStatUncertainty::Weight_t
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:277
ROOT::Experimental::RHistStatContent::sizeNoOver
size_t sizeNoOver() const noexcept
Get the number of bins exluding under- and overflow.
Definition: RHistData.hxx:136
ROOT::Math::fabs
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Definition: UnaryOperators.h:131
ROOT::Experimental::RHistStatUncertainty::RBinStat::GetSumW2
PRECISION & GetSumW2() const
Definition: RHistData.hxx:303
ROOT::Experimental::RHistStatContent::Content_t
std::vector< PRECISION > Content_t
Type of the bin content array.
Definition: RHistData.hxx:55
ROOT::Experimental::RHistDataMomentUncert
Definition: RHistData.hxx:390
ROOT::Experimental::RHistStatUncertainty::RBinStat
Definition: RHistData.hxx:300
ROOT::Experimental::RHistStatContent::RBinStat
Definition: RHistData.hxx:74
ROOT::Experimental::Detail::RHistData::HistBinStat_t
RHistBinStat< RHistData, typename STAT< DIMENSIONS, PRECISION >::BinStat_t... > HistBinStat_t
The type of a modifying view on a bin.
Definition: RHistData.hxx:546
ROOT::Experimental::RHistStatUncertainty::RConstBinStat::fSumW2
PRECISION fSumW2
The bin's sum of square of weights.
Definition: RHistData.hxx:293
ROOT::Experimental::RHistStatContent::RConstBinStat::RConstBinStat
RConstBinStat(const RHistStatContent &stat, int index)
Definition: RHistData.hxx:63
ROOT::Experimental::RHistStatUncertainty::RConstBinStat
Definition: RHistData.hxx:285
ROOT::Experimental::Detail::RHistData::Weight_t
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:536
ROOT::Experimental::RHistStatUncertainty::Add
void Add(const RHistStatUncertainty &other)
Merge with other RHistStatUncertainty data, assuming same bin configuration.
Definition: RHistData.hxx:374
ROOT::Experimental::RHistStatContent::fEntries
int64_t fEntries
Number of calls to Fill().
Definition: RHistData.hxx:88
ROOT::Experimental::RHistStatUncertainty::RConstBinStat::RConstBinStat
RConstBinStat(const RHistStatUncertainty &stat, int index)
Definition: RHistData.hxx:287
ROOT::Experimental::RHistStatUncertainty::fOverflowSumWeightsSquared
Content_t fOverflowSumWeightsSquared
Uncertainty of the under-/overflow content.
Definition: RHistData.hxx:318
ROOT::Experimental::RHistStatRuntime::DoFill
virtual void DoFill(const CoordArray_t &x, int binidx, Weight_t weightN)=0
ROOT::Experimental::RHistStatContent::GetContentArray
const Content_t & GetContentArray() const
Retrieve the content array.
Definition: RHistData.hxx:155
STAT
ROOT::Experimental::RHistStatRuntime::Weight_t
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:450
ROOT::Experimental::RHistStatContent::GetBinArray
Weight_t & GetBinArray(int binidx)
Get a reference to the bin corresponding to binidx of the correct bin content array (non-const) i....
Definition: RHistData.hxx:115
ROOT::Experimental::RHistStatUncertainty::RBinStat::fSumW2
PRECISION & fSumW2
The bin's sum of square of weights.
Definition: RHistData.hxx:308
ROOT::Experimental::RHistStatRuntime::~RHistStatRuntime
virtual ~RHistStatRuntime()=default
ROOT::Experimental::RHistStatTotalSumOfSquaredWeights::fSumWeights2
PRECISION fSumWeights2
Sum of (weights^2).
Definition: RHistData.hxx:248
sqrt
double sqrt(double)
ROOT::Experimental::Hist::RCoordArray
Definition: RHistUtils.hxx:44
void
typedef void((*Func_t)())
ROOT::Experimental::RHistStatContent::size
size_t size() const noexcept
Get the number of bins including under- and overflow..
Definition: RHistData.hxx:139
ROOT::Experimental::RHistStatRuntime::RHistStatRuntime
RHistStatRuntime()=default
ROOT::Experimental::Detail::RHistData::GetView
ConstHistBinStat_t GetView(int idx) const
Get a view on the statistics values of a bin.
Definition: RHistData.hxx:618
ROOT::Experimental::Detail::RHistBinStat::RHistBinStat
RHistBinStat(DATA &data, int index)
Definition: RHistData.hxx:490
ROOT::Experimental::RHistStatContent::GetBinContent
Weight_t GetBinContent(int binidx) const
Get the bin content for the given bin.
Definition: RHistData.hxx:150
ROOT::Experimental::RHistStatContent::RConstBinStat
Definition: RHistData.hxx:61
ROOT::Experimental::RHistStatUncertainty::RBinStat::RBinStat
RBinStat(RHistStatUncertainty &stat, int index)
Definition: RHistData.hxx:302
ROOT::Experimental::RHistStatTotalSumOfWeights::fSumWeights
PRECISION fSumWeights
Sum of weights.
Definition: RHistData.hxx:204
ROOT::Experimental::RHistStatUncertainty::GetSumOfSquaredWeights
const std::vector< double > & GetSumOfSquaredWeights() const
Get the structure holding the sum of squares of weights.
Definition: RHistData.hxx:364
ROOT::Experimental::RHistStatTotalSumOfWeights::GetSumOfWeights
Weight_t GetSumOfWeights() const
Get the sum of weights.
Definition: RHistData.hxx:214
ROOT::Experimental::Detail::RHistBinStat::GetUncertainty
double GetUncertainty() const
Calculate the bin content's uncertainty for the given bin, using base class information,...
Definition: RHistData.hxx:503
ROOT::Experimental::RHistStatContent::RBinStat::RBinStat
RBinStat(RHistStatContent &stat, int index)
Definition: RHistData.hxx:76
ROOT::Experimental::RHistStatContent::GetBinArray
Weight_t GetBinArray(int binidx) const
Get a reference to the bin corresponding to binidx of the correct bin content array i....
Definition: RHistData.hxx:103
ROOT::Experimental::RHistStatUncertainty::ConstBinStat_t
RConstBinStat ConstBinStat_t
Definition: RHistData.hxx:311
ROOT::Experimental::RHistDataMomentUncert::RBinStat::RBinStat
RBinStat(const RHistDataMomentUncert &, int)
Definition: RHistData.hxx:405
ROOT::Experimental::RHistStatUncertainty::Content_t
std::vector< PRECISION > Content_t
Type of the bin content array.
Definition: RHistData.hxx:279
ROOT::Experimental::RHistStatRuntime::RBinStat::RBinStat
RBinStat(const RHistStatRuntime &, int)
Definition: RHistData.hxx:460
ROOT::Experimental::RHistStatTotalSumOfSquaredWeights::RBinStat::RBinStat
RBinStat(const RHistStatTotalSumOfSquaredWeights &, int)
Definition: RHistData.hxx:240
ROOT::Experimental::RHistDataMomentUncert::RBinStat
Definition: RHistData.hxx:403
ROOT::Experimental::Detail::RHistData::RHistData
RHistData()=default
ROOT::Experimental::RHistStatContent::RConstBinStat::GetContent
PRECISION GetContent() const
Definition: RHistData.hxx:64
ROOT::Experimental::RHistStatUncertainty::GetBinUncertaintyImpl
double GetBinUncertaintyImpl(int binidx) const
Calculate a bin's (Poisson) uncertainty of the bin content as the square-root of the bin's sum of squ...
Definition: RHistData.hxx:356
ROOT::Experimental::RHistStatContent
Definition: RHistData.hxx:48
ROOT::Experimental::RHistStatRuntime::RBinStat
Definition: RHistData.hxx:458
ROOT::Math::Chebyshev::T
double T(double x)
Definition: ChebyshevPol.h:52
d
#define d(i)
Definition: RSha256.hxx:120
ROOT::Experimental::RHistStatContent::operator[]
Weight_t operator[](int binidx) const
Get the bin content for the given bin.
Definition: RHistData.hxx:145
ROOT::Experimental::RHistStatTotalSumOfSquaredWeights::GetSumOfSquaredWeights
Weight_t GetSumOfSquaredWeights() const
Get the sum of weights.
Definition: RHistData.hxx:258
ROOT::Experimental::Detail::RHistBinStat::HaveUncertainty
static auto HaveUncertainty(const T *This) -> decltype(This->GetUncertaintyImpl())
Check whether double T::GetBinUncertaintyImpl(int) can be called.
ROOT::Experimental::RHistStatTotalSumOfSquaredWeights
Definition: RHistData.hxx:227
ROOT::Experimental::RHist
Definition: RHist.hxx:44
ROOT::Experimental::Add
void Add(RHist< DIMENSIONS, PRECISION, STAT_TO... > &to, const RHist< DIMENSIONS, PRECISION, STAT_FROM... > &from)
Add two histograms.
Definition: RHist.hxx:335
ROOT::Experimental::RHistStatContent::Fill
void Fill(const CoordArray_t &, int binidx, Weight_t weight=1.)
Add weight to the bin content at binidx.
Definition: RHistData.hxx:125
PRECISION
#define PRECISION
Definition: MnPrint.cxx:26
RSpan.hxx
ROOT::Experimental::RHistStatContent::CoordArray_t
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
Definition: RHistData.hxx:51
ROOT::Experimental::RHistDataMomentUncert::Add
void Add(const RHistDataMomentUncert &other)
Merge with other RHistDataMomentUncert data, assuming same bin configuration.
Definition: RHistData.hxx:433
for
for(Int_t i=0;i< n;i++)
Definition: legend1.C:18
RHistUtils.hxx
ROOT::Experimental::RHistStatContent::fOverflowBinContent
Content_t fOverflowBinContent
Under- and overflow bin content.
Definition: RHistData.hxx:94
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::Detail::RHistData::ConstHistBinStat_t
RHistBinStat< const RHistData, typename STAT< DIMENSIONS, PRECISION >::ConstBinStat_t... > ConstHistBinStat_t
The type of a non-modifying view on a bin.
Definition: RHistData.hxx:543
ROOT::Experimental::Detail::RHistData::HasBinUncertainty
static constexpr bool HasBinUncertainty()
Whether this provides storage for uncertainties, or whether uncertainties are determined as poisson u...
Definition: RHistData.hxx:593
ROOT::Experimental::RHistDataMomentUncert::fMomentXW
std::array< Weight_t, DIMENSIONS > fMomentXW
Definition: RHistData.hxx:412
ROOT::Experimental::RHistStatTotalSumOfSquaredWeights::RBinStat
Definition: RHistData.hxx:238
ROOT::Experimental::RHistStatTotalSumOfWeights::RBinStat::RBinStat
RBinStat(const RHistStatTotalSumOfWeights &, int)
Definition: RHistData.hxx:196
ROOT::Experimental::RHistStatTotalSumOfWeights::Add
void Add(const RHistStatTotalSumOfWeights &other)
Merge with other RHistStatTotalSumOfWeights data, assuming same bin configuration.
Definition: RHistData.hxx:217
ROOT::Experimental::RHistStatUncertainty::GetBinArray
Weight_t & GetBinArray(int binidx)
Get a reference to the bin corresponding to binidx of the correct bin content array (non-const) i....
Definition: RHistData.hxx:339