Skip to content

Commit 2bfdfe9

Browse files
author
Sunanda
committed
Code check
1 parent 6bb502b commit 2bfdfe9

File tree

1 file changed

+81
-79
lines changed

1 file changed

+81
-79
lines changed

Calibration/HcalCalibAlgos/macros/CalibFitPlots.C

Lines changed: 81 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,7 +2305,7 @@ void PlotHistCorrFactor(char* infile,
23052305

23062306
void PlotHistCorrFactor(char* infile,
23072307
std::string text,
2308-
int depth,
2308+
int depth,
23092309
std::string prefixF,
23102310
double scale = 1.0,
23112311
int nmin = 100,
@@ -2388,14 +2388,14 @@ void PlotHistCorrFactor(char* infile,
23882388
if (drawStatBox) {
23892389
TPaveStats* st1 = (TPaveStats*)hists[k]->GetListOfFunctions()->FindObject("stats");
23902390
if (st1 != nullptr) {
2391-
dy = (entries[k] > nmin) ? 0.05 : 0.025;
2392-
st1->SetLineColor(colors[k]);
2393-
st1->SetTextColor(colors[k]);
2394-
st1->SetY1NDC(yh - dy);
2395-
st1->SetY2NDC(yh);
2396-
st1->SetX1NDC(0.70);
2397-
st1->SetX2NDC(0.90);
2398-
yh -= dy;
2391+
dy = (entries[k] > nmin) ? 0.05 : 0.025;
2392+
st1->SetLineColor(colors[k]);
2393+
st1->SetTextColor(colors[k]);
2394+
st1->SetY1NDC(yh - dy);
2395+
st1->SetY2NDC(yh);
2396+
st1->SetX1NDC(0.70);
2397+
st1->SetX2NDC(0.90);
2398+
yh -= dy;
23992399
}
24002400
}
24012401
sprintf(name, "Depth %d (%s)", depth, text.c_str());
@@ -2829,80 +2829,82 @@ void PlotHistCorr2Factors(char* infile1,
28292829
int nline(0);
28302830
if (ratio) {
28312831
for (int ih = 1; ih < nfile; ++ih) {
2832-
sprintf(name, "h%dd%d", ih, depth);
2833-
TH1D* h = new TH1D(name, name, nbin, etamin, etamax);
2834-
double sumNum(0), sumDen(0);
2835-
std::map<int, cfactors>::const_iterator ktr = cfacs[ih].begin();
2836-
for (std::map<int, cfactors>::const_iterator itr = cfacs[0].begin(); itr != cfacs[0].end(); ++itr, ++ktr) {
2837-
int dep = (itr->second).depth;
2838-
if (dep == depth) {
2839-
int ieta = (itr->second).ieta;
2840-
int bin = ieta - etamin + 1;
2841-
float val = (itr->second).corrf / (ktr->second).corrf;
2842-
float dvl = val * sqrt((((itr->second).dcorr * (itr->second).dcorr) / ((itr->second).corrf * (itr->second).corrf)) + (((ktr->second).dcorr * (ktr->second).dcorr) / ((ktr->second).corrf * (ktr->second).corrf)));
2843-
h->SetBinContent(bin, val);
2844-
h->SetBinError(bin, dvl);
2845-
sumNum += (val / (dvl * dvl));
2846-
sumDen += (1.0 / (dvl * dvl));
2832+
sprintf(name, "h%dd%d", ih, depth);
2833+
TH1D* h = new TH1D(name, name, nbin, etamin, etamax);
2834+
double sumNum(0), sumDen(0);
2835+
std::map<int, cfactors>::const_iterator ktr = cfacs[ih].begin();
2836+
for (std::map<int, cfactors>::const_iterator itr = cfacs[0].begin(); itr != cfacs[0].end(); ++itr, ++ktr) {
2837+
int dep = (itr->second).depth;
2838+
if (dep == depth) {
2839+
int ieta = (itr->second).ieta;
2840+
int bin = ieta - etamin + 1;
2841+
float val = (itr->second).corrf / (ktr->second).corrf;
2842+
float dvl =
2843+
val * sqrt((((itr->second).dcorr * (itr->second).dcorr) / ((itr->second).corrf * (itr->second).corrf)) +
2844+
(((ktr->second).dcorr * (ktr->second).dcorr) / ((ktr->second).corrf * (ktr->second).corrf)));
2845+
h->SetBinContent(bin, val);
2846+
h->SetBinError(bin, dvl);
2847+
sumNum += (val / (dvl * dvl));
2848+
sumDen += (1.0 / (dvl * dvl));
28472849
}
2848-
}
2849-
double fit = (sumDen > 0) ? (sumNum / sumDen) : 1.0;
2850-
std::cout << "Fit to Pol0: " << fit << std::endl;
2851-
h->SetLineColor(colors[ih]);
2852-
h->SetMarkerColor(colors[ih]);
2853-
h->SetMarkerStyle(mtype[depth - 1]);
2854-
h->SetMarkerSize(0.9);
2855-
h->GetXaxis()->SetTitle("i#eta");
2856-
sprintf(name, "CF_{%s}/CF_{%s}", texts[0].c_str(), texts[1].c_str());
2857-
h->GetYaxis()->SetTitle(name);
2858-
h->GetYaxis()->SetLabelOffset(0.005);
2859-
h->GetYaxis()->SetTitleSize(0.036);
2860-
h->GetYaxis()->SetTitleOffset(1.20);
2861-
h->GetYaxis()->SetRangeUser(0.50, 1.50);
2862-
hists.push_back(h);
2863-
fitr.push_back(fit);
2864-
htype.push_back(ih);
2865-
++nline;
2850+
}
2851+
double fit = (sumDen > 0) ? (sumNum / sumDen) : 1.0;
2852+
std::cout << "Fit to Pol0: " << fit << std::endl;
2853+
h->SetLineColor(colors[ih]);
2854+
h->SetMarkerColor(colors[ih]);
2855+
h->SetMarkerStyle(mtype[depth - 1]);
2856+
h->SetMarkerSize(0.9);
2857+
h->GetXaxis()->SetTitle("i#eta");
2858+
sprintf(name, "CF_{%s}/CF_{%s}", texts[0].c_str(), texts[1].c_str());
2859+
h->GetYaxis()->SetTitle(name);
2860+
h->GetYaxis()->SetLabelOffset(0.005);
2861+
h->GetYaxis()->SetTitleSize(0.036);
2862+
h->GetYaxis()->SetTitleOffset(1.20);
2863+
h->GetYaxis()->SetRangeUser(0.50, 1.50);
2864+
hists.push_back(h);
2865+
fitr.push_back(fit);
2866+
htype.push_back(ih);
2867+
++nline;
28662868
}
28672869
} else {
28682870
for (int k1 = 0; k1 < nfile; ++k1) {
2869-
sprintf(name, "h%dd%d", k1, depth);
2870-
TH1D* h = new TH1D(name, name, nbin, etamin, etamax);
2871-
int nent(0);
2872-
for (std::map<int, cfactors>::const_iterator itr = cfacs[k1].begin(); itr != cfacs[k1].end(); ++itr) {
2873-
int dep = (itr->second).depth;
2874-
if (dep == depth) {
2875-
int ieta = (itr->second).ieta;
2876-
int bin = ieta - etamin + 1;
2877-
float val = (itr->second).corrf;
2878-
float dvl = (itr->second).dcorr;
2879-
h->SetBinContent(bin, val);
2880-
h->SetBinError(bin, dvl);
2881-
nent++;
2882-
}
2883-
}
2884-
if (nent > nmin) {
2885-
fits++;
2886-
if (drawStatBox)
2887-
dy += 0.025;
2888-
sprintf(name, "h%ddf%d", k1, depth);
2889-
TF1* func = new TF1(name, "pol0", etamin, etamax);
2890-
h->Fit(func, "+QWLR", "");
2891-
}
2892-
h->SetLineColor(colors[k1]);
2893-
h->SetMarkerColor(colors[k1]);
2894-
h->SetMarkerStyle(mtype[depth - 1]);
2895-
h->SetMarkerSize(0.9);
2896-
h->GetXaxis()->SetTitle("i#eta");
2897-
h->GetYaxis()->SetTitle("Correction Factor");
2898-
h->GetYaxis()->SetLabelOffset(0.005);
2899-
h->GetYaxis()->SetTitleOffset(1.20);
2900-
h->GetYaxis()->SetRangeUser(0.5, 1.5);
2901-
hists.push_back(h);
2902-
entries.push_back(nent);
2903-
if (drawStatBox)
2904-
dy += 0.025;
2905-
htype.push_back(k1);
2871+
sprintf(name, "h%dd%d", k1, depth);
2872+
TH1D* h = new TH1D(name, name, nbin, etamin, etamax);
2873+
int nent(0);
2874+
for (std::map<int, cfactors>::const_iterator itr = cfacs[k1].begin(); itr != cfacs[k1].end(); ++itr) {
2875+
int dep = (itr->second).depth;
2876+
if (dep == depth) {
2877+
int ieta = (itr->second).ieta;
2878+
int bin = ieta - etamin + 1;
2879+
float val = (itr->second).corrf;
2880+
float dvl = (itr->second).dcorr;
2881+
h->SetBinContent(bin, val);
2882+
h->SetBinError(bin, dvl);
2883+
nent++;
2884+
}
2885+
}
2886+
if (nent > nmin) {
2887+
fits++;
2888+
if (drawStatBox)
2889+
dy += 0.025;
2890+
sprintf(name, "h%ddf%d", k1, depth);
2891+
TF1* func = new TF1(name, "pol0", etamin, etamax);
2892+
h->Fit(func, "+QWLR", "");
2893+
}
2894+
h->SetLineColor(colors[k1]);
2895+
h->SetMarkerColor(colors[k1]);
2896+
h->SetMarkerStyle(mtype[depth - 1]);
2897+
h->SetMarkerSize(0.9);
2898+
h->GetXaxis()->SetTitle("i#eta");
2899+
h->GetYaxis()->SetTitle("Correction Factor");
2900+
h->GetYaxis()->SetLabelOffset(0.005);
2901+
h->GetYaxis()->SetTitleOffset(1.20);
2902+
h->GetYaxis()->SetRangeUser(0.5, 1.5);
2903+
hists.push_back(h);
2904+
entries.push_back(nent);
2905+
if (drawStatBox)
2906+
dy += 0.025;
2907+
htype.push_back(k1);
29062908
}
29072909
++nline;
29082910
}

0 commit comments

Comments
 (0)