Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooTrace Class Reference

Controls the memory tracing hooks in all RooFit objects.

When tracing is active, a table of live RooFit objects is kept that can be queried at any time. In verbose mode, messages are printed in addition at the construction and destruction of each object.

Usage example:

void exampleRooTrace()
{
using namespace RooFit;
// Activate RooFit memory tracing
// 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
// Activate verbose mode
// 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
// 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
// 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
}
#define f(i)
Definition RSha256.hxx:104
Efficient implementation of a sum of PDFs of the form.
Definition RooAddPdf.h:33
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Plain Gaussian p.d.f.
Definition RooGaussian.h:24
RooPolynomial implements a polynomial p.d.f of the form.
Variable that can be changed from the outside.
Definition RooRealVar.h:37
static void dump()
Dump contents of object registry to stdout.
Definition RooTrace.cxx:282
static void verbose(bool flag)
If flag is true, a message will be printed at each object creation or deletion.
Definition RooTrace.cxx:198
static void printObjectCounts()
Definition RooTrace.cxx:319
static void mark()
Put marker in object list, that allows to dump contents of list relative to this marker.
Definition RooTrace.cxx:261
static void active(bool flag)
If flag is true, memory tracing is activated.
Definition RooTrace.cxx:188
Double_t x[n]
Definition legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:64
TMarker m
Definition textangle.C:8
Note
In the ROOT releases, the RooTrace is disabled at compile time and the example above will not print any objects. If you are an advanced developer who wants to use the RooTrace, you need to recompile ROOT after changing the TRACE_CREATE and TRACE_DESTROY macros in RooTrace.h to call the RooTrace functions:
#define TRACE_CREATE RooTrace::create(this);
#define TRACE_DESTROY RooTrace::destroy(this);

However, as ROOT is not build with this by default, the RooTrace is not tested and there is no guarantee that this works.

Definition at line 26 of file RooTrace.h.

Public Member Functions

 RooTrace ()
 
virtual ~RooTrace ()
 
virtual TClassIsA () const
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 

Static Public Member Functions

static void active (bool flag)
 If flag is true, memory tracing is activated.
 
static void callgrind_dump ()
 Utility function to trigger dumping of callgrind counters.
 
static void callgrind_zero ()
 Utility function to trigger zeroing of callgrind counters.
 
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static void create (const TObject *obj)
 Register creation of object 'obj'.
 
static void createSpecial (const char *name, int size)
 
static const char * DeclFileName ()
 
static void destroy (const TObject *obj)
 Register deletion of object 'obj'.
 
static void destroySpecial (const char *name)
 
static void dump ()
 Dump contents of object registry to stdout.
 
static void dump (std::ostream &os, bool sinceMarked=false)
 
static RooTraceinstance ()
 
static void mark ()
 Put marker in object list, that allows to dump contents of list relative to this marker.
 
static void printObjectCounts ()
 
static void verbose (bool flag)
 If flag is true, a message will be printed at each object creation or deletion.
 

Protected Member Functions

void addPad (const TObject *ref, bool doPad)
 
void create2 (const TObject *obj)
 Back end function of create(), register creation of object 'obj'.
 
void create3 (const TObject *obj)
 
void createSpecial3 (const char *name, int size)
 
void destroy2 (const TObject *obj)
 Back end function of destroy(), register deletion of object 'obj'.
 
void destroy3 (const TObject *obj)
 Back end function of destroy(), register deletion of object 'obj'.
 
void destroySpecial3 (const char *name)
 
void dump3 (std::ostream &, bool sinceMarked)
 Dump contents of object register to stream 'os'.
 
void mark3 ()
 Put marker in object list, that allows to dump contents of list relative to this marker.
 
void printObjectCounts3 ()
 
bool removePad (const TObject *ref)
 

Protected Attributes

bool _active
 
RooLinkedList _list
 
RooLinkedList _markList
 
std::map< TClass *, int_objectCount
 
std::map< std::string, int_specialCount
 
std::map< std::string, int_specialSize
 
bool _verbose
 

Static Protected Attributes

static RooTrace_instance =nullptr
 

#include <RooTrace.h>

Constructor & Destructor Documentation

◆ RooTrace()

RooTrace::RooTrace ( )

Definition at line 114 of file RooTrace.cxx.

◆ ~RooTrace()

virtual RooTrace::~RooTrace ( )
inlinevirtual

Definition at line 29 of file RooTrace.h.

Member Function Documentation

◆ active()

void RooTrace::active ( bool  flag)
static

If flag is true, memory tracing is activated.

Definition at line 188 of file RooTrace.cxx.

◆ addPad()

void RooTrace::addPad ( const TObject ref,
bool  doPad 
)
protected

◆ callgrind_dump()

void RooTrace::callgrind_dump ( )
static

Utility function to trigger dumping of callgrind counters.

Note that this function does not do anything, other than optionally printing this message To trigger callgrind dumping action, run callgrind with argument '–dump-before=RooTrace::callgrind_dump()' (include single quotes in cmdline)

Definition at line 365 of file RooTrace.cxx.

◆ callgrind_zero()

void RooTrace::callgrind_zero ( )
static

Utility function to trigger zeroing of callgrind counters.

Note that this function does not do anything, other than optionally printing this message To trigger callgrind zero counter action, run callgrind with argument '–zero-before=RooTrace::callgrind_zero()' (include single quotes in cmdline)

Definition at line 353 of file RooTrace.cxx.

◆ Class()

static TClass * RooTrace::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * RooTrace::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t RooTrace::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 84 of file RooTrace.h.

◆ create()

void RooTrace::create ( const TObject obj)
static

Register creation of object 'obj'.

Definition at line 123 of file RooTrace.cxx.

◆ create2()

void RooTrace::create2 ( const TObject obj)
protected

Back end function of create(), register creation of object 'obj'.

Definition at line 210 of file RooTrace.cxx.

◆ create3()

void RooTrace::create3 ( const TObject obj)
protected

Definition at line 238 of file RooTrace.cxx.

◆ createSpecial()

void RooTrace::createSpecial ( const char *  name,
int  size 
)
static

Definition at line 147 of file RooTrace.cxx.

◆ createSpecial3()

void RooTrace::createSpecial3 ( const char *  name,
int  size 
)
protected

Definition at line 169 of file RooTrace.cxx.

◆ DeclFileName()

static const char * RooTrace::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 84 of file RooTrace.h.

◆ destroy()

void RooTrace::destroy ( const TObject obj)
static

Register deletion of object 'obj'.

Definition at line 136 of file RooTrace.cxx.

◆ destroy2()

void RooTrace::destroy2 ( const TObject obj)
protected

Back end function of destroy(), register deletion of object 'obj'.

Definition at line 225 of file RooTrace.cxx.

◆ destroy3()

void RooTrace::destroy3 ( const TObject obj)
protected

Back end function of destroy(), register deletion of object 'obj'.

Definition at line 250 of file RooTrace.cxx.

◆ destroySpecial()

void RooTrace::destroySpecial ( const char *  name)
static

Definition at line 158 of file RooTrace.cxx.

◆ destroySpecial3()

void RooTrace::destroySpecial3 ( const char *  name)
protected

Definition at line 178 of file RooTrace.cxx.

◆ dump() [1/2]

void RooTrace::dump ( )
static

Dump contents of object registry to stdout.

Definition at line 282 of file RooTrace.cxx.

◆ dump() [2/2]

void RooTrace::dump ( std::ostream &  os,
bool  sinceMarked = false 
)
static

Definition at line 290 of file RooTrace.cxx.

◆ dump3()

void RooTrace::dump3 ( std::ostream &  os,
bool  sinceMarked 
)
protected

Dump contents of object register to stream 'os'.

If sinceMarked is true, only object created after the last call to mark() are shown.

Definition at line 300 of file RooTrace.cxx.

◆ instance()

RooTrace & RooTrace::instance ( )
static

Definition at line 105 of file RooTrace.cxx.

◆ IsA()

virtual TClass * RooTrace::IsA ( ) const
inlinevirtual
Returns
TClass describing current object

Definition at line 84 of file RooTrace.h.

◆ mark()

void RooTrace::mark ( )
static

Put marker in object list, that allows to dump contents of list relative to this marker.

Definition at line 261 of file RooTrace.cxx.

◆ mark3()

void RooTrace::mark3 ( )
protected

Put marker in object list, that allows to dump contents of list relative to this marker.

Definition at line 272 of file RooTrace.cxx.

◆ printObjectCounts()

void RooTrace::printObjectCounts ( )
static

Definition at line 319 of file RooTrace.cxx.

◆ printObjectCounts3()

void RooTrace::printObjectCounts3 ( )
protected

Definition at line 326 of file RooTrace.cxx.

◆ removePad()

bool RooTrace::removePad ( const TObject ref)
protected

◆ Streamer()

virtual void RooTrace::Streamer ( TBuffer )
virtual

◆ StreamerNVirtual()

void RooTrace::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 84 of file RooTrace.h.

◆ verbose()

void RooTrace::verbose ( bool  flag)
static

If flag is true, a message will be printed at each object creation or deletion.

Definition at line 198 of file RooTrace.cxx.

Member Data Documentation

◆ _active

bool RooTrace::_active
protected

Definition at line 76 of file RooTrace.h.

◆ _instance

RooTrace * RooTrace::_instance =nullptr
staticprotected

Definition at line 57 of file RooTrace.h.

◆ _list

RooLinkedList RooTrace::_list
protected

Definition at line 78 of file RooTrace.h.

◆ _markList

RooLinkedList RooTrace::_markList
protected

Definition at line 79 of file RooTrace.h.

◆ _objectCount

std::map<TClass*,int> RooTrace::_objectCount
protected

Definition at line 80 of file RooTrace.h.

◆ _specialCount

std::map<std::string,int> RooTrace::_specialCount
protected

Definition at line 81 of file RooTrace.h.

◆ _specialSize

std::map<std::string,int> RooTrace::_specialSize
protected

Definition at line 82 of file RooTrace.h.

◆ _verbose

bool RooTrace::_verbose
protected

Definition at line 77 of file RooTrace.h.

Libraries for RooTrace:

The documentation for this class was generated from the following files: