16#ifndef ROO_CACHE_MANAGER
17#define ROO_CACHE_MANAGER
46 return getObj(nset,
nullptr,sterileIndex,isetRangeName) ;
51 return setObj(nset,
nullptr,obj,isetRangeName) ;
76 bool ,
bool )
override {
97 }
else if (
_size==1) {
100 }
else if (
_size>1) {
101 oocoutI(
_owner,Optimization) <<
"RooCacheManager::wireCache(" <<
_owner->
GetName() <<
") cache cannot be wired because it contains more than one element" << std::endl ;
154 :
RooAbsCache(other, owner), _maxSize(other._maxSize), _size(other._size)
163 for (i=0 ; i<other.
_size ; i++) {
177 for (
int i=0 ; i<_size ; i++) {
187 for (
int i=0 ; i<_maxSize ; i++) {
190 _nsetCache[i].clear() ;
203 for (i=0 ; i<_maxSize ; i++) {
215 Int_t sterileIdx(-1) ;
216 if (getObj(nset,iset,&sterileIdx,isetRangeName)) {
225 if (sterileIdx>=_maxSize) {
227 _maxSize = sterileIdx+4;
228 _object.resize(_maxSize,
nullptr) ;
229 _nsetCache.resize(_maxSize) ;
233 _object[sterileIdx] = obj ;
236 insertObjectHook(*obj) ;
241 if (_size>=_maxSize-1) {
244 _object.resize(_maxSize,
nullptr) ;
245 _nsetCache.resize(_maxSize) ;
249 _nsetCache[_size].autoCache(_owner,nset,iset,isetRangeName,
true) ;
250 if (_object[_size]) {
251 delete _object[_size] ;
254 _object[_size] = obj ;
258 insertObjectHook(*obj) ;
275 if(_object[0]==
nullptr && sterileIdx) *sterileIdx=0 ;
280 for (i=0 ; i<_size ; i++) {
281 if (_nsetCache[i].contains(nset,iset,isetRangeName)==
true) {
283 if(_object[i]==
nullptr && sterileIdx) *sterileIdx=i ;
288 for (i=0 ; i<_size ; i++) {
289 if (_nsetCache[i].autoCache(_owner,nset,iset,isetRangeName,
false)==
false) {
291 if(_object[i]==
nullptr && sterileIdx) *sterileIdx=i ;
304 if (index<0||index>=_size) {
305 oocoutE(_owner,ObjectHandling) <<
"RooCacheManager::getNormListByIndex: ERROR index ("
306 <<
index <<
") out of range [0," << _size-1 <<
"]" << std::endl ;
309 return _object[
index] ;
#define ClassDefOverride(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Abstract base class for data members of RooAbsArgs that cache other (composite) RooAbsArg expressions...
RooAbsArg * _owner
Pointer to owning RooAbsArg.
Abstract container object that can hold multiple RooAbsArg objects.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Manages the storage of any type of data indexed on the choice of normalization and optionally the set...
Int_t setObj(const RooArgSet *nset, const RooArgSet *iset, T *obj, const TNamed *isetRangeName=nullptr)
Insert payload object 'obj' in cache indexed on nset,iset and isetRangeName.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=nullptr)
Setter function without integration set.
RooCacheManager(Int_t maxSize=2)
Constructor for simple caches without RooAbsArg payload.
RooCacheManager(const RooCacheManager &other, RooAbsArg *owner=nullptr)
Copy constructor.
Int_t cacheSize() const
Return size of cache.
void printCompactTreeHook(std::ostream &, const char *) override
Interface function to cache add contents to output in tree printing mode.
virtual void insertObjectHook(T &)
Interface function to perform post-insert operations on cached object.
virtual void sterilize()
Clear the cache payload but retain slot mapping w.r.t to normalization and integration sets.
std::vector< T * > _object
! Payload
std::vector< RooNormSetCache > _nsetCache
! Normalization/Integration set manager
~RooCacheManager() override
Destructor.
RooArgSet selectFromSet1(RooArgSet const &argSet, int index) const
Create RooArgSet containing the objects that are both in the cached set 1 with a given index and an i...
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
RooArgSet selectFromSet2(RooArgSet const &argSet, int index) const
Create RooArgSet containing the objects that are both in the cached set 2 with a given index and an i...
bool redirectServersHook(const RooAbsCollection &, bool, bool, bool) override
Interface function to intercept server redirects.
void reset()
Clear the cache.
Int_t lastIndex() const
Return index of slot used in last get or set operation.
void operModeHook() override
Interface function to intercept cache operation mode changes.
T * getObj(const RooArgSet *nset, const RooArgSet *iset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Retrieve payload object indexed on nset,uset amd isetRangeName If sterileIdx is not null,...
Int_t _maxSize
! Maximum size
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
void wireCache() override
T * getObj(const RooArgSet *nset, const RooArgSet *iset, Int_t *sterileIdx, const char *isetRangeName)
RooCacheManager(RooAbsArg *owner, Int_t maxSize=2)
Constructor for simple caches with RooAbsArg derived payload.
Int_t _lastIndex
! Last slot accessed
bool _wired
! In wired mode, there is a single payload which is returned always
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.