Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rf506_msgservice.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_roofit
3## \notebook -nodraw
4## Organization and simultaneous fits: tuning and customizing the ROOT.RooFit message logging facility
5##
6## \macro_code
7## \macro_output
8##
9## \date February 2018
10## \authors Clemens Lange, Wouter Verkerke (C++ version)
11
12import ROOT
13
14# Create pdf
15# --------------------
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# Construct poly(x,p0)
24p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0.0, 1.0)
25poly = ROOT.RooPolynomial("p", "p", x, [p0])
26
27# model = f*gauss(x) + (1-f)*poly(x)
28f = ROOT.RooRealVar("f", "f", 0.5, 0.0, 1.0)
29model = ROOT.RooAddPdf("model", "model", [gauss, poly], [f])
30
31data = model.generate({x}, 10)
32
33# Print configuration of message service
34# ------------------------------------------
35
36# Print streams configuration
37ROOT.RooMsgService.instance().Print()
38
39# Adding integration topic to existing INFO stream
40# ---------------------------------------------------
41
42# Print streams configuration
43ROOT.RooMsgService.instance().Print()
44
45# Add Integration topic to existing INFO stream
46ROOT.RooMsgService.instance().getStream(1).addTopic(ROOT.RooFit.Integration)
47
48# Construct integral over gauss to demonstrate message stream
49igauss = gauss.createIntegral({x})
50igauss.Print()
51
52# Print streams configuration in verbose, also shows inactive streams
53ROOT.RooMsgService.instance().Print()
54
55# Remove stream
56ROOT.RooMsgService.instance().getStream(1).removeTopic(ROOT.RooFit.Integration)
57
58# Examples of pdf value tracing
59# -----------------------------------------------------------------------
60
61# Show DEBUG level message on function tracing, ROOT.RooGaussian only
62ROOT.RooMsgService.instance().addStream(ROOT.RooFit.DEBUG, Topic=ROOT.RooFit.Tracing, ClassName="RooGaussian")
63
64# Perform a fit to generate some tracing messages
65model.fitTo(data, Verbose=True)
66
67# Reset message service to default stream configuration
68ROOT.RooMsgService.instance().reset()
69
70# Show DEBUG level message on function tracing on all objects, output to
71# file
72ROOT.RooMsgService.instance().addStream(ROOT.RooFit.DEBUG, Topic=ROOT.RooFit.Tracing, OutputFile="rf506_debug.log")
73
74# Perform a fit to generate some tracing messages
75model.fitTo(data, Verbose=True)
76
77# Reset message service to default stream configuration
78ROOT.RooMsgService.instance().reset()
79
80# Example of another debugging stream
81# ---------------------------------------------------------------------
82
83# Show DEBUG level messages on client/server link state management
84ROOT.RooMsgService.instance().addStream(ROOT.RooFit.DEBUG, Topic=ROOT.RooFit.LinkStateMgmt)
85ROOT.RooMsgService.instance().Print("v")
86
87# Clone composite pdf g to trigger some link state management activity
88gprime = gauss.cloneTree()
89gprime.Print()
90
91# Reset message service to default stream configuration
92ROOT.RooMsgService.instance().reset()
void Print(GNN_Data &d, std::string txt="")