Loading [MathJax]/extensions/tex2jax.js
Logo ROOT   6.16/01
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
rf507_debugtools.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_roofit
3## \notebook -nodraw
4##
5## 'ORGANIZATION AND SIMULTANEOUS FITS' RooFit tutorial macro #507
6##
7## RooFit memory tracing debug tool
8##
9## \macro_code
10##
11## \date February 2018
12## \author Clemens Lange
13## \author Wouter Verkerke (C version)
14
15import ROOT
16
17
18# Activate ROOT.RooFit memory tracing
19ROOT.RooTrace.active(ROOT.kTRUE)
20
21# Construct gauss(x,m,s)
22x = ROOT.RooRealVar("x", "x", -10, 10)
23m = ROOT.RooRealVar("m", "m", 0, -10, 10)
24s = ROOT.RooRealVar("s", "s", 1, -10, 10)
25gauss = ROOT.RooGaussian("g", "g", x, m, s)
26
27# Show dump of all ROOT.RooFit object in memory
28ROOT.RooTrace.dump()
29
30# Activate verbose mode
31ROOT.RooTrace.verbose(ROOT.kTRUE)
32
33# Construct poly(x,p0)
34p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0., 1.)
35poly = ROOT.RooPolynomial("p", "p", x, ROOT.RooArgList(p0))
36
37# Put marker in trace list for future reference
38ROOT.RooTrace.mark()
39
40# model = f*gauss(x) + (1-f)*poly(x)
41f = ROOT.RooRealVar("f", "f", 0.5, 0., 1.)
42model = ROOT.RooAddPdf("model", "model", ROOT.RooArgList(
43 gauss, poly), ROOT.RooArgList(f))
44
45# Show object added to memory since marker
46ROOT.RooTrace.printObjectCounts()
47
48# Since verbose mode is still on, will see messages
49# pertaining to destructor calls of all RooFit objects
50# made in self macro
51#
52# A call to RooTrace.dump() at the end of self macro
53# should show that there a no RooFit object left in memory