ROOT logo

From $ROOTSYS/tutorials/roofit/rf506_msgservice.C

//////////////////////////////////////////////////////////////////////////
//
// 'ORGANIZATION AND SIMULTANEOUS FITS' RooFit tutorial macro #506
// 
// Tuning and customizing the RooFit message logging facility
//
//
//
// 07/2008 - Wouter Verkerke 
// 
/////////////////////////////////////////////////////////////////////////

#ifndef __CINT__
#include "RooGlobalFunc.h"
#endif
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooPolynomial.h"
#include "RooAddPdf.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
#include "RooMsgService.h"

using namespace RooFit ;


void rf506_msgservice()
{
  // C r e a t e   p d f 
  // --------------------

  // Construct gauss(x,m,s)
  RooRealVar x("x","x",-10,10) ;
  RooRealVar m("m","m",0,-10,10) ;
  RooRealVar s("s","s",1,-10,10) ;
  RooGaussian gauss("g","g",x,m,s) ;

  // Construct poly(x,p0)
  RooRealVar p0("p0","p0",0.01,0.,1.) ;
  RooPolynomial poly("p","p",x,p0) ;		 

  // Construct model = f*gauss(x) + (1-f)*poly(x)
  RooRealVar f("f","f",0.5,0.,1.) ;
  RooAddPdf model("model","model",RooArgSet(gauss,poly),f) ;

  RooDataSet* data = model.generate(x,10) ;



  // 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
  // ---------------------------------------------------------------------------

  // Print streams configuration
  RooMsgService::instance().Print() ;
  cout << endl ;



  // 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
  // -----------------------------------------------------------------------------------------------

  // Print streams configuration
  RooMsgService::instance().Print() ;
  cout << endl ;

  // Add Integration topic to existing INFO stream
  RooMsgService::instance().getStream(1).addTopic(Integration) ;

  // Construct integral over gauss to demonstrate new message stream
  RooAbsReal* igauss = gauss.createIntegral(x) ;
  igauss->Print() ;

  // Print streams configuration in verbose, which also shows inactive streams
  cout << endl ;
  RooMsgService::instance().Print() ;
  cout << endl ;

  // Remove stream
  RooMsgService::instance().getStream(1).removeTopic(Integration) ;



  // 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
  // -----------------------------------------------------------------------
  
  // Show DEBUG level message on function tracing, trace RooGaussian only
  RooMsgService::instance().addStream(DEBUG,Topic(Tracing),ClassName("RooGaussian")) ;

  // Perform a fit to generate some tracing messages
  model.fitTo(*data,Verbose(kTRUE)) ;

  // Reset message service to default stream configuration
  RooMsgService::instance().reset() ;



  // Show DEBUG level message on function tracing on all objects, redirect output to file
  RooMsgService::instance().addStream(DEBUG,Topic(Tracing),OutputFile("rf506_debug.log")) ;

  // Perform a fit to generate some tracing messages
  model.fitTo(*data,Verbose(kTRUE)) ;

  // Reset message service to default stream configuration
  RooMsgService::instance().reset() ;



  // 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
  // ---------------------------------------------------------------------

  // Show DEBUG level messages on client/server link state management
  RooMsgService::instance().addStream(DEBUG,Topic(LinkStateMgmt)) ;
  RooMsgService::instance().Print("v") ;

  // Clone composite pdf g to trigger some link state management activity
  RooAbsArg* gprime = gauss.cloneTree() ;
  gprime->Print() ;

  // Reset message service to default stream configuration
  RooMsgService::instance().reset() ;



}
 rf506_msgservice.C:1
 rf506_msgservice.C:2
 rf506_msgservice.C:3
 rf506_msgservice.C:4
 rf506_msgservice.C:5
 rf506_msgservice.C:6
 rf506_msgservice.C:7
 rf506_msgservice.C:8
 rf506_msgservice.C:9
 rf506_msgservice.C:10
 rf506_msgservice.C:11
 rf506_msgservice.C:12
 rf506_msgservice.C:13
 rf506_msgservice.C:14
 rf506_msgservice.C:15
 rf506_msgservice.C:16
 rf506_msgservice.C:17
 rf506_msgservice.C:18
 rf506_msgservice.C:19
 rf506_msgservice.C:20
 rf506_msgservice.C:21
 rf506_msgservice.C:22
 rf506_msgservice.C:23
 rf506_msgservice.C:24
 rf506_msgservice.C:25
 rf506_msgservice.C:26
 rf506_msgservice.C:27
 rf506_msgservice.C:28
 rf506_msgservice.C:29
 rf506_msgservice.C:30
 rf506_msgservice.C:31
 rf506_msgservice.C:32
 rf506_msgservice.C:33
 rf506_msgservice.C:34
 rf506_msgservice.C:35
 rf506_msgservice.C:36
 rf506_msgservice.C:37
 rf506_msgservice.C:38
 rf506_msgservice.C:39
 rf506_msgservice.C:40
 rf506_msgservice.C:41
 rf506_msgservice.C:42
 rf506_msgservice.C:43
 rf506_msgservice.C:44
 rf506_msgservice.C:45
 rf506_msgservice.C:46
 rf506_msgservice.C:47
 rf506_msgservice.C:48
 rf506_msgservice.C:49
 rf506_msgservice.C:50
 rf506_msgservice.C:51
 rf506_msgservice.C:52
 rf506_msgservice.C:53
 rf506_msgservice.C:54
 rf506_msgservice.C:55
 rf506_msgservice.C:56
 rf506_msgservice.C:57
 rf506_msgservice.C:58
 rf506_msgservice.C:59
 rf506_msgservice.C:60
 rf506_msgservice.C:61
 rf506_msgservice.C:62
 rf506_msgservice.C:63
 rf506_msgservice.C:64
 rf506_msgservice.C:65
 rf506_msgservice.C:66
 rf506_msgservice.C:67
 rf506_msgservice.C:68
 rf506_msgservice.C:69
 rf506_msgservice.C:70
 rf506_msgservice.C:71
 rf506_msgservice.C:72
 rf506_msgservice.C:73
 rf506_msgservice.C:74
 rf506_msgservice.C:75
 rf506_msgservice.C:76
 rf506_msgservice.C:77
 rf506_msgservice.C:78
 rf506_msgservice.C:79
 rf506_msgservice.C:80
 rf506_msgservice.C:81
 rf506_msgservice.C:82
 rf506_msgservice.C:83
 rf506_msgservice.C:84
 rf506_msgservice.C:85
 rf506_msgservice.C:86
 rf506_msgservice.C:87
 rf506_msgservice.C:88
 rf506_msgservice.C:89
 rf506_msgservice.C:90
 rf506_msgservice.C:91
 rf506_msgservice.C:92
 rf506_msgservice.C:93
 rf506_msgservice.C:94
 rf506_msgservice.C:95
 rf506_msgservice.C:96
 rf506_msgservice.C:97
 rf506_msgservice.C:98
 rf506_msgservice.C:99
 rf506_msgservice.C:100
 rf506_msgservice.C:101
 rf506_msgservice.C:102
 rf506_msgservice.C:103
 rf506_msgservice.C:104
 rf506_msgservice.C:105
 rf506_msgservice.C:106
 rf506_msgservice.C:107
 rf506_msgservice.C:108
 rf506_msgservice.C:109
 rf506_msgservice.C:110
 rf506_msgservice.C:111
 rf506_msgservice.C:112
 rf506_msgservice.C:113
 rf506_msgservice.C:114
 rf506_msgservice.C:115
 rf506_msgservice.C:116
 rf506_msgservice.C:117
 rf506_msgservice.C:118
 rf506_msgservice.C:119
 rf506_msgservice.C:120
 rf506_msgservice.C:121
 rf506_msgservice.C:122
 rf506_msgservice.C:123
 rf506_msgservice.C:124
 rf506_msgservice.C:125
 rf506_msgservice.C:126
 rf506_msgservice.C:127
 rf506_msgservice.C:128