16 #ifndef ROOT7_THistData_h 17 #define ROOT7_THistData_h 25 namespace Experimental {
27 template <
int DIMENSIONS,
class PRECISION,
28 template <
int D_,
class P_,
template <
class P__>
class STORAGE>
class... STAT>
36 template <
int DIMENSIONS,
class PRECISION,
template <
class PRECISION_>
class STORAGE>
89 fBinContent[binidx] += weight;
98 size_t size() const noexcept {
return fBinContent.size(); }
120 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
142 PRECISION fSumWeights = 0;
159 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
181 PRECISION fSumWeights2 = 0;
198 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
253 fSumWeightsSquared[binidx] += weight * weight;
275 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
308 for (
int idim = 0; idim < DIMENSIONS; ++idim) {
309 const PRECISION xw = x[idim] * weight;
310 fMomentXW[idim] += xw;
311 fMomentX2W[idim] += x[idim] * xw;
319 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
353 template <
class PRECISION>
359 template <
class DATA,
class... BASES>
364 static auto HaveUncertainty(
const T *This) -> decltype(This->GetUncertaintyImpl());
367 static char HaveUncertainty(...);
376 struct AllYourBaseAreBelongToUs:
public BASES... {
378 return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(
nullptr)) ==
sizeof(double);
385 return this->GetUncertaintyImpl();
401 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE,
402 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
403 class THistData:
public STAT<DIMENSIONS, PRECISION, STORAGE>... {
407 static auto HaveUncertainty(
const T *This) -> decltype(This->GetBinUncertaintyImpl(12));
410 static char HaveUncertainty(...);
430 static constexpr
int GetNDim() noexcept {
return DIMENSIONS; }
455 using trigger_base_fill =
int[];
456 (
void)trigger_base_fill{(STAT<DIMENSIONS, PRECISION, STORAGE>::Fill(x, binidx, weight), 0)...};
463 struct AllYourBaseAreBelongToUs:
public STAT<DIMENSIONS, PRECISION, STORAGE>... {
465 return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(
nullptr)) ==
sizeof(double);
473 return this->GetBinUncertaintyImpl(binidx);
No-op; this class does not provide per-bin statistics.
std::vector< PRECISION > THistDataDefaultStorage
std::vector has more template arguments; for the default storage we don't care about them...
THistStatTotalSumOfWeights(size_t)
PRECISION & GetSumW2() const
No-op; this class does not provide per-bin statistics.
void Fill(const CoordArray_t &x, int, Weight_t weight=1.)
Add weight to the bin at binidx; the coordinate was x.
Namespace for new ROOT classes and functions.
PRECISION & GetContent() const
void Fill(const CoordArray_t &, int binidx, Weight_t weight=1.)
Add weight to the bin at binidx; the coordinate was x.
static constexpr bool HasBinUncertainty()
Whether this provides storage for uncertainties, or whether uncertainties are determined as poisson u...
double GetBinUncertainty(int binidx) const
Calculate the bin content's uncertainty for the given bin, using base class information, i.e.
std::array< Weight_t, DIMENSIONS > fMomentX2W
PRECISION Weight_t
The type of the weight and the bin content.
TBinStat(const THistDataMomentUncert &, int)
PRECISION fSumW2
The bin's sum of square of weights.
static constexpr bool HasBinUncertainty()
Whether this provides storage for uncertainties, or whether uncertainties are determined as poisson u...
TBinStat(THistStatContent &stat, int index)
Keeps track of the histogram's total sum of weights.
int64_t fEntries
Number of calls to Fill().
void Fill(const CoordArray_t &x, int binidx, Weight_t weight=1.)
STORAGE< PRECISION > Content_t
Type of the bin content array.
PRECISION Weight_t
The type of the weight and the bin content.
Weight_t & GetSumOfSquaredWeights(int binidx)
Get a bin's sum of squared weights.
THistDataMomentUncert(size_t)
TBinStat(THistStatUncertainty &stat, int index)
THistStatContent(size_t in_size)
THistStatUncertainty(size_t size)
Modifying view on a THistStatUncertainty for a given bin.
static constexpr int GetNDim() noexcept
Number of dimensions of the coordinates.
const Content_t & GetContentArray() const
Retrieve the content array.
std::array< Weight_t, DIMENSIONS > fMomentXW
PRECISION Weight_t
The type of the weight and the bin content.
STORAGE< PRECISION > Content_t
Type of the bin content array.
PRECISION fContent
The content of this bin.
Interface implementing a pure virtual functions DoFill(), DoFillN().
HistBinStat_t GetView(int idx)
Get a (non-const) view on the statistics values of a bin.
Weight_t GetSumOfSquaredWeights() const
Get the sum of weights.
STORAGE< PRECISION > Content_t
Type of the bin content array.
size_t size() const noexcept
Get the number of bins.
PRECISION GetContent() const
Weight_t GetBinContent(int idx) const
Get the bin content for the given bin.
PRECISION Weight_t
The type of the weight and the bin content.
Weight_t operator[](int idx) const
Get the bin content for the given bin.
double GetUncertainty() const
Calculate the bin content's uncertainty for the given bin, using base class information, i.e.
double GetBinUncertainty(int binidx,...) const
Calculate the bin content's uncertainty for the given bin, using Poisson statistics on the absolute b...
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
TBinStat(const THistStatTotalSumOfWeights &, int)
PRECISION Weight_t
The type of the weight and the bin content.
Weight_t GetSumOfSquaredWeights(int binidx) const
Get a bin's sum of squared weights.
A THistImplBase's data, provides accessors to all its statistics.
Weight_t & GetBinContent(int idx)
Get the bin content for the given bin (non-const).
PRECISION & fContent
The content of this bin.
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...
TConstBinStat(const THistStatUncertainty &stat, int index)
void Fill(const CoordArray_t &, int binidx, Weight_t weight=1.)
Add weight to the bin content at binidx.
const std::vector< double > & GetSumOfSquaredWeights() const
Get the structure holding the sum of squares of weights.
int64_t GetEntries() const
Get the number of entries filled into the histogram - i.e.
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
PRECISION & fSumW2
The bin's sum of square of weights.
PRECISION GetSumW2() const
TBinStat(const THistStatTotalSumOfSquaredWeights &, int)
No-op; this class does not provide per-bin statistics.
Const view on a bin's statistical data.
THistStatTotalSumOfSquaredWeights(size_t)
Const view on a THistStatContent for a given bin.
TConstBinStat(const THistStatContent &stat, int index)
Weight_t & operator[](int idx)
Get the bin content for the given bin (non-const).
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
void Fill(const CoordArray_t &x, int binidx, Weight_t weight=1.)
Fill weight at x to the bin content at binidx.
THistBinStat(DATA &data, int index)
std::vector< double > & GetSumOfSquaredWeights()
Get the structure holding the sum of squares of weights (non-const).
No-op; this class does not provide per-bin statistics.
typedef void((*Func_t)())
THistStatContent()=default
Histogram statistics to keep track of the Poisson uncertainty per bin.
Content_t fSumWeightsSquared
Uncertainty of the content for each bin.
Basic histogram statistics, keeping track of the bin content and the total number of calls to Fill()...
TBinStat(const THistStatRuntime &, int)
STORAGE< PRECISION > Content_t
Type of the bin content array.
Modifying view on a THistStatContent for a given bin.
PRECISION Weight_t
The type of the weight and the bin content.
Content_t fBinContent
Bin content.
For now do as TH1: calculate first (xw) and second (x^2w) moment.
double GetUncertainty(...) const
Calculate the bin content's uncertainty for the given bin, using Poisson statistics on the absolute b...
Content_t & GetContentArray()
Retrieve the content array (non-const).
PRECISION Weight_t
The type of the weight and the bin content.
double GetUncertaintyImpl() const
Weight_t GetSumOfWeights() const
Get the sum of weights.
Const view on a THistStatUncertainty for a given bin.
double GetUncertaintyImpl() const
THistData(size_t size)
Constructor providing the number of bins (incl under, overflow) to the base classes.
Keeps track of the histogram's total sum of squared weights.
ConstHistBinStat_t GetView(int idx) const
Get a view on the statistics values of a bin.