rf506_msgservice.C

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //
00003 // 'ORGANIZATION AND SIMULTANEOUS FITS' RooFit tutorial macro #506
00004 // 
00005 // Tuning and customizing the RooFit message logging facility
00006 //
00007 //
00008 //
00009 // 07/2008 - Wouter Verkerke 
00010 // 
00011 /////////////////////////////////////////////////////////////////////////
00012 
00013 #ifndef __CINT__
00014 #include "RooGlobalFunc.h"
00015 #endif
00016 #include "RooRealVar.h"
00017 #include "RooDataSet.h"
00018 #include "RooGaussian.h"
00019 #include "RooConstVar.h"
00020 #include "RooPolynomial.h"
00021 #include "RooAddPdf.h"
00022 #include "TCanvas.h"
00023 #include "TAxis.h"
00024 #include "RooPlot.h"
00025 #include "RooMsgService.h"
00026 
00027 using namespace RooFit ;
00028 
00029 
00030 void rf506_msgservice()
00031 {
00032   // C r e a t e   p d f 
00033   // --------------------
00034 
00035   // Construct gauss(x,m,s)
00036   RooRealVar x("x","x",-10,10) ;
00037   RooRealVar m("m","m",0,-10,10) ;
00038   RooRealVar s("s","s",1,-10,10) ;
00039   RooGaussian gauss("g","g",x,m,s) ;
00040 
00041   // Construct poly(x,p0)
00042   RooRealVar p0("p0","p0",0.01,0.,1.) ;
00043   RooPolynomial poly("p","p",x,p0) ;             
00044 
00045   // Construct model = f*gauss(x) + (1-f)*poly(x)
00046   RooRealVar f("f","f",0.5,0.,1.) ;
00047   RooAddPdf model("model","model",RooArgSet(gauss,poly),f) ;
00048 
00049   RooDataSet* data = model.generate(x,10) ;
00050 
00051 
00052 
00053   // 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
00054   // ---------------------------------------------------------------------------
00055 
00056   // Print streams configuration
00057   RooMsgService::instance().Print() ;
00058   cout << endl ;
00059 
00060 
00061 
00062   // 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
00063   // -----------------------------------------------------------------------------------------------
00064 
00065   // Print streams configuration
00066   RooMsgService::instance().Print() ;
00067   cout << endl ;
00068 
00069   // Add Integration topic to existing INFO stream
00070   RooMsgService::instance().getStream(1).addTopic(Integration) ;
00071 
00072   // Construct integral over gauss to demonstrate new message stream
00073   RooAbsReal* igauss = gauss.createIntegral(x) ;
00074   igauss->Print() ;
00075 
00076   // Print streams configuration in verbose, which also shows inactive streams
00077   cout << endl ;
00078   RooMsgService::instance().Print() ;
00079   cout << endl ;
00080 
00081   // Remove stream
00082   RooMsgService::instance().getStream(1).removeTopic(Integration) ;
00083 
00084 
00085 
00086   // 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
00087   // -----------------------------------------------------------------------
00088   
00089   // Show DEBUG level message on function tracing, trace RooGaussian only
00090   RooMsgService::instance().addStream(DEBUG,Topic(Tracing),ClassName("RooGaussian")) ;
00091 
00092   // Perform a fit to generate some tracing messages
00093   model.fitTo(*data,Verbose(kTRUE)) ;
00094 
00095   // Reset message service to default stream configuration
00096   RooMsgService::instance().reset() ;
00097 
00098 
00099 
00100   // Show DEBUG level message on function tracing on all objects, redirect output to file
00101   RooMsgService::instance().addStream(DEBUG,Topic(Tracing),OutputFile("rf506_debug.log")) ;
00102 
00103   // Perform a fit to generate some tracing messages
00104   model.fitTo(*data,Verbose(kTRUE)) ;
00105 
00106   // Reset message service to default stream configuration
00107   RooMsgService::instance().reset() ;
00108 
00109 
00110 
00111   // 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
00112   // ---------------------------------------------------------------------
00113 
00114   // Show DEBUG level messages on client/server link state management
00115   RooMsgService::instance().addStream(DEBUG,Topic(LinkStateMgmt)) ;
00116   RooMsgService::instance().Print("v") ;
00117 
00118   // Clone composite pdf g to trigger some link state management activity
00119   RooAbsArg* gprime = gauss.cloneTree() ;
00120   gprime->Print() ;
00121 
00122   // Reset message service to default stream configuration
00123   RooMsgService::instance().reset() ;
00124 
00125 
00126 
00127 }

Generated on Tue Jul 5 15:45:08 2011 for ROOT_528-00b_version by  doxygen 1.5.1