28 #include "TPaveText.h"
29 #include "TDirectory.h"
34 static const size_t NDir = 4;
35 static const size_t NVtx = 4;
44 gErrorIgnoreLevel = kError;
45 cout <<
"\n Beginning old vs. new comparison script..." << endl;
50 const string sOutput(
"oldVsNewComparisonWithNoNorm_oneMatchPerParticle_zVtxCutComp_odd05150.pt10n1evt500pim.d1m2y2024.root");
51 const string sInOld(
"oldEvalPlots_oneMatchPerParticle_embedScanOn_forZVtxCutComp_oddFrac05150.pt10n1evt500pim.d1m2y2024.root");
52 const string sInNew(
"newMatcherTuplePlots_oneMatchPerParticle_forZVtxCutComp_oddFrac05150.pt10n1evt500pim.d1m2y2024.root");
55 const pair<uint32_t, uint32_t> fCol = {923, 899};
56 const pair<uint32_t, uint32_t> fMar = {20, 25};
57 const pair<uint32_t, uint32_t> fLin = {1, 1};
58 const pair<uint32_t, uint32_t> fWid = {1, 1};
59 const pair<uint32_t, uint32_t> fFil = {0, 0};
62 const string sRatioLabel =
"Ratio";
63 const pair<string, string> sHistLabels = {
"Old",
"New"};
64 const array<string, NDir> arrDirNames = {
"OldHists",
"NewHists",
"Ratios",
"Plots"};
67 enum Dir {
Old, New, Ratio, Plot};
70 const string sLegOld =
"evaluator";
71 const string sLegNew =
"truth matcher";
72 const string sHeader =
"";
73 const string sCount =
"counts";
74 const string sNorm =
"normalized counts";
75 const string sRatio =
"ratio";
76 const vector<string> vecTxt = {
77 "#bf{#it{sPHENIX}} Simulation",
78 "1 #pi^{-}/event, p_{T} = 10 GeV/c",
83 const bool doIntNorm =
false;
84 const bool matchVertScales =
true;
87 const vector<string> vecInHists1D = {
137 const vector<string> vecInHists2D = {
138 "hTruthNumTotVsTruthPt",
139 "hTruthNumTotVsNumTpc",
140 "hTrackNumTotVsTruthPt",
141 "hTrackNumTotVsNumTpc",
142 "hWeirdNumTotVsTruthPt",
143 "hWeirdNumTotVsNumTpc",
144 "hNormNumTotVsTruthPt",
145 "hNormNumTotVsNumTpc",
146 "hTruthNumInttVsTruthPt",
147 "hTruthNumInttVsNumTpc",
148 "hTrackNumInttVsTruthPt",
149 "hTrackNumInttVsNumTpc",
150 "hWeirdNumInttVsTruthPt",
151 "hWeirdNumInttVsNumTpc",
152 "hNormNumInttVsTruthPt",
153 "hNormNumInttVsNumTpc",
154 "hTruthNumMvtxVsTruthPt",
155 "hTruthNumMvtxVsNumTpc",
156 "hTrackNumMvtxVsTruthPt",
157 "hTrackNumMvtxVsNumTpc",
158 "hWeirdNumMvtxVsTruthPt",
159 "hWeirdNumMvtxVsNumTpc",
160 "hNormNumMvtxVsTruthPt",
161 "hNormNumMvtxVsNumTpc",
162 "hTruthNumTpcVsTruthPt",
163 "hTruthNumTpcVsNumTpc",
164 "hTrackNumTpcVsTruthPt",
165 "hTrackNumTpcVsNumTpc",
166 "hWeirdNumTpcVsTruthPt",
167 "hWeirdNumTpcVsNumTpc",
168 "hNormNumTpcVsTruthPt",
169 "hNormNumTpcVsNumTpc",
170 "hTruthRatTotVsTruthPt",
171 "hTruthRatTotVsNumTpc",
172 "hTrackRatTotVsTruthPt",
173 "hTrackRatTotVsNumTpc",
174 "hWeirdRatTotVsTruthPt",
175 "hWeirdRatTotVsNumTpc",
176 "hNormRatTotVsTruthPt",
177 "hNormRatTotVsNumTpc",
178 "hTruthRatInttVsTruthPt",
179 "hTruthRatInttVsNumTpc",
180 "hTrackRatInttVsTruthPt",
181 "hTrackRatInttVsNumTpc",
182 "hWeirdRatInttVsTruthPt",
183 "hWeirdRatInttVsNumTpc",
184 "hNormRatInttVsTruthPt",
185 "hNormRatInttVsNumTpc",
186 "hTruthRatMvtxVsTruthPt",
187 "hTruthRatMvtxVsNumTpc",
188 "hTrackRatMvtxVsTruthPt",
189 "hTrackRatMvtxVsNumTpc",
190 "hWeirdRatMvtxVsTruthPt",
191 "hWeirdRatMvtxVsNumTpc",
192 "hNormRatMvtxVsTruthPt",
193 "hNormRatMvtxVsNumTpc",
194 "hTruthRatTpcVsTruthPt",
195 "hTruthRatTpcVsNumTpc",
196 "hTrackRatTpcVsTruthPt",
197 "hTrackRatTpcVsNumTpc",
198 "hWeirdRatTpcVsTruthPt",
199 "hWeirdRatTpcVsNumTpc",
200 "hNormRatTpcVsTruthPt",
201 "hNormRatTpcVsNumTpc",
202 "hTruthPhiVsTruthPt",
204 "hTrackPhiVsTruthPt",
206 "hWeirdPhiVsTruthPt",
210 "hTruthEtaVsTruthPt",
212 "hTrackEtaVsTruthPt",
214 "hWeirdEtaVsTruthPt",
226 "hTruthFracVsTruthPt",
227 "hTruthFracVsNumTpc",
228 "hTrackFracVsTruthPt",
229 "hTrackFracVsNumTpc",
230 "hWeirdFracVsTruthPt",
231 "hWeirdFracVsNumTpc",
232 "hNormFracVsTruthPt",
237 vector<string> vecCanvasNames1D = {
287 vector<string> vecCanvasNames2D = {
288 "cTruthNumTotVsTruthPt",
289 "cTruthNumTotVsNumTpc",
290 "cTrackNumTotVsTruthPt",
291 "cTrackNumTotVsNumTpc",
292 "cWeirdNumTotVsTruthPt",
293 "cWeirdNumTotVsNumTpc",
294 "cNormNumTotVsTruthPt",
295 "cNormNumTotVsNumTpc",
296 "cTruthNumInttVsTruthPt",
297 "cTruthNumInttVsNumTpc",
298 "cTrackNumInttVsTruthPt",
299 "cTrackNumInttVsNumTpc",
300 "cWeirdNumInttVsTruthPt",
301 "cWeirdNumInttVsNumTpc",
302 "cNormNumInttVsTruthPt",
303 "cNormNumInttVsNumTpc",
304 "cTruthNumMvtxVsTruthPt",
305 "cTruthNumMvtxVsNumTpc",
306 "cTrackNumMvtxVsTruthPt",
307 "cTrackNumMvtxVsNumTpc",
308 "cWeirdNumMvtxVsTruthPt",
309 "cWeirdNumMvtxVsNumTpc",
310 "cNormNumMvtxVsTruthPt",
311 "cNormNumMvtxVsNumTpc",
312 "cTruthNumTpcVsTruthPt",
313 "cTruthNumTpcVsNumTpc",
314 "cTrackNumTpcVsTruthPt",
315 "cTrackNumTpcVsNumTpc",
316 "cWeirdNumTpcVsTruthPt",
317 "cWeirdNumTpcVsNumTpc",
318 "cNormNumTpcVsTruthPt",
319 "cNormNumTpcVsNumTpc",
320 "cTruthRatTotVsTruthPt",
321 "cTruthRatTotVsNumTpc",
322 "cTrackRatTotVsTruthPt",
323 "cTrackRatTotVsNumTpc",
324 "cWeirdRatTotVsTruthPt",
325 "cWeirdRatTotVsNumTpc",
326 "cNormRatTotVsTruthPt",
327 "cNormRatTotVsNumTpc",
328 "cTruthRatInttVsTruthPt",
329 "cTruthRatInttVsNumTpc",
330 "cTrackRatInttVsTruthPt",
331 "cTrackRatInttVsNumTpc",
332 "cWeirdRatInttVsTruthPt",
333 "cWeirdRatInttVsNumTpc",
334 "cNormRatInttVsTruthPt",
335 "cNormRatInttVsNumTpc",
336 "cTruthRatMvtxVsTruthPt",
337 "cTruthRatMvtxVsNumTpc",
338 "cTrackRatMvtxVsTruthPt",
339 "cTrackRatMvtxVsNumTpc",
340 "cWeirdRatMvtxVsTruthPt",
341 "cWeirdRatMvtxVsNumTpc",
342 "cNormRatMvtxVsTruthPt",
343 "cNormRatMvtxVsNumTpc",
344 "cTruthRatTpcVsTruthPt",
345 "cTruthRatTpcVsNumTpc",
346 "cTrackRatTpcVsTruthPt",
347 "cTrackRatTpcVsNumTpc",
348 "cWeirdRatTpcVsTruthPt",
349 "cWeirdRatTpcVsNumTpc",
350 "cNormRatTpcVsTruthPt",
351 "cNormRatTpcVsNumTpc",
352 "cTruthPhiVsTruthPt",
354 "cTrackPhiVsTruthPt",
356 "cWeirdPhiVsTruthPt",
360 "cTruthEtaVsTruthPt",
362 "cTrackEtaVsTruthPt",
364 "cWeirdEtaVsTruthPt",
376 "cTruthFracVsTruthPt",
377 "cTruthFracVsNumTpc",
378 "cTrackFracVsTruthPt",
379 "cTrackFracVsNumTpc",
380 "cWeirdFracVsTruthPt",
381 "cWeirdFracVsNumTpc",
382 "cNormFracVsTruthPt",
389 TFile* fOutput =
new TFile(sOutput.data(),
"recreate");
390 TFile* fInOld =
new TFile(sInOld.data(),
"read");
391 TFile* fInNew =
new TFile(sInNew.data(),
"read");
392 if (!fOutput || !fInOld || !fInNew) {
393 cerr <<
"PANIC: couldn't open a file!\n"
394 <<
" fOutput = " << fOutput <<
"fInOld = " << fInOld <<
", fInNew = " << fInNew <<
"\n"
398 cout <<
" Opened files." << endl;
401 vector<TH1D*> vecOldHists1D;
402 vector<TH1D*> vecNewHists1D;
403 vector<TH2D*> vecOldHists2D;
404 vector<TH2D*> vecNewHists2D;
405 for (
const string sInHist1D : vecInHists1D) {
406 vecOldHists1D.push_back((TH1D*) fInOld ->
Get(sInHist1D.data()));
407 vecNewHists1D.push_back((TH1D*) fInNew ->
Get(sInHist1D.data()));
408 if (!vecOldHists1D.back() || !vecNewHists1D.back()) {
409 cerr <<
"PANIC: couldn't grab the 1D histogram '" << sInHist1D <<
"' from an input file!\n"
410 <<
" hInOld1D = " << vecOldHists1D.back() <<
", hInNew1D = " << vecNewHists1D.back() <<
"\n"
415 for (
const string sInHist2D : vecInHists2D) {
416 vecOldHists2D.push_back((TH2D*) fInOld ->
Get(sInHist2D.data()));
417 vecNewHists2D.push_back((TH2D*) fInNew ->
Get(sInHist2D.data()));
418 if (!vecOldHists2D.back() || !vecNewHists2D.back()) {
419 cerr <<
"PANIC: couldn't grab the 2D histogram '" << sInHist2D <<
"' from an input file!\n"
420 <<
" hInOld2D = " << vecOldHists2D.back() <<
", hInNew2D = " << vecNewHists2D.back() <<
"\n"
425 cout <<
" Grabbed histograms." << endl;
431 for (TH1D* hOldHist1D : vecOldHists1D) {
432 const double intOld1D = hOldHist1D -> Integral();
434 hOldHist1D -> Scale(1. / intOld1D);
437 for (TH1D* hNewHist1D : vecNewHists1D) {
438 const double intNew1D = hNewHist1D -> Integral();
440 hNewHist1D -> Scale(1. / intNew1D);
443 for (TH2D* hOldHist2D : vecOldHists2D) {
444 const double intOld2D = hOldHist2D -> Integral();
446 hOldHist2D -> Scale(1. / intOld2D);
449 for (TH2D* hNewHist2D : vecNewHists2D) {
450 const double intNew2D = hNewHist2D -> Integral();
452 hNewHist2D -> Scale(1. / intNew2D);
455 cout <<
" Normalized histograms." << endl;
459 if (matchVertScales) {
460 size_t nHist2D = vecOldHists2D.size();
461 for (
size_t iHist2D = 0; iHist2D < nHist2D; iHist2D++) {
462 const float oldMin = vecOldHists2D[iHist2D] -> GetMinimum(0.);
463 const float oldMax = vecOldHists2D[iHist2D] -> GetMaximum();
464 const float newMin = vecNewHists2D[iHist2D] -> GetMinimum(0.);
465 const float newMax = vecNewHists2D[iHist2D] -> GetMaximum();
466 const float setMin =
min(oldMin, newMin);
467 const float setMax = max(oldMax, newMax);
468 vecOldHists2D[iHist2D] ->
GetZaxis() -> SetRangeUser(setMin, setMax);
469 vecNewHists2D[iHist2D] ->
GetZaxis() -> SetRangeUser(setMin, setMax);
471 cout <<
" Adjusted z-axis scales to match." << endl;
475 string sCountUse(
"");
484 vector<TH1D*> vecRatios1D(vecOldHists1D.size());
485 vector<TH2D*> vecRatios2D(vecOldHists2D.size());
486 for (
size_t iHist1D = 0; iHist1D < vecOldHists1D.size(); iHist1D++) {
489 TString sRatioName = vecOldHists1D.at(iHist1D) -> GetName();
490 sRatioName.Append(
"_");
491 sRatioName.Append(sRatioLabel.data());
493 vecRatios1D.at(iHist1D) = (TH1D*) vecOldHists1D.at(iHist1D) -> Clone();
494 vecRatios1D.at(iHist1D) ->
SetName(sRatioName.Data());
495 vecRatios1D.at(iHist1D) ->
Reset(
"ICES");
496 vecRatios1D.at(iHist1D) -> Divide(vecOldHists1D.at(iHist1D), vecNewHists1D.at(iHist1D), 1., 1.);
498 for (
size_t iHist2D = 0; iHist2D < vecOldHists2D.size(); iHist2D++) {
501 TString sRatioName = vecOldHists2D.at(iHist2D) -> GetName();
502 sRatioName.Append(
"_");
503 sRatioName.Append(sRatioLabel.data());
505 vecRatios2D.at(iHist2D) = (TH2D*) vecOldHists2D.at(iHist2D) -> Clone();
506 vecRatios2D.at(iHist2D) ->
SetName(sRatioName.Data());
507 vecRatios2D.at(iHist2D) ->
Reset(
"ICES");
508 vecRatios2D.at(iHist2D) -> Divide(vecOldHists2D.at(iHist2D), vecNewHists2D.at(iHist2D), 1., 1.);
510 cout <<
" Calculated ratios." << endl;
515 const uint32_t fTxt(42);
516 const uint32_t fAln(12);
517 const uint32_t fCnt(1);
518 const float fLabH[
NAxes] = {0.04, 0.04, 0.03};
519 const float fLabR1[
NAxes] = {0.074, 0.074, 0.056};
520 const float fLabR2[
NAxes] = {0.04, 0.04, 0.03};
521 const float fTitH[
NAxes] = {0.04, 0.04, 0.04};
522 const float fTitR1[
NAxes] = {0.074, 0.074, 0.056};
523 const float fTitR2[
NAxes] = {0.04, 0.04, 0.04};
524 const float fOffTH[
NAxes] = {1.0, 1.3, 1.2};
525 const float fOffTR1[
NAxes] = {0.8, 0.8, 1.0};
526 const float fOffTR2[
NAxes] = {1.0, 1.3, 1.2};
527 const float fOffLH[
NAxes] = {0.005, 0.005, 0.000};
528 const float fOffLR1[
NAxes] = {0.005, 0.005, 0.000};
529 const float fOffLR2[
NAxes] = {0.005, 0.005, 0.000};
532 for (TH1D* hOldHist1D : vecOldHists1D) {
535 TString sOldName = hOldHist1D -> GetName();
536 sOldName.Append(
"_");
537 sOldName.Append(sHistLabels.first.data());
540 hOldHist1D ->
SetName(sOldName.Data());
549 hOldHist1D -> SetTitleFont(fTxt);
550 hOldHist1D ->
GetXaxis() -> SetTitleFont(fTxt);
551 hOldHist1D ->
GetXaxis() -> SetTitleSize(fTitH[0]);
552 hOldHist1D ->
GetXaxis() -> SetTitleOffset(fOffTH[0]);
553 hOldHist1D ->
GetXaxis() -> SetLabelFont(fTxt);
554 hOldHist1D ->
GetXaxis() -> SetLabelSize(fLabH[0]);
555 hOldHist1D ->
GetXaxis() -> SetLabelOffset(fOffLH[0]);
556 hOldHist1D ->
GetXaxis() -> CenterTitle(fCnt);
558 hOldHist1D ->
GetYaxis() -> SetTitleFont(fTxt);
559 hOldHist1D ->
GetYaxis() -> SetTitleSize(fTitH[1]);
560 hOldHist1D ->
GetYaxis() -> SetTitleOffset(fOffTH[1]);
561 hOldHist1D ->
GetYaxis() -> SetLabelFont(fTxt);
562 hOldHist1D ->
GetYaxis() -> SetLabelSize(fLabH[1]);
563 hOldHist1D ->
GetYaxis() -> SetLabelOffset(fOffLH[1]);
564 hOldHist1D ->
GetYaxis() -> CenterTitle(fCnt);
566 for (TH2D* hOldHist2D : vecOldHists2D) {
569 TString sOldName = hOldHist2D -> GetName();
570 sOldName.Append(
"_");
571 sOldName.Append(sHistLabels.first.data());
574 hOldHist2D ->
SetName(sOldName.Data());
582 hOldHist2D ->
SetTitle(sLegOld.data());
583 hOldHist2D -> SetTitleFont(fTxt);
584 hOldHist2D ->
GetXaxis() -> SetTitleFont(fTxt);
585 hOldHist2D ->
GetXaxis() -> SetTitleSize(fTitH[0]);
586 hOldHist2D ->
GetXaxis() -> SetTitleOffset(fOffTH[0]);
587 hOldHist2D ->
GetXaxis() -> SetLabelFont(fTxt);
588 hOldHist2D ->
GetXaxis() -> SetLabelSize(fLabH[0]);
589 hOldHist2D ->
GetXaxis() -> SetLabelOffset(fOffLH[0]);
590 hOldHist2D ->
GetXaxis() -> CenterTitle(fCnt);
591 hOldHist2D ->
GetYaxis() -> SetTitleFont(fTxt);
592 hOldHist2D ->
GetYaxis() -> SetTitleSize(fTitH[1]);
593 hOldHist2D ->
GetYaxis() -> SetTitleOffset(fOffTH[1]);
594 hOldHist2D ->
GetYaxis() -> SetLabelFont(fTxt);
595 hOldHist2D ->
GetYaxis() -> SetLabelSize(fLabH[1]);
596 hOldHist2D ->
GetYaxis() -> SetLabelOffset(fOffLH[1]);
597 hOldHist2D ->
GetYaxis() -> CenterTitle(fCnt);
599 hOldHist2D ->
GetZaxis() -> SetTitleFont(fTxt);
600 hOldHist2D ->
GetZaxis() -> SetTitleSize(fTitH[2]);
601 hOldHist2D ->
GetZaxis() -> SetTitleOffset(fOffTH[2]);
602 hOldHist2D ->
GetZaxis() -> SetLabelFont(fTxt);
603 hOldHist2D ->
GetZaxis() -> SetLabelSize(fLabH[2]);
604 hOldHist2D ->
GetZaxis() -> SetLabelOffset(fOffLH[2]);
605 hOldHist2D ->
GetZaxis() -> CenterTitle(fCnt);
609 for (TH1D* hNewHist1D : vecNewHists1D) {
612 TString sNewName = hNewHist1D -> GetName();
613 sNewName.Append(
"_");
614 sNewName.Append(sHistLabels.second.data());
617 hNewHist1D ->
SetName(sNewName.Data());
626 hNewHist1D -> SetTitleFont(fTxt);
627 hNewHist1D ->
GetXaxis() -> SetTitleFont(fTxt);
628 hNewHist1D ->
GetXaxis() -> SetTitleSize(fTitH[0]);
629 hNewHist1D ->
GetXaxis() -> SetTitleOffset(fOffTH[0]);
630 hNewHist1D ->
GetXaxis() -> SetLabelFont(fTxt);
631 hNewHist1D ->
GetXaxis() -> SetLabelSize(fLabH[0]);
632 hNewHist1D ->
GetXaxis() -> SetLabelOffset(fOffLH[0]);
633 hNewHist1D ->
GetXaxis() -> CenterTitle(fCnt);
635 hNewHist1D ->
GetYaxis() -> SetTitleFont(fTxt);
636 hNewHist1D ->
GetYaxis() -> SetTitleSize(fTitH[1]);
637 hNewHist1D ->
GetYaxis() -> SetTitleOffset(fOffTH[1]);
638 hNewHist1D ->
GetYaxis() -> SetLabelFont(fTxt);
639 hNewHist1D ->
GetYaxis() -> SetLabelSize(fLabH[1]);
640 hNewHist1D ->
GetYaxis() -> SetLabelOffset(fOffLH[1]);
641 hNewHist1D ->
GetYaxis() -> CenterTitle(fCnt);
643 for (TH2D* hNewHist2D : vecNewHists2D) {
646 TString sNewName = hNewHist2D -> GetName();
647 sNewName.Append(
"_");
648 sNewName.Append(sHistLabels.second.data());
651 hNewHist2D ->
SetName(sNewName.Data());
659 hNewHist2D ->
SetTitle(sLegNew.data());
660 hNewHist2D -> SetTitleFont(fTxt);
661 hNewHist2D ->
GetXaxis() -> SetTitleFont(fTxt);
662 hNewHist2D ->
GetXaxis() -> SetTitleSize(fTitH[0]);
663 hNewHist2D ->
GetXaxis() -> SetTitleOffset(fOffTH[0]);
664 hNewHist2D ->
GetXaxis() -> SetLabelFont(fTxt);
665 hNewHist2D ->
GetXaxis() -> SetLabelSize(fLabH[0]);
666 hNewHist2D ->
GetXaxis() -> SetLabelOffset(fOffLH[0]);
667 hNewHist2D ->
GetXaxis() -> CenterTitle(fCnt);
668 hNewHist2D ->
GetYaxis() -> SetTitleFont(fTxt);
669 hNewHist2D ->
GetYaxis() -> SetTitleSize(fTitH[1]);
670 hNewHist2D ->
GetYaxis() -> SetTitleOffset(fOffTH[1]);
671 hNewHist2D ->
GetYaxis() -> SetLabelFont(fTxt);
672 hNewHist2D ->
GetYaxis() -> SetLabelSize(fLabH[1]);
673 hNewHist2D ->
GetYaxis() -> SetLabelOffset(fOffLH[1]);
674 hNewHist2D ->
GetYaxis() -> CenterTitle(fCnt);
676 hNewHist2D ->
GetZaxis() -> SetTitleFont(fTxt);
677 hNewHist2D ->
GetZaxis() -> SetTitleSize(fTitH[2]);
678 hNewHist2D ->
GetZaxis() -> SetTitleOffset(fOffTH[2]);
679 hNewHist2D ->
GetZaxis() -> SetLabelFont(fTxt);
680 hNewHist2D ->
GetZaxis() -> SetLabelSize(fLabH[2]);
681 hNewHist2D ->
GetZaxis() -> SetLabelOffset(fOffLH[2]);
682 hNewHist2D ->
GetZaxis() -> CenterTitle(fCnt);
687 for (TH1D* hRatio1D : vecRatios1D) {
696 hRatio1D -> SetTitleFont(fTxt);
697 hRatio1D ->
GetXaxis() -> SetTitleFont(fTxt);
698 hRatio1D ->
GetXaxis() -> SetTitleSize(fTitR1[0]);
699 hRatio1D ->
GetXaxis() -> SetTitleOffset(fOffTR1[0]);
700 hRatio1D ->
GetXaxis() -> SetLabelFont(fTxt);
701 hRatio1D ->
GetXaxis() -> SetLabelSize(fLabR1[0]);
702 hRatio1D ->
GetXaxis() -> SetLabelOffset(fOffLR1[0]);
703 hRatio1D ->
GetXaxis() -> CenterTitle(fCnt);
705 hRatio1D ->
GetYaxis() -> SetTitleFont(fTxt);
706 hRatio1D ->
GetYaxis() -> SetTitleSize(fTitR1[1]);
707 hRatio1D ->
GetYaxis() -> SetTitleOffset(fOffTR1[1]);
708 hRatio1D ->
GetYaxis() -> SetLabelFont(fTxt);
709 hRatio1D ->
GetYaxis() -> SetLabelSize(fLabR1[1]);
710 hRatio1D ->
GetYaxis() -> SetLabelOffset(fOffLR1[1]);
711 hRatio1D ->
GetYaxis() -> CenterTitle(fCnt);
713 for (TH2D* hRatio2D : vecRatios2D) {
722 hRatio2D -> SetTitleFont(fTxt);
723 hRatio2D ->
GetXaxis() -> SetTitleFont(fTxt);
724 hRatio2D ->
GetXaxis() -> SetTitleSize(fTitR2[0]);
725 hRatio2D ->
GetXaxis() -> SetTitleOffset(fOffTR2[0]);
726 hRatio2D ->
GetXaxis() -> SetLabelFont(fTxt);
727 hRatio2D ->
GetXaxis() -> SetLabelSize(fLabR2[0]);
728 hRatio2D ->
GetXaxis() -> SetLabelOffset(fOffLR2[0]);
729 hRatio2D ->
GetXaxis() -> CenterTitle(fCnt);
730 hRatio2D ->
GetYaxis() -> SetTitleFont(fTxt);
731 hRatio2D ->
GetYaxis() -> SetTitleSize(fTitR2[1]);
732 hRatio2D ->
GetYaxis() -> SetTitleOffset(fOffTR2[1]);
733 hRatio2D ->
GetYaxis() -> SetLabelFont(fTxt);
734 hRatio2D ->
GetYaxis() -> SetLabelSize(fLabR2[1]);
735 hRatio2D ->
GetYaxis() -> SetLabelOffset(fOffLR2[1]);
736 hRatio2D ->
GetYaxis() -> CenterTitle(fCnt);
738 hRatio2D ->
GetZaxis() -> SetTitleFont(fTxt);
739 hRatio2D ->
GetZaxis() -> SetTitleSize(fTitR2[2]);
740 hRatio2D ->
GetZaxis() -> SetTitleOffset(fOffTR2[2]);
741 hRatio2D ->
GetZaxis() -> SetLabelFont(fTxt);
742 hRatio2D ->
GetZaxis() -> SetLabelSize(fLabR2[2]);
743 hRatio2D ->
GetZaxis() -> SetLabelOffset(fOffLR2[2]);
744 hRatio2D ->
GetZaxis() -> CenterTitle(fCnt);
746 cout <<
" Set styles." << endl;
751 const uint32_t fColLe(0);
752 const uint32_t fFilLe(0);
753 const uint32_t fLinLe(0);
754 const float fLegXY[
NVtx] = {0.1, 0.1, 0.3, 0.2};
756 TLegend *
leg =
new TLegend(fLegXY[0], fLegXY[1], fLegXY[2], fLegXY[3], sHeader.data());
762 leg -> SetTextAlign(fAln);
763 leg ->
AddEntry(vecOldHists1D.front(), sLegOld.data(),
"pf");
764 leg ->
AddEntry(vecNewHists1D.front(), sLegNew.data(),
"pf");
765 cout <<
" Made legend." << endl;
768 const uint32_t fColTx(0);
769 const uint32_t fFilTx(0);
770 const uint32_t fLinTx(0);
771 const float fTxtXY[
NVtx] = {0.3, 0.1, 0.5, 0.25};
773 TPaveText *txt =
new TPaveText(fTxtXY[0], fTxtXY[1], fTxtXY[2], fTxtXY[3],
"NDC NB");
779 txt -> SetTextAlign(fAln);
780 for (
const string txtLine : vecTxt) {
781 txt -> AddText(txtLine.data());
783 cout <<
" Made text." << endl;
788 array<TDirectory*, NDir> arrOutDirs;
789 for (
size_t iDir = 0; iDir <
NDir; iDir++) {
790 arrOutDirs[iDir] = fOutput -> mkdir(arrDirNames[iDir].
data());
792 cout <<
" Made directories." << endl;
795 const uint32_t width1D(750);
796 const uint32_t width2D(1500);
797 const uint32_t width2DR(2250);
798 const uint32_t height(750);
799 const uint32_t heightR1(900);
800 const uint32_t heightR2(500);
801 const uint32_t fMode(0);
802 const uint32_t fBord(2);
803 const uint32_t fGrid(0);
804 const uint32_t fTick(1);
805 const uint32_t fLogX(0);
806 const uint32_t fLogY(1);
807 const uint32_t fLogZ(1);
808 const uint32_t fFrame(0);
809 const string sOldPadName(
"pOld");
810 const string sNewPadName(
"pNew");
811 const string sHistPadName(
"pHist");
812 const string sRatPadName(
"pRatio");
813 const float fMargin1D[
NSide] = {0.02, 0.02, 0.15, 0.15};
814 const float fMargin1DH[
NSide] = {0.02, 0.02, 0.005, 0.15};
815 const float fMargin1DR[
NSide] = {0.005, 0.02, 0.2, 0.15};
816 const float fMargin2D[
NSide] = {0.10, 0.15, 0.15, 0.15};
817 const float xyOldPad[
NVtx] = {0.0, 0.0, 0.5, 1.0};
818 const float xyOldPadR[
NVtx] = {0.0, 0.0, 0.33, 1.0};
819 const float xyNewPad[
NVtx] = {0.5, 0.0, 1.0, 1.0};
820 const float xyNewPadR[
NVtx] = {0.33, 0.0, 0.66, 1.0};
821 const float xyHistPadR[
NVtx] = {0.0, 0.33, 1.0, 1.0};
822 const float xyRatPadR1[
NVtx] = {0.0, 0.0, 1.0, 0.33};
823 const float xyRatPadR2[
NVtx] = {0.66, 0.0, 1.0, 1.0};
827 for (
const string sCanvasName : vecCanvasNames1D) {
830 TCanvas* cPlot1D =
new TCanvas(sCanvasName.data(),
"", width1D, height);
831 cPlot1D -> SetGrid(fGrid, fGrid);
832 cPlot1D -> SetTicks(fTick, fTick);
840 cPlot1D -> SetLogx(fLogX);
845 vecOldHists1D.at(iDraw1D) ->
Draw();
846 vecNewHists1D.at(iDraw1D) ->
Draw(
"same");
851 arrOutDirs[Dir::Plot] ->
cd();
860 for (
const string sCanvasName : vecCanvasNames1D) {
863 const string sNameWithRatio = sCanvasName +
"_" + sRatioLabel;
866 TCanvas* cPlot1D =
new TCanvas(sNameWithRatio.data(),
"", width1D, heightR1);
867 TPad* pPadH1D =
new TPad(sHistPadName.data(),
"", xyHistPadR[0], xyHistPadR[1], xyHistPadR[2], xyHistPadR[3]);
868 TPad* pPadR1D =
new TPad(sRatPadName.data(),
"", xyRatPadR1[0], xyRatPadR1[1], xyRatPadR1[2], xyRatPadR1[3]);
869 cPlot1D -> SetGrid(fGrid, fGrid);
870 cPlot1D -> SetTicks(fTick, fTick);
873 pPadH1D -> SetGrid(fGrid, fGrid);
874 pPadH1D -> SetTicks(fTick, fTick);
882 pPadH1D -> SetLogx(fLogX);
884 pPadR1D -> SetGrid(fGrid, fGrid);
885 pPadR1D -> SetTicks(fTick, fTick);
893 pPadR1D -> SetLogx(fLogX);
901 vecOldHists1D.at(iDraw1D) ->
Draw();
902 vecNewHists1D.at(iDraw1D) ->
Draw(
"same");
908 vecRatios1D.at(iDraw1D) ->
Draw();
911 arrOutDirs[Dir::Plot] ->
cd();
921 for (
const string sCanvasName : vecCanvasNames2D) {
924 TCanvas* cPlot2D =
new TCanvas(sCanvasName.data(),
"", width2D, height);
925 TPad* pOld =
new TPad(sOldPadName.data(),
"", xyOldPad[0], xyOldPad[1], xyOldPad[2], xyOldPad[3]);
926 TPad* pNew =
new TPad(sNewPadName.data(),
"", xyNewPad[0], xyNewPad[1], xyNewPad[2], xyNewPad[3]);
927 cPlot2D -> SetGrid(fGrid, fGrid);
928 cPlot2D -> SetTicks(fTick, fTick);
931 pOld -> SetGrid(fGrid, fGrid);
932 pOld -> SetTicks(fTick, fTick);
940 pOld -> SetLogx(fLogX);
942 pOld -> SetLogz(fLogZ);
943 pNew -> SetGrid(fGrid, fGrid);
944 pNew -> SetTicks(fTick, fTick);
952 pNew -> SetLogx(fLogX);
954 pNew -> SetLogz(fLogZ);
961 vecOldHists2D.at(iDraw2D) ->
Draw(
"colz");
963 vecNewHists2D.at(iDraw2D) ->
Draw(
"colz");
968 arrOutDirs[Dir::Plot] ->
cd();
977 for (
const string sCanvasName : vecCanvasNames2D) {
980 const string sNameWithRatio = sCanvasName +
"_" + sRatioLabel;
983 TCanvas* cPlot2D =
new TCanvas(sNameWithRatio.data(),
"", width2D, heightR2);
984 TPad* pOld =
new TPad(sOldPadName.data(),
"", xyOldPadR[0], xyOldPadR[1], xyOldPadR[2], xyOldPadR[3]);
985 TPad* pNew =
new TPad(sNewPadName.data(),
"", xyNewPadR[0], xyNewPadR[1], xyNewPadR[2], xyNewPadR[3]);
986 TPad* pRat =
new TPad(sRatPadName.data(),
"", xyRatPadR2[0], xyRatPadR2[1], xyRatPadR2[2], xyRatPadR2[3]);
987 cPlot2D -> SetGrid(fGrid, fGrid);
988 cPlot2D -> SetTicks(fTick, fTick);
991 pOld -> SetGrid(fGrid, fGrid);
992 pOld -> SetTicks(fTick, fTick);
1000 pOld -> SetLogx(fLogX);
1002 pOld -> SetLogz(fLogZ);
1003 pNew -> SetGrid(fGrid, fGrid);
1004 pNew -> SetTicks(fTick, fTick);
1012 pNew -> SetLogx(fLogX);
1014 pNew -> SetLogz(fLogZ);
1015 pRat -> SetGrid(fGrid, fGrid);
1016 pRat -> SetTicks(fTick, fTick);
1024 pRat -> SetLogx(fLogX);
1026 pRat -> SetLogz(fLogZ);
1034 vecOldHists2D.at(iDraw2D) ->
Draw(
"colz");
1037 vecNewHists2D.at(iDraw2D) ->
Draw(
"colz");
1039 vecRatios2D.at(iDraw2D) ->
Draw(
"colz");
1042 arrOutDirs[Dir::Plot] ->
cd();
1049 cout <<
" Made plots." << endl;
1055 for (TH1D* hOldHist1D : vecOldHists1D) {
1056 hOldHist1D ->
Write();
1058 for (TH2D* hOldHist2D : vecOldHists2D) {
1059 hOldHist2D ->
Write();
1063 arrOutDirs[Dir::New] ->
cd();
1064 for (TH1D* hNewHist1D : vecNewHists1D) {
1065 hNewHist1D ->
Write();
1067 for (TH2D* hNewHist2D : vecNewHists2D) {
1068 hNewHist2D ->
Write();
1072 arrOutDirs[Dir::Ratio] ->
cd();
1073 for (TH1D* hRatio1D : vecRatios1D) {
1074 hRatio1D ->
Write();
1076 for (TH2D* hRatio2D : vecRatios2D) {
1077 hRatio2D ->
Write();
1079 cout <<
" Saved histograms." << endl;
1090 cout <<
" Finished old vs. new comparison script!\n" << endl;