Logo ROOT   master
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>
37 public:
38  /// The type of a (possibly multi-dimensional) coordinate.
40  /// The type of the weight and the bin content.
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 
73 
74 private:
75  /// Number of calls to Fill().
76  int64_t fEntries = 0;
77 
78  /// Bin content.
80 
81 public:
82  RHistStatContent() = default;
83  RHistStatContent(size_t in_size): fBinContent(in_size) {}
84 
85  /// Add weight to the bin content at binidx.
86  void Fill(const CoordArray_t & /*x*/, int binidx, Weight_t weight = 1.)
87  {
88  fBinContent[binidx] += weight;
89  ++fEntries;
90  }
91 
92  /// Get the number of entries filled into the histogram - i.e. the number of
93  /// calls to Fill().
94  int64_t GetEntries() const { return fEntries; }
95 
96  /// Get the number of bins.
97  size_t size() const noexcept { return fBinContent.size(); }
98 
99  /// Get the bin content for the given bin.
100  Weight_t operator[](int idx) const { return fBinContent[idx]; }
101  /// Get the bin content for the given bin (non-const).
102  Weight_t &operator[](int idx) { return fBinContent[idx]; }
103 
104  /// Get the bin content for the given bin.
105  Weight_t GetBinContent(int idx) const { return fBinContent[idx]; }
106  /// Get the bin content for the given bin (non-const).
107  Weight_t &GetBinContent(int idx) { return fBinContent[idx]; }
108 
109  /// Retrieve the content array.
110  const Content_t &GetContentArray() const { return fBinContent; }
111  /// Retrieve the content array (non-const).
113 
114  /// Merge with other RHistStatContent, assuming same bin configuration
115  void Add(const RHistStatContent& other) {
116  assert(fBinContent.size() == other.fBinContent.size());
117  fEntries += other.fEntries;
118  for (size_t b = 0; b < fBinContent.size(); ++b)
119  fBinContent[b] += other.fBinContent[b];
120  }
121 };
122 
123 /**
124  \class RHistStatTotalSumOfWeights
125  Keeps track of the histogram's total sum of weights.
126  */
127 template <int DIMENSIONS, class PRECISION>
129 public:
130  /// The type of a (possibly multi-dimensional) coordinate.
132  /// The type of the weight and the bin content.
134 
135  /**
136  \class RBinStat
137  No-op; this class does not provide per-bin statistics.
138  */
139  class RBinStat {
140  public:
142  };
143 
146 
147 private:
148  /// Sum of weights.
150 
151 public:
152  RHistStatTotalSumOfWeights() = default;
154 
155  /// Add weight to the bin content at binidx.
156  void Fill(const CoordArray_t & /*x*/, int, Weight_t weight = 1.) { fSumWeights += weight; }
157 
158  /// Get the sum of weights.
160 
161  /// Merge with other RHistStatTotalSumOfWeights data, assuming same bin configuration
162  void Add(const RHistStatTotalSumOfWeights& other) {
163  fSumWeights += other.fSumWeights;
164  }
165 };
166 
167 /**
168  \class RHistStatTotalSumOfSquaredWeights
169  Keeps track of the histogram's total sum of squared weights.
170  */
171 template <int DIMENSIONS, class PRECISION>
173 public:
174  /// The type of a (possibly multi-dimensional) coordinate.
176  /// The type of the weight and the bin content.
178 
179  /**
180  \class RBinStat
181  No-op; this class does not provide per-bin statistics.
182  */
183  class RBinStat {
184  public:
186  };
187 
190 
191 private:
192  /// Sum of (weights^2).
194 
195 public:
198 
199  /// Add weight to the bin content at binidx.
200  void Fill(const CoordArray_t & /*x*/, int /*binidx*/, Weight_t weight = 1.) { fSumWeights2 += weight * weight; }
201 
202  /// Get the sum of weights.
204 
205  /// Merge with other RHistStatTotalSumOfSquaredWeights data, assuming same bin configuration
207  fSumWeights2 += other.fSumWeights2;
208  }
209 };
210 
211 /**
212  \class RHistStatUncertainty
213  Histogram statistics to keep track of the Poisson uncertainty per bin.
214  */
215 template <int DIMENSIONS, class PRECISION>
217 
218 public:
219  /// The type of a (possibly multi-dimensional) coordinate.
221  /// The type of the weight and the bin content.
223  /// Type of the bin content array.
224  using Content_t = std::vector<PRECISION>;
225 
226  /**
227  \class RConstBinStat
228  Const view on a RHistStatUncertainty for a given bin.
229  */
231  public:
232  RConstBinStat(const RHistStatUncertainty &stat, int index): fSumW2(stat.GetSumOfSquaredWeights(index)) {}
233  PRECISION GetSumW2() const { return fSumW2; }
234 
235  double GetUncertaintyImpl() const { return std::sqrt(std::abs(fSumW2)); }
236 
237  private:
238  PRECISION fSumW2; ///< The bin's sum of square of weights.
239  };
240 
241  /**
242  \class RBinStat
243  Modifying view on a RHistStatUncertainty for a given bin.
244  */
245  class RBinStat {
246  public:
247  RBinStat(RHistStatUncertainty &stat, int index): fSumW2(stat.GetSumOfSquaredWeights(index)) {}
248  PRECISION &GetSumW2() const { return fSumW2; }
249  // Can never modify this. Set GetSumW2() instead.
250  double GetUncertaintyImpl() const { return std::sqrt(std::abs(fSumW2)); }
251 
252  private:
253  PRECISION &fSumW2; ///< The bin's sum of square of weights.
254  };
255 
258 
259 private:
260  /// Uncertainty of the content for each bin.
261  Content_t fSumWeightsSquared; ///< Sum of squared weights
262 
263 public:
264  RHistStatUncertainty() = default;
266 
267  /// Add weight to the bin at binidx; the coordinate was x.
268  void Fill(const CoordArray_t & /*x*/, int binidx, Weight_t weight = 1.)
269  {
270  fSumWeightsSquared[binidx] += weight * weight;
271  }
272 
273  /// Calculate a bin's (Poisson) uncertainty of the bin content as the
274  /// square-root of the bin's sum of squared weights.
275  double GetBinUncertaintyImpl(int binidx) const { return std::sqrt(fSumWeightsSquared[binidx]); }
276 
277  /// Get a bin's sum of squared weights.
278  Weight_t GetSumOfSquaredWeights(int binidx) const { return fSumWeightsSquared[binidx]; }
279 
280  /// Get a bin's sum of squared weights.
281  Weight_t &GetSumOfSquaredWeights(int binidx) { return fSumWeightsSquared[binidx]; }
282 
283  /// Get the structure holding the sum of squares of weights.
284  const std::vector<double> &GetSumOfSquaredWeights() const { return fSumWeightsSquared; }
285  /// Get the structure holding the sum of squares of weights (non-const).
286  std::vector<double> &GetSumOfSquaredWeights() { return fSumWeightsSquared; }
287 
288  /// Merge with other RHistStatUncertainty data, assuming same bin configuration
289  void Add(const RHistStatUncertainty& other) {
290  assert(fSumWeightsSquared.size() == other.fSumWeightsSquared.size());
291  for (size_t b = 0; b < fSumWeightsSquared.size(); ++b)
293  }
294 };
295 
296 /** \class RHistDataMomentUncert
297  For now do as RH1: calculate first (xw) and second (x^2w) moment.
298 */
299 template <int DIMENSIONS, class PRECISION>
301 public:
302  /// The type of a (possibly multi-dimensional) coordinate.
304  /// The type of the weight and the bin content.
306  /// Type of the bin content array.
307  using Content_t = std::vector<PRECISION>;
308 
309  /**
310  \class RBinStat
311  No-op; this class does not provide per-bin statistics.
312  */
313  class RBinStat {
314  public:
316  };
317 
320 
321 private:
322  std::array<Weight_t, DIMENSIONS> fMomentXW;
323  std::array<Weight_t, DIMENSIONS> fMomentX2W;
324  // FIXME: Add sum(w.x.y)-style stats.
325 
326 public:
327  RHistDataMomentUncert() = default;
329 
330  /// Add weight to the bin at binidx; the coordinate was x.
331  void Fill(const CoordArray_t &x, int /*binidx*/, Weight_t weight = 1.)
332  {
333  for (int idim = 0; idim < DIMENSIONS; ++idim) {
334  const PRECISION xw = x[idim] * weight;
335  fMomentXW[idim] += xw;
336  fMomentX2W[idim] += x[idim] * xw;
337  }
338  }
339 
340  // FIXME: Add a way to query the inner data
341 
342  /// Merge with other RHistDataMomentUncert data, assuming same bin configuration
343  void Add(const RHistDataMomentUncert& other) {
344  for (size_t d = 0; d < DIMENSIONS; ++d) {
345  fMomentXW[d] += other.fMomentXW[d];
346  fMomentX2W[d] += other.fMomentX2W[d];
347  }
348  }
349 };
350 
351 /** \class RHistStatRuntime
352  Interface implementing a pure virtual functions DoFill(), DoFillN().
353  */
354 template <int DIMENSIONS, class PRECISION>
356 public:
357  /// The type of a (possibly multi-dimensional) coordinate.
359  /// The type of the weight and the bin content.
361  /// Type of the bin content array.
362  using Content_t = std::vector<PRECISION>;
363 
364  /**
365  \class RBinStat
366  No-op; this class does not provide per-bin statistics.
367  */
368  class RBinStat {
369  public:
370  RBinStat(const RHistStatRuntime &, int) {}
371  };
372 
375 
376  RHistStatRuntime() = default;
377  RHistStatRuntime(size_t) {}
378  virtual ~RHistStatRuntime() = default;
379 
380  virtual void DoFill(const CoordArray_t &x, int binidx, Weight_t weightN) = 0;
381  void Fill(const CoordArray_t &x, int binidx, Weight_t weight = 1.) { DoFill(x, binidx, weight); }
382 };
383 
384 namespace Detail {
385 
386 /** \class RHistBinStat
387  Const view on a bin's statistical data. Combines all STATs' BinStat_t views.
388  */
389 template <class DATA, class... BASES>
390 class RHistBinStat: public BASES... {
391 private:
392  /// Check whether `double T::GetBinUncertaintyImpl(int)` can be called.
393  template <class T>
394  static auto HaveUncertainty(const T *This) -> decltype(This->GetUncertaintyImpl());
395  /// Fall-back case for check whether `double T::GetBinUncertaintyImpl(int)` can be called.
396  template <class T>
397  static char HaveUncertainty(...);
398 
399 public:
400  RHistBinStat(DATA &data, int index): BASES(data, index)... {}
401 
402  /// Whether this provides storage for uncertainties, or whether uncertainties
403  /// are determined as poisson uncertainty of the content.
404  static constexpr bool HasBinUncertainty()
405  {
406  struct AllYourBaseAreBelongToUs: public BASES... {
407  };
408  return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(nullptr)) == sizeof(double);
409  }
410  /// Calculate the bin content's uncertainty for the given bin, using base class information,
411  /// i.e. forwarding to a base's `GetUncertaintyImpl()`.
413  double GetUncertainty() const
414  {
415  return this->GetUncertaintyImpl();
416  }
417  /// Calculate the bin content's uncertainty for the given bin, using Poisson
418  /// statistics on the absolute bin content. Only available if no base provides
419  /// this functionality. Requires GetContent().
421  double GetUncertainty(...) const
422  {
423  auto content = this->GetContent();
424  return std::sqrt(std::fabs(content));
425  }
426 };
427 
428 /** \class RHistData
429  A RHistImplBase's data, provides accessors to all its statistics.
430  */
431 template <int DIMENSIONS, class PRECISION, class STORAGE, template <int D_, class P_> class... STAT>
432 class RHistData: public STAT<DIMENSIONS, PRECISION>... {
433 private:
434  /// Check whether `double T::GetBinUncertaintyImpl(int)` can be called.
435  template <class T>
436  static auto HaveUncertainty(const T *This) -> decltype(This->GetBinUncertaintyImpl(12));
437  /// Fall-back case for check whether `double T::GetBinUncertaintyImpl(int)` can be called.
438  template <class T>
439  static char HaveUncertainty(...);
440 
441 public:
442  /// Matching RHist
443  using Hist_t = RHist<DIMENSIONS, PRECISION, STAT...>;
444 
445  /// The type of the weight and the bin content.
447 
448  /// The type of a (possibly multi-dimensional) coordinate.
450 
451  /// The type of a non-modifying view on a bin.
452  using ConstHistBinStat_t =
454 
455  /// The type of a modifying view on a bin.
457 
458  /// Number of dimensions of the coordinates
459  static constexpr int GetNDim() noexcept { return DIMENSIONS; }
460 
461  RHistData() = default;
462 
463  /// Constructor providing the number of bins (incl under, overflow) to the
464  /// base classes.
465  RHistData(size_t size): STAT<DIMENSIONS, PRECISION>(size)... {}
466 
467  /// Fill weight at x to the bin content at binidx.
468  void Fill(const CoordArray_t &x, int binidx, Weight_t weight = 1.)
469  {
470  // Call Fill() on all base classes.
471  // This combines a couple of C++ spells:
472  // - "STAT": is a template parameter pack of template template arguments. It
473  // has multiple (or one or no) elements; each is a template name
474  // that needs to be instantiated before it can be used.
475  // - "...": template parameter pack expansion; the expression is evaluated
476  // for each STAT. The expression is
477  // (STAT<DIMENSIONS, PRECISION>::Fill(x, binidx, weight), 0)
478  // - "trigger_base_fill{}":
479  // initialization, provides a context in which template parameter
480  // pack expansion happens.
481  // - ", 0": because Fill() returns void it cannot be used as initializer
482  // expression. The trailing ", 0" gives it the type of the trailing
483  // comma-separated expression - int.
484  using trigger_base_fill = int[];
485  (void)trigger_base_fill{(STAT<DIMENSIONS, PRECISION>::Fill(x, binidx, weight), 0)...};
486  }
487 
488  /// Integrate other statistical data into the current data.
489  ///
490  /// The implementation assumes that the other statistics were recorded with
491  /// the same binning configuration, and that the statistics of `OtherData`
492  /// are a superset of those recorded by the active `RHistData` instance.
493  template <typename OtherData>
494  void Add(const OtherData &other)
495  {
496  // Call Add() on all base classes, using the same tricks as Fill().
497  using trigger_base_add = int[];
498  (void)trigger_base_add{(STAT<DIMENSIONS, PRECISION>::Add(other), 0)...};
499  }
500 
501  /// Whether this provides storage for uncertainties, or whether uncertainties
502  /// are determined as poisson uncertainty of the content.
503  static constexpr bool HasBinUncertainty()
504  {
505  struct AllYourBaseAreBelongToUs: public STAT<DIMENSIONS, PRECISION>... {
506  };
507  return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(nullptr)) == sizeof(double);
508  }
509 
510  /// Calculate the bin content's uncertainty for the given bin, using base class information,
511  /// i.e. forwarding to a base's `GetBinUncertaintyImpl(binidx)`.
513  double GetBinUncertainty(int binidx) const
514  {
515  return this->GetBinUncertaintyImpl(binidx);
516  }
517  /// Calculate the bin content's uncertainty for the given bin, using Poisson
518  /// statistics on the absolute bin content. Only available if no base provides
519  /// this functionality. Requires GetContent().
521  double GetBinUncertainty(int binidx, ...) const
522  {
523  auto content = this->GetBinContent(binidx);
524  return std::sqrt(std::fabs(content));
525  }
526 
527  /// Get a view on the statistics values of a bin.
528  ConstHistBinStat_t GetView(int idx) const { return ConstHistBinStat_t(*this, idx); }
529  /// Get a (non-const) view on the statistics values of a bin.
530  HistBinStat_t GetView(int idx) { return HistBinStat_t(*this, idx); }
531 };
532 } // namespace Detail
533 
534 } // namespace Experimental
535 } // namespace ROOT
536 
537 #endif
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
Definition: RHistData.hxx:156
Keeps track of the histogram&#39;s total sum of squared weights.
Definition: RHistData.hxx:172
const std::vector< double > & GetSumOfSquaredWeights() const
Get the structure holding the sum of squares of weights.
Definition: RHistData.hxx:284
void Add(const RHistStatTotalSumOfWeights &other)
Merge with other RHistStatTotalSumOfWeights data, assuming same bin configuration.
Definition: RHistData.hxx:162
RBinStat(const RHistStatTotalSumOfSquaredWeights &, int)
Definition: RHistData.hxx:185
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:41
double GetUncertainty() const
Calculate the bin content&#39;s uncertainty for the given bin, using base class information, i.e.
Definition: RHistData.hxx:413
void Fill(const CoordArray_t &x, int binidx, Weight_t weight=1.)
Definition: RHistData.hxx:381
Returns the available number of logical cores.
Definition: StringConv.hxx:21
RHistBinStat< const RHistData, typename STAT< DIMENSIONS, PRECISION >::ConstBinStat_t... > ConstHistBinStat_t
The type of a non-modifying view on a bin.
Definition: RHistData.hxx:453
int64_t GetEntries() const
Get the number of entries filled into the histogram - i.e.
Definition: RHistData.hxx:94
Weight_t GetSumOfSquaredWeights() const
Get the sum of weights.
Definition: RHistData.hxx:203
ConstHistBinStat_t GetView(int idx) const
Get a view on the statistics values of a bin.
Definition: RHistData.hxx:528
Weight_t operator[](int idx) const
Get the bin content for the given bin.
Definition: RHistData.hxx:100
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:446
No-op; this class does not provide per-bin statistics.
Definition: RHistData.hxx:313
double T(double x)
Definition: ChebyshevPol.h:34
double GetBinUncertainty(int binidx,...) const
Calculate the bin content&#39;s uncertainty for the given bin, using Poisson statistics on the absolute b...
Definition: RHistData.hxx:521
RBinStat(RHistStatUncertainty &stat, int index)
Definition: RHistData.hxx:247
RHistData(size_t size)
Constructor providing the number of bins (incl under, overflow) to the base classes.
Definition: RHistData.hxx:465
Content_t fBinContent
Bin content.
Definition: RHistData.hxx:79
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a valu...
static constexpr int GetNDim() noexcept
Number of dimensions of the coordinates.
Definition: RHistData.hxx:459
Modifying view on a RHistStatContent for a given bin.
Definition: RHistData.hxx:62
Interface implementing a pure virtual functions DoFill(), DoFillN().
Definition: RHistData.hxx:355
Weight_t & GetSumOfSquaredWeights(int binidx)
Get a bin&#39;s sum of squared weights.
Definition: RHistData.hxx:281
Modifying view on a RHistStatUncertainty for a given bin.
Definition: RHistData.hxx:245
Weight_t GetSumOfWeights() const
Get the sum of weights.
Definition: RHistData.hxx:159
double GetBinUncertainty(int binidx) const
Calculate the bin content&#39;s uncertainty for the given bin, using base class information, i.e.
Definition: RHistData.hxx:513
No-op; this class does not provide per-bin statistics.
Definition: RHistData.hxx:183
double sqrt(double)
void Add(const RHistStatContent &other)
Merge with other RHistStatContent, assuming same bin configuration.
Definition: RHistData.hxx:115
void Add(const OtherData &other)
Integrate other statistical data into the current data.
Definition: RHistData.hxx:494
Double_t x[n]
Definition: legend1.C:17
Histogram statistics to keep track of the Poisson uncertainty per bin.
Definition: RHistData.hxx:216
#define PRECISION
Definition: MnPrint.cxx:26
Weight_t GetSumOfSquaredWeights(int binidx) const
Get a bin&#39;s sum of squared weights.
Definition: RHistData.hxx:278
PRECISION & fSumW2
The bin&#39;s sum of square of weights.
Definition: RHistData.hxx:253
void Add(RHist< DIMENSIONS, PRECISION, STAT_TO... > &to, const RHist< DIMENSIONS, PRECISION, STAT_FROM... > &from)
Add two histograms.
Definition: RHist.hxx:320
RConstBinStat(const RHistStatContent &stat, int index)
Definition: RHistData.hxx:51
std::array< Weight_t, DIMENSIONS > fMomentX2W
Definition: RHistData.hxx:323
RConstBinStat(const RHistStatUncertainty &stat, int index)
Definition: RHistData.hxx:232
std::array< Weight_t, DIMENSIONS > fMomentXW
Definition: RHistData.hxx:322
PRECISION fSumW2
The bin&#39;s sum of square of weights.
Definition: RHistData.hxx:238
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:133
std::vector< PRECISION > Content_t
Type of the bin content array.
Definition: RHistData.hxx:224
std::vector< PRECISION > Content_t
Type of the bin content array.
Definition: RHistData.hxx:43
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:305
PRECISION & fContent
The content of this bin.
Definition: RHistData.hxx:68
virtual void DoFill(const CoordArray_t &x, int binidx, Weight_t weightN)=0
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:468
RHistBinStat< RHistData, typename STAT< DIMENSIONS, PRECISION >::BinStat_t... > HistBinStat_t
The type of a modifying view on a bin.
Definition: RHistData.hxx:456
Weight_t GetBinContent(int idx) const
Get the bin content for the given bin.
Definition: RHistData.hxx:105
static auto HaveUncertainty(const T *This) -> decltype(This->GetBinUncertaintyImpl(12))
Check whether double T::GetBinUncertaintyImpl(int) can be called.
Weight_t & GetBinContent(int idx)
Get the bin content for the given bin (non-const).
Definition: RHistData.hxx:107
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
RBinStat(RHistStatContent &stat, int index)
Definition: RHistData.hxx:64
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:360
RBinStat(const RHistStatTotalSumOfWeights &, int)
Definition: RHistData.hxx:141
A RHistImplBase&#39;s data, provides accessors to all its statistics.
Definition: RHistData.hxx:432
std::vector< double > & GetSumOfSquaredWeights()
Get the structure holding the sum of squares of weights (non-const).
Definition: RHistData.hxx:286
void Fill(const CoordArray_t &, int binidx, Weight_t weight=1.)
Add weight to the bin content at binidx.
Definition: RHistData.hxx:86
static constexpr bool HasBinUncertainty()
Whether this provides storage for uncertainties, or whether uncertainties are determined as poisson u...
Definition: RHistData.hxx:503
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
Definition: RHistData.hxx:200
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
Definition: RHistData.hxx:358
static constexpr bool HasBinUncertainty()
Whether this provides storage for uncertainties, or whether uncertainties are determined as poisson u...
Definition: RHistData.hxx:404
std::vector< PRECISION > Content_t
Type of the bin content array.
Definition: RHistData.hxx:307
RBinStat(const RHistStatRuntime &, int)
Definition: RHistData.hxx:370
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:268
Basic histogram statistics, keeping track of the bin content and the total number of calls to Fill(...
Definition: RHistData.hxx:36
#define d(i)
Definition: RSha256.hxx:102
Keeps track of the histogram&#39;s total sum of weights.
Definition: RHistData.hxx:128
const Content_t & GetContentArray() const
Retrieve the content array.
Definition: RHistData.hxx:110
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:331
std::vector< PRECISION > Content_t
Type of the bin content array.
Definition: RHistData.hxx:362
Const view on a RHistStatContent for a given bin.
Definition: RHistData.hxx:49
int type
Definition: TGX11.cxx:120
RBinStat(const RHistDataMomentUncert &, int)
Definition: RHistData.hxx:315
Content_t fSumWeightsSquared
Uncertainty of the content for each bin.
Definition: RHistData.hxx:261
double GetBinUncertaintyImpl(int binidx) const
Calculate a bin&#39;s (Poisson) uncertainty of the bin content as the square-root of the bin&#39;s sum of squ...
Definition: RHistData.hxx:275
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:222
Content_t & GetContentArray()
Retrieve the content array (non-const).
Definition: RHistData.hxx:112
No-op; this class does not provide per-bin statistics.
Definition: RHistData.hxx:139
typedef void((*Func_t)())
int64_t fEntries
Number of calls to Fill().
Definition: RHistData.hxx:76
void Add(const RHistDataMomentUncert &other)
Merge with other RHistDataMomentUncert data, assuming same bin configuration.
Definition: RHistData.hxx:343
size_t size() const noexcept
Get the number of bins.
Definition: RHistData.hxx:97
For now do as RH1: calculate first (xw) and second (x^2w) moment.
Definition: RHistData.hxx:300
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
PRECISION Weight_t
The type of the weight and the bin content.
Definition: RHistData.hxx:177
HistBinStat_t GetView(int idx)
Get a (non-const) view on the statistics values of a bin.
Definition: RHistData.hxx:530
void Add(const RHistStatTotalSumOfSquaredWeights &other)
Merge with other RHistStatTotalSumOfSquaredWeights data, assuming same bin configuration.
Definition: RHistData.hxx:206
Weight_t & operator[](int idx)
Get the bin content for the given bin (non-const).
Definition: RHistData.hxx:102
static auto HaveUncertainty(const T *This) -> decltype(This->GetUncertaintyImpl())
Check whether double T::GetBinUncertaintyImpl(int) can be called.
void Add(const RHistStatUncertainty &other)
Merge with other RHistStatUncertainty data, assuming same bin configuration.
Definition: RHistData.hxx:289
double GetUncertainty(...) const
Calculate the bin content&#39;s uncertainty for the given bin, using Poisson statistics on the absolute b...
Definition: RHistData.hxx:421
No-op; this class does not provide per-bin statistics.
Definition: RHistData.hxx:368
Const view on a RHistStatUncertainty for a given bin.
Definition: RHistData.hxx:230
PRECISION fContent
The content of this bin.
Definition: RHistData.hxx:55
Const view on a bin&#39;s statistical data.
Definition: RHistData.hxx:390