rf302_utilfuncs.C

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 "TAxis.h"
00021 #include "RooPlot.h"
00022 #include "RooFormulaVar.h"
00023 #include "RooAddition.h"
00024 #include "RooProduct.h"
00025 #include "RooPolyVar.h"
00026 #include "TCanvas.h"
00027 #include "TAxis.h"
00028 #include "TH1.h"
00029 
00030 using namespace RooFit ;
00031 
00032 
00033 void rf302_utilfuncs()
00034 {
00035   // 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 
00036   // -----------------------------------------------------------
00037 
00038   // Create observables
00039   RooRealVar x("x","x",-5,5) ;
00040   RooRealVar y("y","y",-5,5) ;
00041 
00042   // Create parameters
00043   RooRealVar a0("a0","a0",-1.5,-5,5) ;
00044   RooRealVar a1("a1","a1",-0.5,-1,1) ;
00045   RooRealVar sigma("sigma","width of gaussian",0.5) ;
00046 
00047 
00048   // 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 
00049   // -----------------------------------------------------------------------
00050 
00051   // Create interpreted function f(y) = a0 - a1*sqrt(10*abs(y))
00052   RooFormulaVar fy_1("fy_1","a0-a1*sqrt(10*abs(y))",RooArgSet(y,a0,a1)) ;
00053 
00054   // Create gauss(x,f(y),s)
00055   RooGaussian model_1("model_1","Gaussian with shifting mean",x,fy_1,sigma) ;  
00056 
00057 
00058 
00059   // 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
00060   // -----------------------------------------------------------------------
00061 
00062   // Create polynomial function f(y) = a0 + a1*y
00063   RooPolyVar fy_2("fy_2","fy_2",y,RooArgSet(a0,a1)) ;
00064 
00065   // Create gauss(x,f(y),s)
00066   RooGaussian model_2("model_2","Gaussian with shifting mean",x,fy_2,sigma) ;  
00067 
00068 
00069 
00070   // 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 
00071   // -----------------------------------------------------------------------
00072 
00073   // Create sum function f(y) = a0 + y
00074   RooAddition fy_3("fy_3","a0+y",RooArgSet(a0,y)) ;
00075 
00076   // Create gauss(x,f(y),s)
00077   RooGaussian model_3("model_3","Gaussian with shifting mean",x,fy_3,sigma) ;  
00078 
00079 
00080 
00081   // 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 
00082   // -----------------------------------------------------------------------
00083 
00084   // Create product function f(y) = a1*y
00085   RooProduct fy_4("fy_4","a1*y",RooArgSet(a1,y)) ;
00086 
00087   // Create gauss(x,f(y),s)
00088   RooGaussian model_4("model_4","Gaussian with shifting mean",x,fy_4,sigma) ;  
00089 
00090 
00091 
00092   // P l o t   a l l   p d f s 
00093   // ----------------------------
00094 
00095   // Make two-dimensional plots in x vs y
00096   TH1* hh_model_1 = model_1.createHistogram("hh_model_1",x,Binning(50),YVar(y,Binning(50))) ;
00097   TH1* hh_model_2 = model_2.createHistogram("hh_model_2",x,Binning(50),YVar(y,Binning(50))) ;
00098   TH1* hh_model_3 = model_3.createHistogram("hh_model_3",x,Binning(50),YVar(y,Binning(50))) ;
00099   TH1* hh_model_4 = model_4.createHistogram("hh_model_4",x,Binning(50),YVar(y,Binning(50))) ;
00100   hh_model_1->SetLineColor(kBlue) ;
00101   hh_model_2->SetLineColor(kBlue) ;
00102   hh_model_3->SetLineColor(kBlue) ;
00103   hh_model_4->SetLineColor(kBlue) ;
00104 
00105   // Make canvas and draw RooPlots
00106   TCanvas *c = new TCanvas("rf302_utilfuncs","rf302_utilfuncs",800, 800);
00107   c->Divide(2,2);
00108   c->cd(1) ; gPad->SetLeftMargin(0.20) ; hh_model_1->GetZaxis()->SetTitleOffset(2.5) ; hh_model_1->Draw("surf") ;
00109   c->cd(2) ; gPad->SetLeftMargin(0.20) ; hh_model_2->GetZaxis()->SetTitleOffset(2.5) ; hh_model_2->Draw("surf") ;
00110   c->cd(3) ; gPad->SetLeftMargin(0.20) ; hh_model_3->GetZaxis()->SetTitleOffset(2.5) ; hh_model_3->Draw("surf") ;
00111   c->cd(4) ; gPad->SetLeftMargin(0.20) ; hh_model_4->GetZaxis()->SetTitleOffset(2.5) ; hh_model_4->Draw("surf") ;
00112     
00113 }

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