ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rf206_treevistools.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_roofit
3 /// 'ADDITION AND CONVOLUTION' RooFit tutorial macro #206
4 ///
5 /// Tools for visualization of RooAbsArg expression trees
6 ///
7 ///
8 ///
9 /// \macro_code
10 /// \author 07/2008 - Wouter Verkerke
11 
12 
13 #ifndef __CINT__
14 #include "RooGlobalFunc.h"
15 #endif
16 #include "RooRealVar.h"
17 #include "RooDataSet.h"
18 #include "RooGaussian.h"
19 #include "RooChebychev.h"
20 #include "RooAddPdf.h"
21 #include "RooExponential.h"
22 #include "TCanvas.h"
23 #include "TAxis.h"
24 #include "RooPlot.h"
25 using namespace RooFit ;
26 
27 
28 void rf206_treevistools()
29 {
30  // S e t u p c o m p o s i t e p d f
31  // --------------------------------------
32 
33  // Declare observable x
34  RooRealVar x("x","x",0,10) ;
35 
36  // Create two Gaussian PDFs g1(x,mean1,sigma) anf g2(x,mean2,sigma) and their parameters
37  RooRealVar mean("mean","mean of gaussians",5) ;
38  RooRealVar sigma1("sigma1","width of gaussians",0.5) ;
39  RooRealVar sigma2("sigma2","width of gaussians",1) ;
40  RooGaussian sig1("sig1","Signal component 1",x,mean,sigma1) ;
41  RooGaussian sig2("sig2","Signal component 2",x,mean,sigma2) ;
42 
43  // Sum the signal components into a composite signal p.d.f.
44  RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ;
45  RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ;
46 
47  // Build Chebychev polynomial p.d.f.
48  RooRealVar a0("a0","a0",0.5,0.,1.) ;
49  RooRealVar a1("a1","a1",-0.2,0.,1.) ;
50  RooChebychev bkg1("bkg1","Background 1",x,RooArgSet(a0,a1)) ;
51 
52  // Build expontential pdf
53  RooRealVar alpha("alpha","alpha",-1) ;
54  RooExponential bkg2("bkg2","Background 2",x,alpha) ;
55 
56  // Sum the background components into a composite background p.d.f.
57  RooRealVar bkg1frac("bkg1frac","fraction of component 1 in background",0.2,0.,1.) ;
58  RooAddPdf bkg("bkg","Signal",RooArgList(bkg1,bkg2),bkg1frac) ;
59 
60  // Sum the composite signal and background
61  RooRealVar bkgfrac("bkgfrac","fraction of background",0.5,0.,1.) ;
62  RooAddPdf model("model","g1+g2+a",RooArgList(bkg,sig),bkgfrac) ;
63 
64 
65  // 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
66  // -----------------------------------------------------------
67 
68  // Print tree to stdout
69  model.Print("t") ;
70 
71  // Print tree to file
72  model.printCompactTree("","rf206_asciitree.txt") ;
73 
74 
75  // 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
76  // -------------------------------------------------------------
77 
78  // Print GraphViz DOT file with representation of tree
79  model.graphVizTree("rf206_model.dot") ;
80 
81  // Make graphic output file with one of the GraphViz tools
82  // (freely available from www.graphviz.org)
83  //
84  // 'Top-to-bottom graph'
85  // unix> dot -Tgif -o rf207_model_dot.gif rf207_model.dot
86  //
87  // 'Spring-model graph'
88  // unix> fdp -Tgif -o rf207_model_fdp.gif rf207_model.dot
89 
90 }
Double_t x[n]
Definition: legend1.C:17
Plain Gaussian p.d.f.
Definition: RooGaussian.h:25
friend class RooArgSet
Definition: RooAbsArg.h:469
Exponential p.d.f.
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
Chebychev polynomial p.d.f.
Definition: RooChebychev.h:25
RooAbsMoment * mean(RooRealVar &obs)
Definition: RooAbsReal.h:297