Skip to content

Commit

Permalink
Code check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Jun 17, 2024
1 parent 1358163 commit b42f05f
Showing 1 changed file with 85 additions and 83 deletions.
168 changes: 85 additions & 83 deletions Calibration/HcalCalibAlgos/macros/CalibFitPlots.C
Original file line number Diff line number Diff line change
Expand Up @@ -2305,7 +2305,7 @@ void PlotHistCorrFactor(char* infile,

void PlotHistCorrFactor(char* infile,
std::string text,
int depth,
int depth,
std::string prefixF,
double scale = 1.0,
int nmin = 100,
Expand Down Expand Up @@ -2388,14 +2388,14 @@ void PlotHistCorrFactor(char* infile,
if (drawStatBox) {
TPaveStats* st1 = (TPaveStats*)hists[k]->GetListOfFunctions()->FindObject("stats");
if (st1 != nullptr) {
dy = (entries[k] > nmin) ? 0.05 : 0.025;
st1->SetLineColor(colors[k]);
st1->SetTextColor(colors[k]);
st1->SetY1NDC(yh - dy);
st1->SetY2NDC(yh);
st1->SetX1NDC(0.70);
st1->SetX2NDC(0.90);
yh -= dy;
dy = (entries[k] > nmin) ? 0.05 : 0.025;
st1->SetLineColor(colors[k]);
st1->SetTextColor(colors[k]);
st1->SetY1NDC(yh - dy);
st1->SetY2NDC(yh);
st1->SetX1NDC(0.70);
st1->SetX2NDC(0.90);
yh -= dy;
}
}
sprintf(name, "Depth %d (%s)", depth, text.c_str());
Expand Down Expand Up @@ -2640,10 +2640,10 @@ void PlotHistCorrFactors(char* infile1,
h->SetMarkerStyle(mtype[j]);
h->SetMarkerSize(0.9);
h->GetXaxis()->SetTitle("i#eta");
if (nfile > 2)
sprintf(name, "CF_{%s}/CF_{Set}", texts[0].c_str());
else
sprintf(name, "CF_{%s}/CF_{%s}", texts[0].c_str(), texts[ih].c_str());
if (nfile > 2)
sprintf(name, "CF_{%s}/CF_{Set}", texts[0].c_str());
else
sprintf(name, "CF_{%s}/CF_{%s}", texts[0].c_str(), texts[ih].c_str());
h->GetYaxis()->SetTitle(name);
h->GetYaxis()->SetLabelOffset(0.005);
h->GetYaxis()->SetTitleSize(0.036);
Expand Down Expand Up @@ -2832,80 +2832,82 @@ void PlotHistCorr2Factors(char* infile1,
int nline(0);
if (ratio) {
for (int ih = 1; ih < nfile; ++ih) {
sprintf(name, "h%dd%d", ih, depth);
TH1D* h = new TH1D(name, name, nbin, etamin, etamax);
double sumNum(0), sumDen(0);
std::map<int, cfactors>::const_iterator ktr = cfacs[ih].begin();
for (std::map<int, cfactors>::const_iterator itr = cfacs[0].begin(); itr != cfacs[0].end(); ++itr, ++ktr) {
int dep = (itr->second).depth;
if (dep == depth) {
int ieta = (itr->second).ieta;
int bin = ieta - etamin + 1;
float val = (itr->second).corrf / (ktr->second).corrf;
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)));
h->SetBinContent(bin, val);
h->SetBinError(bin, dvl);
sumNum += (val / (dvl * dvl));
sumDen += (1.0 / (dvl * dvl));
sprintf(name, "h%dd%d", ih, depth);
TH1D* h = new TH1D(name, name, nbin, etamin, etamax);
double sumNum(0), sumDen(0);
std::map<int, cfactors>::const_iterator ktr = cfacs[ih].begin();
for (std::map<int, cfactors>::const_iterator itr = cfacs[0].begin(); itr != cfacs[0].end(); ++itr, ++ktr) {
int dep = (itr->second).depth;
if (dep == depth) {
int ieta = (itr->second).ieta;
int bin = ieta - etamin + 1;
float val = (itr->second).corrf / (ktr->second).corrf;
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)));
h->SetBinContent(bin, val);
h->SetBinError(bin, dvl);
sumNum += (val / (dvl * dvl));
sumDen += (1.0 / (dvl * dvl));
}
}
double fit = (sumDen > 0) ? (sumNum / sumDen) : 1.0;
std::cout << "Fit to Pol0: " << fit << std::endl;
h->SetLineColor(colors[ih]);
h->SetMarkerColor(colors[ih]);
h->SetMarkerStyle(mtype[depth - 1]);
h->SetMarkerSize(0.9);
h->GetXaxis()->SetTitle("i#eta");
sprintf(name, "CF_{%s}/CF_{%s}", texts[0].c_str(), texts[1].c_str());
h->GetYaxis()->SetTitle(name);
h->GetYaxis()->SetLabelOffset(0.005);
h->GetYaxis()->SetTitleSize(0.036);
h->GetYaxis()->SetTitleOffset(1.20);
h->GetYaxis()->SetRangeUser(0.50, 1.50);
hists.push_back(h);
fitr.push_back(fit);
htype.push_back(ih);
++nline;
}
double fit = (sumDen > 0) ? (sumNum / sumDen) : 1.0;
std::cout << "Fit to Pol0: " << fit << std::endl;
h->SetLineColor(colors[ih]);
h->SetMarkerColor(colors[ih]);
h->SetMarkerStyle(mtype[depth - 1]);
h->SetMarkerSize(0.9);
h->GetXaxis()->SetTitle("i#eta");
sprintf(name, "CF_{%s}/CF_{%s}", texts[0].c_str(), texts[1].c_str());
h->GetYaxis()->SetTitle(name);
h->GetYaxis()->SetLabelOffset(0.005);
h->GetYaxis()->SetTitleSize(0.036);
h->GetYaxis()->SetTitleOffset(1.20);
h->GetYaxis()->SetRangeUser(0.50, 1.50);
hists.push_back(h);
fitr.push_back(fit);
htype.push_back(ih);
++nline;
}
} else {
for (int k1 = 0; k1 < nfile; ++k1) {
sprintf(name, "h%dd%d", k1, depth);
TH1D* h = new TH1D(name, name, nbin, etamin, etamax);
int nent(0);
for (std::map<int, cfactors>::const_iterator itr = cfacs[k1].begin(); itr != cfacs[k1].end(); ++itr) {
int dep = (itr->second).depth;
if (dep == depth) {
int ieta = (itr->second).ieta;
int bin = ieta - etamin + 1;
float val = (itr->second).corrf;
float dvl = (itr->second).dcorr;
h->SetBinContent(bin, val);
h->SetBinError(bin, dvl);
nent++;
}
}
if (nent > nmin) {
fits++;
if (drawStatBox)
dy += 0.025;
sprintf(name, "h%ddf%d", k1, depth);
TF1* func = new TF1(name, "pol0", etamin, etamax);
h->Fit(func, "+QWLR", "");
}
h->SetLineColor(colors[k1]);
h->SetMarkerColor(colors[k1]);
h->SetMarkerStyle(mtype[depth - 1]);
h->SetMarkerSize(0.9);
h->GetXaxis()->SetTitle("i#eta");
h->GetYaxis()->SetTitle("Correction Factor");
h->GetYaxis()->SetLabelOffset(0.005);
h->GetYaxis()->SetTitleOffset(1.20);
h->GetYaxis()->SetRangeUser(0.5, 1.5);
hists.push_back(h);
entries.push_back(nent);
if (drawStatBox)
dy += 0.025;
htype.push_back(k1);
sprintf(name, "h%dd%d", k1, depth);
TH1D* h = new TH1D(name, name, nbin, etamin, etamax);
int nent(0);
for (std::map<int, cfactors>::const_iterator itr = cfacs[k1].begin(); itr != cfacs[k1].end(); ++itr) {
int dep = (itr->second).depth;
if (dep == depth) {
int ieta = (itr->second).ieta;
int bin = ieta - etamin + 1;
float val = (itr->second).corrf;
float dvl = (itr->second).dcorr;
h->SetBinContent(bin, val);
h->SetBinError(bin, dvl);
nent++;
}
}
if (nent > nmin) {
fits++;
if (drawStatBox)
dy += 0.025;
sprintf(name, "h%ddf%d", k1, depth);
TF1* func = new TF1(name, "pol0", etamin, etamax);
h->Fit(func, "+QWLR", "");
}
h->SetLineColor(colors[k1]);
h->SetMarkerColor(colors[k1]);
h->SetMarkerStyle(mtype[depth - 1]);
h->SetMarkerSize(0.9);
h->GetXaxis()->SetTitle("i#eta");
h->GetYaxis()->SetTitle("Correction Factor");
h->GetYaxis()->SetLabelOffset(0.005);
h->GetYaxis()->SetTitleOffset(1.20);
h->GetYaxis()->SetRangeUser(0.5, 1.5);
hists.push_back(h);
entries.push_back(nent);
if (drawStatBox)
dy += 0.025;
htype.push_back(k1);
}
++nline;
}
Expand Down

0 comments on commit b42f05f

Please sign in to comment.