15 #ifndef ROOT7_THistData_h 16 #define ROOT7_THistData_h 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[];
479 (
void)trigger_base_fill{ (STAT<DIMENSIONS, PRECISION, STORAGE>::Fill(x, binidx, weight), 0)... };
485 struct AllYourBaseAreBelongToUs:
public STAT<DIMENSIONS, PRECISION, STORAGE>... {};
486 return sizeof(HaveUncertainty<AllYourBaseAreBelongToUs>(
nullptr)) ==
sizeof(double);
493 return this->GetBinUncertaintyImpl(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.
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
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)
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.
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.
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.
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.
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.
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
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)
size_t size() const noexcept
Get the number of bins.
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.
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).
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).
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.
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.
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.
Keeps track of the histogram's total sum of squared weights.