Logo ROOT  
Reference Guide
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 #include "TVirtualFFT.h"
21 
22 class RooRealVar;
23 
24 ///PDF for the numerical (FFT) convolution of two PDFs.
26 public:
27 
29  // coverity[UNINIT_CTOR]
30  } ;
31  RooFFTConvPdf(const char *name, const char *title, RooRealVar& convVar, RooAbsPdf& pdf1, RooAbsPdf& pdf2, Int_t ipOrder=2);
32  RooFFTConvPdf(const char *name, const char *title, RooAbsReal& pdfConvVar, RooRealVar& convVar, RooAbsPdf& pdf1, RooAbsPdf& pdf2, Int_t ipOrder=2);
33  RooFFTConvPdf(const RooFFTConvPdf& other, const char* name=0) ;
34  virtual TObject* clone(const char* newname) const { return new RooFFTConvPdf(*this,newname); }
35  virtual ~RooFFTConvPdf() ;
36 
37  void setShift(Double_t val1, Double_t val2) { _shift1 = val1 ; _shift2 = val2 ; }
39  const RooArgSet& cacheObservables() const { return _cacheObs ; }
40 
42  // Return value of buffer fraction applied in FFT calculation array beyond either
43  // end of the observable domain to reduce cyclical effects
44  return _bufFrac ;
45  }
46 
47  enum BufStrat { Extend=0, Mirror=1, Flat=2 } ;
49  // Return the strategy currently used to fill the buffer:
50  // 'Extend' means is that the input p.d.f convolution observable range is widened to include the buffer range
51  // 'Flat' means that the buffer is filled with the p.d.f. value at the boundary of the observable range
52  // 'Mirror' means that the buffer is filled with a mirror image of the p.d.f. around the convolution observable boundary
53  return _bufStrat ;
54  }
55  void setBufferStrategy(BufStrat bs) ;
56  void setBufferFraction(Double_t frac) ;
57 
58  void printMetaArgs(std::ostream& os) const ;
59 
60  // Propagate maximum value estimate of pdf1 as convolution can only result in lower max values
61  virtual Int_t getMaxVal(const RooArgSet& vars) const { return _pdf1.arg().getMaxVal(vars) ; }
62  virtual Double_t maxVal(Int_t code) const { return _pdf1.arg().maxVal(code) ; }
63 
64 
65 protected:
66 
67  RooRealProxy _x ; // Convolution observable
68  RooRealProxy _xprime ; // Input function representing value of convolution observable
69  RooRealProxy _pdf1 ; // First input p.d.f
70  RooRealProxy _pdf2 ; // Second input p.d.f
71  RooSetProxy _params ; // Effective parameters of this p.d.f.
72 
73  void calcParams() ;
74  Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
75 
76  Double_t* scanPdf(RooRealVar& obs, RooAbsPdf& pdf, const RooDataHist& hist, const RooArgSet& slicePos, Int_t& N, Int_t& N2, Int_t& zeroBin, Double_t shift) const ;
77 
78  class FFTCacheElem : public PdfCacheElem {
79  public:
80  FFTCacheElem(const RooFFTConvPdf& self, const RooArgSet* nset) ;
81  ~FFTCacheElem() ;
82 
84 
88 
91 
94 
95  };
96 
97  friend class FFTCacheElem ;
98 
99  virtual Double_t evaluate() const { RooArgSet dummy(_x.arg()) ; return getVal(&dummy) ; } ; // dummy
100  virtual const char* inputBaseName() const ;
101  virtual RooArgSet* actualObservables(const RooArgSet& nset) const ;
102  virtual RooArgSet* actualParameters(const RooArgSet& nset) const ;
103  virtual RooAbsArg& pdfObservable(RooAbsArg& histObservable) const ;
104  virtual void fillCacheObject(PdfCacheElem& cache) const ;
105  void fillCacheSlice(FFTCacheElem& cache, const RooArgSet& slicePosition) const ;
106 
107  virtual PdfCacheElem* createCache(const RooArgSet* nset) const ;
108  virtual TString histNameSuffix() const ;
109 
110  // mutable std:: map<const RooHistPdf*,CacheAuxInfo*> _cacheAuxInfo ; //! Auxilary Cache information (do not persist)
111  Double_t _bufFrac ; // Sampling buffer size as fraction of domain size
112  BufStrat _bufStrat ; // Strategy to fill the buffer
113 
116 
117  virtual RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=0,
118  const RooArgSet* auxProto=0, Bool_t verbose= kFALSE) const ;
119 
120  friend class RooConvGenContext ;
121  RooSetProxy _cacheObs ; // Non-convolution observables that are also cached
122 
123 private:
124 
125  void prepareFFTBinning(RooRealVar& convVar) const;
126 
127  ClassDef(RooFFTConvPdf,1) // Convolution operator p.d.f based on numeric Fourier transforms
128 };
129 
130 #endif
RooFFTConvPdf::scanPdf
Double_t * scanPdf(RooRealVar &obs, RooAbsPdf &pdf, const RooDataHist &hist, const RooArgSet &slicePos, Int_t &N, Int_t &N2, Int_t &zeroBin, Double_t shift) const
Scan the values of 'pdf' in observable 'obs' using the bin values stored in 'hist' at slice position ...
Definition: RooFFTConvPdf.cxx:608
RooFFTConvPdf::FFTCacheElem::fftr2c2
TVirtualFFT * fftr2c2
Definition: RooFFTConvPdf.h:86
RooFFTConvPdf::fillCacheSlice
void fillCacheSlice(FFTCacheElem &cache, const RooArgSet &slicePosition) const
Fill a slice of cachePdf with the output of the FFT convolution calculation.
Definition: RooFFTConvPdf.cxx:514
RooAbsReal.h
RooFFTConvPdf::histNameSuffix
virtual TString histNameSuffix() const
Suffix for cache histogram (added in addition to suffix for cache name)
Definition: RooFFTConvPdf.cxx:378
RooFFTConvPdf::cacheObservables
const RooArgSet & cacheObservables() const
Definition: RooFFTConvPdf.h:39
RooTemplateProxy::arg
const T & arg() const
Return reference to object held in proxy.
Definition: RooTemplateProxy.h:290
RooFFTConvPdf::setBufferFraction
void setBufferFraction(Double_t frac)
Change the size of the buffer on either side of the observable range to frac times the size of the ra...
Definition: RooFFTConvPdf.cxx:866
RooSetProxy
RooSetProxy is the concrete proxy for RooArgSet objects.
Definition: RooSetProxy.h:23
RooFFTConvPdf::FFTCacheElem::FFTCacheElem
FFTCacheElem(const RooFFTConvPdf &self, const RooArgSet *nset)
Clone input pdf and attach to dataset.
Definition: RooFFTConvPdf.cxx:282
RooFFTConvPdf::RooFFTConvPdf
RooFFTConvPdf()
Definition: RooFFTConvPdf.h:28
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooAbsReal::getVal
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooFFTConvPdf::actualParameters
virtual RooArgSet * actualParameters(const RooArgSet &nset) const
Return the parameters on which the cache depends given normalization set nset.
Definition: RooFFTConvPdf.cxx:785
N
#define N
RooFFTConvPdf::Extend
@ Extend
Definition: RooFFTConvPdf.h:47
RooFFTConvPdf::FFTCacheElem::pdf2Clone
RooAbsPdf * pdf2Clone
Definition: RooFFTConvPdf.h:90
RooFFTConvPdf::setCacheObservables
void setCacheObservables(const RooArgSet &obs)
Definition: RooFFTConvPdf.h:38
RooFFTConvPdf::_pdf2
RooRealProxy _pdf2
Definition: RooFFTConvPdf.h:70
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooSetProxy.h
RooFFTConvPdf::FFTCacheElem::~FFTCacheElem
~FFTCacheElem()
Definition: RooFFTConvPdf.cxx:407
RooFFTConvPdf::genContext
virtual RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE) const
Create appropriate generator context for this convolution.
Definition: RooFFTConvPdf.cxx:818
TVirtualFFT.h
RooFFTConvPdf::pdfObservable
virtual RooAbsArg & pdfObservable(RooAbsArg &histObservable) const
Return p.d.f.
Definition: RooFFTConvPdf.cxx:801
TString
Basic string class.
Definition: TString.h:136
RooFFTConvPdf::clone
virtual TObject * clone(const char *newname) const
Definition: RooFFTConvPdf.h:34
RooFFTConvPdf::FFTCacheElem::pdf1Clone
RooAbsPdf * pdf1Clone
Definition: RooFFTConvPdf.h:89
RooAbsCachedPdf::PdfCacheElem
friend class PdfCacheElem
Definition: RooAbsCachedPdf.h:94
RooFFTConvPdf::inputBaseName
virtual const char * inputBaseName() const
Return base name component for cache components in this case 'PDF1_CONV_PDF2'.
Definition: RooFFTConvPdf.cxx:256
RooFFTConvPdf::actualObservables
virtual RooArgSet * actualObservables(const RooArgSet &nset) const
Return the observables to be cached given the normalization set nset.
Definition: RooFFTConvPdf.cxx:723
bool
RooFFTConvPdf::_bufStrat
BufStrat _bufStrat
Definition: RooFFTConvPdf.h:112
RooFFTConvPdf::redirectServersHook
Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
calcParams() ;
Definition: RooFFTConvPdf.cxx:927
RooFFTConvPdf::FFTCacheElem::fftr2c1
TVirtualFFT * fftr2c1
Definition: RooFFTConvPdf.h:85
RooDataHist
The RooDataHist is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:37
RooFFTConvPdf::_params
RooSetProxy _params
Definition: RooFFTConvPdf.h:71
RooFFTConvPdf::printMetaArgs
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooNumConvPdf to more intuitively reflect the contents of the p...
Definition: RooFFTConvPdf.cxx:901
RooFFTConvPdf::getMaxVal
virtual Int_t getMaxVal(const RooArgSet &vars) const
Advertise capability to determine maximum value of function for given set of observables.
Definition: RooFFTConvPdf.h:61
RooConvGenContext
RooConvGenContext is an efficient implementation of the generator context specific for RooAbsAnaConvP...
Definition: RooConvGenContext.h:31
RooFFTConvPdf::_shift2
Double_t _shift2
Definition: RooFFTConvPdf.h:115
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
RooFFTConvPdf::prepareFFTBinning
void prepareFFTBinning(RooRealVar &convVar) const
Try to improve the binning and inform user if possible.
Definition: RooFFTConvPdf.cxx:231
RooFFTConvPdf::~RooFFTConvPdf
virtual ~RooFFTConvPdf()
Destructor.
Definition: RooFFTConvPdf.cxx:221
RooAbsBinning
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
Definition: RooAbsBinning.h:26
RooAbsReal::getMaxVal
virtual Int_t getMaxVal(const RooArgSet &vars) const
Advertise capability to determine maximum value of function for given set of observables.
Definition: RooAbsReal.cxx:3641
RooRealProxy.h
RooFFTConvPdf::FFTCacheElem::containedArgs
virtual RooArgList containedArgs(Action)
Returns all RooAbsArg objects contained in the cache element.
Definition: RooFFTConvPdf.cxx:388
RooAbsCollection
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
Definition: RooAbsCollection.h:33
RooAbsGenContext
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
Definition: RooAbsGenContext.h:26
RooFFTConvPdf::_bufFrac
Double_t _bufFrac
Definition: RooFFTConvPdf.h:111
RooFFTConvPdf::evaluate
virtual Double_t evaluate() const
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition: RooFFTConvPdf.h:99
RooFFTConvPdf::_xprime
RooRealProxy _xprime
Definition: RooFFTConvPdf.h:68
RooFFTConvPdf::FFTCacheElem
Definition: RooFFTConvPdf.h:78
RooAbsCachedPdf
RooAbsCachedPdf is the abstract base class for p.d.f.s that need or want to cache their evaluate() ou...
Definition: RooAbsCachedPdf.h:25
RooFFTConvPdf::FFTCacheElem::histBinning
RooAbsBinning * histBinning
Definition: RooFFTConvPdf.h:92
RooAbsCachedPdf::PdfCacheElem
Definition: RooAbsCachedPdf.h:63
RooSetProxy::removeAll
virtual void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
Definition: RooSetProxy.cxx:229
RooAbsReal::maxVal
virtual Double_t maxVal(Int_t code) const
Return maximum value for set of observables identified by code assigned in getMaxVal.
Definition: RooAbsReal.cxx:3652
RooHistPdf.h
RooFFTConvPdf::calcParams
void calcParams()
(Re)calculate effective parameters of this p.d.f.
Definition: RooFFTConvPdf.cxx:911
RooFFTConvPdf::_pdf1
RooRealProxy _pdf1
Definition: RooFFTConvPdf.h:69
RooAbsCachedPdf.h
RooFFTConvPdf::fillCacheObject
virtual void fillCacheObject(PdfCacheElem &cache) const
Fill the contents of the cache the FFT convolution output.
Definition: RooFFTConvPdf.cxx:427
RooFFTConvPdf::createCache
virtual PdfCacheElem * createCache(const RooArgSet *nset) const
Return specialized cache subclass for FFT calculations.
Definition: RooFFTConvPdf.cxx:271
RooTemplateProxy< RooAbsReal >
RooFFTConvPdf::Mirror
@ Mirror
Definition: RooFFTConvPdf.h:47
Double_t
double Double_t
Definition: RtypesCore.h:59
RooFFTConvPdf
PDF for the numerical (FFT) convolution of two PDFs.
Definition: RooFFTConvPdf.h:25
RooFFTConvPdf::FFTCacheElem
friend class FFTCacheElem
Definition: RooFFTConvPdf.h:97
RooAbsCacheElement::Action
Action
Definition: RooAbsCacheElement.h:39
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
RooFFTConvPdf::bufferStrategy
BufStrat bufferStrategy() const
Definition: RooFFTConvPdf.h:48
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooFFTConvPdf::setShift
void setShift(Double_t val1, Double_t val2)
Definition: RooFFTConvPdf.h:37
name
char name[80]
Definition: TGX11.cxx:110
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooAbsPdf
Definition: RooAbsPdf.h:41
RooFFTConvPdf::_shift1
Double_t _shift1
Definition: RooFFTConvPdf.h:114
RooFFTConvPdf::maxVal
virtual Double_t maxVal(Int_t code) const
Return maximum value for set of observables identified by code assigned in getMaxVal.
Definition: RooFFTConvPdf.h:62
RooFFTConvPdf::_cacheObs
RooSetProxy _cacheObs
Definition: RooFFTConvPdf.h:121
RooFFTConvPdf::setBufferStrategy
void setBufferStrategy(BufStrat bs)
Change strategy to fill the overflow buffer on either side of the convolution observable range.
Definition: RooFFTConvPdf.cxx:890
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
RooFFTConvPdf::BufStrat
BufStrat
Definition: RooFFTConvPdf.h:47
RooFFTConvPdf::Flat
@ Flat
Definition: RooFFTConvPdf.h:47
TVirtualFFT
TVirtualFFT is an interface class for Fast Fourier Transforms.
Definition: TVirtualFFT.h:88
RooFFTConvPdf::FFTCacheElem::scanBinning
RooAbsBinning * scanBinning
Definition: RooFFTConvPdf.h:93
RooFFTConvPdf::FFTCacheElem::fftc2r
TVirtualFFT * fftc2r
Definition: RooFFTConvPdf.h:87
RooAbsCachedPdf::PdfCacheElem::nset
const RooArgSet & nset()
Definition: RooAbsCachedPdf.h:74
RooSetProxy::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
Definition: RooSetProxy.cxx:165
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
RooFFTConvPdf::bufferFraction
Double_t bufferFraction() const
Definition: RooFFTConvPdf.h:41
RooFFTConvPdf::_x
RooRealProxy _x
Definition: RooFFTConvPdf.h:67
int