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();
197 _nset.addClone(*nsetIn) ;
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();
255 for (
int i=0 ; i<
_cacheMgr.cacheSize() ; i++) {
257 cache->pdf()->setInterpolationOrder(order) ;
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."
375 const std::vector<int> codeList =
_anaReg.retrieve(code-1,allVars,anaVars,normSet2,dummy) ;
382 const RooArgSet *cacheNset = (normSet2 && !normSet2->
empty()) ? normSet2 : anaVars;
388 factObs.
remove(*anaVars,
true,
true) ;
390 ret *= arg->volume(rangeName) ;
405std::unique_ptr<RooAbsArg>
408 if (normSet.
empty()) {
411 std::unique_ptr<RooAbsPdf> pdfClone(
static_cast<RooAbsPdf *
>(this->
Clone()));
421 cachedClone->_compiledNormSet.removeAll();
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));
ROOT::RRangeCast< T, true, Range_t > dynamic_range_cast(Range_t &&coll)
static void indent(ostringstream &buf, int indent_level)
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?
RooAbsArg()
Default constructor.
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...
std::unique_ptr< RooAbsReal > _norm
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
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 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.
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...
RooAbsPdf()
Default constructor.
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.
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
const char * GetName() const override
Returns name of object.
const char * Data() const