Logo ROOT  
Reference Guide
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>
21 class RooChangeTracker ;
22 class RooArgSet ;
23 
24 class RooAbsCachedReal : public RooAbsReal {
25 public:
26 
28  RooAbsCachedReal(const char *name, const char *title, Int_t ipOrder=0);
29  RooAbsCachedReal(const RooAbsCachedReal& other, const char* name=0) ;
30  virtual ~RooAbsCachedReal() ;
31 
32  virtual Double_t getValV(const RooArgSet* set=0) const ;
33  virtual Bool_t selfNormalized() const {
34  // Declares function self normalized
35  return kTRUE ;
36  }
37 
38  void setInterpolationOrder(Int_t order) ;
40  // Set interpolation order in RooHistFuncs that represent cache histograms
41  return _ipOrder ;
42  }
43 
44  virtual Bool_t forceAnalyticalInt(const RooAbsArg& /*dep*/) const {
45  // Force all observables to be offered for internal integration
46  return kTRUE ;
47  }
48 
49  virtual Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet, const char* rangeName=0) const ;
50  virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
51 
52  void disableCache(Bool_t flag) {
53  // Switch to disable caching mechanism
54  _disableCache = flag ;
55  }
56 
57 protected:
58 
60  public:
61  FuncCacheElem(const RooAbsCachedReal& self, const RooArgSet* nset) ;
62  virtual ~FuncCacheElem() ;
63 
64  // Cache management functions
66  virtual void printCompactTreeHook(std::ostream&, const char *, Int_t, Int_t) ;
67 
68  RooHistFunc* func() { return _func ; }
69  RooDataHist* hist() { return _hist ; }
71 
73  void setSourceClone(RooAbsReal* newSource) { delete _sourceClone ; _sourceClone = newSource ; }
74 
76  void setCacheSource(Bool_t flag) { _cacheSource = flag ; }
77 
78  private:
79  // Payload
85  } ;
86 
87  FuncCacheElem* getCache(const RooArgSet* nset) const ;
88  void clearCacheObject(FuncCacheElem& cache) const ;
89 
90  virtual const char* payloadUniqueSuffix() const { return 0 ; }
91 
92  friend class FuncCacheElem ;
93  virtual const char* binningName() const {
94  // Returns name of binning to be used for cache histogram creation
95  return "cache" ;
96  }
97  virtual FuncCacheElem* createCache(const RooArgSet* nset) const ;
98  virtual const char* inputBaseName() const = 0 ;
99  virtual RooArgSet* actualObservables(const RooArgSet& nset) const = 0 ;
100  virtual RooArgSet* actualParameters(const RooArgSet& nset) const = 0 ;
101  virtual void fillCacheObject(FuncCacheElem& cache) const = 0 ;
102 
103  mutable RooObjCacheManager _cacheMgr ; //! The cache manager
104 
105 
106  Int_t _ipOrder ; // Interpolation order for cache histograms
107 
108  TString cacheNameSuffix(const RooArgSet& nset) const ;
109 
110  mutable std::map<Int_t,std::pair<const RooArgSet*,const RooArgSet*> > _anaIntMap ; //! Map for analytical integration codes
111 
112 
113 private:
114 
115  Bool_t _disableCache ; // Flag to run object in passthrough (= non-caching mode)
116 
117  ClassDef(RooAbsCachedReal,1) // Abstract base class for cached p.d.f.s
118 };
119 
120 #endif
RooAbsCachedReal::_cacheMgr
RooObjCacheManager _cacheMgr
Definition: RooAbsCachedReal.h:103
RooAbsCachedReal::selfNormalized
virtual Bool_t selfNormalized() const
Definition: RooAbsCachedReal.h:33
RooAbsCachedReal::getAnalyticalIntegralWN
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Return analytical integration capabilities of the RooHistFunc that corresponds to the set of observab...
Definition: RooAbsCachedReal.cxx:343
RooAbsCachedReal::FuncCacheElem::FuncCacheElem
FuncCacheElem(const RooAbsCachedReal &self, const RooArgSet *nset)
Constructor of cache storage unit class.
Definition: RooAbsCachedReal.cxx:194
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooAbsReal.h
RooAbsCachedReal::_ipOrder
Int_t _ipOrder
The cache manager.
Definition: RooAbsCachedReal.h:106
RooAbsCachedReal::FuncCacheElem::_sourceClone
RooAbsReal * _sourceClone
Definition: RooAbsCachedReal.h:83
RooHistFunc.h
RooAbsCachedReal::FuncCacheElem::func
RooHistFunc * func()
Definition: RooAbsCachedReal.h:68
RooAbsCachedReal::FuncCacheElem::cacheSource
Bool_t cacheSource()
Definition: RooAbsCachedReal.h:75
RooAbsCachedReal::~RooAbsCachedReal
virtual ~RooAbsCachedReal()
Destructor.
Definition: RooAbsCachedReal.cxx:77
RooArgList
Definition: RooArgList.h:21
RooAbsCachedReal::RooAbsCachedReal
RooAbsCachedReal()
Definition: RooAbsCachedReal.h:27
RooAbsCachedReal::binningName
virtual const char * binningName() const
Definition: RooAbsCachedReal.h:93
RooAbsCachedReal::getCache
FuncCacheElem * getCache(const RooArgSet *nset) const
Retrieve cache corresponding to observables in nset.
Definition: RooAbsCachedReal.cxx:136
RooAbsCachedReal::fillCacheObject
virtual void fillCacheObject(FuncCacheElem &cache) const =0
RooAbsCachedReal::actualParameters
virtual RooArgSet * actualParameters(const RooArgSet &nset) const =0
RooAbsReal
Definition: RooAbsReal.h:61
RooAbsCachedReal::FuncCacheElem::_cacheSource
Bool_t _cacheSource
Definition: RooAbsCachedReal.h:84
RooAbsCachedReal::payloadUniqueSuffix
virtual const char * payloadUniqueSuffix() const
Definition: RooAbsCachedReal.h:90
RooAbsCacheElement
Definition: RooAbsCacheElement.h:26
TString
Definition: TString.h:136
RooAbsCachedReal::forceAnalyticalInt
virtual Bool_t forceAnalyticalInt(const RooAbsArg &) const
Definition: RooAbsCachedReal.h:44
bool
RooAbsCachedReal::getInterpolationOrder
Int_t getInterpolationOrder() const
Definition: RooAbsCachedReal.h:39
RooChangeTracker
Definition: RooChangeTracker.h:26
RooAbsCachedReal::clearCacheObject
void clearCacheObject(FuncCacheElem &cache) const
Mark all bins as unitialized (value -1)
Definition: RooAbsCachedReal.cxx:112
RooAbsCachedReal::FuncCacheElem::setSourceClone
void setSourceClone(RooAbsReal *newSource)
Definition: RooAbsCachedReal.h:73
RooAbsCachedReal::FuncCacheElem
friend class FuncCacheElem
Definition: RooAbsCachedReal.h:92
RooAbsCachedReal::FuncCacheElem::~FuncCacheElem
virtual ~FuncCacheElem()
Definition: RooAbsCachedReal.cxx:245
RooDataHist
Definition: RooDataHist.h:39
RooAbsCachedReal::FuncCacheElem::setCacheSource
void setCacheSource(Bool_t flag)
Definition: RooAbsCachedReal.h:76
RooAbsCachedReal::_disableCache
Bool_t _disableCache
Map for analytical integration codes.
Definition: RooAbsCachedReal.h:115
RooAbsPdf.h
RooAbsCachedReal::FuncCacheElem::containedArgs
virtual RooArgList containedArgs(Action)
Return list of contained RooAbsArg objects.
Definition: RooAbsCachedReal.cxx:308
RooAbsCachedReal::actualObservables
virtual RooArgSet * actualObservables(const RooArgSet &nset) const =0
RooRealProxy.h
RooAbsCachedReal::FuncCacheElem::hist
RooDataHist * hist()
Definition: RooAbsCachedReal.h:69
RooAbsCachedReal::analyticalIntegralWN
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Forward call to implementation in relevant RooHistFunc instance.
Definition: RooAbsCachedReal.cxx:357
RooAbsCachedReal::createCache
virtual FuncCacheElem * createCache(const RooArgSet *nset) const
Interface function to create an internal cache object that represent each cached function configurati...
Definition: RooAbsCachedReal.cxx:126
RooAbsCachedReal::inputBaseName
virtual const char * inputBaseName() const =0
RooAbsCachedReal::setInterpolationOrder
void setInterpolationOrder(Int_t order)
Set interpolation order of RooHistFunct representing cache histogram.
Definition: RooAbsCachedReal.cxx:291
RooHistFunc
Definition: RooHistFunc.h:30
RooObjCacheManager.h
RooAbsCachedReal::FuncCacheElem::_paramTracker
RooChangeTracker * _paramTracker
Definition: RooAbsCachedReal.h:81
RooAbsCachedReal::cacheNameSuffix
TString cacheNameSuffix(const RooArgSet &nset) const
Construct unique suffix name for cache p.d.f object.
Definition: RooAbsCachedReal.cxx:259
RooAbsCachedReal::FuncCacheElem::sourceClone
RooAbsReal * sourceClone()
Definition: RooAbsCachedReal.h:72
RooAbsCachedReal::disableCache
void disableCache(Bool_t flag)
Definition: RooAbsCachedReal.h:52
Double_t
double Double_t
Definition: RtypesCore.h:59
RooObjCacheManager
Definition: RooObjCacheManager.h:32
RooAbsCacheElement::Action
Action
Definition: RooAbsCacheElement.h:39
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
RooAbsArg
Definition: RooAbsArg.h:73
RooAbsCachedReal::FuncCacheElem::_hist
RooDataHist * _hist
Definition: RooAbsCachedReal.h:82
RooAbsCachedReal::getValV
virtual Double_t getValV(const RooArgSet *set=0) const
Implementation of getVal() overriding default implementation of RooAbsReal.
Definition: RooAbsCachedReal.cxx:89
RooAbsCachedReal::FuncCacheElem
Definition: RooAbsCachedReal.h:59
RooAbsCachedReal::_anaIntMap
std::map< Int_t, std::pair< const RooArgSet *, const RooArgSet * > > _anaIntMap
Definition: RooAbsCachedReal.h:110
RooAbsCachedReal::FuncCacheElem::paramTracker
RooChangeTracker * paramTracker()
Definition: RooAbsCachedReal.h:70
RooAbsCachedReal::FuncCacheElem::_func
RooHistFunc * _func
Definition: RooAbsCachedReal.h:80
RooAbsCachedReal
Definition: RooAbsCachedReal.h:24
RooArgSet
Definition: RooArgSet.h:28
int
RooAbsCachedReal::FuncCacheElem::printCompactTreeHook
virtual void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t)
Print contents of cache when printing self as part of object tree.
Definition: RooAbsCachedReal.cxx:323