Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:52

0001 // ----------------------------------------------------------------------------
0002 // 'CompareOldVsNewPlots.cxx'
0003 // Derek Anderson
0004 // 08.29.2023
0005 //
0006 // Construct a series of plots comparing the
0007 // output of the old evalautor vs. the new
0008 // truth-track matcher (ie. the output of
0009 // MakeOldEvaluatorPlots.cxx vs.
0010 // MakeNewMatcherPlots.cxx)
0011 // ----------------------------------------------------------------------------
0012 
0013 #include <cmath>
0014 #include <array>
0015 #include <string>
0016 #include <vector>
0017 #include <utility>
0018 #include <iostream>
0019 #include "TH1.h"
0020 #include "TH2.h"
0021 #include "TPad.h"
0022 #include "TFile.h"
0023 #include "TLine.h"
0024 #include "TError.h"
0025 #include "TString.h"
0026 #include "TLegend.h"
0027 #include "TCanvas.h"
0028 #include "TPaveText.h"
0029 #include "TDirectory.h"
0030 
0031 using namespace std;
0032 
0033 // global constants
0034 static const size_t NDir  = 4;
0035 static const size_t NVtx  = 4;
0036 static const size_t NSide = 4;
0037 static const size_t NAxes = 3;
0038 
0039 
0040 
0041 void CompareOldVsNewPlots() {
0042 
0043   // lower verbosity
0044   gErrorIgnoreLevel = kError;
0045   cout << "\n  Beginning old vs. new comparison script..." << endl;
0046 
0047   // options ------------------------------------------------------------------
0048 
0049   // io parameters
0050   const string sOutput("oldVsNewComparisonWithNoNorm_oneMatchPerParticle_zVtxCutComp_odd05150.pt10n1evt500pim.d1m2y2024.root");
0051   const string sInOld("oldEvalPlots_oneMatchPerParticle_embedScanOn_forZVtxCutComp_oddFrac05150.pt10n1evt500pim.d1m2y2024.root");
0052   const string sInNew("newMatcherTuplePlots_oneMatchPerParticle_forZVtxCutComp_oddFrac05150.pt10n1evt500pim.d1m2y2024.root");
0053 
0054   // style parameters
0055   const pair<uint32_t, uint32_t> fCol = {923, 899};
0056   const pair<uint32_t, uint32_t> fMar = {20,  25};
0057   const pair<uint32_t, uint32_t> fLin = {1,   1};
0058   const pair<uint32_t, uint32_t> fWid = {1,   1};
0059   const pair<uint32_t, uint32_t> fFil = {0,   0};
0060 
0061   // histogram parameters
0062   const string               sRatioLabel = "Ratio";
0063   const pair<string, string> sHistLabels = {"Old", "New"};
0064   const array<string, NDir>  arrDirNames = {"OldHists", "NewHists", "Ratios", "Plots"};
0065 
0066   // accessor for directories
0067   enum Dir {Old, New, Ratio, Plot};
0068 
0069   // text parameters
0070   const string         sLegOld = "evaluator";
0071   const string         sLegNew = "truth matcher";
0072   const string         sHeader = "";
0073   const string         sCount  = "counts";
0074   const string         sNorm   = "normalized counts";
0075   const string         sRatio  = "ratio";
0076   const vector<string> vecTxt  = {
0077     "#bf{#it{sPHENIX}} Simulation",
0078     "1 #pi^{-}/event, p_{T} = 10 GeV/c",
0079     "#bf{Only #pi^{-}}"
0080   };
0081 
0082   // plot parameters
0083   const bool doIntNorm       = false;
0084   const bool matchVertScales = true;
0085 
0086   // histograms to compare
0087   const vector<string> vecInHists1D = {
0088     "hTruthNumTot",
0089     "hTrackNumTot",
0090     "hWeirdNumTot",
0091     "hNormNumTot",
0092     "hTruthNumIntt",
0093     "hTrackNumIntt",
0094     "hWeirdNumIntt",
0095     "hNormNumIntt",
0096     "hTruthNumMvtx",
0097     "hTrackNumMvtx",
0098     "hWeirdNumMvtx",
0099     "hNormNumMvtx",
0100     "hTruthNumTpc",
0101     "hTrackNumTpc",
0102     "hWeirdNumTpc",
0103     "hNormNumTpc",
0104     "hTruthRatTot",
0105     "hTrackRatTot",
0106     "hWeirdRatTot",
0107     "hNormRatTot",
0108     "hTruthRatIntt",
0109     "hTrackRatIntt",
0110     "hWeirdRatIntt",
0111     "hNormRatIntt",
0112     "hTruthRatMvtx",
0113     "hTrackRatMvtx",
0114     "hWeirdRatMvtx",
0115     "hNormRatMvtx",
0116     "hTruthRatTpc",
0117     "hTrackRatTpc",
0118     "hWeirdRatTpc",
0119     "hNormRatTpc",
0120     "hTruthPhi",
0121     "hTrackPhi",
0122     "hWeirdPhi",
0123     "hNormPhi",
0124     "hTruthEta",
0125     "hTrackEta",
0126     "hWeirdEta",
0127     "hNormEta",
0128     "hTruthPt",
0129     "hTrackPt",
0130     "hWeirdPt",
0131     "hNormPt",
0132     "hTruthFrac",
0133     "hTrackFrac",
0134     "hWeirdFrac",
0135     "hNormFrac"
0136   };
0137   const vector<string> vecInHists2D = {
0138     "hTruthNumTotVsTruthPt",
0139     "hTruthNumTotVsNumTpc",
0140     "hTrackNumTotVsTruthPt",
0141     "hTrackNumTotVsNumTpc",
0142     "hWeirdNumTotVsTruthPt",
0143     "hWeirdNumTotVsNumTpc",
0144     "hNormNumTotVsTruthPt",
0145     "hNormNumTotVsNumTpc",
0146     "hTruthNumInttVsTruthPt",
0147     "hTruthNumInttVsNumTpc",
0148     "hTrackNumInttVsTruthPt",
0149     "hTrackNumInttVsNumTpc",
0150     "hWeirdNumInttVsTruthPt",
0151     "hWeirdNumInttVsNumTpc",
0152     "hNormNumInttVsTruthPt",
0153     "hNormNumInttVsNumTpc",
0154     "hTruthNumMvtxVsTruthPt",
0155     "hTruthNumMvtxVsNumTpc",
0156     "hTrackNumMvtxVsTruthPt",
0157     "hTrackNumMvtxVsNumTpc",
0158     "hWeirdNumMvtxVsTruthPt",
0159     "hWeirdNumMvtxVsNumTpc",
0160     "hNormNumMvtxVsTruthPt",
0161     "hNormNumMvtxVsNumTpc",
0162     "hTruthNumTpcVsTruthPt",
0163     "hTruthNumTpcVsNumTpc",
0164     "hTrackNumTpcVsTruthPt",
0165     "hTrackNumTpcVsNumTpc",
0166     "hWeirdNumTpcVsTruthPt",
0167     "hWeirdNumTpcVsNumTpc",
0168     "hNormNumTpcVsTruthPt",
0169     "hNormNumTpcVsNumTpc",
0170     "hTruthRatTotVsTruthPt",
0171     "hTruthRatTotVsNumTpc",
0172     "hTrackRatTotVsTruthPt",
0173     "hTrackRatTotVsNumTpc",
0174     "hWeirdRatTotVsTruthPt",
0175     "hWeirdRatTotVsNumTpc",
0176     "hNormRatTotVsTruthPt",
0177     "hNormRatTotVsNumTpc",
0178     "hTruthRatInttVsTruthPt",
0179     "hTruthRatInttVsNumTpc",
0180     "hTrackRatInttVsTruthPt",
0181     "hTrackRatInttVsNumTpc",
0182     "hWeirdRatInttVsTruthPt",
0183     "hWeirdRatInttVsNumTpc",
0184     "hNormRatInttVsTruthPt",
0185     "hNormRatInttVsNumTpc",
0186     "hTruthRatMvtxVsTruthPt",
0187     "hTruthRatMvtxVsNumTpc",
0188     "hTrackRatMvtxVsTruthPt",
0189     "hTrackRatMvtxVsNumTpc",
0190     "hWeirdRatMvtxVsTruthPt",
0191     "hWeirdRatMvtxVsNumTpc",
0192     "hNormRatMvtxVsTruthPt",
0193     "hNormRatMvtxVsNumTpc",
0194     "hTruthRatTpcVsTruthPt",
0195     "hTruthRatTpcVsNumTpc",
0196     "hTrackRatTpcVsTruthPt",
0197     "hTrackRatTpcVsNumTpc",
0198     "hWeirdRatTpcVsTruthPt",
0199     "hWeirdRatTpcVsNumTpc",
0200     "hNormRatTpcVsTruthPt",
0201     "hNormRatTpcVsNumTpc",
0202     "hTruthPhiVsTruthPt",
0203     "hTruthPhiVsNumTpc",
0204     "hTrackPhiVsTruthPt",
0205     "hTrackPhiVsNumTpc",
0206     "hWeirdPhiVsTruthPt",
0207     "hWeirdPhiVsNumTpc",
0208     "hNormPhiVsTruthPt",
0209     "hNormPhiVsNumTpc",
0210     "hTruthEtaVsTruthPt",
0211     "hTruthEtaVsNumTpc",
0212     "hTrackEtaVsTruthPt",
0213     "hTrackEtaVsNumTpc",
0214     "hWeirdEtaVsTruthPt",
0215     "hWeirdEtaVsNumTpc",
0216     "hNormEtaVsTruthPt",
0217     "hNormEtaVsNumTpc",
0218     "hTruthPtVsTruthPt",
0219     "hTruthPtVsNumTpc",
0220     "hTrackPtVsTruthPt",
0221     "hTrackPtVsNumTpc",
0222     "hWeirdPtVsTruthPt",
0223     "hWeirdPtVsNumTpc",
0224     "hNormPtVsTruthPt",
0225     "hNormPtVsNumTpc",
0226     "hTruthFracVsTruthPt",
0227     "hTruthFracVsNumTpc",
0228     "hTrackFracVsTruthPt",
0229     "hTrackFracVsNumTpc",
0230     "hWeirdFracVsTruthPt",
0231     "hWeirdFracVsNumTpc",
0232     "hNormFracVsTruthPt",
0233     "hNormFracVsNumTpc"
0234   };
0235 
0236   // canvas names
0237   vector<string> vecCanvasNames1D = {
0238     "cTruthNumTot",
0239     "cTrackNumTot",
0240     "cWeirdNumTot",
0241     "cNormNumTot",
0242     "cTruthNumIntt",
0243     "cTrackNumIntt",
0244     "cWeirdNumIntt",
0245     "cNormNumIntt",
0246     "cTruthNumMvtx",
0247     "cTrackNumMvtx",
0248     "cWeirdNumMvtx",
0249     "cNormNumMvtx",
0250     "cTruthNumTpc",
0251     "cTrackNumTpc",
0252     "cWeirdNumTpc",
0253     "cNormNumTpc",
0254     "cTruthRatTot",
0255     "cTrackRatTot",
0256     "cWeirdRatTot",
0257     "cNormRatTot",
0258     "cTruthRatIntt",
0259     "cTrackRatIntt",
0260     "cWeirdRatIntt",
0261     "cNormRatIntt",
0262     "cTruthRatMvtx",
0263     "cTrackRatMvtx",
0264     "cWeirdRatMvtx",
0265     "cNormRatMvtx",
0266     "cTruthRatTpc",
0267     "cTrackRatTpc",
0268     "cWeirdRatTpc",
0269     "cNormRatTpc",
0270     "cTruthPhi",
0271     "cTrackPhi",
0272     "cWeirdPhi",
0273     "cNormPhi",
0274     "cTruthEta",
0275     "cTrackEta",
0276     "cWeirdEta",
0277     "cNormEta",
0278     "cTruthPt",
0279     "cTrackPt",
0280     "cWeirdPt",
0281     "cNormPt",
0282     "cTruthFrac",
0283     "cTrackFrac",
0284     "cWeirdFrac",
0285     "cNormFrac"
0286   };
0287   vector<string> vecCanvasNames2D = {
0288     "cTruthNumTotVsTruthPt",
0289     "cTruthNumTotVsNumTpc",
0290     "cTrackNumTotVsTruthPt",
0291     "cTrackNumTotVsNumTpc",
0292     "cWeirdNumTotVsTruthPt",
0293     "cWeirdNumTotVsNumTpc",
0294     "cNormNumTotVsTruthPt",
0295     "cNormNumTotVsNumTpc",
0296     "cTruthNumInttVsTruthPt",
0297     "cTruthNumInttVsNumTpc",
0298     "cTrackNumInttVsTruthPt",
0299     "cTrackNumInttVsNumTpc",
0300     "cWeirdNumInttVsTruthPt",
0301     "cWeirdNumInttVsNumTpc",
0302     "cNormNumInttVsTruthPt",
0303     "cNormNumInttVsNumTpc",
0304     "cTruthNumMvtxVsTruthPt",
0305     "cTruthNumMvtxVsNumTpc",
0306     "cTrackNumMvtxVsTruthPt",
0307     "cTrackNumMvtxVsNumTpc",
0308     "cWeirdNumMvtxVsTruthPt",
0309     "cWeirdNumMvtxVsNumTpc",
0310     "cNormNumMvtxVsTruthPt",
0311     "cNormNumMvtxVsNumTpc",
0312     "cTruthNumTpcVsTruthPt",
0313     "cTruthNumTpcVsNumTpc",
0314     "cTrackNumTpcVsTruthPt",
0315     "cTrackNumTpcVsNumTpc",
0316     "cWeirdNumTpcVsTruthPt",
0317     "cWeirdNumTpcVsNumTpc",
0318     "cNormNumTpcVsTruthPt",
0319     "cNormNumTpcVsNumTpc",
0320     "cTruthRatTotVsTruthPt",
0321     "cTruthRatTotVsNumTpc",
0322     "cTrackRatTotVsTruthPt",
0323     "cTrackRatTotVsNumTpc",
0324     "cWeirdRatTotVsTruthPt",
0325     "cWeirdRatTotVsNumTpc",
0326     "cNormRatTotVsTruthPt",
0327     "cNormRatTotVsNumTpc",
0328     "cTruthRatInttVsTruthPt",
0329     "cTruthRatInttVsNumTpc",
0330     "cTrackRatInttVsTruthPt",
0331     "cTrackRatInttVsNumTpc",
0332     "cWeirdRatInttVsTruthPt",
0333     "cWeirdRatInttVsNumTpc",
0334     "cNormRatInttVsTruthPt",
0335     "cNormRatInttVsNumTpc",
0336     "cTruthRatMvtxVsTruthPt",
0337     "cTruthRatMvtxVsNumTpc",
0338     "cTrackRatMvtxVsTruthPt",
0339     "cTrackRatMvtxVsNumTpc",
0340     "cWeirdRatMvtxVsTruthPt",
0341     "cWeirdRatMvtxVsNumTpc",
0342     "cNormRatMvtxVsTruthPt",
0343     "cNormRatMvtxVsNumTpc",
0344     "cTruthRatTpcVsTruthPt",
0345     "cTruthRatTpcVsNumTpc",
0346     "cTrackRatTpcVsTruthPt",
0347     "cTrackRatTpcVsNumTpc",
0348     "cWeirdRatTpcVsTruthPt",
0349     "cWeirdRatTpcVsNumTpc",
0350     "cNormRatTpcVsTruthPt",
0351     "cNormRatTpcVsNumTpc",
0352     "cTruthPhiVsTruthPt",
0353     "cTruthPhiVsNumTpc",
0354     "cTrackPhiVsTruthPt",
0355     "cTrackPhiVsNumTpc",
0356     "cWeirdPhiVsTruthPt",
0357     "cWeirdPhiVsNumTpc",
0358     "cNormPhiVsTruthPt",
0359     "cNormPhiVsNumTpc",
0360     "cTruthEtaVsTruthPt",
0361     "cTruthEtaVsNumTpc",
0362     "cTrackEtaVsTruthPt",
0363     "cTrackEtaVsNumTpc",
0364     "cWeirdEtaVsTruthPt",
0365     "cWeirdEtaVsNumTpc",
0366     "cNormEtaVsTruthPt",
0367     "cNormEtaVsNumTpc",
0368     "cTruthPtVsTruthPt",
0369     "cTruthPtVsNumTpc",
0370     "cTrackPtVsTruthPt",
0371     "cTrackPtVsNumTpc",
0372     "cWeirdPtVsTruthPt",
0373     "cWeirdPtVsNumTpc",
0374     "cNormPtVsTruthPt",
0375     "cNormPtVsNumTpc",
0376     "cTruthFracVsTruthPt",
0377     "cTruthFracVsNumTpc",
0378     "cTrackFracVsTruthPt",
0379     "cTrackFracVsNumTpc",
0380     "cWeirdFracVsTruthPt",
0381     "cWeirdFracVsNumTpc",
0382     "cNormFracVsTruthPt",
0383     "cNormFracVsNumTpc"
0384   };
0385 
0386   // open files and load histograms -------------------------------------------
0387 
0388   // open files
0389   TFile* fOutput = new TFile(sOutput.data(), "recreate");
0390   TFile* fInOld  = new TFile(sInOld.data(),  "read");
0391   TFile* fInNew  = new TFile(sInNew.data(),  "read");
0392   if (!fOutput || !fInOld || !fInNew) {
0393      cerr << "PANIC: couldn't open a file!\n"
0394           << "       fOutput = " << fOutput << "fInOld = " << fInOld << ", fInNew = " << fInNew << "\n"
0395           << endl;
0396     return;
0397   }
0398   cout << "    Opened files." << endl;
0399 
0400   // grab histograms
0401   vector<TH1D*> vecOldHists1D;
0402   vector<TH1D*> vecNewHists1D;
0403   vector<TH2D*> vecOldHists2D;
0404   vector<TH2D*> vecNewHists2D;
0405   for (const string sInHist1D : vecInHists1D) {
0406     vecOldHists1D.push_back((TH1D*) fInOld -> Get(sInHist1D.data()));
0407     vecNewHists1D.push_back((TH1D*) fInNew -> Get(sInHist1D.data()));
0408     if (!vecOldHists1D.back() || !vecNewHists1D.back()) {
0409       cerr << "PANIC: couldn't grab the 1D histogram '" << sInHist1D << "' from an input file!\n"
0410            << "       hInOld1D = " << vecOldHists1D.back() << ", hInNew1D = " << vecNewHists1D.back() << "\n"
0411            << endl;
0412       return;
0413     }
0414   }
0415   for (const string sInHist2D : vecInHists2D) {
0416     vecOldHists2D.push_back((TH2D*) fInOld -> Get(sInHist2D.data()));
0417     vecNewHists2D.push_back((TH2D*) fInNew -> Get(sInHist2D.data()));
0418     if (!vecOldHists2D.back() || !vecNewHists2D.back()) {
0419       cerr << "PANIC: couldn't grab the 2D histogram '" << sInHist2D << "' from an input file!\n"
0420            << "       hInOld2D = " << vecOldHists2D.back() << ", hInNew2D = " << vecNewHists2D.back() << "\n"
0421            << endl;
0422       return;
0423     }
0424   }
0425   cout << "    Grabbed histograms." << endl;
0426 
0427   // normalize histograms and set axes' ranges as needed ----------------------
0428 
0429   // normalize by integral if needed
0430   if (doIntNorm) {
0431     for (TH1D* hOldHist1D : vecOldHists1D) {
0432       const double intOld1D = hOldHist1D -> Integral();
0433       if (intOld1D > 0.) {
0434         hOldHist1D -> Scale(1. / intOld1D);
0435       }
0436     }
0437     for (TH1D* hNewHist1D : vecNewHists1D) {
0438       const double intNew1D = hNewHist1D -> Integral();
0439       if (intNew1D > 0.) {
0440         hNewHist1D -> Scale(1. / intNew1D);
0441       }
0442     }
0443     for (TH2D* hOldHist2D : vecOldHists2D) {
0444       const double intOld2D = hOldHist2D -> Integral();
0445       if (intOld2D > 0.) {
0446         hOldHist2D -> Scale(1. / intOld2D);
0447       }
0448     }
0449     for (TH2D* hNewHist2D : vecNewHists2D) {
0450       const double intNew2D = hNewHist2D -> Integral();
0451       if (intNew2D > 0.) {
0452         hNewHist2D -> Scale(1. / intNew2D);
0453       }
0454     }
0455     cout << "    Normalized histograms." << endl;
0456   }
0457 
0458   // set z-axis ranges if needed
0459   if (matchVertScales) {
0460     size_t nHist2D = vecOldHists2D.size();
0461     for (size_t iHist2D = 0; iHist2D < nHist2D; iHist2D++) {
0462       const float oldMin = vecOldHists2D[iHist2D] -> GetMinimum(0.);
0463       const float oldMax = vecOldHists2D[iHist2D] -> GetMaximum();
0464       const float newMin = vecNewHists2D[iHist2D] -> GetMinimum(0.);
0465       const float newMax = vecNewHists2D[iHist2D] -> GetMaximum();
0466       const float setMin = min(oldMin, newMin);
0467       const float setMax = max(oldMax, newMax);
0468       vecOldHists2D[iHist2D] -> GetZaxis() -> SetRangeUser(setMin, setMax);
0469       vecNewHists2D[iHist2D] -> GetZaxis() -> SetRangeUser(setMin, setMax);
0470     }
0471     cout << "    Adjusted z-axis scales to match." << endl;
0472   }
0473 
0474   // pick relevant count
0475   string sCountUse("");
0476   if (doIntNorm) {
0477     sCountUse = sNorm;
0478   } else {
0479     sCountUse = sCount;
0480   }
0481 
0482   // calculate ratios ---------------------------------------------------------
0483 
0484   vector<TH1D*> vecRatios1D(vecOldHists1D.size());
0485   vector<TH2D*> vecRatios2D(vecOldHists2D.size());
0486   for (size_t iHist1D = 0; iHist1D < vecOldHists1D.size(); iHist1D++) {
0487 
0488     // make histogram name
0489     TString sRatioName = vecOldHists1D.at(iHist1D) -> GetName();
0490     sRatioName.Append("_");
0491     sRatioName.Append(sRatioLabel.data());
0492 
0493     vecRatios1D.at(iHist1D) = (TH1D*) vecOldHists1D.at(iHist1D) -> Clone();
0494     vecRatios1D.at(iHist1D) -> SetName(sRatioName.Data());
0495     vecRatios1D.at(iHist1D) -> Reset("ICES");
0496     vecRatios1D.at(iHist1D) -> Divide(vecOldHists1D.at(iHist1D), vecNewHists1D.at(iHist1D), 1., 1.);
0497   }
0498   for (size_t iHist2D = 0; iHist2D < vecOldHists2D.size(); iHist2D++) {
0499 
0500     // make histogram name
0501     TString sRatioName = vecOldHists2D.at(iHist2D) -> GetName();
0502     sRatioName.Append("_");
0503     sRatioName.Append(sRatioLabel.data());
0504 
0505     vecRatios2D.at(iHist2D) = (TH2D*) vecOldHists2D.at(iHist2D) -> Clone();
0506     vecRatios2D.at(iHist2D) -> SetName(sRatioName.Data());
0507     vecRatios2D.at(iHist2D) -> Reset("ICES");
0508     vecRatios2D.at(iHist2D) -> Divide(vecOldHists2D.at(iHist2D), vecNewHists2D.at(iHist2D), 1., 1.);
0509   }
0510   cout << "    Calculated ratios." << endl;
0511 
0512   // set histogram styles -----------------------------------------------------
0513 
0514   // style options
0515   const uint32_t fTxt(42);
0516   const uint32_t fAln(12);
0517   const uint32_t fCnt(1);
0518   const float    fLabH[NAxes]   = {0.04,  0.04,  0.03};
0519   const float    fLabR1[NAxes]  = {0.074, 0.074, 0.056};
0520   const float    fLabR2[NAxes]  = {0.04,  0.04,  0.03};
0521   const float    fTitH[NAxes]   = {0.04,  0.04,  0.04};
0522   const float    fTitR1[NAxes]  = {0.074, 0.074, 0.056};
0523   const float    fTitR2[NAxes]  = {0.04,  0.04,  0.04};
0524   const float    fOffTH[NAxes]  = {1.0,   1.3,   1.2};
0525   const float    fOffTR1[NAxes] = {0.8,   0.8,   1.0};
0526   const float    fOffTR2[NAxes] = {1.0,   1.3,   1.2};
0527   const float    fOffLH[NAxes]  = {0.005, 0.005, 0.000};
0528   const float    fOffLR1[NAxes] = {0.005, 0.005, 0.000};
0529   const float    fOffLR2[NAxes] = {0.005, 0.005, 0.000};
0530 
0531   // set old histogram styles
0532   for (TH1D* hOldHist1D : vecOldHists1D) {
0533 
0534     // label histogram accordingly
0535     TString sOldName = hOldHist1D -> GetName();
0536     sOldName.Append("_");
0537     sOldName.Append(sHistLabels.first.data());
0538 
0539     // set style
0540     hOldHist1D -> SetName(sOldName.Data());
0541     hOldHist1D -> SetMarkerColor(fCol.first);
0542     hOldHist1D -> SetMarkerStyle(fMar.first);
0543     hOldHist1D -> SetFillColor(fCol.first);
0544     hOldHist1D -> SetFillStyle(fFil.first);
0545     hOldHist1D -> SetLineColor(fCol.first);
0546     hOldHist1D -> SetLineStyle(fLin.first);
0547     hOldHist1D -> SetLineWidth(fWid.first);
0548     hOldHist1D -> SetTitle("");
0549     hOldHist1D -> SetTitleFont(fTxt);
0550     hOldHist1D -> GetXaxis() -> SetTitleFont(fTxt);
0551     hOldHist1D -> GetXaxis() -> SetTitleSize(fTitH[0]);
0552     hOldHist1D -> GetXaxis() -> SetTitleOffset(fOffTH[0]);
0553     hOldHist1D -> GetXaxis() -> SetLabelFont(fTxt);
0554     hOldHist1D -> GetXaxis() -> SetLabelSize(fLabH[0]);
0555     hOldHist1D -> GetXaxis() -> SetLabelOffset(fOffLH[0]);
0556     hOldHist1D -> GetXaxis() -> CenterTitle(fCnt);
0557     hOldHist1D -> GetYaxis() -> SetTitle(sCountUse.data());
0558     hOldHist1D -> GetYaxis() -> SetTitleFont(fTxt);
0559     hOldHist1D -> GetYaxis() -> SetTitleSize(fTitH[1]);
0560     hOldHist1D -> GetYaxis() -> SetTitleOffset(fOffTH[1]);
0561     hOldHist1D -> GetYaxis() -> SetLabelFont(fTxt);
0562     hOldHist1D -> GetYaxis() -> SetLabelSize(fLabH[1]);
0563     hOldHist1D -> GetYaxis() -> SetLabelOffset(fOffLH[1]);
0564     hOldHist1D -> GetYaxis() -> CenterTitle(fCnt);
0565   }
0566   for (TH2D* hOldHist2D : vecOldHists2D) {
0567 
0568     // label histogram accordingly
0569     TString sOldName = hOldHist2D -> GetName();
0570     sOldName.Append("_");
0571     sOldName.Append(sHistLabels.first.data());
0572 
0573     // set style
0574     hOldHist2D -> SetName(sOldName.Data());
0575     hOldHist2D -> SetMarkerColor(fCol.first);
0576     hOldHist2D -> SetMarkerStyle(fMar.first);
0577     hOldHist2D -> SetFillColor(fCol.first);
0578     hOldHist2D -> SetFillStyle(fFil.first);
0579     hOldHist2D -> SetLineColor(fCol.first);
0580     hOldHist2D -> SetLineStyle(fLin.first);
0581     hOldHist2D -> SetLineWidth(fWid.first);
0582     hOldHist2D -> SetTitle(sLegOld.data());
0583     hOldHist2D -> SetTitleFont(fTxt);
0584     hOldHist2D -> GetXaxis() -> SetTitleFont(fTxt);
0585     hOldHist2D -> GetXaxis() -> SetTitleSize(fTitH[0]);
0586     hOldHist2D -> GetXaxis() -> SetTitleOffset(fOffTH[0]);
0587     hOldHist2D -> GetXaxis() -> SetLabelFont(fTxt);
0588     hOldHist2D -> GetXaxis() -> SetLabelSize(fLabH[0]);
0589     hOldHist2D -> GetXaxis() -> SetLabelOffset(fOffLH[0]);
0590     hOldHist2D -> GetXaxis() -> CenterTitle(fCnt);
0591     hOldHist2D -> GetYaxis() -> SetTitleFont(fTxt);
0592     hOldHist2D -> GetYaxis() -> SetTitleSize(fTitH[1]);
0593     hOldHist2D -> GetYaxis() -> SetTitleOffset(fOffTH[1]);
0594     hOldHist2D -> GetYaxis() -> SetLabelFont(fTxt);
0595     hOldHist2D -> GetYaxis() -> SetLabelSize(fLabH[1]);
0596     hOldHist2D -> GetYaxis() -> SetLabelOffset(fOffLH[1]);
0597     hOldHist2D -> GetYaxis() -> CenterTitle(fCnt);
0598     hOldHist2D -> GetZaxis() -> SetTitle(sCountUse.data());
0599     hOldHist2D -> GetZaxis() -> SetTitleFont(fTxt);
0600     hOldHist2D -> GetZaxis() -> SetTitleSize(fTitH[2]);
0601     hOldHist2D -> GetZaxis() -> SetTitleOffset(fOffTH[2]);
0602     hOldHist2D -> GetZaxis() -> SetLabelFont(fTxt);
0603     hOldHist2D -> GetZaxis() -> SetLabelSize(fLabH[2]);
0604     hOldHist2D -> GetZaxis() -> SetLabelOffset(fOffLH[2]);
0605     hOldHist2D -> GetZaxis() -> CenterTitle(fCnt);
0606   }
0607 
0608   // set new histogram styles
0609   for (TH1D* hNewHist1D : vecNewHists1D) {
0610 
0611     // label histogram accordingly
0612     TString sNewName = hNewHist1D -> GetName();
0613     sNewName.Append("_");
0614     sNewName.Append(sHistLabels.second.data());
0615 
0616     // set style
0617     hNewHist1D -> SetName(sNewName.Data());
0618     hNewHist1D -> SetMarkerColor(fCol.second);
0619     hNewHist1D -> SetMarkerStyle(fMar.second);
0620     hNewHist1D -> SetFillColor(fCol.second);
0621     hNewHist1D -> SetFillStyle(fFil.second);
0622     hNewHist1D -> SetLineColor(fCol.second);
0623     hNewHist1D -> SetLineStyle(fLin.second);
0624     hNewHist1D -> SetLineWidth(fWid.second);
0625     hNewHist1D -> SetTitle("");
0626     hNewHist1D -> SetTitleFont(fTxt);
0627     hNewHist1D -> GetXaxis() -> SetTitleFont(fTxt);
0628     hNewHist1D -> GetXaxis() -> SetTitleSize(fTitH[0]);
0629     hNewHist1D -> GetXaxis() -> SetTitleOffset(fOffTH[0]);
0630     hNewHist1D -> GetXaxis() -> SetLabelFont(fTxt);
0631     hNewHist1D -> GetXaxis() -> SetLabelSize(fLabH[0]);
0632     hNewHist1D -> GetXaxis() -> SetLabelOffset(fOffLH[0]);
0633     hNewHist1D -> GetXaxis() -> CenterTitle(fCnt);
0634     hNewHist1D -> GetYaxis() -> SetTitle(sCountUse.data());
0635     hNewHist1D -> GetYaxis() -> SetTitleFont(fTxt);
0636     hNewHist1D -> GetYaxis() -> SetTitleSize(fTitH[1]);
0637     hNewHist1D -> GetYaxis() -> SetTitleOffset(fOffTH[1]);
0638     hNewHist1D -> GetYaxis() -> SetLabelFont(fTxt);
0639     hNewHist1D -> GetYaxis() -> SetLabelSize(fLabH[1]);
0640     hNewHist1D -> GetYaxis() -> SetLabelOffset(fOffLH[1]);
0641     hNewHist1D -> GetYaxis() -> CenterTitle(fCnt);
0642   }
0643   for (TH2D* hNewHist2D : vecNewHists2D) {
0644 
0645     // label histogram accordingly
0646     TString sNewName = hNewHist2D -> GetName();
0647     sNewName.Append("_");
0648     sNewName.Append(sHistLabels.second.data());
0649 
0650     // set style
0651     hNewHist2D -> SetName(sNewName.Data());
0652     hNewHist2D -> SetMarkerColor(fCol.first);
0653     hNewHist2D -> SetMarkerStyle(fMar.first);
0654     hNewHist2D -> SetFillColor(fCol.first);
0655     hNewHist2D -> SetFillStyle(fFil.first);
0656     hNewHist2D -> SetLineColor(fCol.first);
0657     hNewHist2D -> SetLineStyle(fLin.first);
0658     hNewHist2D -> SetLineWidth(fWid.first);
0659     hNewHist2D -> SetTitle(sLegNew.data());
0660     hNewHist2D -> SetTitleFont(fTxt);
0661     hNewHist2D -> GetXaxis() -> SetTitleFont(fTxt);
0662     hNewHist2D -> GetXaxis() -> SetTitleSize(fTitH[0]);
0663     hNewHist2D -> GetXaxis() -> SetTitleOffset(fOffTH[0]);
0664     hNewHist2D -> GetXaxis() -> SetLabelFont(fTxt);
0665     hNewHist2D -> GetXaxis() -> SetLabelSize(fLabH[0]);
0666     hNewHist2D -> GetXaxis() -> SetLabelOffset(fOffLH[0]);
0667     hNewHist2D -> GetXaxis() -> CenterTitle(fCnt);
0668     hNewHist2D -> GetYaxis() -> SetTitleFont(fTxt);
0669     hNewHist2D -> GetYaxis() -> SetTitleSize(fTitH[1]);
0670     hNewHist2D -> GetYaxis() -> SetTitleOffset(fOffTH[1]);
0671     hNewHist2D -> GetYaxis() -> SetLabelFont(fTxt);
0672     hNewHist2D -> GetYaxis() -> SetLabelSize(fLabH[1]);
0673     hNewHist2D -> GetYaxis() -> SetLabelOffset(fOffLH[1]);
0674     hNewHist2D -> GetYaxis() -> CenterTitle(fCnt);
0675     hNewHist2D -> GetZaxis() -> SetTitle(sCountUse.data());
0676     hNewHist2D -> GetZaxis() -> SetTitleFont(fTxt);
0677     hNewHist2D -> GetZaxis() -> SetTitleSize(fTitH[2]);
0678     hNewHist2D -> GetZaxis() -> SetTitleOffset(fOffTH[2]);
0679     hNewHist2D -> GetZaxis() -> SetLabelFont(fTxt);
0680     hNewHist2D -> GetZaxis() -> SetLabelSize(fLabH[2]);
0681     hNewHist2D -> GetZaxis() -> SetLabelOffset(fOffLH[2]);
0682     hNewHist2D -> GetZaxis() -> CenterTitle(fCnt);
0683   }
0684 
0685 
0686   // set ratio styles
0687   for (TH1D* hRatio1D : vecRatios1D) {
0688     hRatio1D -> SetMarkerColor(fCol.first);
0689     hRatio1D -> SetMarkerStyle(fMar.first);
0690     hRatio1D -> SetFillColor(fCol.first);
0691     hRatio1D -> SetFillStyle(fFil.first);
0692     hRatio1D -> SetLineColor(fCol.first);
0693     hRatio1D -> SetLineStyle(fLin.first);
0694     hRatio1D -> SetLineWidth(fWid.first);
0695     hRatio1D -> SetTitle("");
0696     hRatio1D -> SetTitleFont(fTxt);
0697     hRatio1D -> GetXaxis() -> SetTitleFont(fTxt);
0698     hRatio1D -> GetXaxis() -> SetTitleSize(fTitR1[0]);
0699     hRatio1D -> GetXaxis() -> SetTitleOffset(fOffTR1[0]);
0700     hRatio1D -> GetXaxis() -> SetLabelFont(fTxt);
0701     hRatio1D -> GetXaxis() -> SetLabelSize(fLabR1[0]);
0702     hRatio1D -> GetXaxis() -> SetLabelOffset(fOffLR1[0]);
0703     hRatio1D -> GetXaxis() -> CenterTitle(fCnt);
0704     hRatio1D -> GetYaxis() -> SetTitle(sRatio.data());
0705     hRatio1D -> GetYaxis() -> SetTitleFont(fTxt);
0706     hRatio1D -> GetYaxis() -> SetTitleSize(fTitR1[1]);
0707     hRatio1D -> GetYaxis() -> SetTitleOffset(fOffTR1[1]);
0708     hRatio1D -> GetYaxis() -> SetLabelFont(fTxt);
0709     hRatio1D -> GetYaxis() -> SetLabelSize(fLabR1[1]);
0710     hRatio1D -> GetYaxis() -> SetLabelOffset(fOffLR1[1]);
0711     hRatio1D -> GetYaxis() -> CenterTitle(fCnt);
0712   }
0713   for (TH2D* hRatio2D : vecRatios2D) {
0714     hRatio2D -> SetMarkerColor(fCol.first);
0715     hRatio2D -> SetMarkerStyle(fMar.first);
0716     hRatio2D -> SetFillColor(fCol.first);
0717     hRatio2D -> SetFillStyle(fFil.first);
0718     hRatio2D -> SetLineColor(fCol.first);
0719     hRatio2D -> SetLineStyle(fLin.first);
0720     hRatio2D -> SetLineWidth(fWid.first);
0721     hRatio2D -> SetTitle("");
0722     hRatio2D -> SetTitleFont(fTxt);
0723     hRatio2D -> GetXaxis() -> SetTitleFont(fTxt);
0724     hRatio2D -> GetXaxis() -> SetTitleSize(fTitR2[0]);
0725     hRatio2D -> GetXaxis() -> SetTitleOffset(fOffTR2[0]);
0726     hRatio2D -> GetXaxis() -> SetLabelFont(fTxt);
0727     hRatio2D -> GetXaxis() -> SetLabelSize(fLabR2[0]);
0728     hRatio2D -> GetXaxis() -> SetLabelOffset(fOffLR2[0]);
0729     hRatio2D -> GetXaxis() -> CenterTitle(fCnt);
0730     hRatio2D -> GetYaxis() -> SetTitleFont(fTxt);
0731     hRatio2D -> GetYaxis() -> SetTitleSize(fTitR2[1]);
0732     hRatio2D -> GetYaxis() -> SetTitleOffset(fOffTR2[1]);
0733     hRatio2D -> GetYaxis() -> SetLabelFont(fTxt);
0734     hRatio2D -> GetYaxis() -> SetLabelSize(fLabR2[1]);
0735     hRatio2D -> GetYaxis() -> SetLabelOffset(fOffLR2[1]);
0736     hRatio2D -> GetYaxis() -> CenterTitle(fCnt);
0737     hRatio2D -> GetZaxis() -> SetTitle(sRatio.data());
0738     hRatio2D -> GetZaxis() -> SetTitleFont(fTxt);
0739     hRatio2D -> GetZaxis() -> SetTitleSize(fTitR2[2]);
0740     hRatio2D -> GetZaxis() -> SetTitleOffset(fOffTR2[2]);
0741     hRatio2D -> GetZaxis() -> SetLabelFont(fTxt);
0742     hRatio2D -> GetZaxis() -> SetLabelSize(fLabR2[2]);
0743     hRatio2D -> GetZaxis() -> SetLabelOffset(fOffLR2[2]);
0744     hRatio2D -> GetZaxis() -> CenterTitle(fCnt);
0745   }
0746   cout << "    Set styles." << endl;
0747 
0748   // make legends and text boxes ----------------------------------------------
0749 
0750   // make legend
0751   const uint32_t fColLe(0);
0752   const uint32_t fFilLe(0);
0753   const uint32_t fLinLe(0);
0754   const float    fLegXY[NVtx] = {0.1, 0.1, 0.3, 0.2};
0755 
0756   TLegend *leg = new TLegend(fLegXY[0], fLegXY[1], fLegXY[2], fLegXY[3], sHeader.data());
0757   leg -> SetFillColor(fColLe);
0758   leg -> SetFillStyle(fFilLe);
0759   leg -> SetLineColor(fColLe);
0760   leg -> SetLineStyle(fLinLe);
0761   leg -> SetTextFont(fTxt);
0762   leg -> SetTextAlign(fAln);
0763   leg -> AddEntry(vecOldHists1D.front(), sLegOld.data(), "pf");
0764   leg -> AddEntry(vecNewHists1D.front(), sLegNew.data(), "pf");
0765   cout << "    Made legend." << endl;
0766 
0767   // make text
0768   const uint32_t fColTx(0);
0769   const uint32_t fFilTx(0);
0770   const uint32_t fLinTx(0);
0771   const float    fTxtXY[NVtx] = {0.3, 0.1, 0.5, 0.25};
0772 
0773   TPaveText *txt = new TPaveText(fTxtXY[0], fTxtXY[1], fTxtXY[2], fTxtXY[3], "NDC NB");
0774   txt -> SetFillColor(fColTx);
0775   txt -> SetFillStyle(fFilTx);
0776   txt -> SetLineColor(fColTx);
0777   txt -> SetLineStyle(fLinTx);
0778   txt -> SetTextFont(fTxt);
0779   txt -> SetTextAlign(fAln);
0780   for (const string txtLine : vecTxt) {
0781     txt -> AddText(txtLine.data());
0782   }
0783   cout << "    Made text." << endl;
0784 
0785   // make plots ---------------------------------------------------------------
0786 
0787   // create output directories
0788   array<TDirectory*, NDir> arrOutDirs;
0789   for (size_t iDir = 0; iDir < NDir; iDir++) {
0790     arrOutDirs[iDir] = fOutput -> mkdir(arrDirNames[iDir].data());
0791   }
0792   cout << "    Made directories." << endl;
0793 
0794   // canvas parameters
0795   const uint32_t width1D(750);
0796   const uint32_t width2D(1500);
0797   const uint32_t width2DR(2250);
0798   const uint32_t height(750);
0799   const uint32_t heightR1(900);
0800   const uint32_t heightR2(500);
0801   const uint32_t fMode(0);
0802   const uint32_t fBord(2);
0803   const uint32_t fGrid(0);
0804   const uint32_t fTick(1);
0805   const uint32_t fLogX(0);
0806   const uint32_t fLogY(1);
0807   const uint32_t fLogZ(1);
0808   const uint32_t fFrame(0);
0809   const string   sOldPadName("pOld");
0810   const string   sNewPadName("pNew");
0811   const string   sHistPadName("pHist");
0812   const string   sRatPadName("pRatio");
0813   const float    fMargin1D[NSide]  = {0.02,  0.02, 0.15,  0.15};
0814   const float    fMargin1DH[NSide] = {0.02,  0.02, 0.005, 0.15};
0815   const float    fMargin1DR[NSide] = {0.005, 0.02, 0.2,   0.15};
0816   const float    fMargin2D[NSide]  = {0.10, 0.15, 0.15, 0.15};
0817   const float    xyOldPad[NVtx]    = {0.0,  0.0,  0.5,  1.0};
0818   const float    xyOldPadR[NVtx]   = {0.0,  0.0,  0.33, 1.0};
0819   const float    xyNewPad[NVtx]    = {0.5,  0.0,  1.0,  1.0};  
0820   const float    xyNewPadR[NVtx]   = {0.33, 0.0,  0.66, 1.0};
0821   const float    xyHistPadR[NVtx]  = {0.0,  0.33, 1.0,  1.0};
0822   const float    xyRatPadR1[NVtx]  = {0.0,  0.0,  1.0,  0.33};
0823   const float    xyRatPadR2[NVtx]  = {0.66, 0.0,  1.0,  1.0};
0824 
0825   // make 1D plots
0826   size_t iDraw1D = 0;
0827   for (const string sCanvasName : vecCanvasNames1D) {
0828 
0829     // construct canvas
0830     TCanvas* cPlot1D = new TCanvas(sCanvasName.data(), "", width1D, height);
0831     cPlot1D -> SetGrid(fGrid, fGrid);
0832     cPlot1D -> SetTicks(fTick, fTick);
0833     cPlot1D -> SetBorderMode(fMode);
0834     cPlot1D -> SetBorderSize(fBord);
0835     cPlot1D -> SetFrameBorderMode(fFrame);
0836     cPlot1D -> SetTopMargin(fMargin1D[0]);
0837     cPlot1D -> SetRightMargin(fMargin1D[1]);
0838     cPlot1D -> SetBottomMargin(fMargin1D[2]);
0839     cPlot1D -> SetLeftMargin(fMargin1D[3]);
0840     cPlot1D -> SetLogx(fLogX);
0841     cPlot1D -> SetLogy(fLogY);
0842     cPlot1D -> cd();
0843 
0844     // draw old vs. new histograms
0845     vecOldHists1D.at(iDraw1D) -> Draw();
0846     vecNewHists1D.at(iDraw1D) -> Draw("same");
0847 
0848     // draw text and save
0849     leg                   -> Draw();
0850     txt                   -> Draw();
0851     arrOutDirs[Dir::Plot] -> cd();
0852     cPlot1D               -> Write();
0853     cPlot1D               -> Close();
0854 
0855     // increment counter
0856     ++iDraw1D;
0857   }
0858 
0859   iDraw1D = 0;
0860   for (const string sCanvasName : vecCanvasNames1D) {
0861 
0862     // make new name
0863     const string sNameWithRatio = sCanvasName + "_" + sRatioLabel;
0864 
0865     // construct canvas
0866     TCanvas* cPlot1D = new TCanvas(sNameWithRatio.data(), "", width1D, heightR1);
0867     TPad*    pPadH1D = new TPad(sHistPadName.data(), "", xyHistPadR[0], xyHistPadR[1], xyHistPadR[2], xyHistPadR[3]);
0868     TPad*    pPadR1D = new TPad(sRatPadName.data(),  "", xyRatPadR1[0], xyRatPadR1[1], xyRatPadR1[2], xyRatPadR1[3]);
0869     cPlot1D -> SetGrid(fGrid, fGrid);
0870     cPlot1D -> SetTicks(fTick, fTick);
0871     cPlot1D -> SetBorderMode(fMode);
0872     cPlot1D -> SetBorderSize(fBord);
0873     pPadH1D -> SetGrid(fGrid, fGrid);
0874     pPadH1D -> SetTicks(fTick, fTick);
0875     pPadH1D -> SetBorderMode(fMode);
0876     pPadH1D -> SetBorderSize(fBord);
0877     pPadH1D -> SetFrameBorderMode(fFrame);
0878     pPadH1D -> SetTopMargin(fMargin1DH[0]);
0879     pPadH1D -> SetRightMargin(fMargin1DH[1]);
0880     pPadH1D -> SetBottomMargin(fMargin1DH[2]);
0881     pPadH1D -> SetLeftMargin(fMargin1DH[3]);
0882     pPadH1D -> SetLogx(fLogX);
0883     pPadH1D -> SetLogy(fLogY);
0884     pPadR1D -> SetGrid(fGrid, fGrid);
0885     pPadR1D -> SetTicks(fTick, fTick);
0886     pPadR1D -> SetBorderMode(fMode);
0887     pPadR1D -> SetBorderSize(fBord);
0888     pPadR1D -> SetFrameBorderMode(fFrame);
0889     pPadR1D -> SetTopMargin(fMargin1DR[0]);
0890     pPadR1D -> SetRightMargin(fMargin1DR[1]);
0891     pPadR1D -> SetBottomMargin(fMargin1DR[2]);
0892     pPadR1D -> SetLeftMargin(fMargin1DR[3]);
0893     pPadR1D -> SetLogx(fLogX);
0894     pPadR1D -> SetLogy(fLogY);
0895     cPlot1D -> cd();
0896     pPadH1D -> Draw();
0897     pPadR1D -> Draw();
0898 
0899     // draw old vs. new histograms
0900     pPadH1D                   -> cd();
0901     vecOldHists1D.at(iDraw1D) -> Draw();
0902     vecNewHists1D.at(iDraw1D) -> Draw("same");
0903     leg                       -> Draw();
0904     txt                       -> Draw();
0905 
0906     // draw ratio
0907     pPadR1D                 -> cd();
0908     vecRatios1D.at(iDraw1D) -> Draw();
0909 
0910     // draw text and save
0911     arrOutDirs[Dir::Plot] -> cd();
0912     cPlot1D               -> Write();
0913     cPlot1D               -> Close();
0914 
0915     // increment counter
0916     ++iDraw1D;
0917   }
0918 
0919   // make 2D plots
0920   size_t iDraw2D = 0;
0921   for (const string sCanvasName : vecCanvasNames2D) {
0922 
0923     // construct canvas
0924     TCanvas* cPlot2D = new TCanvas(sCanvasName.data(), "", width2D, height);
0925     TPad*    pOld    = new TPad(sOldPadName.data(), "", xyOldPad[0], xyOldPad[1], xyOldPad[2], xyOldPad[3]);
0926     TPad*    pNew    = new TPad(sNewPadName.data(), "", xyNewPad[0], xyNewPad[1], xyNewPad[2], xyNewPad[3]);
0927     cPlot2D -> SetGrid(fGrid, fGrid);
0928     cPlot2D -> SetTicks(fTick, fTick);
0929     cPlot2D -> SetBorderMode(fMode);
0930     cPlot2D -> SetBorderSize(fBord);
0931     pOld    -> SetGrid(fGrid, fGrid);
0932     pOld    -> SetTicks(fTick, fTick);
0933     pOld    -> SetBorderMode(fMode);
0934     pOld    -> SetBorderSize(fBord);
0935     pOld    -> SetFrameBorderMode(fFrame);
0936     pOld    -> SetTopMargin(fMargin2D[0]);
0937     pOld    -> SetRightMargin(fMargin2D[1]);
0938     pOld    -> SetBottomMargin(fMargin2D[2]);
0939     pOld    -> SetLeftMargin(fMargin2D[3]);
0940     pOld    -> SetLogx(fLogX);
0941     pOld    -> SetLogy(fLogY);
0942     pOld    -> SetLogz(fLogZ);
0943     pNew    -> SetGrid(fGrid, fGrid);
0944     pNew    -> SetTicks(fTick, fTick);
0945     pNew    -> SetBorderMode(fMode);
0946     pNew    -> SetBorderSize(fBord);
0947     pNew    -> SetFrameBorderMode(fFrame);
0948     pNew    -> SetTopMargin(fMargin2D[0]);
0949     pNew    -> SetRightMargin(fMargin2D[1]);
0950     pNew    -> SetBottomMargin(fMargin2D[2]);
0951     pNew    -> SetLeftMargin(fMargin2D[3]);
0952     pNew    -> SetLogx(fLogX);
0953     pNew    -> SetLogy(fLogY);
0954     pNew    -> SetLogz(fLogZ);
0955     cPlot2D -> cd();
0956     pOld    -> Draw();
0957     pNew    -> Draw();
0958 
0959     // draw old vs. new histograms
0960     pOld                      -> cd();
0961     vecOldHists2D.at(iDraw2D) -> Draw("colz");
0962     pNew                      -> cd();
0963     vecNewHists2D.at(iDraw2D) -> Draw("colz");
0964 
0965     // draw text and save
0966     pNew                  -> cd();
0967     txt                   -> Draw();
0968     arrOutDirs[Dir::Plot] -> cd();
0969     cPlot2D               -> Write();
0970     cPlot2D               -> Close();
0971 
0972     // increment counter
0973     ++iDraw2D;
0974   }
0975 
0976   iDraw2D = 0;
0977   for (const string sCanvasName : vecCanvasNames2D) {
0978 
0979     // make new name
0980     const string sNameWithRatio = sCanvasName + "_" + sRatioLabel;
0981 
0982     // construct canvas
0983     TCanvas* cPlot2D = new TCanvas(sNameWithRatio.data(), "", width2D, heightR2);
0984     TPad*    pOld    = new TPad(sOldPadName.data(), "", xyOldPadR[0],  xyOldPadR[1],  xyOldPadR[2],  xyOldPadR[3]);
0985     TPad*    pNew    = new TPad(sNewPadName.data(), "", xyNewPadR[0],  xyNewPadR[1],  xyNewPadR[2],  xyNewPadR[3]);
0986     TPad*    pRat    = new TPad(sRatPadName.data(), "", xyRatPadR2[0], xyRatPadR2[1], xyRatPadR2[2], xyRatPadR2[3]);
0987     cPlot2D -> SetGrid(fGrid, fGrid);
0988     cPlot2D -> SetTicks(fTick, fTick);
0989     cPlot2D -> SetBorderMode(fMode);
0990     cPlot2D -> SetBorderSize(fBord);
0991     pOld    -> SetGrid(fGrid, fGrid);
0992     pOld    -> SetTicks(fTick, fTick);
0993     pOld    -> SetBorderMode(fMode);
0994     pOld    -> SetBorderSize(fBord);
0995     pOld    -> SetFrameBorderMode(fFrame);
0996     pOld    -> SetTopMargin(fMargin2D[0]);
0997     pOld    -> SetRightMargin(fMargin2D[1]);
0998     pOld    -> SetBottomMargin(fMargin2D[2]);
0999     pOld    -> SetLeftMargin(fMargin2D[3]);
1000     pOld    -> SetLogx(fLogX);
1001     pOld    -> SetLogy(fLogY);
1002     pOld    -> SetLogz(fLogZ);
1003     pNew    -> SetGrid(fGrid, fGrid);
1004     pNew    -> SetTicks(fTick, fTick);
1005     pNew    -> SetBorderMode(fMode);
1006     pNew    -> SetBorderSize(fBord);
1007     pNew    -> SetFrameBorderMode(fFrame);
1008     pNew    -> SetTopMargin(fMargin2D[0]);
1009     pNew    -> SetRightMargin(fMargin2D[1]);
1010     pNew    -> SetBottomMargin(fMargin2D[2]);
1011     pNew    -> SetLeftMargin(fMargin2D[3]);
1012     pNew    -> SetLogx(fLogX);
1013     pNew    -> SetLogy(fLogY);
1014     pNew    -> SetLogz(fLogZ);
1015     pRat    -> SetGrid(fGrid, fGrid);
1016     pRat    -> SetTicks(fTick, fTick);
1017     pRat    -> SetBorderMode(fMode);
1018     pRat    -> SetBorderSize(fBord);
1019     pRat    -> SetFrameBorderMode(fFrame);
1020     pRat    -> SetTopMargin(fMargin2D[0]);
1021     pRat    -> SetRightMargin(fMargin2D[1]);
1022     pRat    -> SetBottomMargin(fMargin2D[2]);
1023     pRat    -> SetLeftMargin(fMargin2D[3]);
1024     pRat    -> SetLogx(fLogX);
1025     pRat    -> SetLogy(fLogY);
1026     pRat    -> SetLogz(fLogZ);
1027     cPlot2D -> cd();
1028     pOld    -> Draw();
1029     pNew    -> Draw();
1030     pRat    -> Draw();
1031 
1032     // draw old vs. new vs. ratio histograms
1033     pOld                      -> cd();
1034     vecOldHists2D.at(iDraw2D) -> Draw("colz");
1035     txt                       -> Draw();
1036     pNew                      -> cd();
1037     vecNewHists2D.at(iDraw2D) -> Draw("colz");
1038     pRat                      -> cd();
1039     vecRatios2D.at(iDraw2D)   -> Draw("colz");
1040 
1041     // draw text and save
1042     arrOutDirs[Dir::Plot] -> cd();
1043     cPlot2D               -> Write();
1044     cPlot2D               -> Close();
1045 
1046     // increment counter
1047     ++iDraw2D;
1048   }
1049   cout << "    Made plots." << endl; 
1050 
1051   // save histogarms and close ------------------------------------------------
1052 
1053   // save old histograms
1054   arrOutDirs[Dir::Old] -> cd();
1055   for (TH1D* hOldHist1D : vecOldHists1D) {
1056     hOldHist1D -> Write();
1057   }
1058   for (TH2D* hOldHist2D : vecOldHists2D) {
1059     hOldHist2D -> Write();
1060   }
1061 
1062   // save new histograms
1063   arrOutDirs[Dir::New] -> cd();
1064   for (TH1D* hNewHist1D : vecNewHists1D) {
1065     hNewHist1D -> Write();
1066   }
1067   for (TH2D* hNewHist2D : vecNewHists2D) {
1068     hNewHist2D -> Write();
1069   }
1070 
1071   // save ratio histograms
1072   arrOutDirs[Dir::Ratio] -> cd();
1073   for (TH1D* hRatio1D : vecRatios1D) {
1074     hRatio1D -> Write();
1075   }
1076   for (TH2D* hRatio2D : vecRatios2D) {
1077     hRatio2D -> Write();
1078   }
1079   cout << "    Saved histograms." << endl;
1080 
1081   // close files
1082   fOutput -> cd();
1083   fOutput -> Close();
1084   fInOld  -> cd();
1085   fInOld  -> Close();
1086   fInNew  -> cd();
1087   fInNew  -> Close();
1088 
1089   // exit
1090   cout << "  Finished old vs. new comparison script!\n" << endl;
1091   return;
1092 
1093 }
1094 
1095 // end ------------------------------------------------------------------------