116 _pdf(
"inputPdf",
"Function to be converted into a PDF", this, inputPdf),
117 _observable(
"observable",
"Observable to integrate over", this, observable, true, true),
120 throw std::invalid_argument(std::string(
"RooBinSamplingPDF(") +
GetName()
121 +
"): The PDF " +
_pdf->
GetName() +
" needs to depend on the observable "
133 _pdf(
"inputPdf", this, other._pdf),
134 _observable(
"observable", this, other._observable),
135 _relEpsilon(other._relEpsilon) { }
173 for (
unsigned int i=0; i < xValues.size(); ++i) {
174 const double x = xValues[i];
175 const auto upperIt = std::upper_bound(boundaries.begin(), boundaries.end(),
x);
176 const unsigned int bin = std::distance(boundaries.begin(), upperIt) - 1;
177 assert(bin < boundaries.size());
179 output[i] =
integrate(
nullptr, boundaries[bin], boundaries[bin+1]) / (boundaries[bin+1]-boundaries[bin]);
191 const double* boundaries = binning.
array();
214 coutE(Plotting) <<
"RooBinSamplingPdf::binBoundaries(" <<
GetName() <<
"): observable '" << obs.
GetName()
215 <<
"' is not the observable of this PDF ('" <<
_observable->
GetName() <<
"')." << std::endl;
219 auto list =
new std::list<double>;
221 if (xlo <= val && val < xhi)
222 list->push_back(val);
237 coutE(Plotting) <<
"RooBinSamplingPdf::plotSamplingHint(" <<
GetName() <<
"): observable '" << obs.
GetName()
238 <<
"' is not the observable of this PDF ('" <<
_observable->
GetName() <<
"')." << std::endl;
242 auto binEdges =
new std::list<double>;
245 for (
unsigned int bin=0, numBins =
static_cast<unsigned int>(binning.numBins()); bin < numBins; ++bin) {
246 const double low = std::max(binning.binLow(bin), xlo);
247 const double high = std::min(binning.binHigh(bin), xhi);
248 const double width = high - low;
255 binEdges->push_back(low + 0.001 *
width);
256 binEdges->push_back(high - 0.001 *
width);
278 _integrator = std::make_unique<ROOT::Math::IntegratorOneDim>(*
this,
315 const bool oneDimAndBinned = (1 == std::count_if(funcObservables->begin(), funcObservables->end(), [](
const RooAbsArg* arg) {
316 auto var = dynamic_cast<const RooRealVar*>(arg);
317 return var && var->numBins() > 1;
320 if (!oneDimAndBinned) {
321 if (precision > 0.) {
323 <<
"Integration over bins was requested, but this is currently only implemented for 1-D fits." << std::endl;
329 auto theObs = std::find_if(funcObservables->begin(), funcObservables->end(), [](
const RooAbsArg* arg){
330 return dynamic_cast<const RooAbsRealLValue*>(arg);
332 assert(theObs != funcObservables->end());
334 std::unique_ptr<RooAbsPdf> newPdf;
336 if (precision > 0.) {
338 newPdf = std::make_unique<RooBinSamplingPdf>(
345 newPdf = std::make_unique<RooBinSamplingPdf>(
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
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.
const TNamed * namePtr() const
De-duplicated pointer to this object's name.
bool isShapeDirty() const
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
bool inhibitDirty() const
Delete watch flag.
void clearShapeDirty() const
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual double binLow(Int_t bin) const =0
virtual double binHigh(Int_t bin) const =0
virtual Int_t numBoundaries() const =0
virtual double * array() const =0
RooAbsData is the common abstract base class for binned and unbinned datasets.
RooArgSet const * _normSet
Normalization integral (owned by _normMgr)
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual const RooAbsBinning & getBinning(const char *name=nullptr, bool verbose=true, bool createOnTheFly=false) const =0
Retrive binning configuration with given name or default binning.
Int_t getBin(const char *rangeName=nullptr) const override
virtual void setVal(double value)=0
Set the current value of the object. Needs to be overridden by implementations.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual bool isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
The RooBinSamplingPdf is supposed to be used as an adapter between a continuous PDF and a binned dist...
double integrate(const RooArgSet *normSet, double low, double high) const
Integrate the wrapped PDF using our current integrator, with given norm set and limits.
RooTemplateProxy< RooAbsPdf > _pdf
std::vector< double > _binBoundaries
! Workspace to store data for bin sampling
std::unique_ptr< ROOT::Math::IntegratorOneDim > & integrator() const
Direct access to the unique_ptr holding the integrator that's used to sample the bins.
RooTemplateProxy< RooAbsRealLValue > _observable
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const override
Integrate the PDF over all its bins, and return a batch with those values.
RooSpan< const double > binBoundaries() const
Get the bin boundaries for the observable.
std::unique_ptr< ROOT::Math::IntegratorOneDim > _integrator
! Integrator used to sample bins.
double _relEpsilon
Default integrator precision.
static std::unique_ptr< RooAbsPdf > create(RooAbsPdf &pdf, RooAbsData const &data, double precision)
Creates a wrapping RooBinSamplingPdf if appropriate.
double operator()(double x) const
Binding used by the integrator to evaluate the PDF.
double evaluate() const override
Integrate the PDF over the current bin of the observable.
const RooAbsPdf & pdf() const
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return a list of all bin edges, so the PDF is plotted as a step function.
The RooDataHist is a container class to hold N-dimensional binned data.
RooSpan< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
A simple container to hold a batch of data values.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
@ kADAPTIVE
to be used for general functions without singularities
Disable all caches for sub-branches in an expression tree.