forked from AliceO2Group/QualityControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReferenceComparatorPlot.cxx
More file actions
587 lines (519 loc) · 22.5 KB
/
ReferenceComparatorPlot.cxx
File metadata and controls
587 lines (519 loc) · 22.5 KB
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \file ReferenceComparatorPlot.xx
/// \author Andrea Ferrero
/// \brief Utility class for the combined drawing of the current and reference plots, and their ratio
///
#include "Common/ReferenceComparatorPlot.h"
#include "Common/TH1Ratio.h"
#include "Common/TH2Ratio.h"
#include "QualityControl/QcInfoLogger.h"
// ROOT
#include <TClass.h>
#include <TLine.h>
#include <TH1.h>
#include <TH2.h>
#include <TCanvas.h>
#include <TPaveText.h>
#include <TLegend.h>
namespace o2::quality_control_modules::common
{
static bool isBinningIdentical(TH1* h1, TH1* h2)
{
// check consistency of X-axis binning
if (h1->GetXaxis()->GetNbins() != h2->GetXaxis()->GetNbins()) {
return false;
}
if (h1->GetXaxis()->GetXmin() != h2->GetXaxis()->GetXmin()) {
return false;
}
if (h1->GetXaxis()->GetXmax() != h2->GetXaxis()->GetXmax()) {
return false;
}
// check consistency of Y-axis binning
if (h1->GetYaxis()->GetNbins() != h2->GetYaxis()->GetNbins()) {
return false;
}
if (h1->GetYaxis()->GetXmin() != h2->GetYaxis()->GetXmin()) {
return false;
}
if (h1->GetYaxis()->GetXmax() != h2->GetYaxis()->GetXmax()) {
return false;
}
// check consistency of Z-axis binning
if (h1->GetZaxis()->GetNbins() != h2->GetZaxis()->GetNbins()) {
return false;
}
if (h1->GetZaxis()->GetXmin() != h2->GetZaxis()->GetXmin()) {
return false;
}
if (h1->GetZaxis()->GetXmax() != h2->GetZaxis()->GetXmax()) {
return false;
}
return true;
}
//_________________________________________________________________________________________
static void copyAndScaleHistograms(TH1* histogram, TH1* referenceHistogram, TH1* outputHisto, TH1* outputRefHisto, bool scaleReference)
{
if (!histogram || !referenceHistogram || !outputHisto || !outputRefHisto) {
ILOG(Warning, Devel) << "histogram is nullptr" << ENDM;
return;
}
if (!isBinningIdentical(histogram, referenceHistogram)) {
ILOG(Warning, Devel) << "mismatch in axis dimensions for '" << histogram->GetName() << "'" << ENDM;
return;
}
outputHisto->Reset();
outputHisto->Add(histogram);
outputRefHisto->Reset();
outputRefHisto->Add(referenceHistogram);
if (scaleReference) {
// the reference histogram is scaled to match the integral of the current histogram
double integral = histogram->Integral();
double integralRef = referenceHistogram->Integral();
if (integral != 0 && integralRef != 0) {
outputRefHisto->Scale(integral / integralRef);
}
}
}
template <class HIST>
static std::shared_ptr<HIST> createHisto1D(const char* name, const char* title, TH1* source)
{
std::shared_ptr<HIST> result;
if (source->GetXaxis()->IsVariableBinSize()) {
result = std::make_shared<HIST>(name, title,
source->GetXaxis()->GetNbins(),
source->GetXaxis()->GetXbins()->GetArray());
} else {
result = std::make_shared<HIST>(name, title,
source->GetXaxis()->GetNbins(),
source->GetXaxis()->GetXmin(),
source->GetXaxis()->GetXmax());
}
return result;
}
template <class HIST>
static std::shared_ptr<HIST> createHisto2D(const char* name, const char* title, TH1* source)
{
std::shared_ptr<HIST> result;
if (source->GetXaxis()->IsVariableBinSize() && source->GetYaxis()->IsVariableBinSize()) {
result = std::make_shared<HIST>(name, title,
source->GetXaxis()->GetNbins(),
source->GetXaxis()->GetXbins()->GetArray(),
source->GetYaxis()->GetNbins(),
source->GetYaxis()->GetXbins()->GetArray());
} else if (source->GetXaxis()->IsVariableBinSize() && !source->GetYaxis()->IsVariableBinSize()) {
result = std::make_shared<HIST>(name, title,
source->GetXaxis()->GetNbins(),
source->GetXaxis()->GetXbins()->GetArray(),
source->GetYaxis()->GetNbins(),
source->GetYaxis()->GetXmin(),
source->GetYaxis()->GetXmax());
} else if (!source->GetXaxis()->IsVariableBinSize() && source->GetYaxis()->IsVariableBinSize()) {
result = std::make_shared<HIST>(name, title,
source->GetXaxis()->GetNbins(),
source->GetXaxis()->GetXmin(),
source->GetXaxis()->GetXmax(),
source->GetYaxis()->GetNbins(),
source->GetYaxis()->GetXbins()->GetArray());
} else {
result = std::make_shared<HIST>(name, title,
source->GetXaxis()->GetNbins(),
source->GetXaxis()->GetXmin(),
source->GetXaxis()->GetXmax(),
source->GetYaxis()->GetNbins(),
source->GetYaxis()->GetXmin(),
source->GetYaxis()->GetXmax());
}
return result;
}
//_________________________________________________________________________________________
class ReferenceComparatorPlotImpl
{
public:
ReferenceComparatorPlotImpl(TH1* referenceHistogram, bool scaleReference)
: mReferenceHistogram(referenceHistogram), mScaleReference(scaleReference)
{
}
virtual ~ReferenceComparatorPlotImpl() = default;
virtual TObject* getMainCanvas()
{
return nullptr;
}
TH1* getReferenceHistogram()
{
return mReferenceHistogram;
}
void setScaleRef(bool scaleReference)
{
mScaleReference = scaleReference;
}
bool getScaleReference() { return mScaleReference; }
virtual void update(TH1* histogram) = 0;
private:
TH1* mReferenceHistogram{ nullptr };
bool mScaleReference{ true };
};
template <class HIST>
class ReferenceComparatorPlotImpl1D : public ReferenceComparatorPlotImpl
{
public:
ReferenceComparatorPlotImpl1D(TH1* referenceHistogram,
int referenceRun,
const std::string& outputPath,
bool scaleReference,
bool drawRatioOnly,
double legendHeight,
bool logScale,
const std::string& drawOption)
: ReferenceComparatorPlotImpl(referenceHistogram, scaleReference), mLegendHeight(legendHeight), mLogScale(logScale)
{
float labelSize = 0.04;
if (!referenceHistogram) {
return;
}
// full name of the main canvas
std::string canvasName = outputPath;
mCanvas = std::make_shared<TCanvas>(canvasName.c_str(), canvasName.c_str(), 800, 600);
// Pad where the histogram ratio is drawn. If drawRatioOnly is true the pad is placed on top
// without any transparency, and fully covers the other pad
mCanvas->cd();
if (drawRatioOnly) {
mPadHistRatio = std::make_shared<TPad>((canvasName + "_PadHistRatio").c_str(), "PadHistRatio", 0, 0, 1, 1);
} else {
mPadHistRatio = std::make_shared<TPad>((canvasName + "_PadHistRatio").c_str(), "PadHistRatio", 0, 1.0 / 3, 1, 1);
mPadHistRatio->SetTopMargin(0.15);
mPadHistRatio->SetBottomMargin(0.5);
mPadHistRatio->SetLeftMargin(0.1);
mPadHistRatio->SetRightMargin(0.1);
mPadHistRatio->SetGridy();
}
// Pad where the histograms are drawn. If drawRatioOnly is true the pad is placed hidden
// behind the second pad where the ratio histogram is drawn
mCanvas->cd();
if (drawRatioOnly) {
mPadHist = std::make_shared<TPad>((canvasName + "_PadHist").c_str(), "PadHist", 0.2, 0.2, 0.8, 0.8);
} else {
mPadHist = std::make_shared<TPad>((canvasName + "_PadHist").c_str(), "PadHist", 0, 0, 1, 2.0 / 3 - 0.01);
mPadHist->SetTopMargin(0);
mPadHist->SetBottomMargin(0.15);
mPadHist->SetLeftMargin(0.1);
mPadHist->SetRightMargin(0.1);
}
if (drawRatioOnly) {
// If drawRatioOnly is true the pad with the ratio plot is placed on top
mCanvas->cd();
mPadHist->Draw();
mCanvas->cd();
mPadHistRatio->Draw();
} else {
// otherwise the pad with the superimposed histograms goes on top
mCanvas->cd();
mPadHistRatio->Draw();
mCanvas->cd();
mPadHist->Draw();
}
// histogram from the current run
mPadHist->cd();
mPlot = createHisto1D<HIST>((canvasName + "_hist").c_str(), "", referenceHistogram);
mPlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
mPlot->GetXaxis()->SetLabelSize(labelSize);
mPlot->GetXaxis()->SetTitleSize(labelSize);
mPlot->GetXaxis()->SetTitleOffset(1.0);
mPlot->GetYaxis()->SetTitle(referenceHistogram->GetYaxis()->GetTitle());
mPlot->GetYaxis()->SetLabelSize(labelSize);
mPlot->GetYaxis()->SetTitleSize(labelSize);
mPlot->GetYaxis()->SetTitleOffset(1.0);
mPlot->SetLineColor(kBlack);
mPlot->SetStats(0);
mPlot->SetOption(drawOption.c_str());
mPlot->Draw(drawOption.c_str());
// histogram from the reference run
mReferencePlot = createHisto1D<HIST>((canvasName + "_hist_ref").c_str(), "", referenceHistogram);
mReferencePlot->SetLineColor(kBlue);
mReferencePlot->SetOption((drawOption + "SAME").c_str());
mReferencePlot->Draw((drawOption + "SAME").c_str());
if (!drawRatioOnly && mLegendHeight > 0) {
mHistogramLegend = std::make_shared<TLegend>(0.2, 0.91, 0.8, 0.98);
mHistogramLegend->SetNColumns(2);
mHistogramLegend->SetBorderSize(0);
mHistogramLegend->SetFillStyle(0);
mHistogramLegend->AddEntry(mPlot.get(), "current run", "l");
mHistogramLegend->AddEntry(mReferencePlot.get(), TString::Format("reference run %d", referenceRun), "l");
mHistogramLegend->Draw();
}
// histogram with current/reference ratio
mPadHistRatio->cd();
mRatioPlot = createHisto1D<HIST>((canvasName + "_hist_ratio").c_str(), "", referenceHistogram);
if (drawRatioOnly) {
mRatioPlot->SetTitle(TString::Format("%s (ref. %d)", referenceHistogram->GetTitle(), referenceRun));
mRatioPlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
mRatioPlot->GetYaxis()->SetTitle("current / reference");
} else {
// hide the X axis labels
mRatioPlot->GetXaxis()->SetLabelSize(0);
mRatioPlot->GetXaxis()->SetTitleSize(0);
mRatioPlot->GetYaxis()->SetTitle("ratio");
mRatioPlot->GetYaxis()->CenterTitle(kTRUE);
mRatioPlot->GetYaxis()->SetNdivisions(5);
mRatioPlot->GetYaxis()->SetLabelSize(labelSize);
mRatioPlot->GetYaxis()->SetTitleSize(labelSize);
mRatioPlot->GetYaxis()->SetTitleOffset(1.0);
}
mRatioPlot->SetLineColor(kBlack);
mRatioPlot->SetStats(0);
mRatioPlot->SetOption(drawOption.c_str());
mRatioPlot->Draw(drawOption.c_str());
if (drawRatioOnly) {
mRatioPlot->SetMinimum(0);
mRatioPlot->SetMaximum(2);
} else {
// set the minimum and maximum sligtly above 0 and below 2.0, such that the first and last bin labels are not shown
mRatioPlot->SetMinimum(0.001);
mRatioPlot->SetMaximum(1.999);
}
mCanvas->cd();
// We place an empty TPaveText in the good place, it will be used by the checker
// to draw the quality labels and flags
mQualityLabel = std::make_shared<TPaveText>(0.00, 0.9, 0.9, 0.98, "brNDC");
mQualityLabel->SetBorderSize(0);
mQualityLabel->SetFillStyle(0);
mQualityLabel->SetTextAlign(12);
mQualityLabel->SetTextFont(42);
mQualityLabel->Draw();
if (!drawRatioOnly) {
// draw the histogram title
mHistogramTitle = std::make_shared<TPaveText>(0.1, 0.94, 0.9, 1.0, "brNDC");
mHistogramTitle->SetBorderSize(0);
mHistogramTitle->SetFillStyle(0);
mHistogramTitle->SetTextAlign(22);
mHistogramTitle->SetTextFont(42);
mHistogramTitle->AddText(TString::Format("%s (ref. %d)", referenceHistogram->GetTitle(), referenceRun));
mHistogramTitle->Draw();
}
}
TObject* getMainCanvas()
{
return mCanvas.get();
}
void update(TH1* hist)
{
TH1* referenceHistogram = getReferenceHistogram();
if (!hist || !referenceHistogram) {
return;
}
copyAndScaleHistograms(hist, referenceHistogram, mPlot.get(), mReferencePlot.get(), getScaleReference());
double max = std::max(mPlot->GetMaximum(), mReferencePlot->GetMaximum());
double histMax = (mLegendHeight > 0) ? (1.0 + mLegendHeight) * max : 1.05 * max;
mPlot->SetMaximum(histMax);
mReferencePlot->SetMaximum(histMax);
if (mPadHist) {
mPadHist->SetLogy(mLogScale ? kTRUE : kFALSE);
}
mRatioPlot->Reset();
mRatioPlot->Add(mPlot.get());
mRatioPlot->Divide(mReferencePlot.get());
mRatioPlot->SetMinimum(0.001);
mRatioPlot->SetMaximum(1.999);
}
private:
std::shared_ptr<TCanvas> mCanvas;
std::shared_ptr<TPad> mPadHist;
std::shared_ptr<TPad> mPadHistRatio;
std::shared_ptr<HIST> mPlot;
std::shared_ptr<HIST> mReferencePlot;
std::shared_ptr<HIST> mRatioPlot;
std::shared_ptr<TLine> mBorderTop;
std::shared_ptr<TLine> mBorderMiddle;
std::shared_ptr<TLine> mBorderRight;
std::shared_ptr<TPaveText> mQualityLabel;
std::shared_ptr<TPaveText> mHistogramTitle;
std::shared_ptr<TLegend> mHistogramLegend;
double mLegendHeight;
bool mLogScale;
};
template <class HIST>
class ReferenceComparatorPlotImpl2D : public ReferenceComparatorPlotImpl
{
public:
ReferenceComparatorPlotImpl2D(TH1* referenceHistogram,
int referenceRun,
const std::string& outputPath,
bool scaleReference,
bool drawRatioOnly,
bool logScale,
const std::string& drawOption)
: ReferenceComparatorPlotImpl(referenceHistogram, scaleReference), mLogScale(logScale)
{
if (!referenceHistogram) {
return;
}
// full name of the main canvas
std::string canvasName = outputPath;
mCanvas = std::make_shared<TCanvas>(canvasName.c_str(), canvasName.c_str(), 800, 600);
// Size of the pad for the ratio histogram, relative to the canvas size
// Only used when drawRatioOnly is false, and both the ratio and the individual histograms are drawn
const float padSizeRatio = 2.0 / 3;
// Pad where the current histogram is drawn. If drawRatioOnly is true the pad is draw hidden
// behind the main pad where the ratio histogram is drawn
mCanvas->cd();
if (!drawRatioOnly) {
// the pad occupies a bottom-left portion of the canvas with a size equal to (1-padSizeRatio)
mPadHist = std::make_shared<TPad>((canvasName + "_PadHist").c_str(), "PadHist", 0, 0, 0.5, 1.0 - padSizeRatio);
} else {
// hide the pad below the one with the ratio plot
mPadHist = std::make_shared<TPad>((canvasName + "_PadHist").c_str(), "PadHist", 0.1, 2.0 / 3, 0.5, 0.9);
}
mPadHist->Draw();
// Pad where the reference histogram is drawn. If drawRatioOnly is true the pad is draw hidden
// behind the main pad where the ratio histogram is drawn
mCanvas->cd();
if (!drawRatioOnly) {
// the pad occupies a bottom-right portion of the canvas with a size equal to (1-padSizeRatio)
mPadHistRef = std::make_shared<TPad>((canvasName + "_PadHistRef").c_str(), "PadHistRef", 0.5, 0, 1, 1.0 - padSizeRatio);
} else {
// hide the pad below the one with thenratio plot
mPadHistRef = std::make_shared<TPad>((canvasName + "_PadHistRef").c_str(), "PadHistRef", 0.5, 2.0 / 3, 0.9, 0.9);
}
mPadHistRef->Draw();
// Pad where the histogram ratio is drawn. If drawRatioOnly is true the pad occupies the full canvas
mCanvas->cd();
if (!drawRatioOnly) {
// the pad occupies a top portion of the canvas with a size equal to padSizeRatio
mPadHistRatio = std::make_shared<TPad>((canvasName + "_PadHistRatio").c_str(), "PadHistRatio", 0, 1.0 - padSizeRatio, 1, 1);
// The top margin of the pad is increased in a way inversely proportional to the pad size.
// The resulting margin corresponds to 0.1 in the outer canvas coordinates, such that the histogram
// title is drawn with the usual text size
mPadHistRatio->SetTopMargin(0.1 / padSizeRatio);
} else {
// the pad occupies the full canvas
mPadHistRatio = std::make_shared<TPad>((canvasName + "_PadHistRatio").c_str(), "PadHistRatio", 0, 0, 1, 1);
}
mPadHistRatio->Draw();
// histogram from the current run
mPadHist->cd();
mPlot = createHisto2D<HIST>((canvasName + "_hist").c_str(),
referenceHistogram->GetTitle(),
referenceHistogram);
mPlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
mPlot->GetYaxis()->SetTitle(referenceHistogram->GetYaxis()->GetTitle());
mPlot->SetStats(0);
mPlot->SetOption(drawOption.c_str());
mPlot->Draw(drawOption.c_str());
// histogram from the reference run
mPadHistRef->cd();
mReferencePlot = createHisto2D<HIST>((canvasName + "_hist_ref").c_str(),
TString::Format("%s (ref. %d)", referenceHistogram->GetTitle(), referenceRun),
referenceHistogram);
mReferencePlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
mReferencePlot->GetYaxis()->SetTitle(referenceHistogram->GetYaxis()->GetTitle());
mReferencePlot->SetStats(0);
mReferencePlot->SetOption(drawOption.c_str());
mReferencePlot->Draw(drawOption.c_str());
// histogram with current/reference ratio
mPadHistRatio->cd();
mRatioPlot = createHisto2D<HIST>((canvasName + "_hist_ratio").c_str(),
TString::Format("%s (ratio wrt %d)", referenceHistogram->GetTitle(), referenceRun),
referenceHistogram);
mRatioPlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
mRatioPlot->GetYaxis()->SetTitle(referenceHistogram->GetYaxis()->GetTitle());
if (!drawRatioOnly) {
mRatioPlot->GetZaxis()->SetTitle("ratio");
} else {
mRatioPlot->GetZaxis()->SetTitle("current / reference");
}
mRatioPlot->SetStats(0);
mRatioPlot->SetOption("COLZ");
mRatioPlot->Draw("COLZ");
mRatioPlot->SetMinimum(0);
mRatioPlot->SetMaximum(2);
// We place an empty TPaveText in the good place, it will be used by the checker
// to draw the quality labels and flags
mCanvas->cd();
mQualityLabel = std::make_shared<TPaveText>(0.0, 0.9, 0.9, 0.98, "brNDC");
mQualityLabel->SetBorderSize(0);
mQualityLabel->SetFillStyle(0);
mQualityLabel->SetTextAlign(12);
mQualityLabel->SetTextFont(42);
mQualityLabel->Draw();
}
TObject* getMainCanvas()
{
return mCanvas.get();
}
void update(TH1* histogram)
{
TH1* referenceHistogram = getReferenceHistogram();
if (!histogram || !referenceHistogram) {
return;
}
copyAndScaleHistograms(histogram, referenceHistogram, mPlot.get(), mReferencePlot.get(), getScaleReference());
if (mPadHist) {
mPadHist->SetLogz(mLogScale ? kTRUE : kFALSE);
}
if (mPadHistRef) {
mPadHistRef->SetLogz(mLogScale ? kTRUE : kFALSE);
}
mRatioPlot->Reset();
mRatioPlot->Add(mPlot.get());
mRatioPlot->Divide(mReferencePlot.get());
mRatioPlot->SetMinimum(0);
mRatioPlot->SetMaximum(2);
}
private:
std::shared_ptr<TCanvas> mCanvas;
std::shared_ptr<TPad> mPadHist;
std::shared_ptr<TPad> mPadHistRef;
std::shared_ptr<TPad> mPadHistRatio;
std::shared_ptr<HIST> mPlot;
std::shared_ptr<HIST> mReferencePlot;
std::shared_ptr<HIST> mRatioPlot;
std::shared_ptr<TPaveText> mQualityLabel;
bool mLogScale;
};
ReferenceComparatorPlot::ReferenceComparatorPlot(TH1* referenceHistogram,
int referenceRun,
const std::string& outputPath,
bool scaleReference,
bool drawRatioOnly,
double legendHeight,
bool logScale,
const std::string& drawOption1D,
const std::string& drawOption2D)
{
// histograms with integer values are promoted to floating point or double to allow correctly scaling the reference and computing the ratios
// 1-D histograms
if (referenceHistogram->InheritsFrom("TH1C") || referenceHistogram->InheritsFrom("TH1S") || referenceHistogram->InheritsFrom("TH1F")) {
mImplementation = std::make_shared<ReferenceComparatorPlotImpl1D<TH1F>>(referenceHistogram, referenceRun, outputPath, scaleReference, drawRatioOnly, legendHeight, logScale, drawOption1D);
}
if (referenceHistogram->InheritsFrom("TH1I") || referenceHistogram->InheritsFrom("TH1D")) {
mImplementation = std::make_shared<ReferenceComparatorPlotImpl1D<TH1D>>(referenceHistogram, referenceRun, outputPath, scaleReference, drawRatioOnly, legendHeight, logScale, drawOption1D);
}
// 2-D histograms
if (referenceHistogram->InheritsFrom("TH2C") || referenceHistogram->InheritsFrom("TH2S") || referenceHistogram->InheritsFrom("TH2F")) {
mImplementation = std::make_shared<ReferenceComparatorPlotImpl2D<TH2F>>(referenceHistogram, referenceRun, outputPath, scaleReference, drawRatioOnly, logScale, drawOption2D);
}
if (referenceHistogram->InheritsFrom("TH2I") || referenceHistogram->InheritsFrom("TH2D")) {
mImplementation = std::make_shared<ReferenceComparatorPlotImpl2D<TH2D>>(referenceHistogram, referenceRun, outputPath, scaleReference, drawRatioOnly, logScale, drawOption2D);
}
}
TObject* ReferenceComparatorPlot::getMainCanvas()
{
return (mImplementation.get() ? mImplementation->getMainCanvas() : nullptr);
}
void ReferenceComparatorPlot::update(TH1* histogram)
{
if (mImplementation) {
mImplementation->update(histogram);
}
}
} // namespace o2::quality_control_modules::common