rf206_treevistools.C

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //
00003 // 'ADDITION AND CONVOLUTION' RooFit tutorial macro #206
00004 // 
00005 // Tools for visualization of RooAbsArg expression trees
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 "RooChebychev.h"
00020 #include "RooAddPdf.h"
00021 #include "RooExponential.h"
00022 #include "TCanvas.h"
00023 #include "TAxis.h"
00024 #include "RooPlot.h"
00025 using namespace RooFit ;
00026 
00027 
00028 void rf206_treevistools()
00029 {
00030   // S e t u p   c o m p o s i t e    p d f
00031   // --------------------------------------
00032 
00033   // Declare observable x
00034   RooRealVar x("x","x",0,10) ;
00035 
00036   // Create two Gaussian PDFs g1(x,mean1,sigma) anf g2(x,mean2,sigma) and their paramaters
00037   RooRealVar mean("mean","mean of gaussians",5) ;
00038   RooRealVar sigma1("sigma1","width of gaussians",0.5) ;
00039   RooRealVar sigma2("sigma2","width of gaussians",1) ;
00040   RooGaussian sig1("sig1","Signal component 1",x,mean,sigma1) ;  
00041   RooGaussian sig2("sig2","Signal component 2",x,mean,sigma2) ;  
00042 
00043   // Sum the signal components into a composite signal p.d.f.
00044   RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ;
00045   RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ;
00046   
00047   // Build Chebychev polynomial p.d.f.  
00048   RooRealVar a0("a0","a0",0.5,0.,1.) ;
00049   RooRealVar a1("a1","a1",-0.2,0.,1.) ;
00050   RooChebychev bkg1("bkg1","Background 1",x,RooArgSet(a0,a1)) ;
00051 
00052   // Build expontential pdf
00053   RooRealVar alpha("alpha","alpha",-1) ;
00054   RooExponential bkg2("bkg2","Background 2",x,alpha) ;
00055 
00056   // Sum the background components into a composite background p.d.f.
00057   RooRealVar bkg1frac("bkg1frac","fraction of component 1 in background",0.2,0.,1.) ;
00058   RooAddPdf bkg("bkg","Signal",RooArgList(bkg1,bkg2),bkg1frac) ;
00059   
00060   // Sum the composite signal and background 
00061   RooRealVar bkgfrac("bkgfrac","fraction of background",0.5,0.,1.) ;
00062   RooAddPdf  model("model","g1+g2+a",RooArgList(bkg,sig),bkgfrac) ;
00063 
00064 
00065   // P r i n t   c o m p o s i t e   t r e e   i n   A S C I I 
00066   // -----------------------------------------------------------
00067 
00068   // Print tree to stdout
00069   model.Print("t") ;
00070 
00071   // Print tree to file
00072   model.printCompactTree("","rf206_asciitree.txt") ;
00073 
00074 
00075   // D r a w   c o m p o s i t e   t r e e   g r a p h i c a l l y 
00076   // -------------------------------------------------------------
00077 
00078   // Print GraphViz DOT file with representation of tree
00079   model.graphVizTree("rf206_model.dot") ;
00080 
00081   // Make graphic output file with one of the GraphViz tools
00082   // (freely available from www.graphviz.org)
00083   //
00084   // 'Top-to-bottom graph'
00085   // unix> dot -Tgif -o rf207_model_dot.gif rf207_model.dot
00086   //
00087   // 'Spring-model graph'
00088   // unix> fdp -Tgif -o rf207_model_fdp.gif rf207_model.dot
00089 
00090 }

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