ROOT  6.06/09
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 protected:
63 
65  public:
66  PdfCacheElem(const RooAbsCachedPdf& self, const RooArgSet* nset) ;
67  virtual ~PdfCacheElem() ;
68 
69  // Cache management functions
71  virtual void printCompactTreeHook(std::ostream&, const char *, Int_t, Int_t) ;
72 
73  RooHistPdf* pdf() { return _pdf ; }
74  RooDataHist* hist() { return _hist ; }
75  const RooArgSet& nset() { return _nset ; }
77 
78  private:
79  // Payload
85 
86  } ;
87 
88  PdfCacheElem* getCache(const RooArgSet* nset, Bool_t recalculate=kTRUE) const ;
89  void clearCacheObject(PdfCacheElem& cache) const ;
90 
91  virtual const char* payloadUniqueSuffix() const { return 0 ; }
92 
93  friend class PdfCacheElem ;
94  virtual const char* binningName() const {
95  // Return name of binning to be used for creation of cache histogram
96  return "cache" ;
97  }
98  virtual PdfCacheElem* createCache(const RooArgSet* nset) const {
99  // Create cache storage element
100  return new PdfCacheElem(*this,nset) ;
101  }
102  virtual const char* inputBaseName() const = 0 ;
103  virtual RooArgSet* actualObservables(const RooArgSet& nset) const = 0 ;
104  virtual RooArgSet* actualParameters(const RooArgSet& nset) const = 0 ;
105  virtual RooAbsArg& pdfObservable(RooAbsArg& histObservable) const { return histObservable ; }
106  virtual void fillCacheObject(PdfCacheElem& cache) const = 0 ;
107 
108  mutable RooObjCacheManager _cacheMgr ; // The cache manager
109  Int_t _ipOrder ; // Interpolation order for cache histograms
110 
111  TString cacheNameSuffix(const RooArgSet& nset) const ;
112  virtual TString histNameSuffix() const { return TString("") ; }
113  void disableCache(Bool_t flag) {
114  // Flag to disable caching mechanism
115  _disableCache = flag ;
116  }
117 
118  mutable RooAICRegistry _anaReg ; //! Registry for analytical integration codes
119  class AnaIntConfig {
120  public:
123  const RooArgSet* _nset ;
125  } ;
126  mutable std::map<Int_t,AnaIntConfig> _anaIntMap ; //! Map for analytical integration codes
127 
128 
129 
130 private:
131 
132  Bool_t _disableCache ; // Flag to run object in passthrough (= non-caching mode)
133 
134  ClassDef(RooAbsCachedPdf,1) // Abstract base class for cached p.d.f.s
135 };
136 
137 #endif
virtual Bool_t forceAnalyticalInt(const RooAbsArg &dep) const
Force RooRealIntegral to offer all our actual observable for internal integration.
virtual const char * binningName() const
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implements internal (analytical) integration capabilities.
RooChangeTracker * _paramTracker
virtual const char * inputBaseName() const =0
virtual Double_t getValV(const RooArgSet *set=0) const
Implementation of getVal() overriding default implementation of RooAbsPdf.
RooAbsPdf * getCachePdf(const RooArgSet &nset) const
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
virtual const char * payloadUniqueSuffix() const
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.
PdfCacheElem * getCache(const RooArgSet *nset, Bool_t recalculate=kTRUE) const
Retrieve cache object associated with given choice of observables.
virtual RooAbsArg & pdfObservable(RooAbsArg &histObservable) const
TString cacheNameSuffix(const RooArgSet &nset) const
Construct string with unique suffix for cache objects based on observable names that define cache con...
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t getInterpolationOrder() const
virtual ~RooAbsCachedPdf()
Destructor.
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Advertises internal (analytical) integration capabilities.
Bool_t _disableCache
Map for analytical integration codes.
virtual PdfCacheElem * createCache(const RooArgSet *nset) const
virtual RooArgSet * actualParameters(const RooArgSet &nset) const =0
friend class PdfCacheElem
RooAICRegistry _anaReg
std::map< Int_t, AnaIntConfig > _anaIntMap
virtual void fillCacheObject(PdfCacheElem &cache) const =0
RooDataHist * getCacheHist(const RooArgSet &nset) 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 void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t)
Print contents of cache when printing self as part of object tree.
#define name(a, b)
Definition: linkTestLib0.cpp:5
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 clearCacheObject(PdfCacheElem &cache) const
Mark all bins of given cache as unitialized (value -1)
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
virtual Bool_t selfNormalized() const
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual TString histNameSuffix() const