Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 void computeBatch(cudaStream_t*, double* output, size_t size, RooFit::Detail::DataMap const&) const;
87
88 PdfCacheElem* getCache(const RooArgSet* nset, bool recalculate=true) 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 std::string cacheNameSuffix(const RooArgSet& nset) const ;
112 virtual TString histNameSuffix() const { return TString("") ; }
113 void disableCache(bool flag) {
114 // Flag to disable caching mechanism
115 _disableCache = flag ;
116 }
117
118 mutable RooAICRegistry _anaReg ; //! Registry for analytical integration codes
120 public:
125 } ;
126 mutable std::map<Int_t,AnaIntConfig> _anaIntMap ; //! Map for analytical integration codes
127
128
129
130private:
131
132 bool _disableCache = false; // Flag to run object in passthrough (= non-caching mode)
133
134 ClassDef(RooAbsCachedPdf,2) // Abstract base class for cached p.d.f.s
135};
136
137#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#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:69
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()
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.
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const
Base function for computing multiple values of a RooAbsReal.
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...
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:45
const RooArgSet * get() const override
Get bin centre of current bin.
Definition RooDataHist.h:84
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
static void output(int code)
Definition gifencode.c:226