Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
rf507_debugtools.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_roofit
3 /// \notebook -nodraw
4 /// Organization and simultaneous fits: RooFit memory tracing debug tool
5 ///
6 /// \macro_output
7 /// \macro_code
8 /// \author 07/2008 - Wouter Verkerke
9 
10 #include "RooRealVar.h"
11 #include "RooDataSet.h"
12 #include "RooGaussian.h"
13 #include "RooConstVar.h"
14 #include "RooPolynomial.h"
15 #include "RooAddPdf.h"
16 #include "TCanvas.h"
17 #include "TAxis.h"
18 #include "RooPlot.h"
19 #include "RooTrace.h"
20 using namespace RooFit;
21 
22 void rf507_debugtools()
23 {
24  // Activate RooFit memory tracing
25  RooTrace::active(kTRUE);
26 
27  // Construct gauss(x,m,s)
28  RooRealVar x("x", "x", -10, 10);
29  RooRealVar m("m", "m", 0, -10, 10);
30  RooRealVar s("s", "s", 1, -10, 10);
31  RooGaussian gauss("g", "g", x, m, s);
32 
33  // Show dump of all RooFit object in memory
34  RooTrace::dump();
35 
36  // Activate verbose mode
37  RooTrace::verbose(kTRUE);
38 
39  // Construct poly(x,p0)
40  RooRealVar p0("p0", "p0", 0.01, 0., 1.);
41  RooPolynomial poly("p", "p", x, p0);
42 
43  // Put marker in trace list for future reference
44  RooTrace::mark();
45 
46  // Construct model = f*gauss(x) + (1-f)*poly(x)
47  RooRealVar f("f", "f", 0.5, 0., 1.);
48  RooAddPdf model("model", "model", RooArgSet(gauss, poly), f);
49 
50  // Show object added to memory since marker
51  RooTrace::printObjectCounts();
52 
53  // Since verbose mode is still on, you will see messages
54  // pertaining to destructor calls of all RooFit objects
55  // made in this macro
56  //
57  // A call to RooTrace::dump() at the end of this macro
58  // should show that there a no RooFit object left in memory
59 }