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>
90 fBinContent[binidx] += weight;
99 size_t size() const noexcept {
return fBinContent.size(); }
121 template<
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
143 PRECISION fSumWeights = 0;
151 fSumWeights += weight;
164 template<
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
186 PRECISION fSumWeights2 = 0;
194 fSumWeights2 += weight * weight;
207 template<
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
225 fSumW2(stat.GetSumOfSquaredWeights(index)) {}
241 fSumW2(stat.GetSumOfSquaredWeights(index)) {}
263 fSumWeightsSquared[binidx] += weight * weight;
269 return std::sqrt(fSumWeightsSquared[binidx]);
274 return fSumWeightsSquared[binidx];
279 return fSumWeightsSquared[binidx];
291 template<
int DIMENSIONS,
class PRECISION,
template <
class P_>
class STORAGE>
323 for (
int idim = 0; idim < DIMENSIONS; ++idim) {
324 const PRECISION xw = x[idim] * weight;
325 fMomentXW[idim] += xw ;
326 fMomentX2W[idim] += x[idim] * xw;
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());
388 static char HaveUncertainty(...);
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,
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));
432 static char HaveUncertainty(...);
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);
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)
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
std::array< double, DIMENSIONS > CoordArray_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.
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.
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.
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.
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.
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
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.
Hist::CoordArray_t< DIMENSIONS > CoordArray_t
The type of a (possibly multi-dimensional) coordinate.
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)())
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.
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.
static void Fill(TTree *tree, int init, int count)
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.