00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOABSCACHEDPDF
00013 #define ROOABSCACHEDPDF
00014
00015 #include "RooAbsPdf.h"
00016 #include "RooRealProxy.h"
00017 #include "RooAbsReal.h"
00018 #include "RooHistPdf.h"
00019 #include "RooObjCacheManager.h"
00020 #include "RooAICRegistry.h"
00021 #include <map>
00022 class RooArgSet ;
00023 class RooChangeTracker ;
00024
00025 class RooAbsCachedPdf : public RooAbsPdf {
00026 public:
00027
00028 RooAbsCachedPdf() {
00029
00030 } ;
00031 RooAbsCachedPdf(const char *name, const char *title, Int_t ipOrder=0);
00032 RooAbsCachedPdf(const RooAbsCachedPdf& other, const char* name=0) ;
00033 virtual ~RooAbsCachedPdf() ;
00034
00035 virtual Double_t getVal(const RooArgSet* set=0) const ;
00036 virtual Bool_t selfNormalized() const {
00037
00038 return kTRUE ;
00039 }
00040
00041 RooAbsPdf* getCachePdf(const RooArgSet& nset) const {
00042
00043 return getCachePdf(&nset) ;
00044 }
00045 RooDataHist* getCacheHist(const RooArgSet& nset) const {
00046
00047 return getCacheHist(&nset) ;
00048 }
00049 RooAbsPdf* getCachePdf(const RooArgSet* nset=0) const ;
00050 RooDataHist* getCacheHist(const RooArgSet* nset=0) const ;
00051
00052 void setInterpolationOrder(Int_t order) ;
00053 Int_t getInterpolationOrder() const {
00054
00055 return _ipOrder ;
00056 }
00057
00058 virtual Bool_t forceAnalyticalInt(const RooAbsArg& dep) const ;
00059 virtual Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet, const char* rangeName=0) const ;
00060 virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
00061
00062 protected:
00063
00064 class PdfCacheElem : public RooAbsCacheElement {
00065 public:
00066 PdfCacheElem(const RooAbsCachedPdf& self, const RooArgSet* nset) ;
00067 virtual ~PdfCacheElem() ;
00068
00069
00070 virtual RooArgList containedArgs(Action) ;
00071 virtual void printCompactTreeHook(std::ostream&, const char *, Int_t, Int_t) ;
00072
00073 RooHistPdf* pdf() { return _pdf ; }
00074 RooDataHist* hist() { return _hist ; }
00075 const RooArgSet& nset() { return _nset ; }
00076 RooChangeTracker* paramTracker() { return _paramTracker ; }
00077
00078 private:
00079
00080 RooHistPdf* _pdf ;
00081 RooChangeTracker* _paramTracker ;
00082 RooDataHist* _hist ;
00083 RooArgSet _nset ;
00084 RooAbsReal* _norm ;
00085
00086 } ;
00087
00088 PdfCacheElem* getCache(const RooArgSet* nset, Bool_t recalculate=kTRUE) const ;
00089 void clearCacheObject(PdfCacheElem& cache) const ;
00090
00091 virtual const char* payloadUniqueSuffix() const { return 0 ; }
00092
00093 friend class PdfCacheElem ;
00094 virtual const char* binningName() const {
00095
00096 return "cache" ;
00097 }
00098 virtual PdfCacheElem* createCache(const RooArgSet* nset) const {
00099
00100 return new PdfCacheElem(*this,nset) ;
00101 }
00102 virtual const char* inputBaseName() const = 0 ;
00103 virtual RooArgSet* actualObservables(const RooArgSet& nset) const = 0 ;
00104 virtual RooArgSet* actualParameters(const RooArgSet& nset) const = 0 ;
00105 virtual RooAbsArg& pdfObservable(RooAbsArg& histObservable) const { return histObservable ; }
00106 virtual void fillCacheObject(PdfCacheElem& cache) const = 0 ;
00107
00108 mutable RooObjCacheManager _cacheMgr ;
00109 Int_t _ipOrder ;
00110
00111 TString cacheNameSuffix(const RooArgSet& nset) const ;
00112 virtual TString histNameSuffix() const { return TString("") ; }
00113 void disableCache(Bool_t flag) {
00114
00115 _disableCache = flag ;
00116 }
00117
00118 mutable RooAICRegistry _anaReg ;
00119 class AnaIntConfig {
00120 public:
00121 RooArgSet _allVars ;
00122 RooArgSet _anaVars ;
00123 const RooArgSet* _nset ;
00124 Bool_t _unitNorm ;
00125 } ;
00126 mutable std::map<Int_t,AnaIntConfig> _anaIntMap ;
00127
00128
00129
00130 private:
00131
00132 Bool_t _disableCache ;
00133
00134 ClassDef(RooAbsCachedPdf,1)
00135 };
00136
00137 #endif