forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeEmbeddingValidationPlots.C
2032 lines (1819 loc) · 107 KB
/
makeEmbeddingValidationPlots.C
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
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <TFile.h>
#include <TString.h>
#include <TObjArray.h>
#include <TObjString.h>
#include <TH1.h>
#include <TH2.h>
#include <TGraphErrors.h>
#include <TGraphAsymmErrors.h>
#include <TF1.h>
#include <TPaveText.h>
#include <TCanvas.h>
#include <TLegend.h>
#include <TMath.h>
#include <TROOT.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <limits>
TH1* getHistogram(TFile* inputFile, const std::string& dqmDirectory, const std::string& meName)
{
if ( !inputFile ) return 0;
TString histogramName = "DQMData";
if ( dqmDirectory != "" ) histogramName.Append(Form("/%s", dqmDirectory.data()));
if ( histogramName.Length() > 0 && !histogramName.EndsWith("/") ) histogramName.Append("/");
histogramName.Append(meName);
TH1* histogram = (TH1*)inputFile->Get(histogramName.Data());
if ( !histogram ) {
std::cerr << "Failed to find histogram = " << histogramName.Data() << " in inputFile = " << inputFile->GetName() << " !!" << std::endl;
assert(0);
}
std::cout << "histogram = " << histogramName.Data() << ": integral = " << histogram->Integral() << std::endl;
if ( !histogram->GetSumw2N() ) histogram->Sumw2();
//if ( histogram->GetDimension() == 1 ) histogram->Rebin(5);
//histogram->Scale(1./histogram->Integral());
return histogram;
}
double square(double x)
{
return x*x;
}
TH1* rebinHistogram(const TH1* histogram, unsigned numBinsMin_rebinned, double xMin, double xMax, bool normalize)
{
TH1* histogram_rebinned = 0;
if ( histogram ) {
unsigned numBins = histogram->GetNbinsX();
unsigned numBins_withinRange = 0;
for ( unsigned iBin = 1; iBin <= numBins; ++iBin ) {
double binCenter = histogram->GetBinCenter(iBin);
if ( binCenter >= xMin && binCenter <= xMax ) ++numBins_withinRange;
}
std::cout << "histogram = " << histogram->GetName() << ":"
<< " numBins(" << xMin << ".." << "xMax) = " << numBins_withinRange << ", integral = " << histogram->Integral() << std::endl;
unsigned numBins_rebinned = numBins_withinRange;
for ( int combineNumBins = 5; combineNumBins >= 2; --combineNumBins ) {
if ( numBins_withinRange >= (combineNumBins*numBinsMin_rebinned) && (numBins % combineNumBins) == 0 ) {
numBins_rebinned /= combineNumBins;
numBins_withinRange /= combineNumBins;
}
}
std::string histogramName_rebinned = std::string(histogram->GetName()).append("_rebinned");
histogram_rebinned = new TH1D(histogramName_rebinned.data(), histogram->GetTitle(), numBins_rebinned, xMin, xMax);
if ( !histogram_rebinned->GetSumw2N() ) histogram_rebinned->Sumw2();
TAxis* xAxis = histogram_rebinned->GetXaxis();
unsigned iBin = 1;
for ( unsigned iBin_rebinned = 1; iBin_rebinned <= numBins_rebinned; ++iBin_rebinned ) {
double binContent_rebinned = 0.;
double binError2_rebinned = 0.;
double xMin_rebinnedBin = xAxis->GetBinLowEdge(iBin_rebinned);
double xMax_rebinnedBin = xAxis->GetBinUpEdge(iBin_rebinned);
while ( histogram->GetBinCenter(iBin) < xMin_rebinnedBin ) {
++iBin;
}
while ( histogram->GetBinCenter(iBin) >= xMin_rebinnedBin && histogram->GetBinCenter(iBin) < xMax_rebinnedBin ) {
binContent_rebinned += histogram->GetBinContent(iBin);
binError2_rebinned += square(histogram->GetBinError(iBin));
++iBin;
}
histogram_rebinned->SetBinContent(iBin_rebinned, binContent_rebinned);
histogram_rebinned->SetBinError(iBin_rebinned, TMath::Sqrt(binError2_rebinned));
}
if ( normalize ) {
if ( !histogram_rebinned->GetSumw2N() ) histogram_rebinned->Sumw2();
histogram_rebinned->Scale(1./histogram_rebinned->Integral());
}
std::cout << "histogram(rebinned) = " << histogram_rebinned->GetName() << ":"
<< " numBins = " << histogram_rebinned->GetNbinsX() << ", integral = " << histogram_rebinned->Integral() << std::endl;
}
return histogram_rebinned;
}
//-------------------------------------------------------------------------------
void getBinomialBounds(Int_t n, Int_t r, Float_t& rMin, Float_t& rMax)
{
rMin = 0.;
rMax = 0.;
if ( n == 0 ){
return;
}
if ( r < 0 ){
std::cerr << "Error in <getBinomialBounds>: n = " << n << ", r = " << r << std::endl;
return;
}
if ( ((Double_t)r*(n - r)) > (9.*n) ){
rMin = r - TMath::Sqrt((Double_t)r*(n - r)/((Double_t)n));
rMax = r + TMath::Sqrt((Double_t)r*(n - r)/((Double_t)n));
return;
}
Double_t binomialCoefficient = 1.;
Double_t rMinLeft = 0.;
Double_t rMinMiddle = TMath::Max(0.5*r, n - 1.5*r);
Double_t rMinRight = n;
Double_t rMinLeftProb = 0.;
Double_t rMinMiddleProb = 0.5;
Double_t rMinRightProb = 1.;
while ( (rMinRight - rMinLeft) > (0.001*n) ){
rMinMiddleProb = 0;
for ( Int_t i = r; i <= n; i++ ){
binomialCoefficient = 1;
for ( Int_t j = n; j > i; j-- ){
binomialCoefficient *= j/((Double_t)(j - i));
}
rMinMiddleProb += binomialCoefficient*TMath::Power(rMinMiddle/((Double_t)(n)), i)
*TMath::Power((n - rMinMiddle)/((Double_t)(n)), n - i);
}
if ( rMinMiddleProb > 0.16 ){
rMinRight = rMinMiddle;
rMinRightProb = rMinMiddleProb;
} else if ( rMinMiddleProb < 0.16 ){
rMinLeft = rMinMiddle;
rMinLeftProb = rMinMiddleProb;
} else {
rMinLeft = rMinRight = rMinMiddle;
rMinLeftProb = rMinRightProb = rMinMiddleProb;
}
rMinMiddle = 0.5*(rMinLeft + rMinRight);
if ( rMinLeft > r ){
rMinMiddle = rMinLeft = rMinRight = 0;
}
}
Double_t rMaxLeft = 0.;
Double_t rMaxMiddle = TMath::Min(1.5*r, n - 0.5*r);
Double_t rMaxRight = n;
Double_t rMaxLeftProb = 1.;
Double_t rMaxMiddleProb = 0.5;
Double_t rMaxRightProb = 0.;
while ( (rMaxRight - rMaxLeft) > (0.001*n) ){
rMaxMiddleProb = 0;
for ( Int_t i = 0; i <= r; i++ ){
binomialCoefficient = 1;
for ( Int_t j = n; j > (n - i); j-- ){
binomialCoefficient *= j/((Double_t)(i - (n - j)));
}
rMaxMiddleProb += binomialCoefficient*TMath::Power(rMaxMiddle/((Double_t)(n)), i)
*TMath::Power((n - rMaxMiddle)/((Double_t)(n)), n - i);
}
if ( rMaxMiddleProb > 0.16 ){
rMaxLeft = rMaxMiddle;
rMaxLeftProb = rMaxMiddleProb;
} else if ( rMaxMiddleProb < 0.16 ){
rMaxRight = rMaxMiddle;
rMaxRightProb = rMaxMiddleProb;
} else {
rMaxLeft = rMaxRight = rMaxMiddle;
rMaxLeftProb = rMaxRightProb = rMaxMiddleProb;
}
rMaxMiddle = 0.5*(rMaxLeft + rMaxRight);
if ( rMaxRight < r ){
rMaxMiddle = rMaxLeft = rMaxRight = n;
}
}
rMin = rMinMiddle;
rMax = rMaxMiddle;
}
TGraphAsymmErrors* getEfficiency(const TH1* histogram_numerator, const TH1* histogram_denominator)
{
Int_t error = 0;
if ( !(histogram_numerator->GetNbinsX() == histogram_denominator->GetNbinsX()) ) error = 1;
if ( !(histogram_numerator->GetXaxis()->GetXmin() == histogram_denominator->GetXaxis()->GetXmin()) ) error = 1;
if ( !(histogram_numerator->GetXaxis()->GetXmax() == histogram_denominator->GetXaxis()->GetXmax()) ) error = 1;
if ( error ){
std::cerr << "Error in <getEfficiency>: Dimensionality of histograms does not match !!" << std::endl;
return 0;
}
const TAxis* xAxis = histogram_numerator->GetXaxis();
Int_t nBins = xAxis->GetNbins();
TArrayF x(nBins);
TArrayF dxUp(nBins);
TArrayF dxDown(nBins);
TArrayF y(nBins);
TArrayF dyUp(nBins);
TArrayF dyDown(nBins);
for ( Int_t ibin = 1; ibin <= nBins; ibin++ ){
Int_t nObs = TMath::Nint(histogram_denominator->GetBinContent(ibin));
Int_t rObs = TMath::Nint(histogram_numerator->GetBinContent(ibin));
Float_t xCenter = histogram_denominator->GetBinCenter(ibin);
Float_t xWidth = histogram_denominator->GetBinWidth(ibin);
x[ibin - 1] = xCenter;
dxUp[ibin - 1] = 0.5*xWidth;
dxDown[ibin - 1] = 0.5*xWidth;
if ( nObs > 0 ){
Float_t rMin = 0.;
Float_t rMax = 0.;
getBinomialBounds(nObs, rObs, rMin, rMax);
y[ibin - 1] = rObs/((Float_t)nObs);
dyUp[ibin - 1] = (rMax - rObs)/((Float_t)nObs);
dyDown[ibin - 1] = (rObs - rMin)/((Float_t)nObs);
} else{
y[ibin - 1] = 0.;
dyUp[ibin - 1] = 0.;
dyDown[ibin - 1] = 0.;
}
}
TString name = TString(histogram_numerator->GetName()).Append("Graph");
TString title = histogram_numerator->GetTitle();
TGraphAsymmErrors* graph =
new TGraphAsymmErrors(nBins, x.GetArray(), y.GetArray(),
dxDown.GetArray(), dxUp.GetArray(), dyDown.GetArray(), dyUp.GetArray());
graph->SetName(name);
graph->SetTitle(title);
return graph;
}
TGraphAsymmErrors* makeGraph_div_ref(const TGraph* graph, const TGraph* graph_ref)
{
TGraphAsymmErrors* graph_div_ref = new TGraphAsymmErrors(graph->GetN());
for ( int iPoint = 0; iPoint < graph->GetN(); ++iPoint ) {
double x, y;
graph->GetPoint(iPoint, x, y);
double yErrUp = graph->GetErrorYhigh(iPoint);
double yErrDown = graph->GetErrorYlow(iPoint);
double x_ref, y_ref;
graph_ref->GetPoint(iPoint, x_ref, y_ref);
double yErrUp_ref = graph_ref->GetErrorYhigh(iPoint);
double yErrDown_ref = graph_ref->GetErrorYlow(iPoint);
if ( !(y_ref > 0.) ) continue;
double yDiv = (y - y_ref)/y_ref;
double yDivErrUp = 0.;
if ( y > 0. ) yDivErrUp += square(yErrUp/y);
if ( y_ref > 0. ) yDivErrUp += square(yErrDown_ref/y_ref);
yDivErrUp *= square(y/y_ref);
yDivErrUp = TMath::Sqrt(yDivErrUp);
double yDivErrDown = 0.;
if ( y > 0. ) yDivErrDown += square(yErrDown/y);
if ( y_ref > 0. ) yDivErrDown += square(yErrUp_ref/y_ref);
yDivErrDown *= square(y/y_ref);
yDivErrDown = TMath::Sqrt(yDivErrDown);
//std::cout << "x = " << x << ": y = " << yDiv << " + " << yDivErrUp << " - " << yDivErrDown << std::endl;
graph_div_ref->SetPoint(iPoint, x, yDiv);
graph_div_ref->SetPointError(iPoint, 0., 0., yDivErrDown, yDivErrUp);
}
graph_div_ref->SetLineColor(graph->GetLineColor());
graph_div_ref->SetMarkerColor(graph->GetMarkerColor());
graph_div_ref->SetMarkerStyle(graph->GetMarkerStyle());
graph_div_ref->SetMarkerSize(graph->GetMarkerSize());
return graph_div_ref;
}
void showEfficiency(const TString& title, double canvasSizeX, double canvasSizeY,
const TH1* histogram_ref_numerator, const TH1* histogram_ref_denominator, const std::string& legendEntry_ref,
const TH1* histogram2_numerator, const TH1* histogram2_denominator, const std::string& legendEntry2,
const TH1* histogram3_numerator, const TH1* histogram3_denominator, const std::string& legendEntry3,
const TH1* histogram4_numerator, const TH1* histogram4_denominator, const std::string& legendEntry4,
const TH1* histogram5_numerator, const TH1* histogram5_denominator, const std::string& legendEntry5,
const TH1* histogram6_numerator, const TH1* histogram6_denominator, const std::string& legendEntry6,
double xMin, double xMax, unsigned numBinsMin_rebinned, const std::string& xAxisTitle, double xAxisOffset,
double yMin, double yMax, double yAxisOffset,
double legendX0, double legendY0,
const std::string& outputFileName)
{
TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
canvas->SetLeftMargin(0.135);
canvas->SetBottomMargin(0.135);
TPad* topPad = new TPad("topPad", "topPad", 0.00, 0.35, 1.00, 1.00);
topPad->SetFillColor(10);
topPad->SetTopMargin(0.04);
topPad->SetLeftMargin(0.15);
topPad->SetBottomMargin(0.03);
topPad->SetRightMargin(0.05);
topPad->SetGridx();
topPad->SetGridy();
canvas->cd();
topPad->Draw();
topPad->cd();
TH1* dummyHistogram_top = new TH1D("dummyHistogram_top", "dummyHistogram_top", 10, xMin, xMax);
dummyHistogram_top->SetTitle("");
dummyHistogram_top->SetStats(false);
dummyHistogram_top->SetMaximum(yMax);
dummyHistogram_top->SetMinimum(yMin);
TAxis* xAxis_top = dummyHistogram_top->GetXaxis();
xAxis_top->SetTitle(xAxisTitle.data());
xAxis_top->SetTitleOffset(xAxisOffset);
xAxis_top->SetLabelColor(10);
xAxis_top->SetTitleColor(10);
TAxis* yAxis_top = dummyHistogram_top->GetYaxis();
yAxis_top->SetTitle("#varepsilon");
yAxis_top->SetTitleOffset(yAxisOffset);
dummyHistogram_top->Draw();
int colors[6] = { kBlack, kGreen - 6, kBlue - 7, kMagenta - 7, kCyan - 6, kRed - 6 };
int markerStyles[6] = { 24, 25, 20, 21, 22, 23 };
int markerSizes[6] = { 1, 1, 1, 1, 1, 1 };
TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.44, legendY0 + 0.20, "", "brNDC");
legend->SetBorderSize(0);
legend->SetFillColor(0);
TH1* histogram_ref_numerator_rebinned = rebinHistogram(histogram_ref_numerator, numBinsMin_rebinned, xMin, xMax, false);
TH1* histogram_ref_denominator_rebinned = rebinHistogram(histogram_ref_denominator, numBinsMin_rebinned, xMin, xMax, false);
TGraphAsymmErrors* graph_ref = getEfficiency(histogram_ref_numerator_rebinned, histogram_ref_denominator_rebinned);
graph_ref->SetLineColor(colors[0]);
graph_ref->SetMarkerColor(colors[0]);
graph_ref->SetMarkerStyle(markerStyles[0]);
graph_ref->SetMarkerSize(markerSizes[0]);
graph_ref->Draw("p");
legend->AddEntry(graph_ref, legendEntry_ref.data(), "p");
TGraphAsymmErrors* graph2 = 0;
if ( histogram2_numerator && histogram2_denominator ) {
TH1* histogram2_numerator_rebinned = rebinHistogram(histogram2_numerator, numBinsMin_rebinned, xMin, xMax, false);
TH1* histogram2_denominator_rebinned = rebinHistogram(histogram2_denominator, numBinsMin_rebinned, xMin, xMax, false);
graph2 = getEfficiency(histogram2_numerator_rebinned, histogram2_denominator_rebinned);
graph2->SetLineColor(colors[1]);
graph2->SetMarkerColor(colors[1]);
graph2->SetMarkerStyle(markerStyles[1]);
graph2->SetMarkerSize(markerSizes[1]);
graph2->Draw("p");
legend->AddEntry(graph2, legendEntry2.data(), "p");
}
TGraphAsymmErrors* graph3 = 0;
if ( histogram3_numerator && histogram3_denominator ) {
TH1* histogram3_numerator_rebinned = rebinHistogram(histogram3_numerator, numBinsMin_rebinned, xMin, xMax, false);
TH1* histogram3_denominator_rebinned = rebinHistogram(histogram3_denominator, numBinsMin_rebinned, xMin, xMax, false);
graph3 = getEfficiency(histogram3_numerator_rebinned, histogram3_denominator_rebinned);
graph3->SetLineColor(colors[2]);
graph3->SetMarkerColor(colors[2]);
graph3->SetMarkerStyle(markerStyles[2]);
graph3->SetMarkerSize(markerSizes[2]);
graph3->Draw("p");
legend->AddEntry(graph3, legendEntry3.data(), "p");
}
TGraphAsymmErrors* graph4 = 0;
if ( histogram4_numerator && histogram4_denominator ) {
TH1* histogram4_numerator_rebinned = rebinHistogram(histogram4_numerator, numBinsMin_rebinned, xMin, xMax, false);
TH1* histogram4_denominator_rebinned = rebinHistogram(histogram4_denominator, numBinsMin_rebinned, xMin, xMax, false);
graph4 = getEfficiency(histogram4_numerator_rebinned, histogram4_denominator_rebinned);
graph4->SetLineColor(colors[3]);
graph4->SetMarkerColor(colors[3]);
graph4->SetMarkerStyle(markerStyles[3]);
graph4->SetMarkerSize(markerSizes[3]);
graph4->Draw("p");
legend->AddEntry(graph4, legendEntry4.data(), "p");
}
TGraphAsymmErrors* graph5 = 0;
if ( histogram5_numerator && histogram5_denominator ) {
TH1* histogram5_numerator_rebinned = rebinHistogram(histogram5_numerator, numBinsMin_rebinned, xMin, xMax, false);
TH1* histogram5_denominator_rebinned = rebinHistogram(histogram5_denominator, numBinsMin_rebinned, xMin, xMax, false);
graph5 = getEfficiency(histogram5_numerator_rebinned, histogram5_denominator_rebinned);
graph5->SetLineColor(colors[4]);
graph5->SetMarkerColor(colors[4]);
graph5->SetMarkerStyle(markerStyles[4]);
graph5->SetMarkerSize(markerSizes[4]);
graph5->Draw("p");
legend->AddEntry(graph5, legendEntry5.data(), "p");
}
TGraphAsymmErrors* graph6 = 0;
if ( histogram6_numerator && histogram6_denominator ) {
TH1* histogram6_numerator_rebinned = rebinHistogram(histogram6_numerator, numBinsMin_rebinned, xMin, xMax, false);
TH1* histogram6_denominator_rebinned = rebinHistogram(histogram6_denominator, numBinsMin_rebinned, xMin, xMax, false);
graph6 = getEfficiency(histogram6_numerator_rebinned, histogram6_denominator_rebinned);
graph6->SetLineColor(colors[5]);
graph6->SetMarkerColor(colors[5]);
graph6->SetMarkerStyle(markerStyles[5]);
graph6->SetMarkerSize(markerSizes[5]);
graph6->Draw("p");
legend->AddEntry(graph6, legendEntry6.data(), "p");
}
legend->Draw();
TPaveText* label = 0;
if ( title.Length() > 0 ) {
label = new TPaveText(0.145, 0.975, 0.48, 1.02, "NDC");
label->AddText(title.Data());
label->SetTextAlign(13);
label->SetTextSize(0.045);
label->SetFillStyle(0);
label->SetBorderSize(0);
label->Draw();
}
TPad* bottomPad = new TPad("bottomPad", "bottomPad", 0.00, 0.00, 1.00, 0.35);
bottomPad->SetFillColor(10);
bottomPad->SetTopMargin(0.02);
bottomPad->SetLeftMargin(0.15);
bottomPad->SetBottomMargin(0.24);
bottomPad->SetRightMargin(0.05);
bottomPad->SetGridx();
bottomPad->SetGridy();
canvas->cd();
bottomPad->Draw();
bottomPad->cd();
TH1* dummyHistogram_bottom = new TH1D("dummyHistogram_bottom", "dummyHistogram_bottom", 10, xMin, xMax);
dummyHistogram_bottom->SetMinimum(-0.50);
dummyHistogram_bottom->SetMaximum(+0.50);
TAxis* xAxis_bottom = dummyHistogram_bottom->GetXaxis();
xAxis_bottom->SetTitle(xAxisTitle.data());
xAxis_bottom->SetTitleOffset(1.20);
xAxis_bottom->SetLabelColor(1);
xAxis_bottom->SetTitleColor(1);
xAxis_bottom->SetTitleSize(0.08);
xAxis_bottom->SetLabelOffset(0.02);
xAxis_bottom->SetLabelSize(0.08);
xAxis_bottom->SetTickLength(0.055);
TAxis* yAxis_bottom = dummyHistogram_bottom->GetYaxis();
yAxis_bottom->SetTitle("#frac{Embedding - Z/#gamma^{*} #rightarrow #tau #tau}{Z/#gamma^{*} #rightarrow #tau #tau}");
yAxis_bottom->SetTitleOffset(0.85);
yAxis_bottom->SetNdivisions(505);
yAxis_bottom->CenterTitle();
yAxis_bottom->SetTitleSize(0.08);
yAxis_bottom->SetLabelSize(0.08);
yAxis_bottom->SetTickLength(0.04);
dummyHistogram_bottom->SetTitle("");
dummyHistogram_bottom->SetStats(false);
dummyHistogram_bottom->Draw();
TGraphAsymmErrors* graph2_div_ref = 0;
if ( graph2 ) {
graph2_div_ref = makeGraph_div_ref(graph2, graph_ref);
graph2_div_ref->Draw("p");
}
TGraphAsymmErrors* graph3_div_ref = 0;
if ( graph3 ) {
graph3_div_ref = makeGraph_div_ref(graph3, graph_ref);
graph3_div_ref->Draw("p");
}
TGraphAsymmErrors* graph4_div_ref = 0;
if ( graph4 ) {
graph4_div_ref = makeGraph_div_ref(graph4, graph_ref);
graph4_div_ref->Draw("p");
}
TGraphAsymmErrors* graph5_div_ref = 0;
if ( graph5 ) {
graph5_div_ref = makeGraph_div_ref(graph5, graph_ref);
graph5_div_ref->Draw("p");
}
TGraphAsymmErrors* graph6_div_ref = 0;
if ( graph6 ) {
graph6_div_ref = makeGraph_div_ref(graph6, graph_ref);
graph6_div_ref->Draw("p");
}
canvas->Update();
size_t idx = outputFileName.find_last_of('.');
std::string outputFileName_plot = std::string(outputFileName, 0, idx);
if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
canvas->Print(std::string(outputFileName_plot).append(".png").data());
canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
delete legend;
delete label;
delete dummyHistogram_top;
delete topPad;
delete dummyHistogram_bottom;
delete graph2_div_ref;
delete graph3_div_ref;
delete graph4_div_ref;
delete graph5_div_ref;
delete graph6_div_ref;
delete bottomPad;
delete canvas;
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
TH1* compRatioHistogram(const std::string& ratioHistogramName, const TH1* numerator, const TH1* denominator)
{
assert(numerator->GetDimension() == denominator->GetDimension());
assert(numerator->GetNbinsX() == denominator->GetNbinsX());
TH1* histogramRatio = (TH1*)numerator->Clone(ratioHistogramName.data());
histogramRatio->Divide(denominator);
int nBins = histogramRatio->GetNbinsX();
for ( int iBin = 1; iBin <= nBins; ++iBin ){
double binContent = histogramRatio->GetBinContent(iBin);
histogramRatio->SetBinContent(iBin, binContent - 1.);
}
histogramRatio->SetLineColor(numerator->GetLineColor());
histogramRatio->SetLineWidth(numerator->GetLineWidth());
histogramRatio->SetMarkerColor(numerator->GetMarkerColor());
histogramRatio->SetMarkerStyle(numerator->GetMarkerStyle());
histogramRatio->SetMarkerSize(numerator->GetMarkerSize());
return histogramRatio;
}
void showDistribution(double canvasSizeX, double canvasSizeY,
TH1* histogram_ref, const std::string& legendEntry_ref,
TH1* histogram2, const std::string& legendEntry2,
TH1* histogram3, const std::string& legendEntry3,
TH1* histogram4, const std::string& legendEntry4,
TH1* histogram5, const std::string& legendEntry5,
TH1* histogram6, const std::string& legendEntry6,
double xMin, double xMax, unsigned numBinsMin_rebinned, const std::string& xAxisTitle, double xAxisOffset,
bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
double legendX0, double legendY0,
const std::string& outputFileName)
{
TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
canvas->SetLeftMargin(0.12);
canvas->SetBottomMargin(0.12);
TPad* topPad = new TPad("topPad", "topPad", 0.00, 0.35, 1.00, 1.00);
topPad->SetFillColor(10);
topPad->SetTopMargin(0.04);
topPad->SetLeftMargin(0.15);
topPad->SetBottomMargin(0.03);
topPad->SetRightMargin(0.05);
topPad->SetLogy(useLogScale);
TPad* bottomPad = new TPad("bottomPad", "bottomPad", 0.00, 0.00, 1.00, 0.35);
bottomPad->SetFillColor(10);
bottomPad->SetTopMargin(0.02);
bottomPad->SetLeftMargin(0.15);
bottomPad->SetBottomMargin(0.24);
bottomPad->SetRightMargin(0.05);
bottomPad->SetLogy(false);
canvas->cd();
topPad->Draw();
topPad->cd();
int colors[6] = { kBlack, kGreen - 6, kBlue - 7, kMagenta - 7, kCyan - 6, kRed - 6 };
int markerStyles[6] = { 24, 25, 20, 21, 22, 23 };
int markerSizes[6] = { 1, 1, 1, 1, 1, 1 };
TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.44, legendY0 + 0.20, "", "brNDC");
legend->SetBorderSize(0);
legend->SetFillColor(0);
TH1* histogram_ref_rebinned = rebinHistogram(histogram_ref, numBinsMin_rebinned, xMin, xMax, false);
histogram_ref_rebinned->SetTitle("");
histogram_ref_rebinned->SetStats(false);
histogram_ref_rebinned->SetMinimum(yMin);
histogram_ref_rebinned->SetMaximum(yMax);
histogram_ref_rebinned->SetLineColor(colors[0]);
histogram_ref_rebinned->SetLineWidth(2);
histogram_ref_rebinned->SetMarkerColor(colors[0]);
histogram_ref_rebinned->SetMarkerStyle(markerStyles[0]);
histogram_ref_rebinned->SetMarkerSize(markerSizes[0]);
histogram_ref_rebinned->Draw("e1p");
legend->AddEntry(histogram_ref_rebinned, legendEntry_ref.data(), "p");
TAxis* xAxis_top = histogram_ref_rebinned->GetXaxis();
xAxis_top->SetTitle(xAxisTitle.data());
xAxis_top->SetTitleOffset(xAxisOffset);
xAxis_top->SetLabelColor(10);
xAxis_top->SetTitleColor(10);
TAxis* yAxis_top = histogram_ref_rebinned->GetYaxis();
yAxis_top->SetTitle(yAxisTitle.data());
yAxis_top->SetTitleOffset(yAxisOffset);
TH1* histogram2_rebinned = 0;
if ( histogram2 ) {
histogram2_rebinned = rebinHistogram(histogram2, numBinsMin_rebinned, xMin, xMax, false);
histogram2_rebinned->SetLineColor(colors[1]);
histogram2_rebinned->SetLineWidth(2);
histogram2_rebinned->SetMarkerColor(colors[1]);
histogram2_rebinned->SetMarkerStyle(markerStyles[1]);
histogram2_rebinned->SetMarkerSize(markerSizes[1]);
histogram2_rebinned->Draw("e1psame");
legend->AddEntry(histogram2_rebinned, legendEntry2.data(), "p");
}
TH1* histogram3_rebinned = 0;
if ( histogram3 ) {
histogram3_rebinned = rebinHistogram(histogram3, numBinsMin_rebinned, xMin, xMax, false);
histogram3_rebinned->SetLineColor(colors[2]);
histogram3_rebinned->SetLineWidth(2);
histogram3_rebinned->SetMarkerColor(colors[2]);
histogram3_rebinned->SetMarkerStyle(markerStyles[2]);
histogram3_rebinned->SetMarkerSize(markerSizes[2]);
histogram3_rebinned->Draw("e1psame");
legend->AddEntry(histogram3_rebinned, legendEntry3.data(), "p");
}
TH1* histogram4_rebinned = 0;
if ( histogram4 ) {
histogram4_rebinned = rebinHistogram(histogram4, numBinsMin_rebinned, xMin, xMax, false);
histogram4_rebinned->SetLineColor(colors[3]);
histogram4_rebinned->SetLineWidth(2);
histogram4_rebinned->SetMarkerColor(colors[3]);
histogram4_rebinned->SetMarkerStyle(markerStyles[3]);
histogram4_rebinned->SetMarkerSize(markerSizes[3]);
histogram4_rebinned->Draw("e1psame");
legend->AddEntry(histogram4_rebinned, legendEntry4.data(), "p");
}
TH1* histogram5_rebinned = 0;
if ( histogram5 ) {
histogram5_rebinned = rebinHistogram(histogram5, numBinsMin_rebinned, xMin, xMax, false);
histogram5_rebinned->SetLineColor(colors[4]);
histogram5_rebinned->SetLineWidth(2);
histogram5_rebinned->SetMarkerColor(colors[4]);
histogram5_rebinned->SetMarkerStyle(markerStyles[4]);
histogram5_rebinned->SetMarkerSize(markerSizes[4]);
histogram5_rebinned->Draw("e1psame");
legend->AddEntry(histogram5_rebinned, legendEntry5.data(), "p");
}
TH1* histogram6_rebinned = 0;
if ( histogram6 ) {
histogram6_rebinned = rebinHistogram(histogram6, numBinsMin_rebinned, xMin, xMax, false);
histogram6_rebinned->SetLineColor(colors[5]);
histogram6_rebinned->SetLineWidth(2);
histogram6_rebinned->SetMarkerColor(colors[5]);
histogram6_rebinned->SetMarkerStyle(markerStyles[5]);
histogram6_rebinned->SetMarkerSize(markerSizes[5]);
histogram6_rebinned->Draw("e1psame");
legend->AddEntry(histogram6_rebinned, legendEntry6.data(), "p");
}
legend->Draw();
canvas->cd();
bottomPad->Draw();
bottomPad->cd();
TH1* histogram2_div_ref = 0;
if ( histogram2 ) {
std::string histogramName2_div_ref = std::string(histogram2->GetName()).append("_div_").append(histogram_ref->GetName());
histogram2_div_ref = compRatioHistogram(histogramName2_div_ref, histogram2_rebinned, histogram_ref_rebinned);
histogram2_div_ref->SetTitle("");
histogram2_div_ref->SetStats(false);
histogram2_div_ref->SetMinimum(-0.50);
histogram2_div_ref->SetMaximum(+0.50);
TAxis* xAxis_bottom = histogram2_div_ref->GetXaxis();
xAxis_bottom->SetTitle(xAxis_top->GetTitle());
xAxis_bottom->SetLabelColor(1);
xAxis_bottom->SetTitleColor(1);
xAxis_bottom->SetTitleOffset(1.20);
xAxis_bottom->SetTitleSize(0.08);
xAxis_bottom->SetLabelOffset(0.02);
xAxis_bottom->SetLabelSize(0.08);
xAxis_bottom->SetTickLength(0.055);
TAxis* yAxis_bottom = histogram2_div_ref->GetYaxis();
yAxis_bottom->SetTitle("#frac{Embedding - Z/#gamma^{*} #rightarrow #tau #tau}{Z/#gamma^{*} #rightarrow #tau #tau}");
yAxis_bottom->SetTitleOffset(0.70);
yAxis_bottom->SetNdivisions(505);
yAxis_bottom->CenterTitle();
yAxis_bottom->SetTitleSize(0.08);
yAxis_bottom->SetLabelSize(0.08);
yAxis_bottom->SetTickLength(0.04);
histogram2_div_ref->Draw("e1p");
}
TH1* histogram3_div_ref = 0;
if ( histogram3 ) {
std::string histogramName3_div_ref = std::string(histogram3->GetName()).append("_div_").append(histogram_ref->GetName());
histogram3_div_ref = compRatioHistogram(histogramName3_div_ref, histogram3_rebinned, histogram_ref_rebinned);
histogram3_div_ref->SetTitle("");
histogram3_div_ref->SetStats(false);
histogram3_div_ref->SetMinimum(-0.50);
histogram3_div_ref->SetMaximum(+0.50);
TAxis* xAxis_bottom = histogram3_div_ref->GetXaxis();
xAxis_bottom->SetTitle(xAxis_top->GetTitle());
xAxis_bottom->SetLabelColor(1);
xAxis_bottom->SetTitleColor(1);
xAxis_bottom->SetTitleOffset(1.20);
xAxis_bottom->SetTitleSize(0.08);
xAxis_bottom->SetLabelOffset(0.02);
xAxis_bottom->SetLabelSize(0.08);
xAxis_bottom->SetTickLength(0.055);
TAxis* yAxis_bottom = histogram3_div_ref->GetYaxis();
yAxis_bottom->SetTitle("#frac{Embedding - Z/#gamma^{*} #rightarrow #tau #tau}{Z/#gamma^{*} #rightarrow #tau #tau}");
yAxis_bottom->SetTitleOffset(0.70);
yAxis_bottom->SetNdivisions(505);
yAxis_bottom->CenterTitle();
yAxis_bottom->SetTitleSize(0.08);
yAxis_bottom->SetLabelSize(0.08);
yAxis_bottom->SetTickLength(0.04);
if ( histogram2 ) histogram3_div_ref->Draw("e1psame");
else histogram3_div_ref->Draw("e1p");
}
TH1* histogram4_div_ref = 0;
if ( histogram4 ) {
std::string histogramName4_div_ref = std::string(histogram4->GetName()).append("_div_").append(histogram_ref->GetName());
histogram4_div_ref = compRatioHistogram(histogramName4_div_ref, histogram4_rebinned, histogram_ref_rebinned);
histogram4_div_ref->Draw("e1psame");
}
TH1* histogram5_div_ref = 0;
if ( histogram5 ) {
std::string histogramName5_div_ref = std::string(histogram5->GetName()).append("_div_").append(histogram_ref->GetName());
histogram5_div_ref = compRatioHistogram(histogramName5_div_ref, histogram5_rebinned, histogram_ref_rebinned);
histogram5_div_ref->Draw("e1psame");
}
TH1* histogram6_div_ref = 0;
if ( histogram6 ) {
std::string histogramName6_div_ref = std::string(histogram6->GetName()).append("_div_").append(histogram_ref->GetName());
histogram6_div_ref = compRatioHistogram(histogramName6_div_ref, histogram6_rebinned, histogram_ref_rebinned);
histogram6_div_ref->Draw("e1psame");
}
canvas->Update();
size_t idx = outputFileName.find_last_of('.');
std::string outputFileName_plot = std::string(outputFileName, 0, idx);
if ( useLogScale ) outputFileName_plot.append("_log");
else outputFileName_plot.append("_linear");
if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
canvas->Print(std::string(outputFileName_plot).append(".png").data());
canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
delete legend;
delete histogram2_div_ref;
delete histogram3_div_ref;
delete histogram4_div_ref;
delete histogram5_div_ref;
delete histogram6_div_ref;
delete topPad;
delete bottomPad;
delete canvas;
}
//-------------------------------------------------------------------------------
struct plotEntryTypeBase
{
plotEntryTypeBase(const std::string& name, const std::string& title,
double xMin, double xMax, unsigned numBinsMin_rebinned, const std::string& xAxisTitle, double xAxisOffset,
double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, bool useLogScale)
: name_(name),
title_(title),
xMin_(xMin),
xMax_(xMax),
numBinsMin_rebinned_(numBinsMin_rebinned),
xAxisTitle_(xAxisTitle),
xAxisOffset_(xAxisOffset),
yMin_(yMin),
yMax_(yMax),
yAxisTitle_(yAxisTitle),
yAxisOffset_(yAxisOffset),
useLogScale_(useLogScale)
{}
~plotEntryTypeBase() {}
std::string name_;
std::string title_;
double xMin_;
double xMax_;
unsigned numBinsMin_rebinned_;
std::string xAxisTitle_;
double xAxisOffset_;
double yMin_;
double yMax_;
std::string yAxisTitle_;
double yAxisOffset_;
bool useLogScale_;
};
struct plotEntryType_distribution : public plotEntryTypeBase
{
plotEntryType_distribution(const std::string& name, const std::string& title, const std::string& dqmDirectory, const std::string& meName,
double xMin, double xMax, unsigned numBinsMin_rebinned, const std::string& xAxisTitle, double xAxisOffset,
double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, bool useLogScale)
: plotEntryTypeBase(name, title,
xMin, xMax, numBinsMin_rebinned, xAxisTitle, xAxisOffset,
yMin, yMax, yAxisTitle, yAxisOffset, useLogScale)
{
TString meName_full = dqmDirectory.data();
if ( meName_full.Length() > 0 && !meName_full.EndsWith("/") ) meName_full.Append("/");
meName_full.Append(meName.data());
meName_ = meName_full.Data();
}
~plotEntryType_distribution() {}
std::string meName_;
};
struct plotEntryType_efficiency : public plotEntryTypeBase
{
plotEntryType_efficiency(const std::string& name, const std::string& title, const std::string& dqmDirectory, const std::string& meName_numerator, const std::string& meName_denominator,
double xMin, double xMax, unsigned numBinsMin_rebinned, const std::string& xAxisTitle, double xAxisOffset,
double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, bool useLogScale)
: plotEntryTypeBase(name, title,
xMin, xMax, numBinsMin_rebinned, xAxisTitle, xAxisOffset,
yMin, yMax, yAxisTitle, yAxisOffset, useLogScale)
{
TString meName_numerator_full = dqmDirectory.data();
if ( meName_numerator_full.Length() > 0 && !meName_numerator_full.EndsWith("/") ) meName_numerator_full.Append("/");
meName_numerator_full.Append(meName_numerator.data());
meName_numerator_ = meName_numerator_full.Data();
TString meName_denominator_full = dqmDirectory.data();
if ( meName_denominator_full.Length() > 0 && !meName_denominator_full.EndsWith("/") ) meName_denominator_full.Append("/");
meName_denominator_full.Append(meName_denominator.data());
meName_denominator_ = meName_denominator_full.Data();
}
~plotEntryType_efficiency() {}
std::string meName_numerator_;
std::string meName_denominator_;
};
//-------------------------------------------------------------------------------
TGraphAsymmErrors* convertToGraph(const TH1* histogram, const TH1* histogramErrUp = 0, const TH1* histogramErrDown = 0)
{
if ( histogramErrUp ) assert(histogram->GetNbinsX() == histogramErrUp->GetNbinsX());
if ( histogramErrDown ) assert(histogram->GetNbinsX() == histogramErrDown->GetNbinsX());
int nPoints = histogram->GetNbinsX();
TGraphAsymmErrors* graph = new TGraphAsymmErrors(nPoints);
int nBins = histogram->GetNbinsX();
for ( int iBin = 1; iBin <= nBins; ++iBin ){
double x = histogram->GetBinCenter(iBin);
double y = histogram->GetBinContent(iBin);
double xErrUp = 0.5*histogram->GetBinWidth(iBin);
double xErrDown = xErrUp;
double yErr2Up = square(histogram->GetBinError(iBin));
if ( histogramErrUp && histogramErrUp->GetBinContent(iBin) > y ) yErr2Up = square(histogramErrUp->GetBinContent(iBin) - y);
if ( histogramErrDown && histogramErrDown->GetBinContent(iBin) > y ) yErr2Up = square(histogramErrDown->GetBinContent(iBin) - y);
double yErrUp = TMath::Sqrt(yErr2Up);
double yErr2Down = square(histogram->GetBinError(iBin));
if ( histogramErrUp && histogramErrUp->GetBinContent(iBin) < y ) yErr2Down = square(y - histogramErrUp->GetBinContent(iBin));
if ( histogramErrDown && histogramErrDown->GetBinContent(iBin) < y ) yErr2Down = square(y - histogramErrDown->GetBinContent(iBin));
double yErrDown = TMath::Sqrt(yErr2Down);
int iPoint = iBin - 1;
graph->SetPoint(iPoint, x, y);
graph->SetPointError(iPoint, xErrDown, xErrUp, yErrDown, yErrUp);
}
graph->SetLineColor(histogram->GetLineColor());
graph->SetLineWidth(histogram->GetLineWidth());
graph->SetMarkerColor(histogram->GetMarkerColor());
graph->SetMarkerStyle(histogram->GetMarkerStyle());
graph->SetMarkerSize(histogram->GetMarkerSize());
return graph;
}
TGraphAsymmErrors* compRatioGraph(const std::string& ratioGraphName, const TGraph* numerator, const TGraph* denominator)
{
assert(numerator->GetN() == denominator->GetN());
int nPoints = numerator->GetN();
TGraphAsymmErrors* graphRatio = new TGraphAsymmErrors(nPoints);
graphRatio->SetName(ratioGraphName.data());
for ( int iPoint = 0; iPoint < nPoints; ++iPoint ){
double x_numerator, y_numerator;
numerator->GetPoint(iPoint, x_numerator, y_numerator);
double xErrUp_numerator = 0.;
double xErrDown_numerator = 0.;
double yErrUp_numerator = 0.;
double yErrDown_numerator = 0.;
if ( dynamic_cast<const TGraphAsymmErrors*>(numerator) ) {
const TGraphAsymmErrors* numerator_asymmerrors = dynamic_cast<const TGraphAsymmErrors*>(numerator);
xErrUp_numerator = numerator_asymmerrors->GetErrorXhigh(iPoint);
xErrDown_numerator = numerator_asymmerrors->GetErrorXlow(iPoint);
yErrUp_numerator = numerator_asymmerrors->GetErrorYhigh(iPoint);
yErrDown_numerator = numerator_asymmerrors->GetErrorYlow(iPoint);
} else if ( dynamic_cast<const TGraphErrors*>(numerator) ) {
const TGraphErrors* numerator_errors = dynamic_cast<const TGraphErrors*>(numerator);
xErrUp_numerator = numerator_errors->GetErrorX(iPoint);
xErrDown_numerator = xErrUp_numerator;
yErrUp_numerator = numerator_errors->GetErrorY(iPoint);
yErrDown_numerator = yErrUp_numerator;
}
double x_denominator, y_denominator;
denominator->GetPoint(iPoint, x_denominator, y_denominator);
assert(x_denominator == x_numerator);
double xErrUp_denominator = 0.;
double xErrDown_denominator = 0.;
double yErrUp_denominator = 0.;
double yErrDown_denominator = 0.;
if ( dynamic_cast<const TGraphAsymmErrors*>(denominator) ) {
const TGraphAsymmErrors* denominator_asymmerrors = dynamic_cast<const TGraphAsymmErrors*>(denominator);
xErrUp_denominator = denominator_asymmerrors->GetErrorXhigh(iPoint);
xErrDown_denominator = denominator_asymmerrors->GetErrorXlow(iPoint);
yErrUp_denominator = denominator_asymmerrors->GetErrorYhigh(iPoint);
yErrDown_denominator = denominator_asymmerrors->GetErrorYlow(iPoint);
} else if ( dynamic_cast<const TGraphErrors*>(denominator) ) {
const TGraphErrors* denominator_errors = dynamic_cast<const TGraphErrors*>(denominator);
xErrUp_denominator = denominator_errors->GetErrorX(iPoint);
xErrDown_denominator = xErrUp_denominator;
yErrUp_denominator = denominator_errors->GetErrorY(iPoint);
yErrDown_denominator = yErrUp_denominator;
}
double x_ratio = x_numerator;
double y_ratio = ( y_denominator > 0. ) ? (y_numerator/y_denominator) : 0.;
double xErrUp_ratio = TMath::Max(xErrUp_numerator, xErrUp_denominator);
double xErrDown_ratio = TMath::Max(xErrDown_numerator, xErrDown_denominator);
double yErr2Up_ratio = 0.;
if ( y_numerator ) yErr2Up_ratio += square(yErrUp_numerator/y_numerator);
if ( y_denominator ) yErr2Up_ratio += square(yErrDown_denominator/y_numerator);
double yErrUp_ratio = TMath::Sqrt(yErr2Up_ratio)*y_ratio;
double yErr2Down_ratio = 0.;
if ( y_numerator ) yErr2Down_ratio += square(yErrDown_numerator/y_numerator);
if ( y_denominator ) yErr2Down_ratio += square(yErrUp_denominator/y_numerator);