54 _depList(
"depList",
"List of dependents",this),
64 coutE(InputArguments) <<
"RooHistFunc::ctor(" <<
GetName()
65 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
66 throw std::invalid_argument(
"RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
69 for (
const auto arg : vars) {
70 if (!dvars->
find(arg->GetName())) {
71 coutE(InputArguments) <<
"RooHistFunc::ctor(" <<
GetName()
72 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
73 throw std::invalid_argument(
"RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
91 _depList(
"depList",
"List of dependents",this),
100 if (histObs.
size()!=dvars->
size()) {
101 coutE(InputArguments) <<
"RooHistFunc::ctor(" <<
GetName()
102 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
103 throw std::invalid_argument(
"RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
106 for (
const auto arg : histObs) {
107 if (!dvars->
find(arg->GetName())) {
108 coutE(InputArguments) <<
"RooHistFunc::ctor(" <<
GetName()
109 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
110 throw std::invalid_argument(
"RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
124 std::unique_ptr<RooDataHist> dhist,
int intOrder)
136 _depList(
"depList",this,other._depList),
137 _dataHist(other._dataHist),
138 _intOrder(other._intOrder),
139 _cdfBoundaries(other._cdfBoundaries),
140 _totVolume(other._totVolume)
172 harg->copyCache(parg,
true) ;
173 if (!harg->inRange(
nullptr)) {
186 std::span<double> output = ctx.
output();
187 std::size_t nEvents = output.size();
195 std::vector<std::span<const double>> inputValues;
197 auto realObs =
dynamic_cast<const RooAbsReal*
>(obs);
199 inputValues.push_back(ctx.
at(realObs));
201 inputValues.emplace_back();
205 for (std::size_t i = 0; i < nEvents; ++i) {
211 if (i < inputValues[j].
size()) {
212 histObs->setCachedValue(inputValues[j][i],
false);
213 if (!histObs->inRange(
nullptr)) {
243 if (wgt>max) max=wgt ;
326 const std::vector<double> boundaries =
328 if (boundaries.empty()) {
332 auto hint =
new std::list<double>;
333 const double delta = (xhi - xlo) * 1
e-8;
334 for (
double b : boundaries) {
335 if (
b > xlo - delta &&
b < xhi + delta) {
372 coutE(ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " << uniqueName <<
", abort" << std::endl ;
384 coutE(ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " << uniqueName <<
", abort" << std::endl ;
409 if (std::abs(dh1.
weight(i)-dh2.
weight(i))>1
e-8)
return false ;
412 if (getColonSeparatedNameString(*dh1.
get()) != getColonSeparatedNameString(*dh2.
get()))
return false ;
460 harg->copyCache(parg,
true) ;
461 if (!harg->inRange(
nullptr)) {
476 std::vector<std::span<const double>> depData;
478 auto real =
dynamic_cast<const RooAbsReal*
>(dep);
480 depData.push_back(ctx.
at(real));
482 depData.emplace_back();
486 const auto batchSize = std::max_element(depData.begin(), depData.end(),
487 [](
const std::span<const double>&
a,
const std::span<const double>&
b){ return a.size() < b.size(); })->size();
488 std::vector<Int_t> results;
490 for (std::size_t evt = 0; evt < batchSize; ++evt) {
495 if (evt < depData[i].
size())
496 harg->setCachedValue(depData[i][evt],
false);
498 if (!harg->inRange(
nullptr)) {
499 results.push_back(-1);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
void registerProxy(RooArgProxy &proxy)
Register an RooArgProxy in the proxy list.
friend void RooRefArray::Streamer(TBuffer &)
virtual void ioStreamerPass2()
Method called by workspace container to finalize schema evolution issues that cannot be handled in a ...
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.
RooAbsArg * find(const char *name) const
Find object with given name in 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 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.
Abstract base class for objects that represent a real value and implements functionality common to al...
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...
Container class to hold N-dimensional binned data.
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...
Int_t getIndex(const RooAbsCollection &coord, bool fast=false) const
Calculate bin number of the given coordinates.
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.
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
std::span< double > output()
A real-valued function sampled from a multidimensional histogram.
bool _cdfBoundaries
Use boundary conditions for CDFs.
RooDataHist * _dataHist
Unowned pointer to underlying histogram.
double _totVolume
! Total volume of space (product of ranges of observables)
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
bool forceAnalyticalInt(const RooAbsArg &dep) const override
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Return integral identified by 'code'.
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Return the histogram bin boundaries mapped into the plot-observable coordinate.
void ioStreamerPass2() override
Schema evolution: if histObsList wasn't filled from persistence (v1) then fill it here.
void initializeOwnedDataHist(std::unique_ptr< RooDataHist > &&dataHist)
double evaluate() const override
Return the current value: The value of the bin enclosing the current coordinates of the dependents,...
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() const
Get total bin volume spanned by this hist function.
Int_t getBin() const
Compute bin number corresponding to current coordinates.
bool areIdentical(const RooDataHist &dh1, const RooDataHist &dh2)
double maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
std::vector< Int_t > getBins(RooFit::EvalContext &ctx) const
Compute bin numbers corresponding to all coordinates in evalData.
bool importWorkspaceHook(RooWorkspace &ws) override
Check if our datahist is already in the workspace.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Determine integration scenario.
Int_t _intOrder
Interpolation order.
RooSetProxy _depList
List of observables mapped onto histogram observables.
RooArgSet _histObsList
List of observables defining dimensions of histogram.
bool forceAnalyticalInt(const RooAbsArg &dep) const override
static std::vector< double > histogramBoundariesInPlotObs(RooDataHist const &dataHist, RooArgSet const &pdfObsList, RooArgSet const &histObsList, RooAbsRealLValue &obs, double xlo, double xhi)
Return the histogram bin boundaries mapped to the coordinates of the plot observable obs.
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 getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Determine integration scenario.
Variable that can be changed from the outside.
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={}, 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.
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.
void Clear(Option_t *option="") override
Remove all objects from the array.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
RooCmdArg Rename(const char *suffix)
RooCmdArg Embedded(bool flag=true)
std::string getColonSeparatedNameString(RooArgSet const &argSet, char delim=':')