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 
23 using namespace RooFit;
24 
25 void rf506_msgservice()
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 }
m
auto * m
Definition: textangle.C:8
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooMsgService.h
RooAddPdf
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:32
f
#define f(i)
Definition: RSha256.hxx:104
RooMsgService::StreamConfig::addTopic
void addTopic(RooFit::MsgTopic newTopic)
Definition: RooMsgService.h:114
RooFit::DEBUG
@ DEBUG
Definition: RooGlobalFunc.h:65
RooFit::OutputFile
RooCmdArg OutputFile(const char *fileName)
Definition: RooGlobalFunc.cxx:165
RooAbsArg::Print
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
Definition: RooAbsArg.h:320
RooGaussian.h
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
RooMsgService::StreamConfig::removeTopic
void removeTopic(RooFit::MsgTopic oldTopic)
Definition: RooMsgService.h:118
RooMsgService::getStream
StreamConfig & getStream(Int_t id)
Definition: RooMsgService.h:152
x
Double_t x[n]
Definition: legend1.C:17
RooGaussian
Plain Gaussian p.d.f.
Definition: RooGaussian.h:24
RooAddPdf.h
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
TCanvas.h
RooDataSet.h
RooPolynomial.h
RooFit::LinkStateMgmt
@ LinkStateMgmt
Definition: RooGlobalFunc.h:67
rf506_msgservice
Definition: rf506_msgservice.py:1
TGeant4Unit::gauss
static constexpr double gauss
Definition: TGeant4SystemOfUnits.h:263
RooFit
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition: RooCFunction1Binding.h:29
RooPolynomial
RooPolynomial implements a polynomial p.d.f of the form.
Definition: RooPolynomial.h:28
RooFit::Verbose
RooCmdArg Verbose(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:189
RooMsgService::Print
void Print(Option_t *options=0) const
Print configuration of message service.
Definition: RooMsgService.cxx:554
RooPlot.h
RooMsgService::addStream
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.
Definition: RooMsgService.cxx:198
RooRealVar.h
RooConstVar.h
RooFit::Tracing
@ Tracing
Definition: RooGlobalFunc.h:68
RooFit::ClassName
RooCmdArg ClassName(const char *name)
Definition: RooGlobalFunc.cxx:306
TAxis.h
RooFit::Topic
RooCmdArg Topic(Int_t topic)
Definition: RooGlobalFunc.cxx:304
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
make_cnn_model.model
model
Definition: make_cnn_model.py:6
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooFit::Integration
@ Integration
Definition: RooGlobalFunc.h:67
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:37
RooMsgService::instance
static RooMsgService & instance()
Return reference to singleton instance.
Definition: RooMsgService.cxx:366
RooMsgService::reset
void reset()
Definition: RooMsgService.cxx:113
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29