rf302_utilfuncs.cxx

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //
00003 // 'MULTIDIMENSIONAL MODELS' RooFit tutorial macro #302
00004 // 
00005 //  Utility functions classes available for use in tailoring
00006 //  of composite (multidimensional) pdfs
00007 //
00008 //
00009 // 07/2008 - Wouter Verkerke 
00010 // 
00011 /////////////////////////////////////////////////////////////////////////
00012 
00013 #ifndef __CINT__
00014 #include "RooGlobalFunc.h"
00015 #endif
00016 #include "RooRealVar.h"
00017 #include "RooDataSet.h"
00018 #include "RooGaussian.h"
00019 #include "TCanvas.h"
00020 #include "RooPlot.h"
00021 #include "RooFormulaVar.h"
00022 #include "RooAddition.h"
00023 #include "RooProduct.h"
00024 #include "RooPolyVar.h"
00025 #include "TCanvas.h"
00026 #include "TH1.h"
00027 
00028 using namespace RooFit ;
00029 
00030 
00031 class TestBasic302 : public RooFitTestUnit
00032 {
00033 public: 
00034   TestBasic302(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Sum and product utility functions",refFile,writeRef,verbose) {} ;
00035   Bool_t testCode() {
00036 
00037   // C r e a t e   o b s e r v a b l e s ,   p a r a m e t e r s 
00038   // -----------------------------------------------------------
00039 
00040   // Create observables
00041   RooRealVar x("x","x",-5,5) ;
00042   RooRealVar y("y","y",-5,5) ;
00043 
00044   // Create parameters
00045   RooRealVar a0("a0","a0",-1.5,-5,5) ;
00046   RooRealVar a1("a1","a1",-0.5,-1,1) ;
00047   RooRealVar sigma("sigma","width of gaussian",0.5) ;
00048 
00049 
00050   // U s i n g   R o o F o r m u l a V a r   t o   t a i l o r   p d f 
00051   // -----------------------------------------------------------------------
00052 
00053   // Create interpreted function f(y) = a0 - a1*sqrt(10*abs(y))
00054   RooFormulaVar fy_1("fy_1","a0-a1*sqrt(10*abs(y))",RooArgSet(y,a0,a1)) ;
00055 
00056   // Create gauss(x,f(y),s)
00057   RooGaussian model_1("model_1","Gaussian with shifting mean",x,fy_1,sigma) ;  
00058 
00059 
00060 
00061   // U s i n g   R o o P o l y V a r   t o   t a i l o r   p d f
00062   // -----------------------------------------------------------------------
00063 
00064   // Create polynomial function f(y) = a0 + a1*y
00065   RooPolyVar fy_2("fy_2","fy_2",y,RooArgSet(a0,a1)) ;
00066 
00067   // Create gauss(x,f(y),s)
00068   RooGaussian model_2("model_2","Gaussian with shifting mean",x,fy_2,sigma) ;  
00069 
00070 
00071 
00072   // U s i n g   R o o A d d i t i o n   t o   t a i l o r   p d f 
00073   // -----------------------------------------------------------------------
00074 
00075   // Create sum function f(y) = a0 + y
00076   RooAddition fy_3("fy_3","a0+y",RooArgSet(a0,y)) ;
00077 
00078   // Create gauss(x,f(y),s)
00079   RooGaussian model_3("model_3","Gaussian with shifting mean",x,fy_3,sigma) ;  
00080 
00081 
00082 
00083   // U s i n g   R o o P r o d u c t   t o   t a i l o r   p d f 
00084   // -----------------------------------------------------------------------
00085 
00086   // Create product function f(y) = a1*y
00087   RooProduct fy_4("fy_4","a1*y",RooArgSet(a1,y)) ;
00088 
00089   // Create gauss(x,f(y),s)
00090   RooGaussian model_4("model_4","Gaussian with shifting mean",x,fy_4,sigma) ;  
00091 
00092 
00093 
00094   // P l o t   a l l   p d f s 
00095   // ----------------------------
00096 
00097   // Make two-dimensional plots in x vs y
00098   TH1* hh_model_1 = model_1.createHistogram("hh_model_1",x,Binning(50),YVar(y,Binning(50))) ;
00099   TH1* hh_model_2 = model_2.createHistogram("hh_model_2",x,Binning(50),YVar(y,Binning(50))) ;
00100   TH1* hh_model_3 = model_3.createHistogram("hh_model_3",x,Binning(50),YVar(y,Binning(50))) ;
00101   TH1* hh_model_4 = model_4.createHistogram("hh_model_4",x,Binning(50),YVar(y,Binning(50))) ;
00102   hh_model_1->SetLineColor(kBlue) ;
00103   hh_model_2->SetLineColor(kBlue) ;
00104   hh_model_3->SetLineColor(kBlue) ;
00105   hh_model_4->SetLineColor(kBlue) ;
00106 
00107   regTH(hh_model_1,"rf202_model2d_1") ;
00108   regTH(hh_model_2,"rf202_model2d_2") ;
00109   regTH(hh_model_3,"rf202_model2d_3") ;
00110   regTH(hh_model_4,"rf202_model2d_4") ;
00111 
00112   return kTRUE ;
00113   }
00114 } ;

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