55 _depList(
"depList",
"List of dependents",this),
67 coutE(InputArguments) <<
"RooHistFunc::ctor(" <<
GetName()
68 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
69 throw std::invalid_argument(
"RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
72 for (
const auto arg : vars) {
73 if (!dvars->
find(arg->GetName())) {
74 coutE(InputArguments) <<
"RooHistFunc::ctor(" <<
GetName()
75 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
76 throw std::invalid_argument(
"RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
95 _depList(
"depList",
"List of dependents",this),
106 if (histObs.
size()!=dvars->
size()) {
107 coutE(InputArguments) <<
"RooHistFunc::ctor(" <<
GetName()
108 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
109 throw std::invalid_argument(
"RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
112 for (
const auto arg : histObs) {
113 if (!dvars->
find(arg->GetName())) {
114 coutE(InputArguments) <<
"RooHistFunc::ctor(" <<
GetName()
115 <<
") ERROR variable list and RooDataHist must contain the same variables." << std::endl ;
116 throw std::invalid_argument(
"RooHistFunc: ERROR variable list and RooDataHist must contain the same variables.");
125 std::unique_ptr<RooDataHist> dhist,
int intOrder)
133 std::unique_ptr<RooDataHist> dhist,
int intOrder)
145 _depList(
"depList",this,other._depList),
146 _dataHist(other._dataHist),
147 _codeReg(other._codeReg),
148 _intOrder(other._intOrder),
149 _cdfBoundaries(other._cdfBoundaries),
150 _totVolume(other._totVolume),
151 _unitNorm(other._unitNorm)
185 harg->copyCache(parg,
true) ;
186 if (!harg->inRange(
nullptr)) {
209 std::vector<std::span<const double>> inputValues;
211 auto realObs =
dynamic_cast<const RooAbsReal*
>(obs);
213 auto inputs = dataMap.
at(realObs);
214 inputValues.push_back(std::move(inputs));
216 inputValues.emplace_back();
220 for (std::size_t i = 0; i <
size; ++i) {
226 if (i < inputValues[j].
size()) {
227 histObs->setCachedValue(inputValues[j][i],
false);
228 if (!histObs->inRange(
nullptr)) {
259 if (wgt>max) max=wgt ;
360 if (std::string(parg->GetName())==obs.
GetName()) {
376 if (std::string(harg->GetName())==obs.
GetName()) {
384 std::cout <<
"RooHistFunc::binBoundaries(" <<
GetName() <<
") obs = " << obs.
GetName() <<
" hobs is not found, returning null" << std::endl ;
400 std::cout <<
"RooHistFunc::binBoundaries(" <<
GetName() <<
") hobs = " << hobs->
GetName() <<
" is not found in dataset?" << std::endl ;
406 std::cout <<
"RooHistFunc::binBoundaries(" <<
GetName() <<
") hobs = " << hobs->
GetName() <<
" but is not an LV, returning null" << std::endl ;
412 double* boundaries = binning->
array() ;
414 auto hint =
new std::list<double> ;
416 double delta = (xhi-xlo)*1
e-8 ;
421 if (boundaries[i]>xlo-delta && boundaries[i]<xhi+delta) {
423 double boundary = boundaries[i] ;
425 transform->
setVal(boundary) ;
427 hint->push_back(obs.
getVal()) ;
429 hint->push_back(boundary) ;
466 coutE(ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " << uniqueName <<
", abort" << std::endl ;
478 coutE(ObjectHandling) <<
" RooHistPdf::importWorkspaceHook(" <<
GetName() <<
") unable to import clone of underlying RooDataHist with unique name " << uniqueName <<
", abort" << std::endl ;
508 if (getColonSeparatedNameString(*dh1.
get()) != getColonSeparatedNameString(*dh2.
get()))
return false ;
556 harg->copyCache(parg,
true) ;
557 if (!harg->inRange(
nullptr)) {
572 std::vector<std::span<const double>> depData;
574 auto real =
dynamic_cast<const RooAbsReal*
>(dep);
576 depData.push_back(dataMap.
at(real));
578 depData.emplace_back();
582 const auto batchSize = std::max_element(depData.begin(), depData.end(),
583 [](
const std::span<const double>&
a,
const std::span<const double>&
b){ return a.size() < b.size(); })->size();
584 std::vector<Int_t> results;
586 for (std::size_t evt = 0; evt < batchSize; ++evt) {
591 if (evt < depData[i].
size())
592 harg->setCachedValue(depData[i][evt],
false);
594 if (!harg->inRange(
nullptr)) {
595 results.push_back(-1);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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.
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 ...
RooAbsBinning is the 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.
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.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
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 void setVal(double value)=0
Set the current value of the object. Needs to be overridden by implementations.
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...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
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.
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.
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.
A class to maintain the context for squashing of RooFit models into code.
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
RooHistFunc implements 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)
std::vector< Int_t > getBins(RooFit::Detail::DataMap const &dataMap) const
Compute bin numbers corresponding to all coordinates in evalData.
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 sampling hint for making curves of (projections) of this function as the recursive division st...
std::unique_ptr< RooDataHist > _ownedDataHist
! Owned pointer to underlying histogram
void ioStreamerPass2() override
Schema evolution: if histObsList wasn't filled from persistence (v1) then fill it here.
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)
std::string buildCallToAnalyticIntegral(int code, const char *rangeName, RooFit::Detail::CodeSquashContext &ctx) const override
This function defines the analytical integral translation for the class.
double maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
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.
RooDataHist * cloneAndOwnDataHist(const char *newname="")
Replaces underlying RooDataHist with a clone, which is now owned, and returns the clone.
Int_t _intOrder
Interpolation order.
void computeBatch(double *output, size_t size, RooFit::Detail::DataMap const &) const override
Base function for computing multiple values of a RooAbsReal.
RooSetProxy _depList
List of observables mapped onto histogram observables.
RooArgSet _histObsList
List of observables defining dimensions of histogram.
static void rooHistTranslateImpl(RooAbsArg const *klass, RooFit::Detail::CodeSquashContext &ctx, int intOrder, RooDataHist const *dataHist, const RooArgSet &obs, bool correctForBinSize)
bool forceAnalyticalInt(const RooAbsArg &dep) const override
static std::string rooHistIntegralTranslateImpl(int code, RooAbsArg const *klass, RooDataHist const *dataHist, const RooArgSet &obs, bool histFuncMode)
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.
RooRealVar represents a 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=':')