Logo ROOT   6.10/09
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
void setInterpolationOrder(Int_t order)
Set interpolation order of RooHistFunct representing cache histogram.
void disableCache(Bool_t flag)
virtual Double_t getValV(const RooArgSet *set=0) const
Implementation of getVal() overriding default implementation of RooAbsReal.
TString cacheNameSuffix(const RooArgSet &nset) const
Construct unique suffix name for cache p.d.f object.
Bool_t _disableCache
Map for analytical integration codes.
virtual Bool_t selfNormalized() const
Basic string class.
Definition: TString.h:129
std::map< Int_t, std::pair< const RooArgSet *, const RooArgSet * > > _anaIntMap
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void clearCacheObject(FuncCacheElem &cache) const
Mark all bins as unitialized (value -1)
virtual const char * inputBaseName() const =0
RooDataSet is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
#define ClassDef(name, id)
Definition: Rtypes.h:297
RooHistFunc implements a real-valued function sampled from a multidimensional histogram.
Definition: RooHistFunc.h:29
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...
RooChangeTracker * paramTracker()
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Forward call to implementation in relevant RooHistFunc instance.
RooAbsCachedReal is the abstract base class for functions that need or want to cache their evaluate()...
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
virtual RooArgList containedArgs(Action)
Return list of contained RooAbsArg objects.
virtual Bool_t forceAnalyticalInt(const RooAbsArg &) const
FuncCacheElem(const RooAbsCachedReal &self, const RooArgSet *nset)
Constructor of cache storage unit class.
FuncCacheElem * getCache(const RooArgSet *nset) const
Retrieve cache corresponding to observables in nset.
virtual const char * binningName() const
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
virtual RooArgSet * actualParameters(const RooArgSet &nset) const =0
Int_t getInterpolationOrder() const
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
Int_t _ipOrder
The cache manager.
RooObjCacheManager _cacheMgr
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
virtual void fillCacheObject(FuncCacheElem &cache) const =0
virtual void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t)
Print contents of cache when printing self as part of object tree.
void setSourceClone(RooAbsReal *newSource)
virtual RooArgSet * actualObservables(const RooArgSet &nset) const =0
virtual const char * payloadUniqueSuffix() const
virtual FuncCacheElem * createCache(const RooArgSet *nset) const
Interface function to create an internal cache object that represent each cached function configurati...
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
virtual ~RooAbsCachedReal()
Destructor.
const Bool_t kTRUE
Definition: RtypesCore.h:91