Logo ROOT  
Reference Guide
rf506_msgservice.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_roofit
3/// \notebook -nodraw
4///
5/// Organisation and simultaneous fits: tuning and customizing the RooFit message logging facility
6///
7/// \macro_output
8/// \macro_code
9///
10/// \date 07/2008
11/// \author Wouter Verkerke
12
13#include "RooRealVar.h"
14#include "RooDataSet.h"
15#include "RooGaussian.h"
16#include "RooConstVar.h"
17#include "RooPolynomial.h"
18#include "RooAddPdf.h"
19#include "TCanvas.h"
20#include "TAxis.h"
21#include "RooPlot.h"
22#include "RooMsgService.h"
23
24using namespace RooFit;
25
27{
28 // C r e a t e p d f
29 // --------------------
30
31 // Construct gauss(x,m,s)
32 RooRealVar x("x", "x", -10, 10);
33 RooRealVar m("m", "m", 0, -10, 10);
34 RooRealVar s("s", "s", 1, -10, 10);
35 RooGaussian gauss("g", "g", x, m, s);
36
37 // Construct poly(x,p0)
38 RooRealVar p0("p0", "p0", 0.01, 0., 1.);
39 RooPolynomial poly("p", "p", x, p0);
40
41 // Construct model = f*gauss(x) + (1-f)*poly(x)
42 RooRealVar f("f", "f", 0.5, 0., 1.);
43 RooAddPdf model("model", "model", RooArgSet(gauss, poly), f);
44
45 RooDataSet *data = model.generate(x, 10);
46
47 // 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
48 // ---------------------------------------------------------------------------
49
50 // Print streams configuration
52 cout << endl;
53
54 // 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
55 // -----------------------------------------------------------------------------------------------
56
57 // Print streams configuration
59 cout << endl;
60
61 // Add Integration topic to existing INFO stream
63
64 // Construct integral over gauss to demonstrate new message stream
65 RooAbsReal *igauss = gauss.createIntegral(x);
66 igauss->Print();
67
68 // Print streams configuration in verbose, which also shows inactive streams
69 cout << endl;
71 cout << endl;
72
73 // Remove stream
75
76 // 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
77 // -----------------------------------------------------------------------
78
79 // Show DEBUG level message on function tracing, trace RooGaussian only
81
82 // Perform a fit to generate some tracing messages
83 model.fitTo(*data, Verbose(kTRUE));
84
85 // Reset message service to default stream configuration
87
88 // Show DEBUG level message on function tracing on all objects, redirect output to file
90
91 // Perform a fit to generate some tracing messages
92 model.fitTo(*data, Verbose(kTRUE));
93
94 // Reset message service to default stream configuration
96
97 // 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
98 // ---------------------------------------------------------------------
99
100 // Show DEBUG level messages on client/server link state management
103
104 // Clone composite pdf g to trigger some link state management activity
105 RooAbsArg *gprime = gauss.cloneTree();
106 gprime->Print();
107
108 // Reset message service to default stream configuration
110}
#define DEBUG
Definition: Polynomial.cxx:40
#define f(i)
Definition: RSha256.hxx:104
const Bool_t kTRUE
Definition: RtypesCore.h:89
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:73
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
Definition: RooAbsArg.h:302
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:60
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:29
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
Plain Gaussian p.d.f.
Definition: RooGaussian.h:25
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
Int_t addStream(RooFit::MsgLevel level, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg())
Add a message logging stream for message with given RooFit::MsgLevel or higher (i....
void Print(Option_t *options=0) const
Print configuration of message service.
RooPolynomial implements a polynomial p.d.f of the form.
Definition: RooPolynomial.h:28
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
RooCmdArg ClassName(const char *name)
RooCmdArg Topic(Int_t topic)
RooCmdArg OutputFile(const char *fileName)
RooCmdArg Verbose(Bool_t flag=kTRUE)
Double_t x[n]
Definition: legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
@ Integration
Definition: RooGlobalFunc.h:67
@ LinkStateMgmt
Definition: RooGlobalFunc.h:67
static constexpr double s
static constexpr double gauss
void addTopic(RooFit::MsgTopic newTopic)
void removeTopic(RooFit::MsgTopic oldTopic)
auto * m
Definition: textangle.C:8