15 #ifndef ROOT7_THistData_h
16 #define ROOT7_THistData_h
20 #include "ROOT/RArrayView.hxx"
24 namespace Experimental {
27 template <
int D_,
class P_,
template <
class P__>
class STORAGE>
class... STAT>
36 template <
class PRECISION_>
class STORAGE>
121 template<
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
164 template<
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
207 template<
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
291 template<
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
323 for (
int idim = 0; idim < DIMENSIONS; ++idim) {
335 template<
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
364 DoFill(x, binidx, weight);
373 template<
class PRECISION>
380 template <
class DATA,
class...BASES>
385 static auto HaveUncertainty(
const T* This) -> decltype(This->GetUncertaintyImpl());
392 BASES(data, index)... {}
397 struct AllYourBaseAreBelongToUs:
public BASES... {};
398 return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(
nullptr)) ==
sizeof(double);
402 template <
bool B =
true,
405 return this->GetUncertaintyImpl();
410 template <
bool B =
true,
413 auto content = this->GetContent();
422 template<
int DIMENSIONS,
class PRECISION,
423 template <
class P_>
class STORAGE,
424 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
425 class THistData:
public STAT<DIMENSIONS, PRECISION, STORAGE>... {
429 static auto HaveUncertainty(
const T* This) -> decltype(This->GetBinUncertaintyImpl(12));
453 static constexpr
int GetNDim() noexcept {
return DIMENSIONS; }
478 using trigger_base_fill =
int[];
485 struct AllYourBaseAreBelongToUs:
public STAT<DIMENSIONS, PRECISION, STORAGE>... {};
486 return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(
nullptr)) ==
sizeof(double);
493 return this->GetBinUncertaintyImpl(binidx);
500 auto content = this->GetBinContent(binidx);
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...
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 & GetContent() const
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
std::array< double, DIMENSIONS > CoordArray_t
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.
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...
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.
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
PRECISION Weight_t
The type of the weight and the bin content.
int64_t GetEntries() const
Get the number of entries filled into the histogram - i.e.
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
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.
const std::vector< double > & GetSumOfSquaredWeights() const
Get the structure holding the sum of squares of weights.
Weight_t GetSumOfWeights() const
Get the sum of weights.
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.
STORAGE< PRECISION > Content_t
Type of the bin content array.
size_t size() const noexcept
Get the number of bins.
THistStatTotalSumOfWeights()=default
THistStatTotalSumOfSquaredWeights()=default
double GetUncertaintyImpl() const
Weight_t operator[](int idx) const
Get the bin content for the given bin.
PRECISION Weight_t
The type of the weight and the bin content.
THistStatUncertainty()=default
double GetBinUncertainty(int binidx) const
Calculate the bin content's uncertainty for the given bin, using base class information, i.e.
PRECISION GetContent() const
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.
double GetUncertaintyImpl() const
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.
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
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.
PRECISION GetSumW2() const
static auto HaveUncertainty(const T *This) -> decltype(This->GetBinUncertaintyImpl(12))
Check whether double T::GetBinUncertaintyImpl(int) can be called.
PRECISION & GetSumW2() const
double GetUncertainty(...) const
Calculate the bin content's uncertainty for the given bin, using Poisson statistics on the absolute b...
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.
TBinStat(const THistStatTotalSumOfSquaredWeights &, int)
No-op; this class does not provide per-bin statistics.
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
double GetUncertainty() const
Calculate the bin content's uncertainty for the given bin, using base class information, i.e.
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 GetSumOfSquaredWeights(int binidx) const
Get a bin's sum of squared weights.
Weight_t GetSumOfSquaredWeights() const
Get the sum of weights.
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).
ConstHistBinStat_t GetView(int idx) const
Get a view on the statistics values of a bin.
No-op; this class does not provide per-bin statistics.
typedef void((*Func_t)())
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
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.
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
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.
Weight_t GetBinContent(int idx) const
Get the bin content for the given bin.
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.
const Content_t & GetContentArray() const
Retrieve the content array.
static void Fill(TTree *tree, int init, int count)
Const view on a THistStatUncertainty for a given bin.
double GetBinUncertainty(int binidx,...) const
Calculate the bin content's uncertainty for the given bin, using Poisson statistics on the absolute b...
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.