rf208_convolution.C

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////
00002 //
00003 // 'ADDITION AND CONVOLUTION' RooFit tutorial macro #208
00004 // 
00005 // One-dimensional numeric convolution
00006 // (require ROOT to be compiled with --enable-fftw3)
00007 // 
00008 // pdf = landau(t) (x) gauss(t)
00009 // 
00010 //
00011 // 07/2008 - Wouter Verkerke 
00012 //
00013 /////////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef __CINT__
00016 #include "RooGlobalFunc.h"
00017 #endif
00018 #include "RooRealVar.h"
00019 #include "RooDataSet.h"
00020 #include "RooGaussian.h"
00021 #include "RooLandau.h"
00022 #include "RooFFTConvPdf.h"
00023 #include "RooPlot.h"
00024 #include "TCanvas.h"
00025 #include "TAxis.h"
00026 #include "TH1.h"
00027 using namespace RooFit ;
00028 
00029 
00030 
00031 void rf208_convolution()
00032 {
00033   // S e t u p   c o m p o n e n t   p d f s 
00034   // ---------------------------------------
00035 
00036   // Construct observable
00037   RooRealVar t("t","t",-10,30) ;
00038 
00039   // Construct landau(t,ml,sl) ;
00040   RooRealVar ml("ml","mean landau",5.,-20,20) ;
00041   RooRealVar sl("sl","sigma landau",1,0.1,10) ;
00042   RooLandau landau("lx","lx",t,ml,sl) ;
00043   
00044   // Construct gauss(t,mg,sg)
00045   RooRealVar mg("mg","mg",0) ;
00046   RooRealVar sg("sg","sg",2,0.1,10) ;
00047   RooGaussian gauss("gauss","gauss",t,mg,sg) ;
00048 
00049 
00050   // C o n s t r u c t   c o n v o l u t i o n   p d f 
00051   // ---------------------------------------
00052 
00053   // Set #bins to be used for FFT sampling to 10000
00054   t.setBins(10000,"cache") ; 
00055 
00056   // Construct landau (x) gauss
00057   RooFFTConvPdf lxg("lxg","landau (X) gauss",t,landau,gauss) ;
00058 
00059 
00060 
00061   // S a m p l e ,   f i t   a n d   p l o t   c o n v o l u t e d   p d f 
00062   // ----------------------------------------------------------------------
00063 
00064   // Sample 1000 events in x from gxlx
00065   RooDataSet* data = lxg.generate(t,10000) ;
00066 
00067   // Fit gxlx to data
00068   lxg.fitTo(*data) ;
00069 
00070   // Plot data, landau pdf, landau (X) gauss pdf
00071   RooPlot* frame = t.frame(Title("landau (x) gauss convolution")) ;
00072   data->plotOn(frame) ;
00073   lxg.plotOn(frame) ;
00074   landau.plotOn(frame,LineStyle(kDashed)) ;
00075 
00076 
00077   // Draw frame on canvas
00078   new TCanvas("rf208_convolution","rf208_convolution",600,600) ;
00079   gPad->SetLeftMargin(0.15) ; frame->GetYaxis()->SetTitleOffset(1.4) ; frame->Draw() ;
00080 
00081 }
00082 
00083 
00084 

Generated on Tue Jul 5 15:45:02 2011 for ROOT_528-00b_version by  doxygen 1.5.1