Logo ROOT   6.16/01
Reference Guide
rf506_msgservice.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_roofit
3## \notebook -nodraw
4##
5## 'ORGANIZATION AND SIMULTANEOUS FITS' RooFit tutorial macro #506
6##
7## Tuning and customizing the ROOT.RooFit message logging facility
8##
9## \macro_code
10##
11## \date February 2018
12## \author Clemens Lange
13## \author Wouter Verkerke (C version)
14
15
16import ROOT
17
18# Create pdf
19# --------------------
20
21# Construct gauss(x,m,s)
22x = ROOT.RooRealVar("x", "x", -10, 10)
23m = ROOT.RooRealVar("m", "m", 0, -10, 10)
24s = ROOT.RooRealVar("s", "s", 1, -10, 10)
25gauss = ROOT.RooGaussian("g", "g", x, m, s)
26
27# Construct poly(x,p0)
28p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0., 1.)
29poly = ROOT.RooPolynomial("p", "p", x, ROOT.RooArgList(p0))
30
31# model = f*gauss(x) + (1-f)*poly(x)
32f = ROOT.RooRealVar("f", "f", 0.5, 0., 1.)
33model = ROOT.RooAddPdf("model", "model", ROOT.RooArgList(
34 gauss, poly), ROOT.RooArgList(f))
35
36data = model.generate(ROOT.RooArgSet(x), 10)
37
38# Print configuration of message service
39# ------------------------------------------
40
41# Print streams configuration
42ROOT.RooMsgService.instance().Print()
43
44# Adding integration topic to existing INFO stream
45# ---------------------------------------------------
46
47# Print streams configuration
48ROOT.RooMsgService.instance().Print()
49
50# Add Integration topic to existing INFO stream
51ROOT.RooMsgService.instance().getStream(1).addTopic(ROOT.RooFit.Integration)
52
53# Construct integral over gauss to demonstrate message stream
54igauss = gauss.createIntegral(ROOT.RooArgSet(x))
55igauss.Print()
56
57# Print streams configuration in verbose, also shows inactive streams
58ROOT.RooMsgService.instance().Print()
59
60# Remove stream
61ROOT.RooMsgService.instance().getStream(1).removeTopic(ROOT.RooFit.Integration)
62
63# Examples of pdf value tracing
64# -----------------------------------------------------------------------
65
66# Show DEBUG level message on function tracing, ROOT.RooGaussian only
67ROOT.RooMsgService.instance().addStream(
68 ROOT.RooFit.DEBUG, ROOT.RooFit.Topic(ROOT.RooFit.Tracing), ROOT.RooFit.ClassName("RooGaussian"))
69
70# Perform a fit to generate some tracing messages
71model.fitTo(data, ROOT.RooFit.Verbose(ROOT.kTRUE))
72
73# Reset message service to default stream configuration
74ROOT.RooMsgService.instance().reset()
75
76# Show DEBUG level message on function tracing on all objects, output to
77# file
78ROOT.RooMsgService.instance().addStream(
79 ROOT.RooFit.DEBUG, ROOT.RooFit.Topic(ROOT.RooFit.Tracing), ROOT.RooFit.OutputFile("rf506_debug.log"))
80
81# Perform a fit to generate some tracing messages
82model.fitTo(data, ROOT.RooFit.Verbose(ROOT.kTRUE))
83
84# Reset message service to default stream configuration
85ROOT.RooMsgService.instance().reset()
86
87# Example of another debugging stream
88# ---------------------------------------------------------------------
89
90# Show DEBUG level messages on client/server link state management
91ROOT.RooMsgService.instance().addStream(
92 ROOT.RooFit.DEBUG, ROOT.RooFit.Topic(ROOT.RooFit.LinkStateMgmt))
93ROOT.RooMsgService.instance().Print("v")
94
95# Clone composite pdf g to trigger some link state management activity
96gprime = gauss.cloneTree()
97gprime.Print()
98
99# Reset message service to default stream configuration
100ROOT.RooMsgService.instance().reset()
void Print(std::ostream &os, const OptionType &opt)