Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFFTConvPdf.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 ROOFFTCONVPDF
13#define ROOFFTCONVPDF
14
15#include "RooAbsCachedPdf.h"
16#include "RooRealProxy.h"
17#include "RooSetProxy.h"
18#include "RooAbsReal.h"
19#include "RooHistPdf.h"
20
21class RooRealVar;
22
23///PDF for the numerical (FFT) convolution of two PDFs.
25public:
26
28 // coverity[UNINIT_CTOR]
29 } ;
30 RooFFTConvPdf(const char *name, const char *title, RooRealVar& convVar, RooAbsPdf& pdf1, RooAbsPdf& pdf2, Int_t ipOrder=2);
31 RooFFTConvPdf(const char *name, const char *title, RooAbsReal& pdfConvVar, RooRealVar& convVar, RooAbsPdf& pdf1, RooAbsPdf& pdf2, Int_t ipOrder=2);
32 RooFFTConvPdf(const RooFFTConvPdf& other, const char* name=nullptr) ;
33 TObject* clone(const char* newname=nullptr) const override { return new RooFFTConvPdf(*this,newname); }
34 ~RooFFTConvPdf() override ;
35
36 void setShift(double val1, double val2) { _shift1 = val1 ; _shift2 = val2 ; }
38 const RooArgSet& cacheObservables() const { return _cacheObs ; }
39
40 /// Return value of buffer fraction applied in FFT calculation array beyond either
41 /// end of the observable domain to reduce cyclical effects
42 double bufferFraction() const {
43 return _bufFrac ;
44 }
45
46 enum BufStrat { Extend=0, Mirror=1, Flat=2 } ;
47 /// Return the strategy currently used to fill the buffer:
48 /// 'Extend' means is that the input p.d.f convolution observable range is widened to include the buffer range
49 /// 'Flat' means that the buffer is filled with the p.d.f. value at the boundary of the observable range
50 /// 'Mirror' means that the buffer is filled with a mirror image of the p.d.f. around the convolution observable boundary
52 return _bufStrat ;
53 }
54 void setBufferStrategy(BufStrat bs) ;
55 void setBufferFraction(double frac) ;
56
57 void printMetaArgs(std::ostream& os) const override ;
58
59 // Propagate maximum value estimate of pdf1 as convolution can only result in lower max values
60 Int_t getMaxVal(const RooArgSet& vars) const override { return _pdf1.arg().getMaxVal(vars) ; }
61 double maxVal(Int_t code) const override { return _pdf1.arg().maxVal(code) ; }
62
63 RooAbsReal const &getConvVar() const { return *_x; }
64
65 RooAbsReal const &getPdf1() const { return *_pdf1; }
66
67 RooAbsReal const &getPdf2() const { return *_pdf2; }
68
69 RooAbsReal const *getPdfConvVar() const { return dynamic_cast<RooAbsReal *>(_xprime.absArg()); }
70
71 protected:
72
73 RooRealProxy _x ; ///< Convolution observable
74 RooRealProxy _xprime ; ///< Input function representing value of convolution observable
75 RooRealProxy _pdf1 ; ///< First input p.d.f
76 RooRealProxy _pdf2 ; ///< Second input p.d.f
77 RooSetProxy _params ; ///< Effective parameters of this p.d.f.
78
79 void calcParams() ;
80
81 std::vector<double> scanPdf(RooRealVar& obs, RooAbsPdf& pdf, double normVal, const RooDataHist& hist, const RooArgSet& slicePos, Int_t& N, Int_t& N2, Int_t& zeroBin, double shift) const ;
82
83 class FFTCacheElem : public PdfCacheElem {
84 public:
85 FFTCacheElem(const RooFFTConvPdf& self, const RooArgSet* nset) ;
86
88
89 std::unique_ptr<RooAbsPdf> pdf1Clone;
90 std::unique_ptr<RooAbsPdf> pdf2Clone;
91
92 double normVal1 = 0.0;
93 double normVal2 = 0.0;
94
95 std::unique_ptr<RooAbsBinning> histBinning;
96 std::unique_ptr<RooAbsBinning> scanBinning;
97 };
98
99 friend class FFTCacheElem ;
100
101 double evaluate() const override { RooArgSet dummy(_x.arg()) ; return getVal(&dummy) ; } ; // dummy
102 const char* inputBaseName() const override ;
103 RooFit::OwningPtr<RooArgSet> actualObservables(const RooArgSet& nset) const override ;
104 RooFit::OwningPtr<RooArgSet> actualParameters(const RooArgSet& nset) const override ;
105 RooAbsArg& pdfObservable(RooAbsArg& histObservable) const override ;
106 void fillCacheObject(PdfCacheElem& cache) const override ;
107 void fillCacheSlice(FFTCacheElem& cache, const RooArgSet& slicePosition) const ;
108
109 PdfCacheElem* createCache(const RooArgSet* nset) const override ;
110 TString histNameSuffix() const override ;
111
112 // mutable std::map<const RooHistPdf*,CacheAuxInfo*> _cacheAuxInfo ; ///<! Auxiliary Cache information (do not persist)
113 double _bufFrac ; // Sampling buffer size as fraction of domain size
114 BufStrat _bufStrat ; // Strategy to fill the buffer
115
116 double _shift1 ;
117 double _shift2 ;
118
119 RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr,
120 const RooArgSet* auxProto=nullptr, bool verbose= false) const override ;
121
122 friend class RooConvGenContext ;
123 RooSetProxy _cacheObs ; ///< Non-convolution observables that are also cached
124
125private:
126
127 void prepareFFTBinning(RooRealVar& convVar) const;
128
129 ClassDefOverride(RooFFTConvPdf,1) // Convolution operator p.d.f based on numeric Fourier transforms
130};
131
132#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:347
#define N
char name[80]
Definition TGX11.cxx:142
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
Abstract base class for p.d.f.s that need or want to cache their evaluate() output in a RooHistPdf de...
friend class PdfCacheElem
Abstract base class for generator contexts of RooAbsPdf objects.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:32
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:107
virtual double maxVal(Int_t code) const
Return maximum value for set of observables identified by code assigned in getMaxVal.
virtual Int_t getMaxVal(const RooArgSet &vars) const
Advertise capability to determine maximum value of function for given set of observables.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooAbsArg * absArg() const
Return pointer to contained argument.
Definition RooArgProxy.h:46
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
Efficient implementation of the generator context specific for RooAbsAnaConvPdf objects.
Container class to hold N-dimensional binned data.
Definition RooDataHist.h:40
Container class to hold unbinned data.
Definition RooDataSet.h:32
RooArgList containedArgs(Action) override
Returns all RooAbsArg objects contained in the cache element.
std::unique_ptr< RooAbsPdf > pdf2Clone
std::unique_ptr< RooAbsBinning > histBinning
std::unique_ptr< RooAbsBinning > scanBinning
std::unique_ptr< RooAbsPdf > pdf1Clone
PDF for the numerical (FFT) convolution of two PDFs.
double maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
RooSetProxy _params
Effective parameters of this p.d.f.
BufStrat _bufStrat
void calcParams()
(Re)calculate effective parameters of this p.d.f.
TObject * clone(const char *newname=nullptr) const override
BufStrat bufferStrategy() const
Return the strategy currently used to fill the buffer: 'Extend' means is that the input p....
void setBufferFraction(double frac)
Change the size of the buffer on either side of the observable range to frac times the size of the ra...
RooAbsReal const * getPdfConvVar() const
double bufferFraction() const
Return value of buffer fraction applied in FFT calculation array beyond either end of the observable ...
TString histNameSuffix() const override
Suffix for cache histogram (added in addition to suffix for cache name)
void setCacheObservables(const RooArgSet &obs)
void prepareFFTBinning(RooRealVar &convVar) const
Try to improve the binning and inform user if possible.
void fillCacheSlice(FFTCacheElem &cache, const RooArgSet &slicePosition) const
Fill a slice of cachePdf with the output of the FFT convolution calculation.
RooRealProxy _xprime
Input function representing value of convolution observable.
RooRealProxy _pdf1
First input p.d.f.
RooRealProxy _x
Convolution observable.
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
const RooArgSet & cacheObservables() const
const char * inputBaseName() const override
Return base name component for cache components in this case 'PDF1_CONV_PDF2'.
RooAbsArg & pdfObservable(RooAbsArg &histObservable) const override
Return p.d.f.
std::vector< double > scanPdf(RooRealVar &obs, RooAbsPdf &pdf, double normVal, const RooDataHist &hist, const RooArgSet &slicePos, Int_t &N, Int_t &N2, Int_t &zeroBin, double shift) const
Scan the values of 'pdf' in observable 'obs' using the bin values stored in 'hist' at slice position ...
Int_t getMaxVal(const RooArgSet &vars) const override
Advertise capability to determine maximum value of function for given set of observables.
~RooFFTConvPdf() override
Destructor.
void setShift(double val1, double val2)
RooFit::OwningPtr< RooArgSet > actualParameters(const RooArgSet &nset) const override
Return the parameters on which the cache depends given normalization set nset.
RooRealProxy _pdf2
Second input p.d.f.
RooAbsReal const & getConvVar() const
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooNumConvPdf to more intuitively reflect the contents of the p...
void setBufferStrategy(BufStrat bs)
Change strategy to fill the overflow buffer on either side of the convolution observable range.
RooAbsReal const & getPdf2() const
PdfCacheElem * createCache(const RooArgSet *nset) const override
Return specialized cache subclass for FFT calculations.
RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false) const override
Create appropriate generator context for this convolution.
RooFit::OwningPtr< RooArgSet > actualObservables(const RooArgSet &nset) const override
Return the observables to be cached given the normalization set nset.
void fillCacheObject(PdfCacheElem &cache) const override
Fill the contents of the cache the FFT convolution output.
RooAbsReal const & getPdf1() const
friend class FFTCacheElem
RooSetProxy _cacheObs
Non-convolution observables that are also cached.
Variable that can be changed from the outside.
Definition RooRealVar.h:37
const T & arg() const
Return reference to object held in proxy.
Mother of all ROOT objects.
Definition TObject.h:42
Basic string class.
Definition TString.h:137
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
Definition Config.h:35