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/// \author 07/2008 - Wouter Verkerke
9
10#include "RooRealVar.h"
11#include "RooDataSet.h"
12#include "RooGaussian.h"
13#include "RooConstVar.h"
14#include "RooPolynomial.h"
15#include "RooAddPdf.h"
16#include "TCanvas.h"
17#include "TAxis.h"
18#include "RooPlot.h"
19#include "RooMsgService.h"
20
21using namespace RooFit;
22
24{
25 // C r e a t e p d f
26 // --------------------
27
28 // Construct gauss(x,m,s)
29 RooRealVar x("x", "x", -10, 10);
30 RooRealVar m("m", "m", 0, -10, 10);
31 RooRealVar s("s", "s", 1, -10, 10);
32 RooGaussian gauss("g", "g", x, m, s);
33
34 // Construct poly(x,p0)
35 RooRealVar p0("p0", "p0", 0.01, 0., 1.);
36 RooPolynomial poly("p", "p", x, p0);
37
38 // Construct model = f*gauss(x) + (1-f)*poly(x)
39 RooRealVar f("f", "f", 0.5, 0., 1.);
40 RooAddPdf model("model", "model", RooArgSet(gauss, poly), f);
41
42 RooDataSet *data = model.generate(x, 10);
43
44 // 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
45 // ---------------------------------------------------------------------------
46
47 // Print streams configuration
49 cout << endl;
50
51 // 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
52 // -----------------------------------------------------------------------------------------------
53
54 // Print streams configuration
56 cout << endl;
57
58 // Add Integration topic to existing INFO stream
60
61 // Construct integral over gauss to demonstrate new message stream
62 RooAbsReal *igauss = gauss.createIntegral(x);
63 igauss->Print();
64
65 // Print streams configuration in verbose, which also shows inactive streams
66 cout << endl;
68 cout << endl;
69
70 // Remove stream
72
73 // 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
74 // -----------------------------------------------------------------------
75
76 // Show DEBUG level message on function tracing, trace RooGaussian only
78
79 // Perform a fit to generate some tracing messages
80 model.fitTo(*data, Verbose(kTRUE));
81
82 // Reset message service to default stream configuration
84
85 // Show DEBUG level message on function tracing on all objects, redirect output to file
87
88 // Perform a fit to generate some tracing messages
89 model.fitTo(*data, Verbose(kTRUE));
90
91 // Reset message service to default stream configuration
93
94 // 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
95 // ---------------------------------------------------------------------
96
97 // Show DEBUG level messages on client/server link state management
100
101 // Clone composite pdf g to trigger some link state management activity
102 RooAbsArg *gprime = gauss.cloneTree();
103 gprime->Print();
104
105 // Reset message service to default stream configuration
107}
#define DEBUG
Definition: Polynomial.cxx:41
#define f(i)
Definition: RSha256.hxx:104
const Bool_t kTRUE
Definition: RtypesCore.h:87
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:71
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
Definition: RooAbsArg.h:281
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:59
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:31
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
Double_t x[n]
Definition: legend1.C:17
const std::string ClassName(PyObject *pyobj)
Retrieve the class name from the given python object (which may be just an instance of the class).
Definition: Utility.cxx:725
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
RooCmdArg Topic(Int_t topic)
@ Integration
Definition: RooGlobalFunc.h:67
@ LinkStateMgmt
Definition: RooGlobalFunc.h:67
RooCmdArg Verbose(Bool_t flag=kTRUE)
RooCmdArg OutputFile(const char *fileName)
static constexpr double s
static constexpr double gauss
void addTopic(RooFit::MsgTopic newTopic)
void removeTopic(RooFit::MsgTopic oldTopic)
auto * m
Definition: textangle.C:8