MINT2
Plotter.h
Go to the documentation of this file.
1 
12 #ifndef PLOTTER_HH
13 #define PLOTTER_HH
14 
15 #include "TH1.h"
16 #include "TObject.h"
17 #include "TLegend.h"
18 #include "TBox.h"
19 #include "TArc.h"
20 #include "TCanvas.h"
21 #include "TStyle.h"
22 #include "TEllipse.h"
23 #include "Mint/MessageService.h"
24 
25 
26 class Plotter {
27 
28  protected:
29 
30 
31  //This class has ownership of the _objToPlot, but not the _histograms
32 
33  TPad* _canvas;
34  TLegend* _legend;
35  double _forcedMax;
36  double _forcedMin;
37  std::vector<TObject*> _objToPlot;
38  std::vector<TObject*> _histograms;
39  std::vector<int> _colours;
41  double _lMargin;
42  double _rMargin;
43  double _tMargin;
44  double _bMargin;
55  double _xAxisLabelSize;
56  double _yAxisLabelSize;
58  double _xAxisTitleSize;
59  double _yAxisTitleSize;
67  virtual void setCanvasDefaults(TPad* pad);
68 
69  public:
70 
71  static TString s_imageformat;
72  static TString s_imageformat2;
73  static TString s_legend_position;
74  static int s_plotterCount;
75  static double s_forcedMax;
76  static double s_forcedMin;
78  int getColor(int i);
80  void setColor(int i, int color);
82  void usePresetColours(bool val= true){_usePresetColours = val;}
83  void allImageFormats (bool val= true){_allImageFormats = val;}
88  void setObjectOwnership(bool i=1){_objectOwnership = i;}
91  Plotter(TString canvasName, double width, double height);
92 
93  Plotter(const Plotter& other);
94 
96  virtual void plot(TString plotDirectory, TString plotOptions = "", TPad* pad = 0, double scaleFactor = 1.0) = 0;
97  void add(TObject* histogram);
98  void addDot(double xpos, double ypos, double size, int colour = 1, TString shape = "circle", double sizeY = 0.0);
99  void logX(bool log = 1);
100  void logY(bool log = 1);
101  void logZ(bool log = 1);
102 
103  //note that any object passed here will have ownership taken by the class
104  void addObject(TObject* obj);
105 
106  int getNumObjects();
107 
108  void setImageFormat(TString format);
109 
110 
111  TPad* getCanvas() { return _canvas; }
114  void scaleTextSize(double scale){
115  _xAxisLabelSize *= scale;
116  _yAxisLabelSize *= scale;
117  _xAxisTitleSize *= scale;
118  _yAxisTitleSize *= scale;
119  }
122  void scaleAxisTitleSize(double scale){
123  _xAxisTitleSize *= scale;
124  _yAxisTitleSize *= scale;
125  }
128  void scaleAxisTitleOffset(double scale){
129  _xAxisTitleOffset *= scale;
130  _yAxisTitleOffset *= scale;
131  }
134  void setXAxisLabelSize(double val ){_xAxisLabelSize = val;}
135  void setYAxisLabelSize(double val ){_yAxisLabelSize = val;}
136  void setXAxisTitleSize(double val ){_xAxisTitleOffset = val;}
137  void setYAxisTitleSize(double val ){_yAxisTitleOffset = val;}
138  void setXAxisLabelOffset(double val ){_xAxisLabelOffset = val;}
139  void setYAxisLabelOffset(double val ){_yAxisLabelOffset = val;}
140  void setXAxisTitleOffset(double val ){_xAxisTitleOffset = val;}
141  void setYAxisTitleOffset(double val ){_yAxisTitleOffset = val;}
142  void setXAxisTickLength(double val ){_xAxisTickLength = val;}
143  void setYAxisTickLength(double val ){_yAxisTickLength = val;}
145  void setPropertiesFromTH1(TH1* hist);
153  void setMin(double min) { _forcedMin = min; }
155  void setMax(double max) { _forcedMax = max; }
158  void setBMargin(double val){_bMargin = val;}
159  void setLMargin(double val){_lMargin = val;}
160  void setRMargin(double val){_rMargin = val;}
161  void setTMargin(double val){_tMargin = val;}
163  virtual ~Plotter();
164 
165 };
166 
167 #endif
double _yAxisTickLength
Definition: Plotter.h:53
static TString s_imageformat
Definition: Plotter.h:71
void usePresetColours(bool val=true)
Definition: Plotter.h:82
double _tMargin
Definition: Plotter.h:43
static int s_plotterCount
Definition: Plotter.h:74
double _rMargin
Definition: Plotter.h:42
void addObject(TObject *obj)
Definition: Plotter.cpp:168
void setYAxisTitleOffset(double val)
Definition: Plotter.h:141
virtual void setCanvasDefaults(TPad *pad)
Definition: Plotter.cpp:84
void setTMargin(double val)
Definition: Plotter.h:161
static double s_forcedMin
Definition: Plotter.h:76
void setYAxisTitleSize(double val)
Definition: Plotter.h:137
std::vector< TObject * > _histograms
Definition: Plotter.h:38
double _forcedMax
Definition: Plotter.h:35
double _yAxisLabelOffset
Definition: Plotter.h:50
double _xAxisLabelOffset
Definition: Plotter.h:49
std::vector< TObject * > _objToPlot
Definition: Plotter.h:37
void setXAxisTickLength(double val)
Definition: Plotter.h:142
void setYAxisTickLength(double val)
Definition: Plotter.h:143
void setPropertiesFromTH1(TH1 *hist)
Definition: Plotter.cpp:172
double _yAxisTitleSize
Definition: Plotter.h:59
int getNumObjects()
Definition: Plotter.cpp:103
TPad * _canvas
Definition: Plotter.h:33
TPad * getCanvas()
Definition: Plotter.h:111
void setBMargin(double val)
Definition: Plotter.h:158
virtual void plot(TString plotDirectory, TString plotOptions="", TPad *pad=0, double scaleFactor=1.0)=0
Draw the histograms and objects onto the canvas.
double _xAxisLabelSize
Definition: Plotter.h:55
double _xAxisTitleSize
Definition: Plotter.h:58
static TString s_imageformat2
Definition: Plotter.h:72
void setXAxisTitleSize(double val)
Definition: Plotter.h:136
double _forcedMin
Definition: Plotter.h:36
void scaleAxisTitleOffset(double scale)
Definition: Plotter.h:128
void scaleAxisTitleSize(double scale)
Definition: Plotter.h:122
void setMin(double min)
Definition: Plotter.h:153
virtual ~Plotter()
Definition: Plotter.cpp:190
double _xAxisTitleOffset
Definition: Plotter.h:46
std::vector< int > _colours
Definition: Plotter.h:39
TLegend * _legend
Definition: Plotter.h:34
void addDot(double xpos, double ypos, double size, int colour=1, TString shape="circle", double sizeY=0.0)
Definition: Plotter.cpp:134
void setColor(int i, int color)
Definition: Plotter.cpp:93
void setMax(double max)
Definition: Plotter.h:155
double _xAxisTickLength
Definition: Plotter.h:52
void setXAxisLabelOffset(double val)
Definition: Plotter.h:138
double _bMargin
Definition: Plotter.h:44
bool _usePresetColours
Definition: Plotter.h:64
void logZ(bool log=1)
Definition: Plotter.cpp:162
void setLMargin(double val)
Definition: Plotter.h:159
void setYAxisLabelOffset(double val)
Definition: Plotter.h:139
void setHistogramOwnership(bool i=1)
Definition: Plotter.h:86
double _lMargin
Definition: Plotter.h:41
double _yAxisTitleOffset
Definition: Plotter.h:47
bool _allImageFormats
Definition: Plotter.h:65
bool _objectOwnership
Definition: Plotter.h:62
void logY(bool log=1)
Definition: Plotter.cpp:157
void allImageFormats(bool val=true)
Definition: Plotter.h:83
void logX(bool log=1)
Definition: Plotter.cpp:152
void add(TObject *histogram)
Definition: Plotter.cpp:122
void setYAxisLabelSize(double val)
Definition: Plotter.h:135
void setObjectOwnership(bool i=1)
Definition: Plotter.h:88
void setXAxisTitleOffset(double val)
Definition: Plotter.h:140
static double s_forcedMax
Definition: Plotter.h:75
Plotter(TString canvasName, double width, double height)
Definition: Plotter.cpp:20
void setRMargin(double val)
Definition: Plotter.h:160
void setImageFormat(TString format)
Definition: Plotter.cpp:13
double _yAxisLabelSize
Definition: Plotter.h:56
static TString s_legend_position
Definition: Plotter.h:73
int getColor(int i)
Definition: Plotter.cpp:109
void setXAxisLabelSize(double val)
Definition: Plotter.h:134
bool _histogramOwnership
Definition: Plotter.h:61
void scaleTextSize(double scale)
Definition: Plotter.h:114