MINT2
Public Member Functions | Protected Member Functions | List of all members
RootPlotter2D Class Reference

#include <RootPlotter2D.h>

Inheritance diagram for RootPlotter2D:
RootPlotter Plotter

Public Member Functions

virtual double getGlobalMax ()
 
virtual double getGlobalMin ()
 
 RootPlotter2D (TH1 *histogram, double width=350, double height=300)
 
void addVerticalLine (double xpos, int style=1)
 
void addHorizontalLine (double ypos, int style=1)
 
void addVerticalBox (double xmin, double xmax, int fillColour, int fillstyle)
 
virtual ~RootPlotter2D ()
 
- Public Member Functions inherited from RootPlotter
void setXaxisName (TString name)
 
void setYaxisName (TString name)
 
 RootPlotter (TH1 *histogram, double width=300, double height=200)
 
TString & drawOptions (int i)
 
TString & objDrawOptions (int i)
 
void plotStacked (TPad *pad, double scaleFactor)
 
void plotSame (TPad *pad, TString plotOptions, double scaleFactor=1.0)
 
virtual void plot (TString plotDirectory, TString plotOptions="", TPad *pad=0, double scaleFactor=1.0)
 
void addText (TString text, double x, double y, int alignh=1, int alignv=2, double size=0.06, int ndc=true, int color=kBlack)
 
void drawLegend ()
 
virtual ~RootPlotter ()
 
- Public Member Functions inherited from Plotter
int getColor (int i)
 
void setColor (int i, int color)
 
void usePresetColours (bool val=true)
 
void allImageFormats (bool val=true)
 
void setHistogramOwnership (bool i=1)
 
void setObjectOwnership (bool i=1)
 
 Plotter (TString canvasName, double width, double height)
 
 Plotter (const Plotter &other)
 
void add (TObject *histogram)
 
void addDot (double xpos, double ypos, double size, int colour=1, TString shape="circle", double sizeY=0.0)
 
void logX (bool log=1)
 
void logY (bool log=1)
 
void logZ (bool log=1)
 
void addObject (TObject *obj)
 
int getNumObjects ()
 
void setImageFormat (TString format)
 
TPad * getCanvas ()
 
void scaleTextSize (double scale)
 
void scaleAxisTitleSize (double scale)
 
void scaleAxisTitleOffset (double scale)
 
void setXAxisLabelSize (double val)
 
void setYAxisLabelSize (double val)
 
void setXAxisTitleSize (double val)
 
void setYAxisTitleSize (double val)
 
void setXAxisLabelOffset (double val)
 
void setYAxisLabelOffset (double val)
 
void setXAxisTitleOffset (double val)
 
void setYAxisTitleOffset (double val)
 
void setXAxisTickLength (double val)
 
void setYAxisTickLength (double val)
 
void setPropertiesFromTH1 (TH1 *hist)
 
void setMin (double min)
 
void setMax (double max)
 
void setBMargin (double val)
 
void setLMargin (double val)
 
void setRMargin (double val)
 
void setTMargin (double val)
 
virtual ~Plotter ()
 

Protected Member Functions

virtual void setHistogramStyle (TH1 *histogram, bool setMinMax)
 
- Protected Member Functions inherited from RootPlotter
TH1 * getHistogram (int i)
 
- Protected Member Functions inherited from Plotter
virtual void setCanvasDefaults (TPad *pad)
 

Additional Inherited Members

- Static Public Attributes inherited from Plotter
static TString s_imageformat = ".eps"
 
static TString s_imageformat2 = ""
 
static TString s_legend_position = "RightTop"
 
static int s_plotterCount = 0
 
static double s_forcedMax = -999.999
 
static double s_forcedMin = -999.999
 
- Protected Attributes inherited from RootPlotter
TString _xAxisName
 
TString _yAxisName
 
std::vector< TString > _drawOptions
 
std::vector< TString > _objDrawOptions
 
- Protected Attributes inherited from Plotter
TPad * _canvas
 
TLegend * _legend
 
double _forcedMax
 
double _forcedMin
 
std::vector< TObject * > _objToPlot
 
std::vector< TObject * > _histograms
 
std::vector< int > _colours
 
double _lMargin
 
double _rMargin
 
double _tMargin
 
double _bMargin
 
double _xAxisTitleOffset
 
double _yAxisTitleOffset
 
double _xAxisLabelOffset
 
double _yAxisLabelOffset
 
double _xAxisTickLength
 
double _yAxisTickLength
 
double _xAxisLabelSize
 
double _yAxisLabelSize
 
double _xAxisTitleSize
 
double _yAxisTitleSize
 
bool _histogramOwnership
 
bool _objectOwnership
 
bool _usePresetColours
 
bool _allImageFormats
 

Detailed Description

HyperPlot, Author: Sam Harnew, sam.h.nosp@m.arne.nosp@m.w@gma.nosp@m.il.c.nosp@m.om , Date: Dec 2015

Class to make plotting 2D root histograms a little easier.

Definition at line 20 of file RootPlotter2D.h.

Constructor & Destructor Documentation

◆ RootPlotter2D()

RootPlotter2D::RootPlotter2D ( TH1 *  histogram,
double  width = 350,
double  height = 300 
)

Construct a RootPlotter with one histogram on a canvas with specified width and height

Definition at line 5 of file RootPlotter2D.cpp.

5  :
6  RootPlotter(histogram, width, height)
7 {
8  WELCOME_LOG << "Hello from the Plotter() constructor!";
9  //_yAxisLabelOffset = 0.0;
10  _yAxisTitleOffset = 1.3;
11  //_xAxisLabelOffset = 0.9;
12  _lMargin = 0.20;
13  _rMargin = 0.18;
14  _tMargin = 0.10;
15  _bMargin = 0.14;
16 }
double _tMargin
Definition: Plotter.h:43
double _rMargin
Definition: Plotter.h:42
RootPlotter(TH1 *histogram, double width=300, double height=200)
Definition: RootPlotter.cpp:4
double _bMargin
Definition: Plotter.h:44
double _lMargin
Definition: Plotter.h:41
double _yAxisTitleOffset
Definition: Plotter.h:47
#define WELCOME_LOG

◆ ~RootPlotter2D()

RootPlotter2D::~RootPlotter2D ( )
virtual

destructor

Definition at line 120 of file RootPlotter2D.cpp.

120  {
121 
122 }

Member Function Documentation

◆ addHorizontalLine()

void RootPlotter2D::addHorizontalLine ( double  ypos,
int  style = 1 
)

Add a line that spans the canvas in the Horizontal direction, and is at ymin in the horizontal direction

Definition at line 110 of file RootPlotter2D.cpp.

110  {
111  double xlow = getHistogram(0)->GetXaxis()->GetBinLowEdge(1);
112  double xhigh = getHistogram(0)->GetXaxis()->GetBinUpEdge (getHistogram(0)->GetXaxis()->GetNbins());
113  TLine* line = new TLine(xlow ,ypos ,xhigh, ypos );
114  line->SetLineColor(1);
115  line->SetLineStyle(style);
116  _objToPlot.push_back(line);
117 }
std::vector< TObject * > _objToPlot
Definition: Plotter.h:37
TH1 * getHistogram(int i)
Definition: RootPlotter.cpp:16

◆ addVerticalBox()

void RootPlotter2D::addVerticalBox ( double  xmin,
double  xmax,
int  fillColour,
int  fillstyle 
)

Add a box that spans the canvas in the vertical direction, and goes from xmin to xmax in the horizontal direction

Definition at line 50 of file RootPlotter2D.cpp.

50  {
51  double ymin = getHistogram(0)->GetYaxis()->GetBinLowEdge(0);
52  double ymax = getHistogram(0)->GetYaxis()->GetBinUpEdge( getHistogram(0)->GetYaxis()->GetNbins() );
53 
54  TBox* box = new TBox(xmin ,ymin ,xmax, ymax );
55  box->SetLineColor(0);
56  box->SetFillColor(fillColour);
57  box->SetFillStyle(fillstyle);
58  _objToPlot.push_back(box);
59 }
std::vector< TObject * > _objToPlot
Definition: Plotter.h:37
TH1 * getHistogram(int i)
Definition: RootPlotter.cpp:16

◆ addVerticalLine()

void RootPlotter2D::addVerticalLine ( double  xpos,
int  style = 1 
)

Add a line that spans the canvas in the vertical direction, and is at xmin in the horizontal direction

Definition at line 98 of file RootPlotter2D.cpp.

98  {
99  double ymin = getHistogram(0)->GetYaxis()->GetBinLowEdge(1);
100  double ymax = getHistogram(0)->GetYaxis()->GetBinUpEdge (getHistogram(0)->GetXaxis()->GetNbins());
101  INFO_LOG << "Adding TLine from (" << xpos << ", " << ymin << ") to (" << xpos << ", " << ymax << ")";
102  TLine* line = new TLine(xpos ,ymin ,xpos, ymax );
103  line->SetLineColor(1);
104  line->SetLineStyle(style);
105  _objToPlot.push_back(line);
106 }
#define INFO_LOG
std::vector< TObject * > _objToPlot
Definition: Plotter.h:37
TH1 * getHistogram(int i)
Definition: RootPlotter.cpp:16

◆ getGlobalMax()

double RootPlotter2D::getGlobalMax ( )
virtual

find the maximum value accross all histogrmas

Reimplemented from RootPlotter.

Definition at line 80 of file RootPlotter2D.cpp.

80  {
81 
82  if (_forcedMax != -999.999) return _forcedMax;
83  double globalMax = getHistogram(0)->GetBinContent(getHistogram(0)->GetMaximumBin());
84  for (unsigned int h=1; h<_histograms.size(); h++)
85  {
86  double max = getHistogram(h)->GetBinContent(getHistogram(h)->GetMaximumBin());
87  if (max > globalMax) globalMax = max;
88  }
89 
90  globalMax = globalMax*1.05;
91 
92  return globalMax;
93 
94 }
std::vector< TObject * > _histograms
Definition: Plotter.h:38
double _forcedMax
Definition: Plotter.h:35
TH1 * getHistogram(int i)
Definition: RootPlotter.cpp:16

◆ getGlobalMin()

double RootPlotter2D::getGlobalMin ( )
virtual

find the minimum value accross all histogrmas

Reimplemented from RootPlotter.

Definition at line 62 of file RootPlotter2D.cpp.

62  {
63 
64  if (_forcedMin != -999.999) return _forcedMin;
65  double globalMin = getHistogram(0)->GetBinContent(getHistogram(0)->GetMinimumBin());
66 
67  for (unsigned int h=1; h<_histograms.size(); h++)
68  {
69  double min = getHistogram(h)->GetBinContent(getHistogram(h)->GetMinimumBin());
70  if (min < globalMin) globalMin = min;
71  }
72 
73  if (globalMin > 0) globalMin = globalMin*0.95;
74  else globalMin = globalMin*1.05;
75 
76  return globalMin;
77 }
std::vector< TObject * > _histograms
Definition: Plotter.h:38
double _forcedMin
Definition: Plotter.h:36
TH1 * getHistogram(int i)
Definition: RootPlotter.cpp:16

◆ setHistogramStyle()

void RootPlotter2D::setHistogramStyle ( TH1 *  histogram,
bool  setMinMax 
)
protectedvirtual

Set the style of a TH2D

Implements RootPlotter.

Definition at line 19 of file RootPlotter2D.cpp.

19  {
20 
21  histogram->SetTitle("");
22 
23  histogram->GetXaxis()->SetTitleSize(_xAxisTitleSize);
24  histogram->GetYaxis()->SetTitleSize(_yAxisTitleSize);
25 
26  histogram->GetXaxis()->SetLabelSize(_xAxisLabelSize);
27  histogram->GetYaxis()->SetLabelSize(_yAxisLabelSize);
28 
29  histogram->GetXaxis()->SetTickLength(_xAxisTickLength);
30  histogram->GetYaxis()->SetTickLength(_yAxisTickLength);
31 
32  histogram->GetXaxis()->SetLabelOffset(_xAxisLabelOffset);
33  histogram->GetYaxis()->SetLabelOffset(_yAxisLabelOffset);
34 
35  histogram->GetXaxis()->SetTitleOffset(_xAxisTitleOffset);
36  histogram->GetYaxis()->SetTitleOffset(_yAxisTitleOffset);
37 
38  histogram->GetXaxis()->SetTitle(_xAxisName);
39  histogram->GetYaxis()->SetTitle(_yAxisName);
40 
41 
42  if (setMinMax) histogram->SetMaximum(getGlobalMax());
43  if (setMinMax) histogram->SetMinimum(getGlobalMin());
44  if (setMinMax) histogram->GetZaxis()->SetRangeUser(getGlobalMin(), getGlobalMax());
45 
46 }
double _yAxisTickLength
Definition: Plotter.h:53
double _yAxisLabelOffset
Definition: Plotter.h:50
double _xAxisLabelOffset
Definition: Plotter.h:49
double _yAxisTitleSize
Definition: Plotter.h:59
virtual double getGlobalMin()
double _xAxisLabelSize
Definition: Plotter.h:55
double _xAxisTitleSize
Definition: Plotter.h:58
double _xAxisTitleOffset
Definition: Plotter.h:46
double _xAxisTickLength
Definition: Plotter.h:52
TString _yAxisName
Definition: RootPlotter.h:28
TString _xAxisName
Definition: RootPlotter.h:27
double _yAxisTitleOffset
Definition: Plotter.h:47
virtual double getGlobalMax()
double _yAxisLabelSize
Definition: Plotter.h:56

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