ROOT logo

From $ROOTSYS/tutorials/roofit/rf206_treevistools.C

//////////////////////////////////////////////////////////////////////////
//
// 'ADDITION AND CONVOLUTION' RooFit tutorial macro #206
// 
// Tools for visualization of RooAbsArg expression trees
//
//
//
// 07/2008 - Wouter Verkerke 
// 
/////////////////////////////////////////////////////////////////////////

#ifndef __CINT__
#include "RooGlobalFunc.h"
#endif
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooChebychev.h"
#include "RooAddPdf.h"
#include "RooExponential.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
using namespace RooFit ;


void rf206_treevistools()
{
  // S e t u p   c o m p o s i t e    p d f
  // --------------------------------------

  // Declare observable x
  RooRealVar x("x","x",0,10) ;

  // Create two Gaussian PDFs g1(x,mean1,sigma) anf g2(x,mean2,sigma) and their paramaters
  RooRealVar mean("mean","mean of gaussians",5) ;
  RooRealVar sigma1("sigma1","width of gaussians",0.5) ;
  RooRealVar sigma2("sigma2","width of gaussians",1) ;
  RooGaussian sig1("sig1","Signal component 1",x,mean,sigma1) ;  
  RooGaussian sig2("sig2","Signal component 2",x,mean,sigma2) ;  

  // Sum the signal components into a composite signal p.d.f.
  RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ;
  RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ;
  
  // Build Chebychev polynomial p.d.f.  
  RooRealVar a0("a0","a0",0.5,0.,1.) ;
  RooRealVar a1("a1","a1",-0.2,0.,1.) ;
  RooChebychev bkg1("bkg1","Background 1",x,RooArgSet(a0,a1)) ;

  // Build expontential pdf
  RooRealVar alpha("alpha","alpha",-1) ;
  RooExponential bkg2("bkg2","Background 2",x,alpha) ;

  // Sum the background components into a composite background p.d.f.
  RooRealVar bkg1frac("bkg1frac","fraction of component 1 in background",0.2,0.,1.) ;
  RooAddPdf bkg("bkg","Signal",RooArgList(bkg1,bkg2),bkg1frac) ;
  
  // Sum the composite signal and background 
  RooRealVar bkgfrac("bkgfrac","fraction of background",0.5,0.,1.) ;
  RooAddPdf  model("model","g1+g2+a",RooArgList(bkg,sig),bkgfrac) ;


  // 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 
  // -----------------------------------------------------------

  // Print tree to stdout
  model.Print("t") ;

  // Print tree to file
  model.printCompactTree("","rf206_asciitree.txt") ;


  // 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 
  // -------------------------------------------------------------

  // Print GraphViz DOT file with representation of tree
  model.graphVizTree("rf206_model.dot") ;

  // Make graphic output file with one of the GraphViz tools
  // (freely available from www.graphviz.org)
  //
  // 'Top-to-bottom graph'
  // unix> dot -Tgif -o rf207_model_dot.gif rf207_model.dot
  //
  // 'Spring-model graph'
  // unix> fdp -Tgif -o rf207_model_fdp.gif rf207_model.dot

}
 rf206_treevistools.C:1
 rf206_treevistools.C:2
 rf206_treevistools.C:3
 rf206_treevistools.C:4
 rf206_treevistools.C:5
 rf206_treevistools.C:6
 rf206_treevistools.C:7
 rf206_treevistools.C:8
 rf206_treevistools.C:9
 rf206_treevistools.C:10
 rf206_treevistools.C:11
 rf206_treevistools.C:12
 rf206_treevistools.C:13
 rf206_treevistools.C:14
 rf206_treevistools.C:15
 rf206_treevistools.C:16
 rf206_treevistools.C:17
 rf206_treevistools.C:18
 rf206_treevistools.C:19
 rf206_treevistools.C:20
 rf206_treevistools.C:21
 rf206_treevistools.C:22
 rf206_treevistools.C:23
 rf206_treevistools.C:24
 rf206_treevistools.C:25
 rf206_treevistools.C:26
 rf206_treevistools.C:27
 rf206_treevistools.C:28
 rf206_treevistools.C:29
 rf206_treevistools.C:30
 rf206_treevistools.C:31
 rf206_treevistools.C:32
 rf206_treevistools.C:33
 rf206_treevistools.C:34
 rf206_treevistools.C:35
 rf206_treevistools.C:36
 rf206_treevistools.C:37
 rf206_treevistools.C:38
 rf206_treevistools.C:39
 rf206_treevistools.C:40
 rf206_treevistools.C:41
 rf206_treevistools.C:42
 rf206_treevistools.C:43
 rf206_treevistools.C:44
 rf206_treevistools.C:45
 rf206_treevistools.C:46
 rf206_treevistools.C:47
 rf206_treevistools.C:48
 rf206_treevistools.C:49
 rf206_treevistools.C:50
 rf206_treevistools.C:51
 rf206_treevistools.C:52
 rf206_treevistools.C:53
 rf206_treevistools.C:54
 rf206_treevistools.C:55
 rf206_treevistools.C:56
 rf206_treevistools.C:57
 rf206_treevistools.C:58
 rf206_treevistools.C:59
 rf206_treevistools.C:60
 rf206_treevistools.C:61
 rf206_treevistools.C:62
 rf206_treevistools.C:63
 rf206_treevistools.C:64
 rf206_treevistools.C:65
 rf206_treevistools.C:66
 rf206_treevistools.C:67
 rf206_treevistools.C:68
 rf206_treevistools.C:69
 rf206_treevistools.C:70
 rf206_treevistools.C:71
 rf206_treevistools.C:72
 rf206_treevistools.C:73
 rf206_treevistools.C:74
 rf206_treevistools.C:75
 rf206_treevistools.C:76
 rf206_treevistools.C:77
 rf206_treevistools.C:78
 rf206_treevistools.C:79
 rf206_treevistools.C:80
 rf206_treevistools.C:81
 rf206_treevistools.C:82
 rf206_treevistools.C:83
 rf206_treevistools.C:84
 rf206_treevistools.C:85
 rf206_treevistools.C:86
 rf206_treevistools.C:87
 rf206_treevistools.C:88
 rf206_treevistools.C:89
 rf206_treevistools.C:90
 rf206_treevistools.C:91