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(True)
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(True)
28
29# Construct poly(x,p0)
30p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0.0, 1.0)
31poly = ROOT.RooPolynomial("p", "p", x, [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.0, 1.0)
38model = ROOT.RooAddPdf("model", "model", [gauss, poly], [f])
39
40# Show object added to memory since marker
41ROOT.RooTrace.printObjectCounts()
42
43# Since verbose mode is still on, will see messages
44# pertaining to destructor calls of all RooFit objects
45# made in self macro
46#
47# A call to RooTrace.dump() at the end of self macro
48# should show that there a no RooFit object left in memory