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