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