55 _pdfObsList(
"pdfObs",
"List of p.d.f. observables",this),
67 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
68 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
71 for (
const auto arg : vars) {
72 if (!dvars->
find(arg->GetName())) {
73 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
74 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
105 _pdfObsList(
"pdfObs",
"List of p.d.f. observables",this),
109 _cdfBoundaries(false)
116 if (histObs.
size()!=dvars->
size()) {
117 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
118 <<
") ERROR histogram variable list and RooDataHist must contain the same variables." << std::endl ;
119 throw(std::string(
"RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
122 for (
const auto arg : histObs) {
123 if (!dvars->
find(arg->GetName())) {
124 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
125 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
126 throw(std::string(
"RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
128 if (!arg->isFundamental()) {
129 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
130 <<
") ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory." << std::endl ;
131 throw(std::string(
"RooHistPdf::ctor() ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory.")) ;
149 std::unique_ptr<RooDataHist> dhist,
int intOrder)
155 std::unique_ptr<RooDataHist> dhist,
int intOrder)
167 _pdfObsList(
"pdfObs",this,other._pdfObsList),
168 _dataHist(other._dataHist),
169 _codeReg(other._codeReg),
170 _intOrder(other._intOrder),
171 _cdfBoundaries(other._cdfBoundaries),
172 _totVolume(other._totVolume),
173 _unitNorm(other._unitNorm)
233 return std::max(ret, 0.0);
268 if (!_x || !_y)
return false;
269 if (!range || !strlen(range) || !_x->
hasRange(range) ||
284 const char* rangeName,
293 for (
unsigned int n=0;
n < pdfObsList.
size() &&
n < histObsList.
size(); ++
n) {
294 const auto pa = pdfObsList[
n];
295 const auto ha = histObsList[
n];
297 if (allVars.
find(*pa)) {
300 if (fullRange(*pa, *ha, rangeName)) {
306 if (code == frcode) {
315 if (intOrder > 1 && !(code & 1)) {
319 return (code >= 2) ? code : 0;
324 const char* rangeName,
330 if (((2 << histObsList.
size()) - 1) == code) {
337 std::map<const RooAbsArg*, std::pair<double, double> > ranges;
338 for (
unsigned int n=0;
n < pdfObsList.
size() &&
n < histObsList.
size(); ++
n) {
339 const auto pa = pdfObsList[
n];
340 const auto ha = histObsList[
n];
342 if (code & (2 <<
n)) {
352 ha->copyCache(pa,
true);
356 double ret = (code & 1) ?
dataHist.
sum(intSet,histObsList,
true,!histFuncMode) :
357 dataHist.
sum(intSet,histObsList,
true,!histFuncMode, ranges);
412 for (
unsigned int i=0; i < pdfObsList.
size(); ++i) {
432 std::span<double> boundaries{binning->
array(),
static_cast<std::size_t
>(binning->
numBoundaries())};
434 auto hint =
new std::list<double> ;
436 const double delta = (xhi-xlo)*1
e-8 ;
439 hint->push_back(xlo + delta);
440 hint->push_back(xhi - delta);
444 for (
const double x : boundaries) {
445 if (
x - xlo > delta && xhi -
x > delta) {
446 hint->push_back(
x - delta);
447 hint->push_back(
x + delta);
475 double* boundaries = binning->
array() ;
477 auto hint =
new std::list<double> ;
482 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
483 hint->push_back(boundaries[i]) ;
516 if (wgt>max) max=wgt ;
570 coutE(ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " << uniqueName <<
", abort" << std::endl ;
582 coutE(ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " << uniqueName <<
", abort" << std::endl ;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
virtual void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true)=0
virtual void syncCache(const RooArgSet *nset=nullptr)=0
friend void RooRefArray::Streamer(TBuffer &)
virtual bool inRange(const char *) const
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual bool isParameterized() const
Interface function.
virtual Int_t numBoundaries() const =0
virtual double * array() const =0
Int_t numTypes(const char *=nullptr) const
Return number of types defined (in range named rangeName if rangeName!=nullptr)
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Abstract base class for objects that are lvalues, i.e.
virtual const RooAbsBinning * getBinningPtr(const char *rangeName) const =0
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
const RooAbsBinning * getBinningPtr(const char *rangeName) const override
bool hasRange(const char *name) const override
Check if variable has a binning with given name.
virtual void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const
Base function for computing multiple values of a RooAbsReal.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooCategory is an object to represent discrete states.
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
The RooDataHist is a container class to hold N-dimensional binned data.
double sum(bool correctForBinSize, bool inverseCorr=false) const
Return the sum of the weights of all bins in the histogram.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
void weights(double *output, RooSpan< double const > xVals, int intOrder, bool correctForBinSize, bool cdfBoundaries)
A vectorized version of RooDataHist::weight() for one dimensional histograms with up to one dimension...
double weight(std::size_t i) const
Return weight of i-th bin.
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...
const RooArgSet * get() const override
Get bin centre of current bin.
double sumEntries() const override
Sum the weights of all bins.
RooSpan< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
RooHistPdf implements a probablity density function sampled from a multidimensional histogram.
RooArgSet _histObsList
List of observables defining dimensions of histogram.
Int_t _intOrder
Interpolation order.
bool areIdentical(const RooDataHist &dh1, const RooDataHist &dh2)
RooDataHist * _dataHist
Unowned pointer to underlying histogram.
bool _cdfBoundaries
Use boundary conditions for CDFs.
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
double totVolume() const
Return the total volume spanned by the observables of the RooHistPdf.
bool importWorkspaceHook(RooWorkspace &ws) override
Check if our datahist is already in the workspace.
RooSetProxy _pdfObsList
List of observables mapped onto histogram observables.
double maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Return integral identified by 'code'.
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const override
Base function for computing multiple values of a RooAbsReal.
Int_t getMaxVal(const RooArgSet &vars) const override
Only handle case of maximum in all variables.
double _totVolume
! Total volume of space (product of ranges of observables)
RooDataHist * cloneAndOwnDataHist(const char *newname="")
Replaces underlying RooDataHist with a clone, which is now owned, and returns the clone.
std::unique_ptr< RooDataHist > _ownedDataHist
! Owned pointer to underlying histogram
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Determine integration scenario.
~RooHistPdf() override
Destructor.
double evaluate() const override
Return the current value: The value of the bin enclosing the current coordinates of the observables,...
bool _unitNorm
Assume contents is unit normalized (for use as pdf cache)
RooRealVar represents a variable that can be changed from the outside.
void setRange(const char *name, double min, double max)
Set a fit or plotting range.
The RooWorkspace is a persistable container for RooFit projects.
RooAbsData * embeddedData(RooStringView name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
std::list< RooAbsData * > allData() const
Return list of all dataset in the workspace.
Buffer base class used for serializing objects.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
const char * GetName() const override
Returns name of object.
RooCmdArg Rename(const char *suffix)
RooCmdArg Embedded(bool flag=true)
std::pair< double, double > getRangeOrBinningInterval(RooAbsArg const *arg, const char *rangeName)
Get the lower and upper bound of parameter range if arg can be casted to RooAbsRealLValue.