cepgen is hosted by Hepforge, IPPP Durham
CepGen N/A
Central exclusive processes event generator

A "prettified" generic figure canvas. More...

#include <include/CepGenRoot/ROOTCanvas.h>

+ Inheritance diagram for ROOTCanvas:
+ Collaboration diagram for ROOTCanvas:

Public Member Functions

 ROOTCanvas (const std::string &name, const std::string &title="", bool ratio=false)
 Build a canvas from its name, title, and attributes.
 
void SetSize (double size=600)
 Set horizontal canvas width.
 
void Prettify (TH1 *obj) const
 Draw main plot attributes in a pretty manner.
 
void Prettify (const THStack *stack)
 
void Prettify (TMultiGraph *mg)
 
std::vector< TH1 * > RatioPlot (TH1 *denominator, const std::vector< TH1 * > &numerators, double x_min=-999., double x_max=-999., double y_min=-999., double y_max=-999., Option_t *draw_style="hist")
 
std::vector< TGraphErrors * > RatioPlot (const TGraphErrors *denominator, const std::vector< TGraphErrors * > &numerators, double x_min=-999., double x_max=-999., double y_min=-999., double y_max=-999.)
 
void SetTopLabel (const std::string &lab)
 Specify the text to show on top of the canvas.
 
void SetGrid (int x=1, int y=1) override
 
void SetLogx (int log=1) override
 
void SetLogy (int log=1) override
 
void SetLogz (int log=1) override
 
void SetLegendMode (const std::string &mode)
 Set the placement strategy for the legend.
 
void SetLegendX1 (double x)
 Set the horizontal coordinate of the low-left part of the legend object.
 
void SetLegendY1 (double y)
 Set the vertical coordinate of the low-left part of the legend object.
 
void AddLegendEntry (const TObject *obj, const std::string &title, Option_t *option="lpf")
 Add one new entry to the legend object.
 
void Save (const std::string &ext, const std::string &out_dir=".")
 Save the canvas in an external file.
 
TLegend * GetLegend () const
 Retrieve the legend object (if produced)
 
void Place (TLegend *leg, const Option_t *mode="lt")
 
template<typename T , typename... Args>
T * Make (Args &&... args)
 Garbage collector-like TObjects producer.
 

Static Public Attributes

static const std::vector< int > colours
 

Detailed Description

Definition at line 89 of file ROOTCanvas.h.

Constructor & Destructor Documentation

◆ ROOTCanvas()

ROOTCanvas ( const std::string & name,
const std::string & title = "",
bool ratio = false )
explicit
Parameters
[in]nameCanvas name (and subsequently filename on save)
[in]titleUpper title to display on the canvas
[in]ratioDivide the canvas into a main and ratio plots sub-parts?

Definition at line 97 of file ROOTCanvas.h.

Member Function Documentation

◆ AddLegendEntry()

void AddLegendEntry ( const TObject * obj,
const std::string & title,
Option_t * option = "lpf" )

Definition at line 417 of file ROOTCanvas.h.

◆ GetLegend()

TLegend * GetLegend ( ) const

Definition at line 460 of file ROOTCanvas.h.

◆ Make()

template<typename T , typename... Args>
T * Make ( Args &&... args)

Definition at line 484 of file ROOTCanvas.h.

◆ Place()

void Place ( TLegend * leg,
const Option_t * mode = "lt" )

Definition at line 461 of file ROOTCanvas.h.

◆ Prettify() [1/3]

void Prettify ( const THStack * stack)

Definition at line 192 of file ROOTCanvas.h.

◆ Prettify() [2/3]

void Prettify ( TH1 * obj) const

Definition at line 110 of file ROOTCanvas.h.

◆ Prettify() [3/3]

void Prettify ( TMultiGraph * mg)

Definition at line 208 of file ROOTCanvas.h.

◆ RatioPlot() [1/2]

std::vector< TGraphErrors * > RatioPlot ( const TGraphErrors * denominator,
const std::vector< TGraphErrors * > & numerators,
double x_min = -999.,
double x_max = -999.,
double y_min = -999.,
double y_max = -999. )

Definition at line 296 of file ROOTCanvas.h.

◆ RatioPlot() [2/2]

std::vector< TH1 * > RatioPlot ( TH1 * denominator,
const std::vector< TH1 * > & numerators,
double x_min = -999.,
double x_max = -999.,
double y_min = -999.,
double y_max = -999.,
Option_t * draw_style = "hist" )

Definition at line 245 of file ROOTCanvas.h.

◆ Save()

void Save ( const std::string & ext,
const std::string & out_dir = "." )

Definition at line 431 of file ROOTCanvas.h.

◆ SetGrid()

void SetGrid ( int x = 1,
int y = 1 )
override

Definition at line 374 of file ROOTCanvas.h.

◆ SetLegendMode()

void SetLegendMode ( const std::string & mode)

Definition at line 401 of file ROOTCanvas.h.

◆ SetLegendX1()

void SetLegendX1 ( double x)
Note
To be called before the first legend entry is added

Definition at line 404 of file ROOTCanvas.h.

◆ SetLegendY1()

void SetLegendY1 ( double y)
Note
To be called before the first legend entry is added

Definition at line 411 of file ROOTCanvas.h.

◆ SetLogx()

void SetLogx ( int log = 1)
override

Definition at line 380 of file ROOTCanvas.h.

◆ SetLogy()

void SetLogy ( int log = 1)
override

Definition at line 387 of file ROOTCanvas.h.

◆ SetLogz()

void SetLogz ( int log = 1)
override

Definition at line 393 of file ROOTCanvas.h.

◆ SetSize()

void SetSize ( double size = 600)

Definition at line 107 of file ROOTCanvas.h.

◆ SetTopLabel()

void SetTopLabel ( const std::string & lab)

Definition at line 362 of file ROOTCanvas.h.

Member Data Documentation

◆ colours

const std::vector< int > colours
static
Initial value:
= {
kBlack, kRed + 1, kBlue - 2, kGreen + 1, kOrange + 1, kAzure + 1, kMagenta + 1, kCyan + 3, kPink + 5}

Definition at line 91 of file ROOTCanvas.h.