Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rf506_msgservice.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_roofit
3/// \notebook -nodraw
4/// Organisation and simultaneous fits: tuning and customizing the RooFit message logging facility
5///
6/// \macro_code
7/// \macro_output
8///
9/// \date July 2008
10/// \author Wouter Verkerke
11
12#include "RooRealVar.h"
13#include "RooDataSet.h"
14#include "RooGaussian.h"
15#include "RooPolynomial.h"
16#include "RooAddPdf.h"
17#include "TCanvas.h"
18#include "TAxis.h"
19#include "RooPlot.h"
20#include "RooMsgService.h"
21
22using namespace RooFit;
23
25{
26 // C r e a t e p d f
27 // --------------------
28
29 // Construct gauss(x,m,s)
30 RooRealVar x("x", "x", -10, 10);
31 RooRealVar m("m", "m", 0, -10, 10);
32 RooRealVar s("s", "s", 1, -10, 10);
33 RooGaussian gauss("g", "g", x, m, s);
34
35 // Construct poly(x,p0)
36 RooRealVar p0("p0", "p0", 0.01, 0., 1.);
37 RooPolynomial poly("p", "p", x, p0);
38
39 // Construct model = f*gauss(x) + (1-f)*poly(x)
40 RooRealVar f("f", "f", 0.5, 0., 1.);
41 RooAddPdf model("model", "model", RooArgSet(gauss, poly), f);
42
43 std::unique_ptr<RooDataSet> data{model.generate(x, 10)};
44
45 // P r i n t c o n f i g u r a t i o n o f m e s s a g e s e r v i c e
46 // ---------------------------------------------------------------------------
47
48 // Print streams configuration
50 cout << endl;
51
52 // A d d i n g I n t e g r a t i o n t o p i c t o e x i s t i n g I N F O s t r e a m
53 // -----------------------------------------------------------------------------------------------
54
55 // Print streams configuration
57 cout << endl;
58
59 // Add Integration topic to existing INFO stream
61
62 // Construct integral over gauss to demonstrate new message stream
63 std::unique_ptr<RooAbsReal> igauss{gauss.createIntegral(x)};
64 igauss->Print();
65
66 // Print streams configuration in verbose, which also shows inactive streams
67 cout << endl;
69 cout << endl;
70
71 // Remove stream
73
74 // E x a m p l e s o f p d f v a l u e t r a c i n g s t r e a m
75 // -----------------------------------------------------------------------
76
77 // Show DEBUG level message on function tracing, trace RooGaussian only
78 RooMsgService::instance().addStream(DEBUG, Topic(Tracing), ClassName("RooGaussian"));
79
80 // Perform a fit to generate some tracing messages
81 model.fitTo(*data, Verbose(true));
82
83 // Reset message service to default stream configuration
85
86 // Show DEBUG level message on function tracing on all objects, redirect output to file
87 RooMsgService::instance().addStream(DEBUG, Topic(Tracing), OutputFile("rf506_debug.log"));
88
89 // Perform a fit to generate some tracing messages
90 model.fitTo(*data, Verbose(true));
91
92 // Reset message service to default stream configuration
94
95 // E x a m p l e o f a n o t h e r d e b u g g i n g s t r e a m
96 // ---------------------------------------------------------------------
97
98 // Show DEBUG level messages on client/server link state management
101
102 // Clone composite pdf g to trigger some link state management activity
103 RooAbsArg *gprime = gauss.cloneTree();
104 gprime->Print();
105
106 // Reset message service to default stream configuration
108}
#define DEBUG
#define f(i)
Definition RSha256.hxx:104
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
void Print(Option_t *options=nullptr) const override
Print the object to the defaultPrintStream().
Definition RooAbsArg.h:263
virtual RooAbsArg * cloneTree(const char *newname=nullptr) const
Clone tree expression of objects.
Efficient implementation of a sum of PDFs of the form.
Definition RooAddPdf.h:33
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Plain Gaussian p.d.f.
Definition RooGaussian.h:24
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
void Print(Option_t *options=nullptr) const override
Print configuration of message service.
Int_t addStream(RooFit::MsgLevel level, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={})
Add a message logging stream for message with given RooFit::MsgLevel or higher.
RooPolynomial implements a polynomial p.d.f of the form.
Variable that can be changed from the outside.
Definition RooRealVar.h:37
RooCmdArg ClassName(const char *name)
RooCmdArg Topic(Int_t topic)
RooCmdArg OutputFile(const char *fileName)
RooCmdArg Verbose(bool flag=true)
Double_t x[n]
Definition legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:64
void addTopic(RooFit::MsgTopic newTopic)
void removeTopic(RooFit::MsgTopic oldTopic)
TMarker m
Definition textangle.C:8