Logo ROOT   6.08/07
Reference Guide
RooAbsCachedPdf.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 ROOABSCACHEDPDF
13 #define ROOABSCACHEDPDF
14 
15 #include "RooAbsPdf.h"
16 #include "RooRealProxy.h"
17 #include "RooAbsReal.h"
18 #include "RooHistPdf.h"
19 #include "RooObjCacheManager.h"
20 #include "RooAICRegistry.h"
21 #include <map>
22 class RooArgSet ;
23 class RooChangeTracker ;
24 
25 class RooAbsCachedPdf : public RooAbsPdf {
26 public:
27 
29  // Default constructor
30  } ;
31  RooAbsCachedPdf(const char *name, const char *title, Int_t ipOrder=0);
32  RooAbsCachedPdf(const RooAbsCachedPdf& other, const char* name=0) ;
33  virtual ~RooAbsCachedPdf() ;
34 
35  virtual Double_t getValV(const RooArgSet* set=0) const ;
36  virtual Bool_t selfNormalized() const {
37  // Declare p.d.f self normalized
38  return kTRUE ;
39  }
40 
41  RooAbsPdf* getCachePdf(const RooArgSet& nset) const {
42  // Return RooHistPdf that represents cache histogram
43  return getCachePdf(&nset) ;
44  }
45  RooDataHist* getCacheHist(const RooArgSet& nset) const {
46  // Return RooDataHist with cached values
47  return getCacheHist(&nset) ;
48  }
49  RooAbsPdf* getCachePdf(const RooArgSet* nset=0) const ;
50  RooDataHist* getCacheHist(const RooArgSet* nset=0) const ;
51 
52  void setInterpolationOrder(Int_t order) ;
54  // Set interpolation order in RooHistPdf that represent cached histogram
55  return _ipOrder ;
56  }
57 
58  virtual Bool_t forceAnalyticalInt(const RooAbsArg& dep) const ;
59  virtual Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet, const char* rangeName=0) const ;
60  virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
61 
62 
64  public:
65  PdfCacheElem(const RooAbsCachedPdf& self, const RooArgSet* nset) ;
66  virtual ~PdfCacheElem() ;
67 
68  // Cache management functions
70  virtual void printCompactTreeHook(std::ostream&, const char *, Int_t, Int_t) ;
71 
72  RooHistPdf* pdf() { return _pdf ; }
73  RooDataHist* hist() { return _hist ; }
74  const RooArgSet& nset() { return _nset ; }
76 
77  private:
78  // Payload
84 
85  } ;
86 
87  protected:
88 
89  PdfCacheElem* getCache(const RooArgSet* nset, Bool_t recalculate=kTRUE) const ;
90  void clearCacheObject(PdfCacheElem& cache) const ;
91 
92  virtual const char* payloadUniqueSuffix() const { return 0 ; }
93 
94  friend class PdfCacheElem ;
95  virtual const char* binningName() const {
96  // Return name of binning to be used for creation of cache histogram
97  return "cache" ;
98  }
99  virtual PdfCacheElem* createCache(const RooArgSet* nset) const {
100  // Create cache storage element
101  return new PdfCacheElem(*this,nset) ;
102  }
103  virtual const char* inputBaseName() const = 0 ;
104  virtual RooArgSet* actualObservables(const RooArgSet& nset) const = 0 ;
105  virtual RooArgSet* actualParameters(const RooArgSet& nset) const = 0 ;
106  virtual RooAbsArg& pdfObservable(RooAbsArg& histObservable) const { return histObservable ; }
107  virtual void fillCacheObject(PdfCacheElem& cache) const = 0 ;
108 
109  mutable RooObjCacheManager _cacheMgr ; // The cache manager
110  Int_t _ipOrder ; // Interpolation order for cache histograms
111 
112  TString cacheNameSuffix(const RooArgSet& nset) const ;
113  virtual TString histNameSuffix() const { return TString("") ; }
114  void disableCache(Bool_t flag) {
115  // Flag to disable caching mechanism
116  _disableCache = flag ;
117  }
118 
119  mutable RooAICRegistry _anaReg ; //! Registry for analytical integration codes
120  class AnaIntConfig {
121  public:
124  const RooArgSet* _nset ;
126  } ;
127  mutable std::map<Int_t,AnaIntConfig> _anaIntMap ; //! Map for analytical integration codes
128 
129 
130 
131 private:
132 
133  Bool_t _disableCache ; // Flag to run object in passthrough (= non-caching mode)
134 
135  ClassDef(RooAbsCachedPdf,1) // Abstract base class for cached p.d.f.s
136 };
137 
138 #endif
PdfCacheElem * getCache(const RooArgSet *nset, Bool_t recalculate=kTRUE) const
Retrieve cache object associated with given choice of observables.
virtual PdfCacheElem * createCache(const RooArgSet *nset) const
RooChangeTracker * _paramTracker
virtual const char * inputBaseName() const =0
Basic string class.
Definition: TString.h:137
Registry for analytical integration codes.
virtual RooArgList containedArgs(Action)
Returns all RooAbsArg objects contained in the cache element.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
PdfCacheElem(const RooAbsCachedPdf &self, const RooArgSet *nset)
Constructor of cache object which owns RooDataHist cache histogram, RooHistPdf pdf that represents is...
virtual ~PdfCacheElem()
Cache element destructor.
virtual TString histNameSuffix() const
void clearCacheObject(PdfCacheElem &cache) const
Mark all bins of given cache as unitialized (value -1)
RooAbsPdf * getCachePdf(const RooArgSet &nset) const
RooDataSet is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implements internal (analytical) integration capabilities.
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Advertises internal (analytical) integration capabilities.
virtual ~RooAbsCachedPdf()
Destructor.
Bool_t _disableCache
Map for analytical integration codes.
virtual RooArgSet * actualParameters(const RooArgSet &nset) const =0
RooHistPdf implements a probablity density function sampled from a multidimensional histogram...
Definition: RooHistPdf.h:28
virtual const char * payloadUniqueSuffix() const
virtual const char * binningName() const
virtual Bool_t forceAnalyticalInt(const RooAbsArg &dep) const
Force RooRealIntegral to offer all our actual observable for internal integration.
virtual Double_t getValV(const RooArgSet *set=0) const
Implementation of getVal() overriding default implementation of RooAbsPdf.
virtual RooAbsArg & pdfObservable(RooAbsArg &histObservable) const
RooAICRegistry _anaReg
std::map< Int_t, AnaIntConfig > _anaIntMap
RooDataHist * getCacheHist(const RooArgSet &nset) const
virtual void fillCacheObject(PdfCacheElem &cache) const =0
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
virtual Bool_t selfNormalized() const
RooAICRegistry is a utility class for operator p.d.f classes that keeps track of analytical integrati...
RooAbsCachedPdf is the abstract base class for p.d.f.s that need or want to cache their evaluate() ou...
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
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
TString cacheNameSuffix(const RooArgSet &nset) const
Construct string with unique suffix for cache objects based on observable names that define cache con...
virtual void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t)
Print contents of cache when printing self as part of object tree.
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
virtual RooArgSet * actualObservables(const RooArgSet &nset) const =0
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
void setInterpolationOrder(Int_t order)
Change the interpolation order that is used in RooHistPdf cache representation smoothing the RooDataH...
void disableCache(Bool_t flag)
RooObjCacheManager _cacheMgr
RooChangeTracker * paramTracker()
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
const Bool_t kTRUE
Definition: Rtypes.h:91
Int_t getInterpolationOrder() const
char name[80]
Definition: TGX11.cxx:109