RooFFTConvPdf.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  *                                                                           *
00004  * Copyright (c) 2000-2005, Regents of the University of California          *
00005  *                          and Stanford University. All rights reserved.    *
00006  *                                                                           *
00007  * Redistribution and use in source and binary forms,                        *
00008  * with or without modification, are permitted according to the terms        *
00009  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00010  *****************************************************************************/
00011 
00012 #ifndef ROOFFTCONVPDF
00013 #define ROOFFTCONVPDF
00014 
00015 #include "RooAbsCachedPdf.h"
00016 #include "RooRealProxy.h"
00017 #include "RooSetProxy.h"
00018 #include "RooAbsReal.h"
00019 #include "RooHistPdf.h"
00020 #include "TVirtualFFT.h"
00021 class RooRealVar ;
00022 
00023 #include <map>
00024  
00025 class RooFFTConvPdf : public RooAbsCachedPdf {
00026 public:
00027 
00028   RooFFTConvPdf() {
00029     // coverity[UNINIT_CTOR]
00030   } ;
00031   RooFFTConvPdf(const char *name, const char *title, RooRealVar& convVar, RooAbsPdf& pdf1, RooAbsPdf& pdf2, Int_t ipOrder=2);
00032   RooFFTConvPdf(const char *name, const char *title, RooAbsReal& pdfConvVar, RooRealVar& convVar, RooAbsPdf& pdf1, RooAbsPdf& pdf2, Int_t ipOrder=2);
00033   RooFFTConvPdf(const RooFFTConvPdf& other, const char* name=0) ;
00034   virtual TObject* clone(const char* newname) const { return new RooFFTConvPdf(*this,newname); }
00035   virtual ~RooFFTConvPdf() ;
00036 
00037   void setShift(Double_t val1, Double_t val2) { _shift1 = val1 ; _shift2 = val2 ; }
00038   void setCacheObservables(const RooArgSet& obs) { _cacheObs.removeAll() ; _cacheObs.add(obs) ; }
00039   const RooArgSet& cacheObservables() const { return _cacheObs ; }
00040   
00041   Double_t bufferFraction() const { 
00042     // Return value of buffer fraction applied in FFT calculation array beyond either
00043     // end of the observable domain to reduce cyclical effects
00044     return _bufFrac ; 
00045   }
00046 
00047   enum BufStrat { Extend=0, Mirror=1, Flat=2 } ;
00048   BufStrat bufferStrategy() const {
00049     // Return the strategy currently used to fill the buffer: 
00050     // 'Extend' means is that the input p.d.f convolution observable range is widened to include the buffer range
00051     // 'Flat' means that the buffer is filled with the p.d.f. value at the boundary of the observable range
00052     // 'Mirror' means that the buffer is filled with a mirror image of the p.d.f. around the convolution observable boundary 
00053     return _bufStrat ;
00054   }
00055   void setBufferStrategy(BufStrat bs) ;
00056   void setBufferFraction(Double_t frac) ;
00057 
00058   void printMetaArgs(ostream& os) const ;
00059 
00060   // Propagate maximum value estimate of pdf1 as convolution can only result in lower max values
00061   virtual Int_t getMaxVal(const RooArgSet& vars) const { return _pdf1.arg().getMaxVal(vars) ; }
00062   virtual Double_t maxVal(Int_t code) const { return _pdf1.arg().maxVal(code) ; }
00063 
00064 
00065 protected:
00066 
00067   RooRealProxy _x ;       // Convolution observable
00068   RooRealProxy _xprime ;  // Input function representing value of convolution observable
00069   RooRealProxy _pdf1 ; // First input p.d.f
00070   RooRealProxy _pdf2 ; // Second input p.d.f
00071   RooSetProxy _params ; // Effective parameters of this p.d.f.
00072 
00073   void calcParams() ;
00074   Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
00075 
00076   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 ;
00077 
00078   class FFTCacheElem : public PdfCacheElem {
00079   public:
00080     FFTCacheElem(const RooFFTConvPdf& self, const RooArgSet* nset) ;
00081     ~FFTCacheElem() ;
00082 
00083     virtual RooArgList containedArgs(Action) ;
00084 
00085     TVirtualFFT* fftr2c1 ;
00086     TVirtualFFT* fftr2c2 ;
00087     TVirtualFFT* fftc2r ;
00088 
00089     RooAbsPdf* pdf1Clone ;
00090     RooAbsPdf* pdf2Clone ;
00091 
00092     RooAbsBinning* histBinning ;
00093     RooAbsBinning* scanBinning ;
00094 
00095   };
00096 
00097   friend class FFTCacheElem ;  
00098 
00099   virtual Double_t evaluate() const { RooArgSet dummy(_x.arg()) ; return getVal(&dummy) ; } ; // dummy
00100   virtual const char* inputBaseName() const ;
00101   virtual RooArgSet* actualObservables(const RooArgSet& nset) const ;
00102   virtual RooArgSet* actualParameters(const RooArgSet& nset) const ;
00103   virtual RooAbsArg& pdfObservable(RooAbsArg& histObservable) const ;
00104   virtual void fillCacheObject(PdfCacheElem& cache) const ;
00105   void fillCacheSlice(FFTCacheElem& cache, const RooArgSet& slicePosition) const ;
00106 
00107   virtual PdfCacheElem* createCache(const RooArgSet* nset) const ;
00108   virtual TString histNameSuffix() const ;
00109 
00110   // mutable std::map<const RooHistPdf*,CacheAuxInfo*> _cacheAuxInfo ; //! Auxilary Cache information (do not persist)
00111   Double_t _bufFrac ; // Sampling buffer size as fraction of domain size 
00112   BufStrat _bufStrat ; // Strategy to fill the buffer
00113 
00114   Double_t  _shift1 ; 
00115   Double_t  _shift2 ; 
00116 
00117   virtual RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=0, 
00118                                        const RooArgSet* auxProto=0, Bool_t verbose= kFALSE) const ;
00119 
00120   friend class RooConvGenContext ;
00121   RooSetProxy  _cacheObs ; // Non-convolution observables that are also cached
00122 
00123 private:
00124 
00125   ClassDef(RooFFTConvPdf,1) // Convolution operator p.d.f based on numeric Fourier transforms
00126 };
00127  
00128 #endif

Generated on Tue Jul 5 14:26:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1