68 _pdfObsList(
"pdfObs",
"List of p.d.f. observables",this),
72 _cdfBoundaries(false),
83 <<
") ERROR variable list and RooDataHist must contain the same variables." << endl ;
86 for (
const auto arg : vars) {
87 if (!dvars->
find(arg->GetName())) {
89 <<
") ERROR variable list and RooDataHist must contain the same variables." << endl ;
120 _pdfObsList(
"pdfObs",
"List of p.d.f. observables",this),
124 _cdfBoundaries(false),
135 <<
") ERROR histogram variable list and RooDataHist must contain the same variables." << endl ;
136 throw(
string(
"RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
139 for (
const auto arg : histObs) {
140 if (!dvars->
find(arg->GetName())) {
142 <<
") ERROR variable list and RooDataHist must contain the same variables." << endl ;
143 throw(
string(
"RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
145 if (!arg->isFundamental()) {
147 <<
") ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory." << endl ;
148 throw(
string(
"RooHistPdf::ctor() ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory.")) ;
171 _pdfObsList(
"pdfObs",this,other._pdfObsList),
172 _dataHist(other._dataHist),
173 _codeReg(other._codeReg),
174 _intOrder(other._intOrder),
175 _cdfBoundaries(other._cdfBoundaries),
176 _totVolume(other._totVolume),
177 _unitNorm(other._unitNorm)
221 return std::max(ret, 0.0);
256 if (!_x || !_y)
return false;
257 if (!range || !strlen(range) || !_x->
hasRange(range) ||
272 const char* rangeName,
281 for (
unsigned int n=0;
n < pdfObsList.
size() &&
n < histObsList.
size(); ++
n) {
282 const auto pa = pdfObsList[
n];
283 const auto ha = histObsList[
n];
285 if (allVars.
find(*pa)) {
288 if (fullRange(*pa, *ha, rangeName)) {
294 if (code == frcode) {
303 if (intOrder > 1 && !(code & 1)) {
307 return (code >= 2) ? code : 0;
312 const char* rangeName,
318 if (((2 << histObsList.
getSize()) - 1) == code) {
325 std::map<const RooAbsArg*, std::pair<double, double> > ranges;
326 for (
unsigned int n=0;
n < pdfObsList.
size() &&
n < histObsList.
size(); ++
n) {
327 const auto pa = pdfObsList[
n];
328 const auto ha = histObsList[
n];
330 if (code & (2 <<
n)) {
340 ha->copyCache(pa,
true);
344 double ret = (code & 1) ?
dataHist.
sum(intSet,histObsList,
true,!histFuncMode) :
345 dataHist.
sum(intSet,histObsList,
true,!histFuncMode, ranges);
408 double* boundaries = binning->
array() ;
410 list<double>* hint =
new list<double> ;
413 xlo = xlo - 0.01*(xhi-xlo) ;
414 xhi = xhi + 0.01*(xhi-xlo) ;
416 double delta = (xhi-xlo)*1
e-8 ;
421 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
422 hint->push_back(boundaries[i]-delta) ;
423 hint->push_back(boundaries[i]+delta) ;
452 double* boundaries = binning->
array() ;
454 list<double>* hint =
new list<double> ;
459 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
460 hint->push_back(boundaries[i]) ;
495 if (wgt>max) max=wgt ;
525 std::list<RooAbsData*> allData =
ws.allData() ;
526 std::list<RooAbsData*>::const_iterator iter ;
527 for (iter = allData.begin() ; iter != allData.end() ; ++iter) {
553 coutE(
ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " << uniqueName <<
", abort" << endl ;
565 coutE(
ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " << uniqueName <<
", abort" << endl ;
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
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 bool inRange(const char *) const
virtual void syncCache(const RooArgSet *nset=0)=0
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 *=0) const
Return number of types defined (in range named rangeName if rangeName!=0)
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
Storage_t::size_type size() const
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.
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=0) const
Get maximum of currently defined range.
virtual double getMin(const char *name=0) 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.
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.
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...
Int_t numEntries() const override
Return the number of bins.
const RooArgSet * get() const override
Get bin centre of current bin.
double sumEntries() const override
Sum the weights of all bins.
RooHistPdf implements a probablity density function sampled from a multidimensional histogram.
void Streamer(TBuffer &) override
Stream an object of class RooHistPdf.
RooArgSet _histObsList
List of observables defining dimensions of histogram.
Int_t _intOrder
Interpolation order.
RooHistPdf()
Default constructor coverity[UNINIT_CTOR].
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.
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...
RooSetProxy _pdfObsList
List of observables mapped onto histogram observables.
static double analyticalIntegral(Int_t code, const char *rangeName, RooArgSet const &histObsList, RooSetProxy const &pdfObsList, RooDataHist &dataHist, bool histFuncMode)
double maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
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)
static Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName, RooArgSet const &histObsList, RooSetProxy const &pdfObsList, Int_t intOrder)
~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.
Buffer base class used for serializing objects.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
const char * GetName() const override
Returns name of object.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
const char * Data() const
RooCmdArg Rename(const char *suffix)
RooCmdArg Embedded(bool flag=true)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
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.