Skip to content

Commit

Permalink
Merge pull request #47042 from bsunanda/Run3-alca252X
Browse files Browse the repository at this point in the history
Run3-alca252X Update the macros to study the forward-backward asymmetry in the correction factors
  • Loading branch information
cmsbuild authored Jan 6, 2025
2 parents b569e4a + 73a3e58 commit 803864d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions Calibration/HcalCalibAlgos/macros/CalibFitPlots.C
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2472,7 +2472,8 @@ 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<int, cfactors> cfacs;
int etamin(100), etamax(-100), maxdepth(0);
double scale(1.0);
Expand All @@ -2492,21 +2493,23 @@ void PlotHistCorrAsymmetry(char* infile, std::string text, std::string prefixF =
std::vector<int> 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<int, cfactors>::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<int, cfactors>::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);
Expand All @@ -2520,9 +2523,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);
Expand All @@ -2532,7 +2535,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);
Expand All @@ -2541,12 +2547,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");
Expand Down

0 comments on commit 803864d

Please sign in to comment.