16#ifndef ROOT7_RHistData_h
17#define ROOT7_RHistData_h
25namespace Experimental {
27template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_>
class... STAT>
35template <
int DIMENSIONS,
class PRECISION>
119template <
int DIMENSIONS,
class PRECISION>
158template <
int DIMENSIONS,
class PRECISION>
197template <
int DIMENSIONS,
class PRECISION>
274template <
int DIMENSIONS,
class PRECISION>
307 for (
int idim = 0; idim < DIMENSIONS; ++idim) {
318template <
int DIMENSIONS,
class PRECISION>
353template <
class DATA,
class... BASES>
370 struct AllYourBaseAreBelongToUs:
public BASES... {
372 return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(
nullptr)) ==
sizeof(
double);
376 template <
bool B = true,
class =
typename std::enable_if<B && HasBinUncerta
inty()>::type>
379 return this->GetUncertaintyImpl();
384 template <
bool B = true,
class =
typename std::enable_if<B && !HasBinUncerta
inty()>::type>
387 auto content = this->GetContent();
395template <
int DIMENSIONS,
class PRECISION,
class STORAGE,
template <
int D_,
class P_>
class... STAT>
423 static constexpr int GetNDim() noexcept {
return DIMENSIONS; }
448 using trigger_base_fill =
int[];
449 (
void)trigger_base_fill{(STAT<DIMENSIONS, PRECISION>::Fill(
x, binidx, weight), 0)...};
456 struct AllYourBaseAreBelongToUs:
public STAT<DIMENSIONS, PRECISION>... {
458 return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(
nullptr)) ==
sizeof(
double);
463 template <
bool B = true,
class =
typename std::enable_if<B && HasBinUncerta
inty()>::type>
466 return this->GetBinUncertaintyImpl(binidx);
471 template <
bool B = true,
class =
typename std::enable_if<B && !HasBinUncerta
inty()>::type>
474 auto content = this->GetBinContent(binidx);
typedef void((*Func_t)())
Const view on a bin's statistical data.
static char HaveUncertainty(...)
Fall-back case for check whether double T::GetBinUncertaintyImpl(int) can be called.
RHistBinStat(DATA &data, int index)
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.
static constexpr bool HasBinUncertainty()
Whether this provides storage for uncertainties, or whether uncertainties are determined as poisson u...
RHistData(size_t size)
Constructor providing the number of bins (incl under, overflow) to the base classes.
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.
RHistDataMomentUncert()=default
PRECISION Weight_t
The type of the weight and the bin content.
std::array< Weight_t, DIMENSIONS > fMomentX2W
RHistDataMomentUncert(size_t)
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.
PRECISION & GetContent() const
RBinStat(RHistStatContent &stat, int index)
PRECISION & fContent
The content of this bin.
Const view on a RHistStatContent for a given bin.
RConstBinStat(const RHistStatContent &stat, int index)
PRECISION fContent
The content of this bin.
PRECISION GetContent() const
Basic histogram statistics, keeping track of the bin content and the total number of calls to Fill().
RHistStatContent(size_t in_size)
Weight_t GetBinContent(int idx) const
Get the bin content for the given bin.
Content_t & GetContentArray()
Retrieve the content array (non-const).
Content_t fBinContent
Bin content.
RHistStatContent()=default
std::vector< PRECISION > Content_t
Type of the bin content array.
const Content_t & GetContentArray() const
Retrieve the content array.
int64_t GetEntries() const
Get the number of entries filled into the histogram - i.e.
Weight_t & GetBinContent(int idx)
Get the bin content for the given bin (non-const).
int64_t fEntries
Number of calls to Fill().
size_t size() const noexcept
Get the number of bins.
void Fill(const CoordArray_t &, int binidx, Weight_t weight=1.)
Add weight to the bin content at binidx.
Weight_t & operator[](int idx)
Get the bin content for the given bin (non-const).
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.
No-op; this class does not provide per-bin statistics.
RBinStat(const RHistStatRuntime &, int)
Interface implementing a pure virtual functions DoFill(), DoFillN().
virtual ~RHistStatRuntime()=default
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.)
RHistStatRuntime()=default
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.
RHistStatTotalSumOfSquaredWeights()=default
RHistStatTotalSumOfSquaredWeights(size_t)
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
PRECISION fSumWeights2
Sum of (weights^2).
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.
RHistStatTotalSumOfWeights()=default
PRECISION Weight_t
The type of the weight and the bin content.
PRECISION fSumWeights
Sum of weights.
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
RHistStatTotalSumOfWeights(size_t)
Modifying view on a RHistStatUncertainty for a given bin.
double GetUncertaintyImpl() const
PRECISION & fSumW2
The bin's sum of square of weights.
RBinStat(RHistStatUncertainty &stat, int index)
PRECISION & GetSumW2() const
Const view on a RHistStatUncertainty for a given bin.
RConstBinStat(const RHistStatUncertainty &stat, int index)
PRECISION GetSumW2() const
PRECISION fSumW2
The bin's sum of square of weights.
double GetUncertaintyImpl() const
Histogram statistics to keep track of the Poisson uncertainty per 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...
const std::vector< double > & GetSumOfSquaredWeights() const
Get the structure holding the sum of squares of weights.
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.
RHistStatUncertainty(size_t size)
RHistStatUncertainty()=default
Weight_t & GetSumOfSquaredWeights(int binidx)
Get a bin's sum of squared weights.
std::vector< PRECISION > Content_t
Type of the bin content array.
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 ...
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Namespace for new ROOT classes and functions.