Logo ROOT  
Reference Guide
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_output
7/// \macro_code
8///
9/// \date July 2008
10/// \author Wouter Verkerke
11
12#include "RooRealVar.h"
13#include "RooDataSet.h"
14#include "RooGaussian.h"
15#include "RooConstVar.h"
16#include "RooPolynomial.h"
17#include "RooAddPdf.h"
18#include "TCanvas.h"
19#include "TAxis.h"
20#include "RooPlot.h"
21#include "RooMsgService.h"
22
23using namespace RooFit;
24
26{
27 // C r e a t e p d f
28 // --------------------
29
30 // Construct gauss(x,m,s)
31 RooRealVar x("x", "x", -10, 10);
32 RooRealVar m("m", "m", 0, -10, 10);
33 RooRealVar s("s", "s", 1, -10, 10);
34 RooGaussian gauss("g", "g", x, m, s);
35
36 // Construct poly(x,p0)
37 RooRealVar p0("p0", "p0", 0.01, 0., 1.);
38 RooPolynomial poly("p", "p", x, p0);
39
40 // Construct model = f*gauss(x) + (1-f)*poly(x)
41 RooRealVar f("f", "f", 0.5, 0., 1.);
42 RooAddPdf model("model", "model", RooArgSet(gauss, poly), f);
43
44 RooDataSet *data = model.generate(x, 10);
45
46 // 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
47 // ---------------------------------------------------------------------------
48
49 // Print streams configuration
51 cout << endl;
52
53 // 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
54 // -----------------------------------------------------------------------------------------------
55
56 // Print streams configuration
58 cout << endl;
59
60 // Add Integration topic to existing INFO stream
62
63 // Construct integral over gauss to demonstrate new message stream
64 RooAbsReal *igauss = gauss.createIntegral(x);
65 igauss->Print();
66
67 // Print streams configuration in verbose, which also shows inactive streams
68 cout << endl;
70 cout << endl;
71
72 // Remove stream
74
75 // 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
76 // -----------------------------------------------------------------------
77
78 // Show DEBUG level message on function tracing, trace RooGaussian only
80
81 // Perform a fit to generate some tracing messages
82 model.fitTo(*data, Verbose(kTRUE));
83
84 // Reset message service to default stream configuration
86
87 // Show DEBUG level message on function tracing on all objects, redirect output to file
89
90 // Perform a fit to generate some tracing messages
91 model.fitTo(*data, Verbose(kTRUE));
92
93 // Reset message service to default stream configuration
95
96 // 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
97 // ---------------------------------------------------------------------
98
99 // Show DEBUG level messages on client/server link state management
102
103 // Clone composite pdf g to trigger some link state management activity
104 RooAbsArg *gprime = gauss.cloneTree();
105 gprime->Print();
106
107 // Reset message service to default stream configuration
109}
#define DEBUG
Definition: Polynomial.cxx:40
#define f(i)
Definition: RSha256.hxx:104
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
Definition: RooAbsArg.h:340
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:32
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
Plain Gaussian p.d.f.
Definition: RooGaussian.h:24
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.
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:39
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