Logo ROOT   6.18/05
Reference Guide
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 memory tracing debug tool
6##
7## \macro_code
8##
9## \date February 2018
10## \author Clemens Lange, Wouter Verkerke (C++ version)
11
12import ROOT
13
14
15# Activate ROOT.RooFit memory tracing
16ROOT.RooTrace.active(ROOT.kTRUE)
17
18# Construct gauss(x,m,s)
19x = ROOT.RooRealVar("x", "x", -10, 10)
20m = ROOT.RooRealVar("m", "m", 0, -10, 10)
21s = ROOT.RooRealVar("s", "s", 1, -10, 10)
22gauss = ROOT.RooGaussian("g", "g", x, m, s)
23
24# Show dump of all ROOT.RooFit object in memory
25ROOT.RooTrace.dump()
26
27# Activate verbose mode
28ROOT.RooTrace.verbose(ROOT.kTRUE)
29
30# Construct poly(x,p0)
31p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0., 1.)
32poly = ROOT.RooPolynomial("p", "p", x, ROOT.RooArgList(p0))
33
34# Put marker in trace list for future reference
35ROOT.RooTrace.mark()
36
37# model = f*gauss(x) + (1-f)*poly(x)
38f = ROOT.RooRealVar("f", "f", 0.5, 0., 1.)
39model = ROOT.RooAddPdf("model", "model", ROOT.RooArgList(
40 gauss, poly), ROOT.RooArgList(f))
41
42# Show object added to memory since marker
43ROOT.RooTrace.printObjectCounts()
44
45# Since verbose mode is still on, will see messages
46# pertaining to destructor calls of all RooFit objects
47# made in self macro
48#
49# A call to RooTrace.dump() at the end of self macro
50# should show that there a no RooFit object left in memory