62 _pdfObsList(
"pdfObs",
"List of p.d.f. observables",
this),
72 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
73 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
76 for (
const auto arg : vars) {
77 if (!
dvars->find(arg->GetName())) {
78 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
79 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
111 _pdfObsList(
"pdfObs",
"List of p.d.f. observables",
this),
121 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
122 <<
") ERROR histogram variable list and RooDataHist must contain the same variables." << std::endl ;
123 throw(std::string(
"RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
126 for (
const auto arg :
histObs) {
127 if (!
dvars->find(arg->GetName())) {
128 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
129 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
130 throw(std::string(
"RooHistPdf::ctor() ERROR: histogram variable list and RooDataHist must contain the same variables")) ;
132 if (!arg->isFundamental()) {
133 coutE(InputArguments) <<
"RooHistPdf::ctor(" <<
GetName()
134 <<
") ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory." << std::endl ;
135 throw(std::string(
"RooHistPdf::ctor() ERROR all elements of histogram observables set must be of type RooRealVar or RooCategory.")) ;
172 _pdfObsList(
"pdfObs",
this,
other._pdfObsList),
173 _dataHist(
other._dataHist),
174 _intOrder(
other._intOrder),
175 _cdfBoundaries(
other._cdfBoundaries),
176 _totVolume(
other._totVolume),
177 _unitNorm(
other._unitNorm)
195 for (std::size_t i = 0; i < nBins; ++i) {
207 <<
" bins with negative content (sum of negative contents: " <<
sumNegative
208 <<
"). A p.d.f. cannot be negative, so these bins contents are clipped to zero while "
209 "preserving the error. The input "
210 "histogram is not modified. To avoid this message, remove the negative bin contents "
211 "before constructing the RooHistPdf."
215 const bool hasSumW2 =
dh->sumW2Array() !=
nullptr;
216 for (std::size_t i = 0; i < nBins; ++i) {
217 if (
dh->weight(i) < 0.) {
228 const double wgtErr =
hasSumW2 ? std::sqrt(std::max(
dh->weightSquared(i), 0.)) : 0.;
236 std::span<double> output =
ctx.output();
246 for (
auto &
ret : output) {
267 if (!
harg->inRange(
nullptr)) {
275 return std::max(
ret, 0.0);
310 if (!_x || !_y)
return false;
325 if(
lobs ==
nullptr)
return false;
331 if(!
lobs->isJacobianOK(*var))
return false;
364 }
else if (
pa->isFundamental()) {
386 return (code >= 2) ? code : 0;
404 std::map<const RooAbsArg*, std::pair<double, double> > ranges;
409 if (code & (2 <<
n)) {
419 ha->copyCache(
pa,
true);
503 for (
unsigned int i=0; i <
pdfObsList.size(); ++i) {
523 std::span<const double> boundaries{binning->
array(),
static_cast<std::size_t
>(binning->
numBoundaries())};
551 double* boundaries = binning->
array() ;
553 auto hint =
new std::list<double> ;
558 if (boundaries[i]>=xlo && boundaries[i]<=xhi) {
559 hint->push_back(boundaries[i]) ;
604 if (std::abs(
dh1.sumEntries()-
dh2.sumEntries())>1
e-8)
return false ;
605 if (
dh1.numEntries() !=
dh2.numEntries())
return false ;
606 for (
int i=0 ; i <
dh1.numEntries() ; i++) {
607 if (std::abs(
dh1.weight(i)-
dh2.weight(i))>1
e-8)
return false ;
643 coutE(ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " <<
uniqueName <<
", abort" << std::endl ;
655 coutE(ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " <<
uniqueName <<
", abort" << std::endl ;
678 if (
R__b.IsReading()) {
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Common abstract base class for objects that represent a value and a "shape" in RooFit.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
friend void RooRefArray::Streamer(TBuffer &)
Abstract base class for RooRealVar binning definitions.
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)
Storage_t::size_type size() const
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
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.
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
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 doEval(RooFit::EvalContext &) 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.
RooArgSet * selectCommon(const RooAbsCollection &refColl) const
Use RooAbsCollection::selecCommon(), but return as RooArgSet.
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...
static std::list< double > * plotSamplingHintForBinBoundaries(std::span< const double > boundaries, double xlo, double xhi)
Returns sampling hints for a histogram with given boundaries.
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.
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...
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
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.
A probability density function sampled from a multidimensional histogram.
RooArgSet _histObsList
List of observables defining dimensions of histogram.
Int_t _intOrder
Interpolation order.
bool forceAnalyticalInt(const RooAbsArg &dep) const override
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.
void initializeOwnedDataHist(std::unique_ptr< RooDataHist > &&dataHist)
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...
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
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Determine integration scenario.
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)
Variable that can be changed from the outside.
void setRange(const char *name, double min, double max, bool shared=true)
Set a fit or plotting range.
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.
std::list< RooAbsData * > allData() const
Return list of all dataset in the workspace.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
Buffer base class used for serializing objects.
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)