CanvasHelper
CanvasHelper Class Reference

#include "CanvasHelper.h"

Inherits TObject.

Public Member Functions

virtual ~CanvasHelper ()
 Class destructor.
 
void addCanvas (TCanvas *canvas)
 Register your canvas for processing. Canvas needs to be added after all the primitives are drawn on it. More...
 

Static Public Member Functions

static CanvasHelper * getInstance ()
 Obtain an instance of the CanvasHelper class. More...
 
static void addSubtitle (TVirtualPad *pad, const char *text)
 Add subtitle to the canvas. lololo. More...
 
static void setPaveAlignment (TPave *pave, UInt_t align)
 Used to specify TPave's alignment on the ROOT canvas. Emum variables can be combined: More...
 
static TPaveStats * getDefaultPaveStats (TVirtualPad *pad)
 Used to obtain default ROOT statistics box from a canvas with histogram, graph etc. Finds TPave in the histogram (graph) list of primitives. Detaches TPave and attaches to the canvas. Returns a pointer to the TPave. More...
 
static TLegend * getDefaultLegend (TVirtualPad *pad)
 Used to obtain default ROOT legend from a canvas. More...
 
static void addTextToStats (const char *text, TVirtualPad *pad)
 Used to add a line to the default canvas (pad) statistics box. More...
 
static void addTextToStats (const char *text, TPaveStats *stats, TVirtualPad *pad)
 Used to add a line to a custom specific statistics box on a canvas (pad). More...
 
static void addMultiCanvasTitle (TCanvas *canvas, const char *title, const char *subtitle="")
 Adding a multi-pad canvas title. Optionally supprts subtitle too. More...
 
static void saveCanvas (TCanvas *canvas, UInt_t format)
 

Detailed Description

One and only library class represented by a singleton.

Member Function Documentation

◆ addCanvas()

void CanvasHelper::addCanvas ( TCanvas *  canvas)

Register your canvas for processing. Canvas needs to be added after all the primitives are drawn on it.

Parameters
canvasCanvas to be processed.
CavasHelper::getInstance()->addCanvas(myCanvas);

◆ addMultiCanvasTitle()

void CanvasHelper::addMultiCanvasTitle ( TCanvas *  canvas,
const char *  title,
const char *  subtitle = "" 
)
static

Adding a multi-pad canvas title. Optionally supprts subtitle too.

Parameters
canvasROOT canvas divided into a number of sub-pads.
titleString to be used as title.
subtitleString to be used as sub-title.

◆ addSubtitle()

void CanvasHelper::addSubtitle ( TVirtualPad *  pad,
const char *  text 
)
static

Add subtitle to the canvas. lololo.

Parameters
padCanvas object.
textSubtitle text. Can use TLatex syntax.
CavasHelper::addSubtitle(myCanvas, "Sample Subtitle Text");

◆ addTextToStats() [1/2]

void CanvasHelper::addTextToStats ( const char *  text,
TPaveStats *  stats,
TVirtualPad *  pad 
)
static

Used to add a line to a custom specific statistics box on a canvas (pad).

Parameters
textString of text to be added.
statsSpecific statistics box to add a line to.
padCanvas or a sub-pad containing the legend.
CanvasHelper::addTextToStats("Resolution, % = 10.1 #pm 0.2", myStatBox, myCanvas);
static void addTextToStats(const char *text, TVirtualPad *pad)
Used to add a line to the default canvas (pad) statistics box.
Definition: CanvasHelper.cpp:916

◆ addTextToStats() [2/2]

void CanvasHelper::addTextToStats ( const char *  text,
TVirtualPad *  pad 
)
static

Used to add a line to the default canvas (pad) statistics box.

Parameters
textString of text to be added. Use = as a spacer between left and right-aligned substrings. TLatex is also supported.
padCanvas or a sub-pad containing the legend.
CanvasHelper::addTextToStats("Resolution, % = 10.1 #pm 0.2", myCanvas);

◆ getDefaultLegend()

TLegend * CanvasHelper::getDefaultLegend ( TVirtualPad *  pad)
static

Used to obtain default ROOT legend from a canvas.

Parameters
padCanvas or a sub-pad containing the legend.
TLegend *pave = CanvasHelper::getDefaultLegend(myCanvas);
static TLegend * getDefaultLegend(TVirtualPad *pad)
Used to obtain default ROOT legend from a canvas.
Definition: CanvasHelper.cpp:910

◆ getDefaultPaveStats()

TPaveStats * CanvasHelper::getDefaultPaveStats ( TVirtualPad *  pad)
static

Used to obtain default ROOT statistics box from a canvas with histogram, graph etc. Finds TPave in the histogram (graph) list of primitives. Detaches TPave and attaches to the canvas. Returns a pointer to the TPave.

Parameters
padCanvas or a sub-pad containing statistics box.
TPaveStats *pave = CanvasHelper::getDefaultPaveStats(myCanvas);
static TPaveStats * getDefaultPaveStats(TVirtualPad *pad)
Used to obtain default ROOT statistics box from a canvas with histogram, graph etc....
Definition: CanvasHelper.cpp:858

◆ getInstance()

CanvasHelper * CanvasHelper::getInstance ( )
static

Obtain an instance of the CanvasHelper class.

CanvasHelper* canvasHelper = CavasHelper::getInstance();
Definition: CanvasHelper.h:76

◆ saveCanvas()

void CanvasHelper::saveCanvas ( TCanvas *  canvas,
UInt_t  format 
)
static

Function saves canvas to disk in certain format. Formats are manipulated as bits:

CavasHelper::saveCanvas(myCanvas, kCanvasPng | kCanvasPs | kCanvasRoot | kCanvasC);

*

◆ setPaveAlignment()

void CanvasHelper::setPaveAlignment ( TPave *  pave,
UInt_t  align 
)
static

Used to specify TPave's alignment on the ROOT canvas. Emum variables can be combined:

Parameters
paveStatistic box, legend or other TPave
alignBinary combination of EPaveAlignBits
TPave *pave = CanvasHelper::getDefaultPaveStats(myCanvas);
CanvasHelper::setPaveAlignment(pave, kPaveAlignLeft | kPaveAlignTop);
static void setPaveAlignment(TPave *pave, UInt_t align)
Used to specify TPave's alignment on the ROOT canvas. Emum variables can be combined:
Definition: CanvasHelper.cpp:789

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