-
Notifications
You must be signed in to change notification settings - Fork 0
/
ThrowPlotter.cxx
383 lines (317 loc) · 6.82 KB
/
ThrowPlotter.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
///
/// \file ThrowPlotter.cxx
/// \brief Implementation of the Plotter class
///
// std
#include <string>
#include <vector>
// Root
#include <TH1.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TLegend.h>
#include <TPaveText.h>
#include <TGraphAsymmErrors.h>
#include <TF1.h>
// Throw
#include "Throw.h"
/**
* \brief Main constructor of Plotter class.
*
* \param filePath path of the output file.
*/
Throw::Plotter::Plotter(const std::string& filePath) {
xMin = 1.;
xMax = -1.;
yMin = 1.;
yMax = -1.;
logX = 0;
logY = 0;
drawLegend = true;
legendX1 = .60;
legendX2 = .98;
legendY1 = .64;
legendY2 = .92;
legendPlacement = "";
drawAtlasLabel = false;
atlasLabelX1 = .25;
atlasLabelX2 = .55;
atlasLabelY1 = .15;
atlasLabelY2 = .25;
legendPlacement = "";
colorVec.emplace_back(kBlack);
colorVec.emplace_back(kBlue);
colorVec.emplace_back(kRed);
colorVec.emplace_back(kViolet);
colorVec.emplace_back(kOrange + 1);
colorVec.emplace_back(kGreen + 2);
markerVec.emplace_back(20);
markerVec.emplace_back(21);
markerVec.emplace_back(22);
markerVec.emplace_back(23);
markerVec.emplace_back(24);
xOffset = 1.3;
yOffset = 1.3;
tickLength = 0.03;
outFilePath = filePath;
}
/**
* \brief Default destructor of Plotter class.
*/
Throw::Plotter::~Plotter() {
colorVec.clear();
markerVec.clear();
}
/**
* \brief Pick color for the object.
*/
int Throw::Plotter::pickColor(int index) {
index = index % colorVec.size();
return colorVec.at(index);
}
/**
* \brief Pick marker style for the object.
*/
int Throw::Plotter::pickMarker(int index) {
index = index % markerVec.size();
return markerVec.at(index);
}
/**
* \brief Get y-axis minimum.
*/
double Throw::Plotter::getYmin() {
return yMin;
}
/**
* \brief Get y-axis maximum.
*/
double Throw::Plotter::getYmax() {
return yMax;
}
/**
* \brief Set y-axis minimum.
*/
void Throw::Plotter::setYmin(double val) {
yMin = val;
}
/**
* \brief Set y-axis maximum.
*/
void Throw::Plotter::setYmax(double val) {
yMax = val;
}
/**
* \brief Get x-axis minimum.
*/
double Throw::Plotter::getXmin() {
return xMin;
}
/**
* \brief Get x-axis maximum.
*/
double Throw::Plotter::getXmax() {
return xMax;
}
/**
* \brief Set x-axis minimum.
*/
void Throw::Plotter::setXmin(double val) {
xMin = val;
}
/**
* \brief Set x-axis maximum.
*/
void Throw::Plotter::setXmax(double val) {
xMax = val;
}
/**
* \brief Returns whether x-axis will be in logarithmic scale.
*/
bool Throw::Plotter::getLogX() {
return logX;
}
/**
* \brief Returns whether y-axis will be in logarithmic scale.
*/
bool Throw::Plotter::getLogY() {
return logY;
}
/**
* \brief Sets whether x-axis will be in logarithmic scale.
*/
void Throw::Plotter::setLogX(bool val) {
if (val) {
logX = 1;
} else {
logX = 0;
}
}
/**
* \brief Sets whether y-axis will be in logarithmic scale.
*/
void Throw::Plotter::setLogY(bool val) {
if (val) {
logY = 1;
} else {
logY = 0;
}
}
double Throw::Plotter::getXoffset() {
return xOffset;
}
double Throw::Plotter::getYoffset() {
return yOffset;
}
/**
* \brief Get label on x-axis.
*/
std::string Throw::Plotter::getXlabel() {
return xLabel;
}
/**
* \brief Get label on y-axis.
*/
std::string Throw::Plotter::getYlabel() {
return yLabel;
}
/**
* \brief Set label on x-axis.
*/
void Throw::Plotter::setXlabel(const std::string& param) {
xLabel = param;
}
/**
* \brief Set label on y-axis.
*/
void Throw::Plotter::setYlabel(const std::string& param) {
yLabel = param;
}
/**
* \brief Add note to the list of notes.
*/
void Throw::Plotter::addNote(const std::string& note) {
noteVec.emplace_back(note);
}
/**
* \brief Add several notes to the list of notes at once.
*/
void Throw::Plotter::addNotes(const std::vector<std::string>& notes) {
for (size_t i = 0; i < notes.size(); ++i) {
noteVec.emplace_back(notes.at(i));
}
}
/**
* \brief Insert notes to the legend object.
*/
void Throw::Plotter::putNotesToLegend(TLegend* legend) {
for (int i = 0; i < noteVec.size(); ++i) {
legend->AddEntry((TObject*)0, noteVec.at(i).c_str(), "");
}
}
/**
* \brief Set whether legend will be drowned.
*/
void Throw::Plotter::setDrawLegend(bool val) {
drawLegend = val;
}
/**
* \brief Set x-axis offset.
*/
void Throw::Plotter::setXoffset(double val) {
xOffset = val;
}
/**
* \brief Set y-axis offset.
*/
void Throw::Plotter::setYoffset(double val) {
yOffset = val;
}
/**
* \brief Get drawing parameter of histogram at index.
*/
std::string Throw::Plotter::getHistDrawParam(int index) {
return histDrawParamsVec.at(index);
}
/**
* \brief Get drawing parameter of graph at index.
*/
std::string Throw::Plotter::getGraphDrawParam(int index) {
return graphDrawParamsVec.at(index);
}
/**
* \brief Get drawing parameter of function at index.
*/
std::string Throw::Plotter::getFuncDrawParam(int index) {
return funcDrawParamsVec.at(index);
}
/**
* \brief Set drawing parameter of histogram at index.
*/
void Throw::Plotter::setHistDrawParam(int index,
const std::string& param) {
histDrawParamsVec.at(index) = param;
}
/**
* \brief Set drawing parameter of graph at index.
*/
void Throw::Plotter::setGraphDrawParam(int index,
const std::string& param) {
graphDrawParamsVec.at(index) = param;
}
/**
* \brief Set drawing parameter of function at index.
*/
void Throw::Plotter::setFuncDrawParam(int index,
const std::string& param) {
funcDrawParamsVec.at(index) = param;
}
/**
* \brief Add histogram drawing parameter to the list of histogram drawing
* parameters.
*/
void Throw::Plotter::addHistDrawParam(const std::string& param) {
histDrawParamsVec.emplace_back(param);
}
/**
* \brief Add graph drawing parameter to the list of graph drawing parameters.
*/
void Throw::Plotter::addGraphDrawParam(const std::string& param) {
graphDrawParamsVec.emplace_back(param);
}
/**
* \brief Add function drawing parameter to the list of function drawing
* parameters.
*/
void Throw::Plotter::addFuncDrawParam(const std::string& param) {
funcDrawParamsVec.emplace_back(param);
}
/**
* \brief Add line to the vector of lines.
*/
void Throw::Plotter::addLine(TLine* line) {
if (!line) {
throw "ERROR: Throw::Plotter::addLine -- Null TLine* provided!";
}
lineVec.emplace_back(line);
}
/**
* \brief Add line to the vector of lines.
*/
void Throw::Plotter::addLabel(TPaveText* label) {
if (!label) {
throw "ERROR: Throw::Plotter::addLabel -- Null TPaveText* provided!";
}
labelVec.emplace_back(label);
}
/**
* Get plot output file path.
*/
std::string Throw::Plotter::getOutFilePath() {
return outFilePath;
}
/**
* Set plot output file path.
*/
void Throw::Plotter::setOutFilePath(const std::string& filePath) {
outFilePath = filePath;
}