Logo ROOT  
Reference Guide
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 
11 import ROOT
12 
13 
14 # Activate ROOT.RooFit memory tracing
15 ROOT.RooTrace.active(ROOT.kTRUE)
16 
17 # Construct gauss(x,m,s)
18 x = ROOT.RooRealVar("x", "x", -10, 10)
19 m = ROOT.RooRealVar("m", "m", 0, -10, 10)
20 s = ROOT.RooRealVar("s", "s", 1, -10, 10)
21 gauss = ROOT.RooGaussian("g", "g", x, m, s)
22 
23 # Show dump of all ROOT.RooFit object in memory
24 ROOT.RooTrace.dump()
25 
26 # Activate verbose mode
27 ROOT.RooTrace.verbose(ROOT.kTRUE)
28 
29 # Construct poly(x,p0)
30 p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0., 1.)
31 poly = ROOT.RooPolynomial("p", "p", x, ROOT.RooArgList(p0))
32 
33 # Put marker in trace list for future reference
34 ROOT.RooTrace.mark()
35 
36 # model = f*gauss(x) + (1-f)*poly(x)
37 f = ROOT.RooRealVar("f", "f", 0.5, 0., 1.)
38 model = ROOT.RooAddPdf("model", "model", ROOT.RooArgList(
39  gauss, poly), ROOT.RooArgList(f))
40 
41 # Show object added to memory since marker
42 ROOT.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