rf407_latextables.C

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //
00003 // 'DATA AND CATEGORIES' RooFit tutorial macro #407
00004 // 
00005 // Latex printing of lists and sets of RooArgSets
00006 //
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 "RooConstVar.h"
00020 #include "RooChebychev.h"
00021 #include "RooAddPdf.h"
00022 #include "RooExponential.h"
00023 #include "TCanvas.h"
00024 #include "TAxis.h"
00025 #include "RooPlot.h"
00026 using namespace RooFit ;
00027 
00028 
00029 void rf407_latextables()
00030 {
00031   // S e t u p   c o m p o s i t e    p d f
00032   // --------------------------------------
00033 
00034   // Declare observable x
00035   RooRealVar x("x","x",0,10) ;
00036 
00037   // Create two Gaussian PDFs g1(x,mean1,sigma) anf g2(x,mean2,sigma) and their paramaters
00038   RooRealVar mean("mean","mean of gaussians",5) ;
00039   RooRealVar sigma1("sigma1","width of gaussians",0.5) ;
00040   RooRealVar sigma2("sigma2","width of gaussians",1) ;
00041   RooGaussian sig1("sig1","Signal component 1",x,mean,sigma1) ;  
00042   RooGaussian sig2("sig2","Signal component 2",x,mean,sigma2) ;  
00043 
00044   // Sum the signal components into a composite signal p.d.f.
00045   RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ;
00046   RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ;
00047   
00048   // Build Chebychev polynomial p.d.f.  
00049   RooRealVar a0("a0","a0",0.5,0.,1.) ;
00050   RooRealVar a1("a1","a1",-0.2,0.,1.) ;
00051   RooChebychev bkg1("bkg1","Background 1",x,RooArgSet(a0,a1)) ;
00052 
00053   // Build expontential pdf
00054   RooRealVar alpha("alpha","alpha",-1) ;
00055   RooExponential bkg2("bkg2","Background 2",x,alpha) ;
00056 
00057   // Sum the background components into a composite background p.d.f.
00058   RooRealVar bkg1frac("sig1frac","fraction of component 1 in background",0.2,0.,1.) ;
00059   RooAddPdf bkg("bkg","Signal",RooArgList(bkg1,bkg2),sig1frac) ;
00060   
00061   // Sum the composite signal and background 
00062   RooRealVar bkgfrac("bkgfrac","fraction of background",0.5,0.,1.) ;
00063   RooAddPdf  model("model","g1+g2+a",RooArgList(bkg,sig),bkgfrac) ;
00064 
00065 
00066 
00067   // M a k e   l i s t   o f   p a r a m e t e r s   b e f o r e   a n d   a f t e r   f i t
00068   // ----------------------------------------------------------------------------------------
00069 
00070   // Make list of model parameters
00071   RooArgSet* params = model.getParameters(x) ;
00072 
00073   // Save snapshot of prefit parameters
00074   RooArgSet* initParams = (RooArgSet*) params->snapshot() ;
00075 
00076   // Do fit to data, to obtain error estimates on parameters
00077   RooDataSet* data = model.generate(x,1000) ;
00078   model.fitTo(*data) ;
00079 
00080 
00081 
00082   // P r i n t   l a t ex   t a b l e   o f   p a r a m e t e r s   o f   p d f 
00083   // --------------------------------------------------------------------------
00084 
00085 
00086   // Print parameter list in LaTeX for (one column with names, one column with values)
00087   params->printLatex() ;
00088 
00089   // Print parameter list in LaTeX for (names values|names values)
00090   params->printLatex(Columns(2)) ;
00091 
00092   // Print two parameter lists side by side (name values initvalues)
00093   params->printLatex(Sibling(*initParams)) ;
00094 
00095   // Print two parameter lists side by side (name values initvalues|name values initvalues)
00096   params->printLatex(Sibling(*initParams),Columns(2)) ;
00097 
00098   // Write LaTex table to file
00099   params->printLatex(Sibling(*initParams),OutputFile("rf407_latextables.tex")) ;
00100 
00101 
00102 }
00103 
00104 

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