From b24a430cc8a8ef0b9c64e33f68e5b88714bc854b Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 4 Jan 2025 11:09:08 +0100 Subject: [PATCH 1/3] Update to the macros to study forwar-backward asymmetry in the correctin factors --- .../HcalCalibAlgos/macros/CalibFitPlots.C | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C index 04829e1b086f4..8f84d94a3e42a 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C +++ b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C @@ -77,8 +77,8 @@ // // For plotting (fractional) asymmetry in the correction factors // -// PlotHistCorrAsymmetry(infile, text, prefixF, iformat, save); -// Defaults: prefixF="", iformat=0, save=0 +// PlotHistCorrAsymmetry(infile, text, prefixF, depth, iformat, save); +// Defaults: prefixF="", depth = -1, iformat=0, save=0 // // For plotting correction factors from upto 5 different runs // on the same canvas @@ -2472,7 +2472,7 @@ void PlotHistCorrFactor(char* infile, } } -void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF = "", int iformat = 0, int save = 0) { +void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF = "", int depth = -1, int iformat = 0, int save = 0) { std::map cfacs; int etamin(100), etamax(-100), maxdepth(0); double scale(1.0); @@ -2492,21 +2492,23 @@ void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF = std::vector entries; char name[100]; double dy(0); - for (int j = 0; j < maxdepth; ++j) { - sprintf(name, "hd%d", j + 1); + int maxd = (depth < 0) ? maxdepth : 1; + for (int j = 0; j < maxd; ++j) { + int dep = (depth < 0) ? (j + 1) : depth; + sprintf(name, "hd%d", dep); TObject* ob = gROOT->FindObject(name); if (ob) ob->Delete(); TH1D* h = new TH1D(name, name, nbin, 0, etamax); int nent(0); for (std::map::const_iterator itr = cfacs.begin(); itr != cfacs.end(); ++itr) { - if ((itr->second).depth == j + 1) { + if ((itr->second).depth == dep) { int ieta = (itr->second).ieta; float vl1 = (itr->second).corrf; float dv1 = (itr->second).dcorr; if (ieta > 0) { for (std::map::const_iterator ktr = cfacs.begin(); ktr != cfacs.end(); ++ktr) { - if (((ktr->second).depth == j + 1) && ((ktr->second).ieta == -ieta)) { + if (((ktr->second).depth == dep) && ((ktr->second).ieta == -ieta)) { float vl2 = (ktr->second).corrf; float dv2 = (ktr->second).dcorr; float val = 2.0 * (vl1 - vl2) / (vl1 + vl2); @@ -2520,9 +2522,9 @@ void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF = } } } - h->SetLineColor(colors[j]); - h->SetMarkerColor(colors[j]); - h->SetMarkerStyle(mtype[j]); + h->SetLineColor(colors[dep - 1]); + h->SetMarkerColor(colors[dep - 1]); + h->SetMarkerStyle(mtype[dep - 1]); h->GetXaxis()->SetTitle("i#eta"); h->GetYaxis()->SetTitle("Asymmetry in Correction Factor"); h->GetYaxis()->SetLabelOffset(0.005); @@ -2532,7 +2534,10 @@ void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF = entries.push_back(nent); dy += 0.025; } - sprintf(name, "c_%sCorrAsymmetry", prefixF.c_str()); + if (depth < 0) + sprintf(name, "c_%sCorrAsymmetry", prefixF.c_str()); + else + sprintf(name, "c_%sCorrAsymmetryD%d", prefixF.c_str(), depth); TCanvas* pad = new TCanvas(name, name, 700, 500); pad->SetRightMargin(0.10); pad->SetTopMargin(0.10); @@ -2541,12 +2546,13 @@ void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF = TLegend* legend = new TLegend(0.60, yl, 0.90, yl + 0.035 * hists.size()); legend->SetFillColor(kWhite); for (unsigned int k = 0; k < hists.size(); ++k) { + int dep = (depth < 0) ? (k + 1) : depth; if (k == 0) hists[k]->Draw(""); else hists[k]->Draw("sames"); pad->Update(); - sprintf(name, "Depth %d (%s)", k + 1, text.c_str()); + sprintf(name, "Depth %d (%s)", dep, text.c_str()); legend->AddEntry(hists[k], name, "lp"); } legend->Draw("same"); From 0b91d5b1a559236f645a8d03b1f42ea4ef39bc7e Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 4 Jan 2025 11:36:09 +0100 Subject: [PATCH 2/3] Code check --- Calibration/HcalCalibAlgos/macros/CalibFitPlots.C | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C index 8f84d94a3e42a..6c5e6f278ce4a 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C +++ b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C @@ -2472,7 +2472,8 @@ void PlotHistCorrFactor(char* infile, } } -void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF = "", int depth = -1, int iformat = 0, int save = 0) { +void PlotHistCorrAsymmetry( + char* infile, std::string text, std::string prefixF = "", int depth = -1, int iformat = 0, int save = 0) { std::map cfacs; int etamin(100), etamax(-100), maxdepth(0); double scale(1.0); @@ -2494,7 +2495,7 @@ void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF = double dy(0); int maxd = (depth < 0) ? maxdepth : 1; for (int j = 0; j < maxd; ++j) { - int dep = (depth < 0) ? (j + 1) : depth; + int dep = (depth < 0) ? (j + 1) : depth; sprintf(name, "hd%d", dep); TObject* ob = gROOT->FindObject(name); if (ob) @@ -2546,7 +2547,7 @@ void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF = TLegend* legend = new TLegend(0.60, yl, 0.90, yl + 0.035 * hists.size()); legend->SetFillColor(kWhite); for (unsigned int k = 0; k < hists.size(); ++k) { - int dep = (depth < 0) ? (k + 1) : depth; + int dep = (depth < 0) ? (k + 1) : depth; if (k == 0) hists[k]->Draw(""); else From 73a3e58eebda44fb20fb6d644ca2173028773d61 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 6 Jan 2025 02:46:51 +0100 Subject: [PATCH 3/3] Fix as suggested by Andrea --- Calibration/HcalCalibAlgos/macros/CalibFitPlots.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C index 6c5e6f278ce4a..f1062d44c974e 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C +++ b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C @@ -2495,7 +2495,7 @@ void PlotHistCorrAsymmetry( double dy(0); int maxd = (depth < 0) ? maxdepth : 1; for (int j = 0; j < maxd; ++j) { - int dep = (depth < 0) ? (j + 1) : depth; + int dep = (depth <= 0) ? (j + 1) : depth; sprintf(name, "hd%d", dep); TObject* ob = gROOT->FindObject(name); if (ob)