Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RHistData.hxx
Go to the documentation of this file.
1/// \file ROOT/RHistData.hxx
2/// \ingroup HistV7
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
24namespace ROOT {
25namespace Experimental {
26
27template <int DIMENSIONS, class PRECISION, template <int D_, class P_> class... STAT>
28class 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 */
35template <int DIMENSIONS, class PRECISION>
37public:
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 */
50 public:
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:
65 PRECISION &GetContent() const { return fContent; }
66
67 private:
68 PRECISION &fContent; ///< The content of this bin.
69 };
70
73
74private:
75 /// Number of calls to Fill().
76 int64_t fEntries = 0;
77
78 /// Bin content.
80
81 /// Under- and overflow bin content.
83
84public:
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.
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.
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)
163 }
164};
165
166/**
167 \class RHistStatTotalSumOfWeights
168 Keeps track of the histogram's total sum of weights.
169 */
170template <int DIMENSIONS, class PRECISION>
172public:
173 /// The type of a (possibly multi-dimensional) coordinate.
175 /// The type of the weight and the bin content.
177
178 /**
179 \class RBinStat
180 No-op; this class does not provide per-bin statistics.
181 */
182 class RBinStat {
183 public:
185 };
186
189
190private:
191 /// Sum of weights.
193
194public:
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.
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 */
214template <int DIMENSIONS, class PRECISION>
216public:
217 /// The type of a (possibly multi-dimensional) coordinate.
219 /// The type of the weight and the bin content.
221
222 /**
223 \class RBinStat
224 No-op; this class does not provide per-bin statistics.
225 */
226 class RBinStat {
227 public:
229 };
230
233
234private:
235 /// Sum of (weights^2).
237
238public:
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.
247
248 /// Merge with other RHistStatTotalSumOfSquaredWeights data, assuming same bin configuration.
250 fSumWeights2 += other.fSumWeights2;
251 }
252};
253
254/**
255 \class RHistStatUncertainty
256 Histogram statistics to keep track of the Poisson uncertainty per bin.
257 */
258template <int DIMENSIONS, class PRECISION>
260
261public:
262 /// The type of a (possibly multi-dimensional) coordinate.
264 /// The type of the weight and the bin content.
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 */
274 public:
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:
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
301
302private:
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
308public:
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.
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)
369 for (size_t b = 0; b < fOverflowSumWeightsSquared.size(); ++b)
371 }
372};
373
374/** \class RHistDataMomentUncert
375 For now do as `RH1`: calculate first (xw) and second (x^2w) moment.
376*/
377template <int DIMENSIONS, class PRECISION>
379public:
380 /// The type of a (possibly multi-dimensional) coordinate.
382 /// The type of the weight and the bin content.
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
398
399private:
400 std::array<Weight_t, DIMENSIONS> fMomentXW;
401 std::array<Weight_t, DIMENSIONS> fMomentX2W;
402 // FIXME: Add sum(w.x.y)-style stats.
403
404public:
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 */
432template <int DIMENSIONS, class PRECISION>
434public:
435 /// The type of a (possibly multi-dimensional) coordinate.
437 /// The type of the weight and the bin content.
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
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
462namespace Detail {
463
464/** \class RHistBinStat
465 Const view on a bin's statistical data. Combines all STATs' BinStat_t views.
466 */
467template <class DATA, class... BASES>
468class RHistBinStat: public BASES... {
469private:
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
477public:
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 */
509template <int DIMENSIONS, class PRECISION, class STORAGE, template <int D_, class P_> class... STAT>
510class RHistData: public STAT<DIMENSIONS, PRECISION>... {
511private:
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
519public:
520 /// Matching `RHist`.
521 using Hist_t = RHist<DIMENSIONS, PRECISION, STAT...>;
522
523 /// The type of the weight and the bin content.
525
526 /// The type of a (possibly multi-dimensional) coordinate.
528
529 /// The type of a non-modifying view on a bin.
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
constexpr int PRECISION
Definition MnPrint.cxx:30
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Const view on a bin's statistical data.
static char HaveUncertainty(...)
Fall-back case for check whether double T::GetBinUncertaintyImpl(int) can be called.
static auto HaveUncertainty(const T *This) -> decltype(This->GetUncertaintyImpl())
Check whether double T::GetBinUncertaintyImpl(int) can be called.
static constexpr bool HasBinUncertainty()
Whether this provides storage for uncertainties, or whether uncertainties are determined as poisson u...
double GetUncertainty(...) const
Calculate the bin content's uncertainty for the given bin, using Poisson statistics on the absolute b...
double GetUncertainty() const
Calculate the bin content's uncertainty for the given bin, using base class information,...
A RHistImplBase's data, provides accessors to all its statistics.
static char HaveUncertainty(...)
Fall-back case for check whether double T::GetBinUncertaintyImpl(int) can be called.
RHistBinStat< const RHistData, typename STAT< DIMENSIONS, PRECISION >::ConstBinStat_t... > ConstHistBinStat_t
The type of a non-modifying view on a bin.
HistBinStat_t GetView(int idx)
Get a (non-const) view on the statistics values of a bin.
RHistData(size_t bin_size, size_t overflow_size)
Constructor providing the number of bins (incl under, overflow) to the base classes.
static constexpr bool HasBinUncertainty()
Whether this provides storage for uncertainties, or whether uncertainties are determined as poisson u...
void Add(const OtherData &other)
Integrate other statistical data into the current data.
ConstHistBinStat_t GetView(int idx) const
Get a view on the statistics values of a bin.
PRECISION Weight_t
The type of the weight and the bin content.
void Fill(const CoordArray_t &x, int binidx, Weight_t weight=1.)
Fill weight at x to the bin content at binidx.
double GetBinUncertainty(int binidx) const
Calculate the bin content's uncertainty for the given bin, using base class information,...
RHistBinStat< RHistData, typename STAT< DIMENSIONS, PRECISION >::BinStat_t... > HistBinStat_t
The type of a modifying view on a bin.
static constexpr int GetNDim() noexcept
Number of dimensions of the coordinates.
double GetBinUncertainty(int binidx,...) const
Calculate the bin content's uncertainty for the given bin, using Poisson statistics on the absolute b...
static auto HaveUncertainty(const T *This) -> decltype(This->GetBinUncertaintyImpl(12))
Check whether double T::GetBinUncertaintyImpl(int) can be called.
No-op; this class does not provide per-bin statistics.
RBinStat(const RHistDataMomentUncert &, int)
For now do as RH1: calculate first (xw) and second (x^2w) moment.
PRECISION Weight_t
The type of the weight and the bin content.
std::array< Weight_t, DIMENSIONS > fMomentX2W
void Add(const RHistDataMomentUncert &other)
Merge with other RHistDataMomentUncert data, assuming same bin configuration.
std::vector< PRECISION > Content_t
Type of the bin content array.
void Fill(const CoordArray_t &x, int, Weight_t weight=1.)
Add weight to the bin at binidx; the coordinate was x.
std::array< Weight_t, DIMENSIONS > fMomentXW
Modifying view on a RHistStatContent for a given bin.
Definition RHistData.hxx:62
RBinStat(RHistStatContent &stat, int index)
Definition RHistData.hxx:64
PRECISION & fContent
The content of this bin.
Definition RHistData.hxx:68
Const view on a RHistStatContent for a given bin.
Definition RHistData.hxx:49
RConstBinStat(const RHistStatContent &stat, int index)
Definition RHistData.hxx:51
PRECISION fContent
The content of this bin.
Definition RHistData.hxx:55
Basic histogram statistics, keeping track of the bin content and the total number of calls to Fill().
Definition RHistData.hxx:36
Weight_t & GetBinContent(int binidx)
Get the bin content for the given bin (non-const).
Content_t & GetOverflowContentArray()
Retrieve the under-/overflow content array (non-const).
size_t sizeUnderOver() const noexcept
Get the number of bins including under- and overflow..
Content_t & GetContentArray()
Retrieve the content array (non-const).
Content_t fBinContent
Bin content.
Definition RHistData.hxx:79
Weight_t operator[](int binidx) const
Get the bin content for the given bin.
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:91
RHistStatContent(size_t bin_size, size_t overflow_size)
Definition RHistData.hxx:86
Weight_t & operator[](int binidx)
Get the bin content for the given bin (non-const).
std::vector< PRECISION > Content_t
Type of the bin content array.
Definition RHistData.hxx:43
const Content_t & GetContentArray() const
Retrieve the content array.
int64_t GetEntries() const
Get the number of entries filled into the histogram - i.e.
void Add(const RHistStatContent &other)
Merge with other RHistStatContent, assuming same bin configuration.
int64_t fEntries
Number of calls to Fill().
Definition RHistData.hxx:76
size_t size() const noexcept
Get the number of bins including under- and overflow..
const Content_t & GetOverflowContentArray() const
Retrieve the under-/overflow content array.
Weight_t & GetBinArray(int binidx)
Get a reference to the bin corresponding to binidx of the correct bin content array (non-const) i....
void Fill(const CoordArray_t &, int binidx, Weight_t weight=1.)
Add weight to the bin content at binidx.
Content_t fOverflowBinContent
Under- and overflow bin content.
Definition RHistData.hxx:82
Weight_t GetBinContent(int binidx) const
Get the bin content for the given bin.
PRECISION Weight_t
The type of the weight and the bin content.
Definition RHistData.hxx:41
size_t sizeNoOver() const noexcept
Get the number of bins exluding under- and overflow.
No-op; this class does not provide per-bin statistics.
RBinStat(const RHistStatRuntime &, int)
Interface implementing a pure virtual functions DoFill(), DoFillN().
PRECISION Weight_t
The type of the weight and the bin content.
std::vector< PRECISION > Content_t
Type of the bin content array.
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.)
No-op; this class does not provide per-bin statistics.
RBinStat(const RHistStatTotalSumOfSquaredWeights &, int)
Keeps track of the histogram's total sum of squared weights.
void Add(const RHistStatTotalSumOfSquaredWeights &other)
Merge with other RHistStatTotalSumOfSquaredWeights data, assuming same bin configuration.
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
PRECISION Weight_t
The type of the weight and the bin content.
Weight_t GetSumOfSquaredWeights() const
Get the sum of weights.
No-op; this class does not provide per-bin statistics.
RBinStat(const RHistStatTotalSumOfWeights &, int)
Keeps track of the histogram's total sum of weights.
Weight_t GetSumOfWeights() const
Get the sum of weights.
PRECISION Weight_t
The type of the weight and the bin content.
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
void Add(const RHistStatTotalSumOfWeights &other)
Merge with other RHistStatTotalSumOfWeights data, assuming same bin configuration.
Modifying view on a RHistStatUncertainty for a given bin.
PRECISION & fSumW2
The bin's sum of square of weights.
RBinStat(RHistStatUncertainty &stat, int index)
Const view on a RHistStatUncertainty for a given bin.
RConstBinStat(const RHistStatUncertainty &stat, int index)
PRECISION fSumW2
The bin's sum of square of weights.
Histogram statistics to keep track of the Poisson uncertainty per bin.
Content_t fOverflowSumWeightsSquared
Uncertainty of the under-/overflow content.
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...
const std::vector< double > & GetSumOfSquaredWeights() const
Get the structure holding the sum of squares of weights.
void Add(const RHistStatUncertainty &other)
Merge with other RHistStatUncertainty data, assuming same bin configuration.
std::vector< double > & GetSumOfSquaredWeights()
Get the structure holding the sum of squares of weights (non-const).
Weight_t GetSumOfSquaredWeights(int binidx) const
Get a bin's sum of squared weights.
Content_t fSumWeightsSquared
Uncertainty of the content for each bin excluding under-/overflow.
std::vector< double > & GetOverflowSumOfSquaredWeights()
Get the structure holding the under-/overflow sum of squares of weights (non-const).
Weight_t & GetBinArray(int binidx)
Get a reference to the bin corresponding to binidx of the correct bin content array (non-const) i....
Weight_t GetBinArray(int binidx) const
Get a reference to the bin corresponding to binidx of the correct bin content array i....
RHistStatUncertainty(size_t bin_size, size_t overflow_size)
Weight_t & GetSumOfSquaredWeights(int binidx)
Get a bin's sum of squared weights.
std::vector< PRECISION > Content_t
Type of the bin content array.
const std::vector< double > & GetOverflowSumOfSquaredWeights() const
Get the structure holding the under-/overflow sum of squares of weights.
PRECISION Weight_t
The type of the weight and the bin content.
void Fill(const CoordArray_t &, int binidx, Weight_t weight=1.)
Add weight to the bin at binidx; the coordinate was x.
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
Definition RHist.hxx:53
Double_t x[n]
Definition legend1.C:17
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...