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;
115 int sterileIdx = -1 ;
120 if (cache->paramTracker()->hasChanged(
true) && (recalculate || !cache->pdf()->haveUnitNorm()) ) {
121 cxcoutD(Eval) <<
"RooAbsCachedPdf::getCache(" <<
GetName() <<
") cache " << cache <<
" pdf "
122 << cache->pdf()->GetName() <<
" requires recalculation as parameters changed" << std::endl ;
124 cache->pdf()->setValueDirty() ;
135 eoclone->removeSelfFromDir() ;
140 coutI(Caching) <<
"RooAbsCachedPdf::getCache(" <<
GetName() <<
") creating new cache " << cache <<
" with pdf "
141 << cache->pdf()->GetName() <<
" for nset " << (nset?*nset:
RooArgSet()) <<
" with code " << code ;
142 ccoutI(Caching) << std::endl ;
168 _hist = std::make_unique<RooDataHist>(hname,hname,orderedObs,self.
binningName()) ;
169 _hist->removeSelfFromDir() ;
177 for(
auto const& harg : orderedObs) {
181 pdfFinalObs.
add(po) ;
190 if (nsetIn && !nsetIn->
empty()) {
192 for (
auto *arg : *nsetIn)
193 pdfname += std::string(
"_") + arg->GetName();
203 params->remove(pdfFinalObs,
true,
true) ;
205 auto name = std::string(
_pdf->GetName()) +
"_CACHEPARAMS";
211 _pdf->addServerList(*params) ;
214 _pdf->setValueDirty() ;
225 std::string
name =
"_Obs[";
228 for(
auto const& arg : nset) {
234 name += arg->GetName();
257 cache->pdf()->setInterpolationOrder(order) ;
270 ret.
add(*_paramTracker) ;
282 os <<
indent <<
"--- RooAbsCachedPdf begin cache ---" << std::endl ;
285 os <<
"[" << curElem <<
"]" <<
" Configuration for observables " << _nset << std::endl;
286 auto indent2 = std::string(
indent) +
"[" + std::to_string(curElem) +
"]";
287 _pdf->printCompactTree(os,indent2.c_str()) ;
289 os <<
"[" << curElem <<
"] Norm ";
293 if (curElem==maxElem) {
294 os <<
indent <<
"--- RooAbsCachedPdf end cache --- " << std::endl ;
318 if (allVars.
empty()) {
337 std::vector<int> codeList(2);
340 int masterCode =
_anaReg.
store(codeList,&all,&ana,&nrm)+1 ;
345 analVars.
add(allVars,
true) ;
363 if (code < 0 || (code-1) >=
static_cast<int>(
_anaReg.
size())) {
364 coutE(Integration) <<
"RooAbsCachedPdf::analyticalIntegralWN(" <<
GetName()
365 <<
"): analytical integration registry is empty for code: " << code <<
"."
366 <<
" RooWorkspace is not prepared to store integrals to functions when these inherit from RooAbsCachedPdf."
372 std::vector<int>
const &codeList = retrieved.
codes;
382 const RooArgSet *cacheNset = (normSet2 && !normSet2->
empty()) ? normSet2 : anaVars;
388 factObs.
remove(*anaVars,
true,
true) ;
389 for(
auto * arg : dynamic_range_cast<RooAbsLValue*>(factObs)) {
390 ret *= arg->volume(rangeName) ;
405std::unique_ptr<RooAbsArg>
408 if (normSet.
empty()) {
411 std::unique_ptr<RooAbsPdf> pdfClone(
static_cast<RooAbsPdf *
>(this->
Clone()));
422 cachedClone->_compiledNormSet.add(normSet);
423 cachedClone->_hasCompiledNormSet =
true;
425 auto newArg = std::make_unique<RooFit::Detail::RooNormalizedPdf>(*pdfClone, normSet);
430 newArg->addOwnedComponents(std::move(pdfClone));
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
int store(const std::vector< int > &codeList, RooArgSet *set1=nullptr, RooArgSet *set2=nullptr, RooArgSet *set3=nullptr, RooArgSet *set4=nullptr)
Store given arrays of integer codes, and up to four RooArgSets in the registry (each setX pointer may...
Output retrieve(int masterCode)
Retrieve the array of integer codes associated with the given master code, together with the (up to f...
std::size_t size() const
Number of stored code lists.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expression tree)
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Abstract base class for objects to be stored in RooAbsCache cache manager objects.
RooArgList containedArgs(Action) override
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...
void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t) override
Print contents of cache when printing self as part of object tree.
std::unique_ptr< RooHistPdf > _pdf
std::unique_ptr< RooDataHist > _hist
Abstract base class for p.d.f.s that need or want to cache their evaluate() output in a RooHistPdf de...
Int_t getInterpolationOrder() const
virtual RooAbsArg & pdfObservable(RooAbsArg &histObservable) const
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Advertises internal (analytical) integration capabilities.
double getValV(const RooArgSet *set=nullptr) const override
Implementation of getVal() overriding default implementation of RooAbsPdf.
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 RooFit::OwningPtr< RooArgSet > actualObservables(const RooArgSet &nset) const =0
RooAICRegistry _anaReg
! Registry for analytical integration codes
virtual TString histNameSuffix() const
virtual const char * binningName() const
bool _hasCompiledNormSet
! whether _compiledNormSet has been populated
bool forceAnalyticalInt(const RooAbsArg &dep) const override
Force RooRealIntegral to offer all our actual observable for internal integration.
virtual const char * inputBaseName() const =0
RooAbsPdf * getCachePdf(const RooArgSet &nset) const
RooDataHist * getCacheHist(const RooArgSet &nset) const
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
bool _disableCache
Flag to run object in passthrough (= non-caching mode)
virtual void fillCacheObject(PdfCacheElem &cache) const =0
RooObjCacheManager _cacheMgr
! The cache manager
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Implements internal (analytical) integration capabilities.
virtual const char * payloadUniqueSuffix() const
std::string cacheNameSuffix(const RooArgSet &nset) const
Construct string with unique suffix for cache objects based on observable names that define cache con...
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
void setInterpolationOrder(int order)
Change the interpolation order that is used in RooHistPdf cache representation smoothing the RooDataH...
RooArgSet _compiledNormSet
Pinned at compileForNormSet() time on the cloned cache pdf, so that doEval() looks up the same _cache...
virtual RooFit::OwningPtr< RooArgSet > actualParameters(const RooArgSet &nset) const =0
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
Abstract interface for all probability density functions.
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
double getValV(const RooArgSet *set=nullptr) const override
Return current value, normalized by integrating over the observables in nset.
RooArgSet const * _normSet
! Normalization set with for above integral
RooAbsReal * _norm
! Normalization integral (owned by _normMgr)
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Analytical integral with normalization (see RooAbsReal::analyticalIntegralWN() for further informatio...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
double _value
Cache for current value of 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...
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.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=nullptr)
Setter function without integration set.
Int_t cacheSize() const
Return size of cache.
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
Container class to hold N-dimensional binned data.
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
void markSubtreeAsCompiled(RooAbsArg &arg) const
Mark arg and every branch node reachable through its server tree as already compiled.
bool 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,...
const char * GetName() const override
Returns name of object.
const char * Data() const
std::vector< int > const & codes