ROOT logo

From $ROOTSYS/tutorials/roofit/rf507_debugtools.C

//////////////////////////////////////////////////////////////////////////
//
// 'ORGANIZATION AND SIMULTANEOUS FITS' RooFit tutorial macro #507
// 
//   RooFit memory tracing debug tool
//
//
//
// 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 "RooTrace.h"
using namespace RooFit ;


void rf507_debugtools()
{
  // Activate RooFit memory tracing
  RooTrace::active(kTRUE) ;

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

  // Show dump of all RooFit object in memory
  RooTrace::dump() ;

  // Activate verbose mode
  RooTrace::verbose(kTRUE) ;

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

  // Put marker in trace list for future reference
  RooTrace::mark() ;

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

  // Show object added to memory since marker
  RooTrace::dump(cout,kTRUE) ;

  // Since verbose mode is still on, you will see messages
  // pertaining to destructor calls of all RooFit objects
  // made in this macro
  //
  // A call to RooTrace::dump() at the end of this macro
  // should show that there a no RooFit object left in memory
}
 rf507_debugtools.C:1
 rf507_debugtools.C:2
 rf507_debugtools.C:3
 rf507_debugtools.C:4
 rf507_debugtools.C:5
 rf507_debugtools.C:6
 rf507_debugtools.C:7
 rf507_debugtools.C:8
 rf507_debugtools.C:9
 rf507_debugtools.C:10
 rf507_debugtools.C:11
 rf507_debugtools.C:12
 rf507_debugtools.C:13
 rf507_debugtools.C:14
 rf507_debugtools.C:15
 rf507_debugtools.C:16
 rf507_debugtools.C:17
 rf507_debugtools.C:18
 rf507_debugtools.C:19
 rf507_debugtools.C:20
 rf507_debugtools.C:21
 rf507_debugtools.C:22
 rf507_debugtools.C:23
 rf507_debugtools.C:24
 rf507_debugtools.C:25
 rf507_debugtools.C:26
 rf507_debugtools.C:27
 rf507_debugtools.C:28
 rf507_debugtools.C:29
 rf507_debugtools.C:30
 rf507_debugtools.C:31
 rf507_debugtools.C:32
 rf507_debugtools.C:33
 rf507_debugtools.C:34
 rf507_debugtools.C:35
 rf507_debugtools.C:36
 rf507_debugtools.C:37
 rf507_debugtools.C:38
 rf507_debugtools.C:39
 rf507_debugtools.C:40
 rf507_debugtools.C:41
 rf507_debugtools.C:42
 rf507_debugtools.C:43
 rf507_debugtools.C:44
 rf507_debugtools.C:45
 rf507_debugtools.C:46
 rf507_debugtools.C:47
 rf507_debugtools.C:48
 rf507_debugtools.C:49
 rf507_debugtools.C:50
 rf507_debugtools.C:51
 rf507_debugtools.C:52
 rf507_debugtools.C:53
 rf507_debugtools.C:54
 rf507_debugtools.C:55
 rf507_debugtools.C:56
 rf507_debugtools.C:57
 rf507_debugtools.C:58
 rf507_debugtools.C:59
 rf507_debugtools.C:60
 rf507_debugtools.C:61
 rf507_debugtools.C:62
 rf507_debugtools.C:63
 rf507_debugtools.C:64
 rf507_debugtools.C:65
 rf507_debugtools.C:66
 rf507_debugtools.C:67