31#include <unordered_map>
74 void set(std::size_t binNumber,
double weight,
double wgtErr);
86 double sumEntries(
const char* cutSpec,
const char* cutRange=
nullptr)
const override;
92 std::span<const double>
getWeightBatch(std::size_t first, std::size_t len,
bool sumW2=
false)
const override;
95 std::span<const double>
binVolumes(std::size_t first, std::size_t len)
const {
96 return {
_binv + first, len};
99 double sum(
bool correctForBinSize,
bool inverseCorr=
false)
const ;
100 double sum(
const RooArgSet& sumSet,
const RooArgSet& sliceSet,
bool correctForBinSize,
bool inverseCorr=
false) ;
103 bool correctForBinSize,
105 const std::map<
const RooAbsArg*, std::pair<double, double> >& ranges,
106 std::function<
double(
int)> getBinScale = [](
int){
return 1.0; } );
108 void weights(
double* output, std::span<double const> xVals,
int intOrder,
bool correctForBinSize,
bool cdfBoundaries);
111 double weightFast(
const RooArgSet& bin,
int intOrder,
bool correctForBinSize,
bool cdfBoundaries);
112 double weight(
const RooArgSet& bin,
Int_t intOrder=1,
bool correctForBinSize=
false,
bool cdfBoundaries=
false,
bool oneSafe=
false);
136 void reset()
override;
139 void printArgs(std::ostream& os)
const override;
140 void printValue(std::ostream& os)
const override;
143 void printContents(std::ostream& os = std::cout)
const override;
200 void set(
double wgt,
double wgtErr=-1)
226 bool correctForBinSize)
const;
236 void initialize(
const char* binningName=
nullptr,
bool fillTree=
true) ;
238 std::size_t nStart=0, std::size_t nStop=std::numeric_limits<std::size_t>::max())
const override;
239 double interpolateDim(
int iDim,
double xval,
size_t centralIdx,
int intOrder,
bool correctForBinSize,
bool cdfBoundaries) ;
261 std::vector<std::unique_ptr<const RooAbsBinning>>
_lvbins ;
266#if defined(__clang__) && __clang_major__ < 20
267#pragma clang diagnostic push
268#pragma clang diagnostic ignored "-Wshadow"
271#if defined(__clang__) && __clang_major__ < 20
272#pragma clang diagnostic pop
279 void interpolateQuadratic(
double* output, std::span<const double> xVals,
bool correctForBinSize,
bool cdfBoundaries);
280 void interpolateLinear(
double* output, std::span<const double> xVals,
bool correctForBinSize,
bool cdfBoundaries);
288 static std::unique_ptr<RooAbsDataStore>
#define R__SUGGEST_ALTERNATIVE(ALTERNATIVE)
int Int_t
Signed integer 4 bytes (int).
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
#define ClassDefOverride(name, id)
static void indent(ostringstream &buf, int indent_level)
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Abstract container object that can hold multiple RooAbsArg objects.
Abstract base class for binned and unbinned datasets.
RooAbsData()
Default constructor.
RooArgSet _vars
Dimensions of this data set.
Abstract base class for objects that are lvalues, i.e.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Object to represent discrete states.
Named container for two doubles, two integers two object points and three string pointers that can be...
std::span< const double > getWeightBatch(std::size_t first, std::size_t len, bool sumW2=false) const override
Return event weights of all events in range [first, first+len).
void interpolateQuadratic(double *output, std::span< const double > xVals, bool correctForBinSize, bool cdfBoundaries)
A vectorized version of interpolateDim for boundary safe quadratic interpolation of one dimensional h...
double sum(bool correctForBinSize, bool inverseCorr=false) const
Return the sum of the weights of all bins in the histogram.
void weights(double *output, std::span< double const > xVals, int intOrder, bool correctForBinSize, bool cdfBoundaries)
A vectorized version of RooDataHist::weight() for one dimensional histograms with up to one dimension...
RooDataHist(RooStringView name, RooStringView title, const RooArgList &vars, RooCategory &indexCat, RooFit::Detail::FlatMap< std::string, Val_t > const &histMap, double initWgt=1.0)
For internal use in RooFit.
Int_t _cache_sum_valid
! Is cache sum valid? Needs to be Int_t instead of CacheSumState_t for subclasses.
void printContents(std::ostream &os=std::cout) const override
Print the contents of the dataset to the specified output stream.
double interpolateDim(int iDim, double xval, size_t centralIdx, int intOrder, bool correctForBinSize, bool cdfBoundaries)
Perform boundary safe 'intOrder'-th interpolation of weights in dimension 'dim' at current value 'xva...
double weightSquared() const override
Return squared weight of last bin that was requested with get().
friend class RooDataHistSliceIter
std::vector< std::unique_ptr< const RooAbsBinning > > const & getBinnings() const
void importTH1(const RooArgList &vars, const TH1 &histo, double initWgt, bool doDensityCorrection)
Import data from given TH1/2/3 into this RooDataHist.
void SetNameTitle(const char *name, const char *title) override
Change the title of this RooDataHist.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
double _cache_sum
! Cache for sum of entries ;
double const * sumW2Array() const
double const * weightArray() const
std::string declWeightArrayForCodeSquash(RooFit::Experimental::CodegenContext &ctx, bool correctForBinSize) const
Int_t getIndex(const RooAbsCollection &coord, bool fast=false) const
Calculate bin number of the given coordinates.
void add(const RooArgSet &row, double wgt=1.0) override
Add wgt to the bin content enclosed by the coordinates passed in row.
const std::vector< double > & calculatePartialBinVolume(const RooArgSet &dimSet) const
Fill the transient cache with partial bin volumes with up-to-date values for the partial volume speci...
static std::unique_ptr< RooAbsDataStore > makeDefaultDataStore(RooStringView name, RooStringView title, RooArgSet const &vars)
double weightInterpolated(const RooArgSet &bin, int intOrder, bool correctForBinSize, bool cdfBoundaries)
Return the weight at given coordinates with interpolation.
std::unordered_map< int, std::vector< double > > _pbinvCache
! Cache for arrays of partial bin volumes
void checkBinBounds() const
void initializeAsymErrArrays() const
double weight(std::size_t i) const
Return weight of i-th bin.
void set(std::size_t binNumber, double weight, double wgtErr)
Set bin content of bin that was last loaded with get(std::size_t).
void weightError(double &lo, double &hi, ErrorType etype=Poisson) const override
Return the asymmetric errors on the current weight.
double * _errHi
[_arrSize] High-side error on weight array
void importTH1Set(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, TH1 * > hmap, double initWgt, bool doDensityCorrection)
Import data from given set of TH1/2/3 into this RooDataHist.
void adjustBinning(const RooArgList &vars, const TH1 &href, Int_t *offset=nullptr)
Adjust binning specification on first and optionally second and third observable to binning in given ...
double * _binv
[_arrSize] Bin volume array
RooDataHist()
Default constructor.
bool isWeighted() const override
Always returns true as all histograms use event weights.
double weightSquared(std::size_t i) const
Return squared weight sum of i-th bin.
double const * wgtErrHiArray() const
ULong64_t _curIndex
Current index.
std::string calculateTreeIndexForCodeSquash(RooFit::Experimental::CodegenContext &ctx, const RooAbsCollection &coords, bool reverse=false) const
double weightFast(const RooArgSet &bin, int intOrder, bool correctForBinSize, bool cdfBoundaries)
A faster version of RooDataHist::weight that assumes the passed arguments are aligned with the histog...
double weight() const override
Return weight of last bin that was requested with get().
RooFit::OwningPtr< RooAbsData > emptyClone(const char *newName=nullptr, const char *newTitle=nullptr, const RooArgSet *vars=nullptr, const char *=nullptr) const override
Return empty clone of this RooDataHist.
std::span< const double > binVolumes(std::size_t first, std::size_t len) const
Retrieve all bin volumes. Bins are indexed according to getIndex().
std::vector< std::vector< double > > _binbounds
! list of bin bounds per dimension
void printArgs(std::ostream &os) const override
Print argument of dataset, i.e. the observable names.
void importDHistSet(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, RooDataHist * > dmap, double initWgt)
Import data from given set of TH1/2/3 into this RooDataHist.
void _adjustBinning(RooRealVar &theirVar, const TAxis &axis, RooRealVar *ourVar, Int_t *offset)
Helper doing the actual work of adjustBinning().
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Print the details on the dataset contents.
double * _sumw2
[_arrSize] Sum of weights^2
TIterator * sliceIterator(RooAbsArg &sliceArg, const RooArgSet &otherArgs)
Create an iterator over all bins in a slice defined by the subset of observables listed in sliceArg.
Int_t calcTreeIndex() const
Legacy overload to calculate the tree index from the current value of _vars.
~RooDataHist() override
Destructor.
bool isNonPoissonWeighted() const override
Returns true if dataset contains entries with a non-integer weight.
RooDataHist & operator=(const RooDataHist &)=delete
Int_t getIndex(const RooArgSet &coord, bool fast=false) const
Calculate bin number of the given coordinates.
double binVolume(std::size_t i) const
Return bin volume of i-th bin.
std::vector< RooAbsLValue * > _lvvars
! List of observables casted as RooAbsLValue
double weightError(ErrorType etype=Poisson) const override
Return the symmetric error on the current weight.
double const * wgtErrLoArray() const
void SetName(const char *name) override
Change the name of the RooDataHist.
std::vector< std::unique_ptr< const RooAbsBinning > > _lvbins
! List of used binnings associated with lvalues
std::vector< double > _interpolationBuffer
! Buffer to contain values used for weight interpolation
std::vector< Int_t > _idxMult
void registerWeightArraysToDataStore() const
Hand over pointers to our weight arrays to the data store implementation.
void reset() override
Reset all bin weights to zero.
double * _errLo
[_arrSize] Low-side error on weight array
double * _wgt
[_arrSize] Weight array
RooPlot * plotOnImpl(RooPlot *frame, PlotOpt o) const override
Back end function to plotting functionality.
void printValue(std::ostream &os) const override
Print value of the dataset, i.e. the sum of weights contained in the dataset.
VarInfo const & getVarInfo()
Return reference to VarInfo struct with cached histogram variable information that is frequently used...
std::unique_ptr< RooAbsData > reduceEng(const RooArgSet &varSubset, const RooFormulaVar *cutVar, const char *cutRange=nullptr, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max()) const override
Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods.
const RooArgSet * get() const override
Get bin centre of current bin.
void interpolateLinear(double *output, std::span< const double > xVals, bool correctForBinSize, bool cdfBoundaries)
A vectorized version of interpolateDim for boundary safe linear interpolation of one dimensional hist...
double binVolume() const
Return volume of current bin.
double sumEntries() const override
Sum the weights of all bins.
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
A class to maintain the context for squashing of RooFit models into code.
Plot frame and a container for graphics objects within that frame.
Variable that can be changed from the outside.
The RooStringView is a wrapper around a C-style string that can also be constructed from a std::strin...
Class to manage histogram axis.
TH1 is the base class of all histogram classes in ROOT.
Iterator abstract base class.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
TObject()
TObject constructor.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
OwningPtr< T > makeOwningPtr(std::unique_ptr< T > &&ptr)
Internal helper to turn a std::unique_ptr<T> into an OwningPtr.
Structure to cache information on the histogram variable that is frequently used for histogram weight...