58 _cacheMgr(other._cacheMgr,this),
59 _ipOrder(other._ipOrder),
60 _disableCache(other._disableCache)
79 double value = cachedPdf->
getVal(nset) ;
80 _norm = cachedPdf->_norm;
92 return cache ? cache->
pdf() :
nullptr;
102 return cache ? cache->
hist() :
nullptr;
125 int sterileIdx = -1 ;
130 if (cache->paramTracker()->hasChanged(
true) && (recalculate || !cache->pdf()->haveUnitNorm()) ) {
131 cxcoutD(Eval) <<
"RooAbsCachedPdf::getCache(" <<
GetName() <<
") cache " << cache <<
" pdf "
132 << cache->
pdf()->
GetName() <<
" requires recalculation as parameters changed" << std::endl ;
134 cache->pdf()->setValueDirty() ;
147 cache->hist()->
reset() ;
148 cache->hist()->add(*htmp) ;
155 eoclone->removeSelfFromDir() ;
164 coutI(Caching) <<
"RooAbsCachedPdf::getCache(" <<
GetName() <<
") creating new cache " << cache <<
" with pdf "
165 << cache->pdf()->GetName() <<
" for nset " << (nset?*nset:
RooArgSet()) <<
" with code " << code ;
167 ccoutI(Caching) <<
" from preexisting content." ;
169 ccoutI(Caching) << std::endl ;
195 _hist = std::make_unique<RooDataHist>(hname,hname,orderedObs,self.
binningName()) ;
196 _hist->removeSelfFromDir() ;
204 for(
auto const& harg : orderedObs) {
208 pdfFinalObs.
add(po) ;
217 if (nsetIn && !nsetIn->
empty()) {
219 for (
auto *arg : *nsetIn)
220 pdfname += std::string(
"_") + arg->GetName();
230 params->
remove(pdfFinalObs,
true,
true) ;
232 auto name = std::string(
_pdf->GetName()) +
"_CACHEPARAMS";
238 _pdf->addServerList(*params) ;
241 _pdf->setValueDirty() ;
252 std::string
name =
"_Obs[";
255 for(
auto const& arg : nset) {
261 name += arg->GetName();
284 cache->pdf()->setInterpolationOrder(order) ;
297 ret.
add(*_paramTracker) ;
309 os <<
indent <<
"--- RooAbsCachedPdf begin cache ---" << std::endl ;
312 os <<
"[" << curElem <<
"]" <<
" Configuration for observables " << _nset << std::endl;
313 auto indent2 = std::string(
indent) +
"[" + std::to_string(curElem) +
"]";
314 _pdf->printCompactTree(os,indent2.c_str()) ;
316 os <<
"[" << curElem <<
"] Norm ";
320 if (curElem==maxElem) {
321 os <<
indent <<
"--- RooAbsCachedPdf end cache --- " << std::endl ;
345 if (allVars.
empty()) {
364 std::vector<int> codeList(2);
367 int masterCode =
_anaReg.
store(codeList,all,ana,nrm)+1 ;
372 analVars.
add(allVars,
true) ;
391 RooArgSet *allVars(0),*anaVars(0),*normSet2(0),*dummy(0) ;
392 const std::vector<int> codeList =
_anaReg.
retrieve(code-1,allVars,anaVars,normSet2,dummy) ;
399 factObs.
remove(*anaVars,
true,
true) ;
400 for(
auto * arg : dynamic_range_cast<RooAbsLValue*>(factObs)) {
401 ret *= arg->volume(rangeName) ;
412 cachePdf->computeBatch(stream,
output, nEvents, dataMap);
static void indent(ostringstream &buf, int indent_level)
const std::vector< Int_t > & retrieve(Int_t masterCode) const
Retrieve the array of integer codes associated with the given master code.
Int_t store(const std::vector< Int_t > &codeList, RooArgSet *set1=0, RooArgSet *set2=0, RooArgSet *set3=0, RooArgSet *set4=0)
Store given arrays of integer codes, and up to four RooArgSets in the registry (each setX pointer may...
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooExpensiveObjectCache & expensiveObjectCache() const
virtual Bool_t isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
virtual RooArgList containedArgs(Action)
Returns all RooAbsArg objects contained in the cache element.
std::unique_ptr< RooChangeTracker > _paramTracker
PdfCacheElem(const RooAbsCachedPdf &self, const RooArgSet *nset)
Constructor of cache object which owns RooDataHist cache histogram, RooHistPdf pdf that represents is...
std::unique_ptr< RooHistPdf > _pdf
virtual void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t)
Print contents of cache when printing self as part of object tree.
std::unique_ptr< RooDataHist > _hist
RooAbsCachedPdf is the abstract base class for p.d.f.s that need or want to cache their evaluate() ou...
Int_t getInterpolationOrder() const
virtual RooAbsArg & pdfObservable(RooAbsArg &histObservable) const
virtual PdfCacheElem * createCache(const RooArgSet *nset) const
PdfCacheElem * getCache(const RooArgSet *nset, bool recalculate=true) const
Retrieve cache object associated with given choice of observables.
virtual RooArgSet * actualParameters(const RooArgSet &nset) const =0
virtual TString histNameSuffix() const
virtual const char * binningName() const
virtual const char * inputBaseName() const =0
virtual bool forceAnalyticalInt(const RooAbsArg &dep) const
Force RooRealIntegral to offer all our actual observable for internal integration.
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const
Base function for computing multiple values of a RooAbsReal.
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const
Advertises internal (analytical) integration capabilities.
RooAbsPdf * getCachePdf(const RooArgSet &nset) const
RooDataHist * getCacheHist(const RooArgSet &nset) const
bool _disableCache
Map for analytical integration codes.
virtual void fillCacheObject(PdfCacheElem &cache) const =0
void clearCacheObject(PdfCacheElem &cache) const
Mark all bins of given cache as unitialized (value -1)
virtual double getValV(const RooArgSet *set=nullptr) const
Implementation of getVal() overriding default implementation of RooAbsPdf.
RooObjCacheManager _cacheMgr
Int_t _ipOrder
The cache manager
virtual const char * payloadUniqueSuffix() const
virtual RooArgSet * actualObservables(const RooArgSet &nset) const =0
virtual double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const
Implements internal (analytical) integration capabilities.
std::string cacheNameSuffix(const RooArgSet &nset) const
Construct string with unique suffix for cache objects based on observable names that define cache con...
void setInterpolationOrder(int order)
Change the interpolation order that is used in RooHistPdf cache representation smoothing the RooDataH...
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
RooArgSet const * _normSet
Normalization integral (owned by _normMgr)
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Analytical integral with normalization (see RooAbsReal::analyticalIntegralWN() for further informatio...
virtual Double_t getValV(const RooArgSet *set=0) const
Return current value, normalized by integrating over the observables in nset.
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual void preferredObservableScanOrder(const RooArgSet &obs, RooArgSet &orderedObs) const
Interface method for function objects to indicate their preferred order of observables for scanning t...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
The RooDataHist is a container class to hold N-dimensional binned data.
void setAllWeights(Double_t value)
Set all the event weight of all bins to the specified value.
void reset() override
Reset all bin weights to zero.
Bool_t registerObject(const char *ownerName, const char *objectName, TObject &cacheObject, TIterator *paramIter)
Register object associated with given name and given associated parameters with given values in cache...
const TObject * retrieveObject(const char *name, TClass *tclass, const RooArgSet ¶ms)
Retrieve object from cache that was registered under given name with given parameters,...
Bool_t haveUnitNorm() const
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
virtual const char * GetName() const
Returns name of object.
const char * Data() const
static void output(int code)