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 
24 using namespace RooFit;
25 
26 void rf506_msgservice()
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 }
m
auto * m
Definition: textangle.C:8
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooMsgService.h
RooAddPdf
Definition: RooAddPdf.h:32
f
#define f(i)
Definition: RSha256.hxx:122
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:162
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:168
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
Definition: RooGaussian.h:25
RooAddPdf.h
RooAbsReal
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:269
RooFit
Definition: RooCFunction1Binding.h:29
RooPolynomial
Definition: RooPolynomial.h:28
RooFit::Verbose
RooCmdArg Verbose(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:186
RooMsgService::Print
void Print(Option_t *options=0) const
Print configuration of message service.
Definition: RooMsgService.cxx:551
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 (i....
Definition: RooMsgService.cxx:201
RooRealVar.h
RooConstVar.h
RooFit::Tracing
@ Tracing
Definition: RooGlobalFunc.h:68
RooFit::ClassName
RooCmdArg ClassName(const char *name)
Definition: RooGlobalFunc.cxx:300
TAxis.h
RooFit::Topic
RooCmdArg Topic(Int_t topic)
Definition: RooGlobalFunc.cxx:298
RooDataSet
Definition: RooDataSet.h:33
make_cnn_model.model
model
Definition: make_cnn_model.py:6
RooAbsArg
Definition: RooAbsArg.h:73
RooFit::Integration
@ Integration
Definition: RooGlobalFunc.h:67
RooRealVar
Definition: RooRealVar.h:35
RooMsgService::instance
static RooMsgService & instance()
Return reference to singleton instance.
Definition: RooMsgService.cxx:363
RooMsgService::reset
void reset()
Definition: RooMsgService.cxx:113
RooArgSet
Definition: RooArgSet.h:28