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>
120 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
159 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
198 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
275 template <
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
308 for (
int idim = 0; idim < DIMENSIONS; ++idim) {
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());
376 struct AllYourBaseAreBelongToUs:
public BASES... {
378 return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(
nullptr)) ==
sizeof(double);
382 template <bool B = true, class = typename std::enable_if<B && HasBinUncertainty()>::type>
385 return this->GetUncertaintyImpl();
390 template <bool B = true, class = typename std::enable_if<B && !HasBinUncertainty()>::type>
393 auto content = this->GetContent();
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));
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);
470 template <bool B = true, class = typename std::enable_if<B && HasBinUncertainty()>::type>
473 return this->GetBinUncertaintyImpl(binidx);
478 template <bool B = true, class = typename std::enable_if<B && !HasBinUncertainty()>::type>
481 auto content = this->GetBinContent(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)
static auto HaveUncertainty(const T *This) -> decltype(This->GetUncertaintyImpl())
Check whether double T::GetBinUncertaintyImpl(int) can be called.
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.
PRECISION fSumWeights2
Sum of (weights^2).
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.
THistStatRuntime()=default
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.
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
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.
THistStatTotalSumOfWeights()=default
THistStatTotalSumOfSquaredWeights()=default
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.
THistStatUncertainty()=default
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.
virtual ~THistStatRuntime()=default
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.
static auto HaveUncertainty(const T *This) -> decltype(This->GetBinUncertaintyImpl(12))
Check whether double T::GetBinUncertaintyImpl(int) can be called.
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 valu...
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.
virtual void DoFill(const CoordArray_t &x, int binidx, Weight_t weightN)=0
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).
PRECISION fSumWeights
Sum of weights.
void Fill(const CoordArray_t &, int, Weight_t weight=1.)
Add weight to the bin content at binidx.
THistDataMomentUncert()=default
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...
THistBinStat< const THistData, typename STAT< DIMENSIONS, PRECISION, STORAGE >::ConstBinStat_t... > ConstHistBinStat_t
The type of a non-modifying view on a bin.
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.
THistBinStat< THistData, typename STAT< DIMENSIONS, PRECISION, STORAGE >::BinStat_t... > HistBinStat_t
The type of a modifying view on a bin.
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.