Logo ROOT  
Reference Guide
rf206_treevistools.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_roofit
3/// \notebook -nodraw
4///
5/// Addition and convolution: tools for visualization of RooAbsArg expression trees
6///
7/// \macro_output
8/// \macro_code
9///
10/// \date 07/2008
11/// \author Wouter Verkerke
12
13#include "RooRealVar.h"
14#include "RooDataSet.h"
15#include "RooGaussian.h"
16#include "RooChebychev.h"
17#include "RooAddPdf.h"
18#include "RooExponential.h"
19#include "TCanvas.h"
20#include "TAxis.h"
21#include "RooPlot.h"
22using namespace RooFit;
23
25{
26 // S e t u p c o m p o s i t e p d f
27 // --------------------------------------
28
29 // Declare observable x
30 RooRealVar x("x", "x", 0, 10);
31
32 // Create two Gaussian PDFs g1(x,mean1,sigma) anf g2(x,mean2,sigma) and their parameters
33 RooRealVar mean("mean", "mean of gaussians", 5);
34 RooRealVar sigma1("sigma1", "width of gaussians", 0.5);
35 RooRealVar sigma2("sigma2", "width of gaussians", 1);
36 RooGaussian sig1("sig1", "Signal component 1", x, mean, sigma1);
37 RooGaussian sig2("sig2", "Signal component 2", x, mean, sigma2);
38
39 // Sum the signal components into a composite signal p.d.f.
40 RooRealVar sig1frac("sig1frac", "fraction of component 1 in signal", 0.8, 0., 1.);
41 RooAddPdf sig("sig", "Signal", RooArgList(sig1, sig2), sig1frac);
42
43 // Build Chebychev polynomial p.d.f.
44 RooRealVar a0("a0", "a0", 0.5, 0., 1.);
45 RooRealVar a1("a1", "a1", 0.2, 0., 1.);
46 RooChebychev bkg1("bkg1", "Background 1", x, RooArgSet(a0, a1));
47
48 // Build expontential pdf
49 RooRealVar alpha("alpha", "alpha", -1);
50 RooExponential bkg2("bkg2", "Background 2", x, alpha);
51
52 // Sum the background components into a composite background p.d.f.
53 RooRealVar bkg1frac("bkg1frac", "fraction of component 1 in background", 0.2, 0., 1.);
54 RooAddPdf bkg("bkg", "Signal", RooArgList(bkg1, bkg2), bkg1frac);
55
56 // Sum the composite signal and background
57 RooRealVar bkgfrac("bkgfrac", "fraction of background", 0.5, 0., 1.);
58 RooAddPdf model("model", "g1+g2+a", RooArgList(bkg, sig), bkgfrac);
59
60 // 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
61 // -----------------------------------------------------------
62
63 // Print tree to stdout
64 model.Print("t");
65
66 // Print tree to file
67 model.printCompactTree("", "rf206_asciitree.txt");
68
69 // 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
70 // -------------------------------------------------------------
71
72 // Print GraphViz DOT file with representation of tree
73 model.graphVizTree("rf206_model.dot");
74
75 // Make graphic output file with one of the GraphViz tools
76 // (freely available from www.graphviz.org)
77 //
78 // 'Top-to-bottom graph'
79 // unix> dot -Tgif -o rf207_model_dot.gif rf207_model.dot
80 //
81 // 'Spring-model graph'
82 // unix> fdp -Tgif -o rf207_model_fdp.gif rf207_model.dot
83}
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:29
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
Chebychev polynomial p.d.f.
Definition: RooChebychev.h:25
Exponential PDF.
Plain Gaussian p.d.f.
Definition: RooGaussian.h:25
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
Double_t x[n]
Definition: legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...