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 "RooChangeTracker.h"
22
23#include <map>
24
25class RooAbsCachedPdf : public RooAbsPdf {
26public:
27
28 // Default constructor
29 RooAbsCachedPdf() : _cacheMgr(this,10) {}
30 RooAbsCachedPdf(const char *name, const char *title, Int_t ipOrder=0);
31 RooAbsCachedPdf(const RooAbsCachedPdf& other, const char* name=nullptr) ;
32
33 virtual double getValV(const RooArgSet* set=nullptr) const ;
34 virtual bool selfNormalized() const {
35 // Declare p.d.f self normalized
36 return true ;
37 }
38
39 RooAbsPdf* getCachePdf(const RooArgSet& nset) const {
40 // Return RooHistPdf that represents cache histogram
41 return getCachePdf(&nset) ;
42 }
43 RooDataHist* getCacheHist(const RooArgSet& nset) const {
44 // Return RooDataHist with cached values
45 return getCacheHist(&nset) ;
46 }
47 RooAbsPdf* getCachePdf(const RooArgSet* nset=0) const ;
48 RooDataHist* getCacheHist(const RooArgSet* nset=0) const ;
49
50 void setInterpolationOrder(int order) ;
52 // Set interpolation order in RooHistPdf that represent cached histogram
53 return _ipOrder ;
54 }
55
56 virtual bool forceAnalyticalInt(const RooAbsArg& dep) const ;
57 virtual Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet, const char* rangeName=nullptr) const ;
58 virtual double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const ;
59
60
62 public:
63 PdfCacheElem(const RooAbsCachedPdf& self, const RooArgSet* nset) ;
64
65 // Cache management functions
67 virtual void printCompactTreeHook(std::ostream&, const char *, Int_t, Int_t) ;
68
69 RooHistPdf* pdf() { return _pdf.get() ; }
70 RooDataHist* hist() { return _hist.get() ; }
71 const RooArgSet& nset() { return _nset ; }
73
74 private:
75 // Payload
76 std::unique_ptr<RooHistPdf> _pdf ;
77 std::unique_ptr<RooChangeTracker> _paramTracker ;
78 std::unique_ptr<RooDataHist> _hist ;
80 std::unique_ptr<RooAbsReal> _norm ;
81
82 } ;
83
84 protected:
85
86 PdfCacheElem* getCache(const RooArgSet* nset, bool recalculate=true) const ;
87 void clearCacheObject(PdfCacheElem& cache) const ;
88
89 virtual const char* payloadUniqueSuffix() const { return 0 ; }
90
91 friend class PdfCacheElem ;
92 virtual const char* binningName() const {
93 // Return name of binning to be used for creation of cache histogram
94 return "cache" ;
95 }
96 virtual PdfCacheElem* createCache(const RooArgSet* nset) const {
97 // Create cache storage element
98 return new PdfCacheElem(*this,nset) ;
99 }
100 virtual const char* inputBaseName() const = 0 ;
101 virtual RooArgSet* actualObservables(const RooArgSet& nset) const = 0 ;
102 virtual RooArgSet* actualParameters(const RooArgSet& nset) const = 0 ;
103 virtual RooAbsArg& pdfObservable(RooAbsArg& histObservable) const { return histObservable ; }
104 virtual void fillCacheObject(PdfCacheElem& cache) const = 0 ;
105
106 mutable RooObjCacheManager _cacheMgr ; //! The cache manager
107 Int_t _ipOrder ; // Interpolation order for cache histograms
108
109 std::string cacheNameSuffix(const RooArgSet& nset) const ;
110 virtual TString histNameSuffix() const { return TString("") ; }
111 void disableCache(bool flag) {
112 // Flag to disable caching mechanism
113 _disableCache = flag ;
114 }
115
116 mutable RooAICRegistry _anaReg ; //! Registry for analytical integration codes
118 public:
123 } ;
124 mutable std::map<Int_t,AnaIntConfig> _anaIntMap ; //! Map for analytical integration codes
125
126
127
128private:
129
130 bool _disableCache = false; // Flag to run object in passthrough (= non-caching mode)
131
132 ClassDef(RooAbsCachedPdf,2) // Abstract base class for cached p.d.f.s
133};
134
135#endif
int Int_t
Definition: RtypesCore.h:45
#define ClassDef(name, id)
Definition: Rtypes.h:325
char name[80]
Definition: TGX11.cxx:110
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 and a "shape" in RooFi...
Definition: RooAbsArg.h:72
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.
std::unique_ptr< RooChangeTracker > _paramTracker
RooChangeTracker * paramTracker()
PdfCacheElem(const RooAbsCachedPdf &self, const RooArgSet *nset)
Constructor of cache object which owns RooDataHist cache histogram, RooHistPdf pdf that represents is...
std::unique_ptr< RooAbsReal > _norm
std::unique_ptr< RooHistPdf > _pdf
virtual void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t)
Print contents of cache when printing self as part of object tree.
std::unique_ptr< RooDataHist > _hist
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 RooAbsArg & pdfObservable(RooAbsArg &histObservable) const
virtual PdfCacheElem * createCache(const RooArgSet *nset) const
PdfCacheElem * getCache(const RooArgSet *nset, bool recalculate=true) const
Retrieve cache object associated with given choice of observables.
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 bool forceAnalyticalInt(const RooAbsArg &dep) const
Force RooRealIntegral to offer all our actual observable for internal integration.
virtual bool selfNormalized() const
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const
Advertises internal (analytical) integration capabilities.
RooAbsPdf * getCachePdf(const RooArgSet &nset) const
RooDataHist * getCacheHist(const RooArgSet &nset) const
bool _disableCache
Map for analytical integration codes.
virtual void fillCacheObject(PdfCacheElem &cache) const =0
void clearCacheObject(PdfCacheElem &cache) const
Mark all bins of given cache as unitialized (value -1)
virtual double getValV(const RooArgSet *set=nullptr) const
Implementation of getVal() overriding default implementation of RooAbsPdf.
RooObjCacheManager _cacheMgr
Int_t _ipOrder
The cache manager
virtual const char * payloadUniqueSuffix() const
virtual RooArgSet * actualObservables(const RooArgSet &nset) const =0
void disableCache(bool flag)
virtual double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const
Implements internal (analytical) integration capabilities.
std::string cacheNameSuffix(const RooArgSet &nset) const
Construct string with unique suffix for cache objects based on observable names that define cache con...
void setInterpolationOrder(int order)
Change the interpolation order that is used in RooHistPdf cache representation smoothing the RooDataH...
friend class PdfCacheElem
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:35
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:44
RooHistPdf implements a probablity density function sampled from a multidimensional histogram.
Definition: RooHistPdf.h:29
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
Basic string class.
Definition: TString.h:136