Logo ROOT  
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
RooAbsCachedPdf::fillCacheObject
virtual void fillCacheObject(PdfCacheElem &cache) const =0
RooAbsCachedPdf::AnaIntConfig::_anaVars
RooArgSet _anaVars
Definition: RooAbsCachedPdf.h:123
RooAbsCachedPdf::createCache
virtual PdfCacheElem * createCache(const RooArgSet *nset) const
Definition: RooAbsCachedPdf.h:99
RooAbsCachedPdf::clearCacheObject
void clearCacheObject(PdfCacheElem &cache) const
Mark all bins of given cache as unitialized (value -1)
Definition: RooAbsCachedPdf.cxx:141
RooAbsCachedPdf::RooAbsCachedPdf
RooAbsCachedPdf()
Definition: RooAbsCachedPdf.h:28
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooAbsReal.h
RooAbsCachedPdf::AnaIntConfig::_nset
const RooArgSet * _nset
Definition: RooAbsCachedPdf.h:124
RooAbsCachedPdf::~RooAbsCachedPdf
virtual ~RooAbsCachedPdf()
Destructor.
Definition: RooAbsCachedPdf.cxx:79
RooAbsCachedPdf::PdfCacheElem::pdf
RooHistPdf * pdf()
Definition: RooAbsCachedPdf.h:72
RooAICRegistry
Definition: RooAICRegistry.h:26
RooAbsCachedPdf::disableCache
void disableCache(Bool_t flag)
Definition: RooAbsCachedPdf.h:114
RooAbsCachedPdf::_ipOrder
Int_t _ipOrder
Definition: RooAbsCachedPdf.h:110
RooAbsCachedPdf::PdfCacheElem::_norm
RooAbsReal * _norm
Definition: RooAbsCachedPdf.h:83
RooAbsCachedPdf::getCachePdf
RooAbsPdf * getCachePdf(const RooArgSet &nset) const
Definition: RooAbsCachedPdf.h:41
RooAbsCachedPdf::PdfCacheElem::PdfCacheElem
PdfCacheElem(const RooAbsCachedPdf &self, const RooArgSet *nset)
Constructor of cache object which owns RooDataHist cache histogram, RooHistPdf pdf that represents is...
Definition: RooAbsCachedPdf.cxx:214
RooAbsCachedPdf::getValV
virtual Double_t getValV(const RooArgSet *set=0) const
Implementation of getVal() overriding default implementation of RooAbsPdf.
Definition: RooAbsCachedPdf.cxx:91
RooAbsCachedPdf::setInterpolationOrder
void setInterpolationOrder(Int_t order)
Change the interpolation order that is used in RooHistPdf cache representation smoothing the RooDataH...
Definition: RooAbsCachedPdf.cxx:326
RooAbsCachedPdf::_anaReg
RooAICRegistry _anaReg
Definition: RooAbsCachedPdf.h:119
RooAbsCachedPdf::selfNormalized
virtual Bool_t selfNormalized() const
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
Definition: RooAbsCachedPdf.h:36
RooArgList
Definition: RooArgList.h:21
RooAbsCachedPdf::_cacheMgr
RooObjCacheManager _cacheMgr
Definition: RooAbsCachedPdf.h:109
RooAbsCachedPdf::getAnalyticalIntegralWN
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Advertises internal (analytical) integration capabilities.
Definition: RooAbsCachedPdf.cxx:419
RooAbsCachedPdf::_anaIntMap
std::map< Int_t, AnaIntConfig > _anaIntMap
Definition: RooAbsCachedPdf.h:127
RooAbsReal
Definition: RooAbsReal.h:61
RooAbsCachedPdf::cacheNameSuffix
TString cacheNameSuffix(const RooArgSet &nset) const
Construct string with unique suffix for cache objects based on observable names that define cache con...
Definition: RooAbsCachedPdf.cxx:293
RooAbsCacheElement
Definition: RooAbsCacheElement.h:26
TString
Definition: TString.h:136
RooAbsCachedPdf::actualObservables
virtual RooArgSet * actualObservables(const RooArgSet &nset) const =0
RooAbsCachedPdf::PdfCacheElem
friend class PdfCacheElem
Definition: RooAbsCachedPdf.h:94
bool
RooAbsCachedPdf::getCache
PdfCacheElem * getCache(const RooArgSet *nset, Bool_t recalculate=kTRUE) const
Retrieve cache object associated with given choice of observables.
Definition: RooAbsCachedPdf.cxx:154
RooAbsCachedPdf::PdfCacheElem::paramTracker
RooChangeTracker * paramTracker()
Definition: RooAbsCachedPdf.h:75
RooChangeTracker
Definition: RooChangeTracker.h:26
RooAbsCachedPdf::AnaIntConfig::_allVars
RooArgSet _allVars
Definition: RooAbsCachedPdf.h:122
RooAbsCachedPdf::getCacheHist
RooDataHist * getCacheHist(const RooArgSet &nset) const
Definition: RooAbsCachedPdf.h:45
RooDataHist
Definition: RooDataHist.h:39
RooAICRegistry.h
RooAbsPdf.h
RooAbsCachedPdf::PdfCacheElem::hist
RooDataHist * hist()
Definition: RooAbsCachedPdf.h:73
RooAbsCachedPdf::PdfCacheElem::~PdfCacheElem
virtual ~PdfCacheElem()
Cache element destructor.
Definition: RooAbsCachedPdf.cxx:357
RooAbsCachedPdf::actualParameters
virtual RooArgSet * actualParameters(const RooArgSet &nset) const =0
RooRealProxy.h
RooAbsCachedPdf::histNameSuffix
virtual TString histNameSuffix() const
Definition: RooAbsCachedPdf.h:113
RooAbsCachedPdf::payloadUniqueSuffix
virtual const char * payloadUniqueSuffix() const
Definition: RooAbsCachedPdf.h:92
RooAbsCachedPdf::binningName
virtual const char * binningName() const
Definition: RooAbsCachedPdf.h:95
RooAbsCachedPdf::getInterpolationOrder
Int_t getInterpolationOrder() const
Definition: RooAbsCachedPdf.h:53
RooHistPdf
Definition: RooHistPdf.h:29
RooAbsCachedPdf
Definition: RooAbsCachedPdf.h:25
RooAbsCachedPdf::analyticalIntegralWN
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implements internal (analytical) integration capabilities.
Definition: RooAbsCachedPdf.cxx:461
RooAbsCachedPdf::PdfCacheElem::_nset
RooArgSet _nset
Definition: RooAbsCachedPdf.h:82
RooObjCacheManager.h
RooAbsCachedPdf::PdfCacheElem
Definition: RooAbsCachedPdf.h:63
RooHistPdf.h
RooAbsCachedPdf::AnaIntConfig
Registry for analytical integration codes.
Definition: RooAbsCachedPdf.h:120
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAbsCachedPdf::PdfCacheElem::_hist
RooDataHist * _hist
Definition: RooAbsCachedPdf.h:81
RooAbsCachedPdf::forceAnalyticalInt
virtual Bool_t forceAnalyticalInt(const RooAbsArg &dep) const
Force RooRealIntegral to offer all our actual observable for internal integration.
Definition: RooAbsCachedPdf.cxx:404
RooObjCacheManager
Definition: RooObjCacheManager.h:32
RooAbsCacheElement::Action
Action
Definition: RooAbsCacheElement.h:39
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooAbsCachedPdf::AnaIntConfig::_unitNorm
Bool_t _unitNorm
Definition: RooAbsCachedPdf.h:125
name
char name[80]
Definition: TGX11.cxx:110
RooAbsCachedPdf::PdfCacheElem::_pdf
RooHistPdf * _pdf
Definition: RooAbsCachedPdf.h:79
RooAbsCachedPdf::PdfCacheElem::_paramTracker
RooChangeTracker * _paramTracker
Definition: RooAbsCachedPdf.h:80
RooAbsCachedPdf::inputBaseName
virtual const char * inputBaseName() const =0
RooAbsArg
Definition: RooAbsArg.h:73
RooAbsPdf
Definition: RooAbsPdf.h:40
RooAbsCachedPdf::_disableCache
Bool_t _disableCache
Map for analytical integration codes.
Definition: RooAbsCachedPdf.h:133
RooAbsCachedPdf::pdfObservable
virtual RooAbsArg & pdfObservable(RooAbsArg &histObservable) const
Definition: RooAbsCachedPdf.h:106
RooAbsCachedPdf::PdfCacheElem::nset
const RooArgSet & nset()
Definition: RooAbsCachedPdf.h:74
RooArgSet
Definition: RooArgSet.h:28
RooAbsCachedPdf::PdfCacheElem::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: RooAbsCachedPdf.cxx:378
int
RooAbsCachedPdf::PdfCacheElem::containedArgs
virtual RooArgList containedArgs(Action)
Returns all RooAbsArg objects contained in the cache element.
Definition: RooAbsCachedPdf.cxx:344