Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAbsCachedReal.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * *
4 * Copyright (c) 2000-2005, Regents of the University of California *
5 * and Stanford University. All rights reserved. *
6 * *
7 * Redistribution and use in source and binary forms, *
8 * with or without modification, are permitted according to the terms *
9 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
10 *****************************************************************************/
11
12#ifndef ROOABSCACHEDREAL
13#define ROOABSCACHEDREAL
14
15#include "RooAbsPdf.h"
16#include "RooRealProxy.h"
17#include "RooAbsReal.h"
18#include "RooHistFunc.h"
19#include "RooObjCacheManager.h"
20#include <map>
21class RooChangeTracker ;
22class RooArgSet ;
23
25public:
26
28 RooAbsCachedReal(const char *name, const char *title, Int_t ipOrder=0);
29 RooAbsCachedReal(const RooAbsCachedReal& other, const char* name=nullptr) ;
30
31 double getValV(const RooArgSet* set=nullptr) const override ;
32 virtual bool selfNormalized() const {
33 // Declares function self normalized
34 return true ;
35 }
36
37 void setInterpolationOrder(Int_t order) ;
39 // Set interpolation order in RooHistFuncs that represent cache histograms
40 return _ipOrder ;
41 }
42
43 bool forceAnalyticalInt(const RooAbsArg& /*dep*/) const override {
44 // Force all observables to be offered for internal integration
45 return true ;
46 }
47
48 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
49 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
50
51 void disableCache(bool flag) {
52 // Switch to disable caching mechanism
53 _disableCache = flag ;
54 }
55
56protected:
57
59 public:
60 FuncCacheElem(const RooAbsCachedReal& self, const RooArgSet* nset) ;
61 ~FuncCacheElem() override ;
62
63 // Cache management functions
65 void printCompactTreeHook(std::ostream&, const char *, Int_t, Int_t) override ;
66
67 RooHistFunc* func() { return _func ; }
68 RooDataHist* hist() { return _hist ; }
70
72 void setSourceClone(RooAbsReal* newSource) { delete _sourceClone ; _sourceClone = newSource ; }
73
74 bool cacheSource() { return _cacheSource ; }
75 void setCacheSource(bool flag) { _cacheSource = flag ; }
76
77 // Not Relevant for RooAbsCachedReal, only the RooAbsCachedPdf.
78 void setUnitNorm() { }
79
80 private:
81 // Payload
87 } ;
88
90
91 FuncCacheElem* getCache(const RooArgSet* nset) const ;
92
93 virtual const char* payloadUniqueSuffix() const { return nullptr ; }
94
95 friend class FuncCacheElem ;
96 virtual const char* binningName() const {
97 // Returns name of binning to be used for cache histogram creation
98 return "cache" ;
99 }
100 virtual FuncCacheElem* createCache(const RooArgSet* nset) const ;
101 virtual const char* inputBaseName() const = 0 ;
104 virtual void fillCacheObject(FuncCacheElem& cache) const = 0 ;
105
106 mutable RooObjCacheManager _cacheMgr ; ///<! The cache manager
107
108
109 Int_t _ipOrder ; ///< Interpolation order for cache histograms
110
111 TString cacheNameSuffix(const RooArgSet& nset) const ;
112
113 mutable std::map<Int_t,std::pair<const RooArgSet*,const RooArgSet*> > _anaIntMap ; ///<! Map for analytical integration codes
114
115
116private:
117
118 bool _disableCache ; // Flag to run object in passthrough (= non-caching mode)
119
120 ClassDefOverride(RooAbsCachedReal,1) // Abstract base class for cached p.d.f.s
121};
122
123#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
char name[80]
Definition TGX11.cxx:110
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
Abstract base class for objects to be stored in RooAbsCache cache manager objects.
void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t) override
Print contents of cache when printing self as part of object tree.
RooChangeTracker * paramTracker()
RooArgList containedArgs(Action) override
Return list of contained RooAbsArg objects.
void setSourceClone(RooAbsReal *newSource)
Abstract base class for functions that need or want to cache their evaluate() output in a RooHistFunc...
void setInterpolationOrder(Int_t order)
Set interpolation order of RooHistFunct representing cache histogram.
virtual void fillCacheObject(FuncCacheElem &cache) const =0
virtual const char * inputBaseName() const =0
virtual FuncCacheElem * createCache(const RooArgSet *nset) const
Interface function to create an internal cache object that represent each cached function configurati...
virtual RooFit::OwningPtr< RooArgSet > actualParameters(const RooArgSet &nset) const =0
TString cacheNameSuffix(const RooArgSet &nset) const
Construct unique suffix name for cache p.d.f object.
FuncCacheElem * getCache(const RooArgSet *nset) const
Retrieve cache corresponding to observables in nset.
virtual bool selfNormalized() const
void disableCache(bool flag)
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Forward call to implementation in relevant RooHistFunc instance.
RooObjCacheManager _cacheMgr
! The cache manager
Int_t _ipOrder
Interpolation order for cache histograms.
Int_t getInterpolationOrder() const
virtual RooFit::OwningPtr< RooArgSet > actualObservables(const RooArgSet &nset) const =0
std::map< Int_t, std::pair< const RooArgSet *, const RooArgSet * > > _anaIntMap
! Map for analytical integration codes
bool forceAnalyticalInt(const RooAbsArg &) const override
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Return analytical integration capabilities of the RooHistFunc that corresponds to the set of observab...
virtual const char * payloadUniqueSuffix() const
double getValV(const RooArgSet *set=nullptr) const override
Implementation of getVal() overriding default implementation of RooAbsReal.
virtual const char * binningName() const
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Meta object that tracks value changes in a given set of RooAbsArgs by registering itself as value cli...
Container class to hold N-dimensional binned data.
Definition RooDataHist.h:40
A real-valued function sampled from a multidimensional histogram.
Definition RooHistFunc.h:31
Implementation of a RooCacheManager<RooAbsCacheElement> that specializes in the storage of cache elem...
Basic string class.
Definition TString.h:139
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
Definition Config.h:35