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>
22class RooArgSet ;
23class RooChangeTracker ;
24
25class RooAbsCachedPdf : public RooAbsPdf {
26public:
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
121 public:
126 } ;
127 mutable std::map<Int_t,AnaIntConfig> _anaIntMap ; //! Map for analytical integration codes
128
129
130
131private:
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
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
RooAICRegistry is a utility class for operator p.d.f classes that keeps track of analytical integrati...
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:71
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
Registry for analytical integration codes.
virtual RooArgList containedArgs(Action)
Returns all RooAbsArg objects contained in the cache element.
RooChangeTracker * paramTracker()
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.
RooChangeTracker * _paramTracker
virtual void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t)
Print contents of cache when printing self as part of object tree.
RooAbsCachedPdf is the abstract base class for p.d.f.s that need or want to cache their evaluate() ou...
Int_t getInterpolationOrder() const
std::map< Int_t, AnaIntConfig > _anaIntMap
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implements internal (analytical) integration capabilities.
TString cacheNameSuffix(const RooArgSet &nset) const
Construct string with unique suffix for cache objects based on observable names that define cache con...
virtual RooAbsArg & pdfObservable(RooAbsArg &histObservable) const
virtual PdfCacheElem * createCache(const RooArgSet *nset) const
void setInterpolationOrder(Int_t order)
Change the interpolation order that is used in RooHistPdf cache representation smoothing the RooDataH...
virtual RooArgSet * actualParameters(const RooArgSet &nset) const =0
RooAICRegistry _anaReg
virtual TString histNameSuffix() const
virtual const char * binningName() const
virtual const char * inputBaseName() const =0
virtual Double_t getValV(const RooArgSet *set=0) const
Implementation of getVal() overriding default implementation of RooAbsPdf.
Bool_t _disableCache
Map for analytical integration codes.
PdfCacheElem * getCache(const RooArgSet *nset, Bool_t recalculate=kTRUE) const
Retrieve cache object associated with given choice of observables.
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Advertises internal (analytical) integration capabilities.
virtual ~RooAbsCachedPdf()
Destructor.
virtual Bool_t forceAnalyticalInt(const RooAbsArg &dep) const
Force RooRealIntegral to offer all our actual observable for internal integration.
RooAbsPdf * getCachePdf(const RooArgSet &nset) const
RooDataHist * getCacheHist(const RooArgSet &nset) const
virtual void fillCacheObject(PdfCacheElem &cache) const =0
void clearCacheObject(PdfCacheElem &cache) const
Mark all bins of given cache as unitialized (value -1)
RooObjCacheManager _cacheMgr
virtual const char * payloadUniqueSuffix() const
virtual RooArgSet * actualObservables(const RooArgSet &nset) const =0
virtual Bool_t selfNormalized() const
void disableCache(Bool_t flag)
friend class PdfCacheElem
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:59
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
The RooDataHist is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
RooHistPdf implements a probablity density function sampled from a multidimensional histogram.
Definition: RooHistPdf.h:28
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
Basic string class.
Definition: TString.h:131