98 typedef std::vector<std::string>
vstring;
99 typedef std::map<unsigned long int, float> LUTINPUT;
101 static const int NVAR = 5;
102 static const int NDET = 2;
103 static const int NDEP = 7;
104 static const int NLEV = 3;
106 const bool doRatio[NVAR] = {
false,
true,
true,
false,
true};
107 const char* titleVar[NVAR] = {
"Pedestals",
"RespCorrs",
"Gains",
"Threshold",
"LUTs"};
108 const char* titleHisR[NLEV] = {
"Old",
"New",
"Ratio"};
109 const char* titleHisD[NLEV] = {
"Old",
"New",
"Difference"};
110 const char* titleDet[4] = {
"HBHE",
"HF",
"HEP17",
"HO"};
111 const int DEP[NDET] = {7, 4};
112 const char* titleDep[NDEP] = {
"depth1",
"depth2",
"depth3",
"depth4",
"depth5",
"depth6",
"depth7"};
115 TProfile*
p[NVAR][NDET];
117 TH2D*
h[NVAR][NLEV][NDET][NDEP];
122 for (
int d = 0;
d < 4; ++
d) {
123 for (
int i = 0;
i < 3; ++
i) {
124 hlut[
d][
i] =
new TH2D(Form(
"Lut_%s_%s", titleDet[
d], titleHisR[
i]),
125 Form(
"Input LUT, %s", (
i == 2 ?
"Ratio" :
tags_[
i].c_str())),
131 i == NLEV - 1 ? 3 : 2400);
132 hlut[
d][
i]->SetMarkerColor(
d == 0 ? kBlue :
d == 1 ? kGreen + 2 :
d == 2 ? kRed : kCyan);
133 hlut[
d][
i]->SetXTitle(
"raw adc");
134 hlut[
d][
i]->SetYTitle(
"lin adc");
138 for (
int d = 0;
d < NDET; ++
d) {
139 hslope[
d] =
new TH2D(
140 Form(
"GainLutScatter_%s", titleDet[
d]), Form(
"Gain-Lutslope scatter, %s", titleDet[
d]), 200, 0, 2, 200, 0, 2);
141 hslope[
d]->SetXTitle(
"Gain x RespCorr ratio");
142 hslope[
d]->SetYTitle(
"Lut ratio");
144 for (
int j = 0;
j < NVAR; ++
j) {
147 r[
j][
d] =
new TH2D(Form(
"r%s_%s", titleVar[
j], titleDet[
d]),
148 Form(
"%s, %s", titleVar[
j], titleDet[
d]),
155 r[
j][
d]->SetXTitle(
"iEta");
156 r[
j][
d]->SetYTitle(
doRatio[
j] ?
"New / Old" :
"New - Old");
157 p[
j][
d] =
new TProfile(
158 Form(
"p%s_%s", titleVar[
j], titleDet[
d]), Form(
"%s, %s", titleVar[
j], titleDet[
d]), 83, -41.5, 41.5);
159 p[
j][
d]->SetXTitle(
"iEta");
160 p[
j][
d]->SetYTitle(
doRatio[
j] ?
"New / Old" :
"New - Old");
161 p[
j][
d]->SetMarkerStyle(20);
162 p[
j][
d]->SetMarkerSize(0.9);
163 p[
j][
d]->SetMarkerColor(kBlue);
165 for (
int p = 0;
p < DEP[
d]; ++
p) {
166 for (
int i = 0;
i < NLEV; ++
i) {
167 const char* titHist =
doRatio[
j] ? titleHisR[
i] : titleHisD[
i];
168 h[
j][
i][
d][
p] =
new TH2D(Form(
"h%s_%s_%s_%s", titleVar[
j], titHist, titleDet[
d], titleDep[
p]),
169 Form(
"%s, %s, %s, %s", titleVar[
j], titHist, titleDet[
d], titleDep[
p]),
176 h[
j][
i][
d][
p]->SetXTitle(
"iEta");
177 h[
j][
i][
d][
p]->SetYTitle(
"iPhi");
183 for (
int i = 0;
i < 4; ++
i) {
184 int color =
i == 0 ? kBlue :
i == 1 ? kViolet :
i == 2 ? kGreen + 2 : kRed;
186 new TH2D(Form(
"houtlut0_%d",
i), Form(
"Output LUT, %s",
tags_[0].c_str()), 2100, 0, 2100, 260, 0, 260);
188 new TH2D(Form(
"houtlut1_%d",
i), Form(
"Output LUT, %s",
tags_[1].c_str()), 2100, 0, 2100, 260, 0, 260);
189 for (
int j = 0;
j < 2; ++
j) {
190 houtput[
i][
j]->SetMarkerColor(color);
191 houtput[
i][
j]->SetLineColor(color);
205 unsigned long int iraw;
208 float val1, val2, val3, val4;
209 float wid1, wid2, wid3, wid4;
212 std::vector<HcalDetId> BadChans[2];
213 std::vector<HcalDetId> ZeroLuts[2];
216 for (
int ii = 0;
ii < 2; ++
ii) {
225 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> iraw;
226 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
229 float theval = (val1 + val2 + val3 + val4) / 4.0;
239 std::ifstream infped(
244 while (!infped.eof()) {
245 infped.getline(
buffer, 1024);
248 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> wid1 >> wid2 >>
249 wid3 >> wid4 >> iraw;
250 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
253 float theval = (val1 + val2 + val3 + val4) / 4.0;
263 std::ifstream inresp(
268 while (!inresp.eof()) {
269 inresp.getline(
buffer, 1024);
272 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> iraw;
273 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
286 std::ifstream inchan(
291 while (!inchan.eof()) {
292 inchan.getline(
buffer, 1024);
305 BadChans[
ii].push_back(
id);
313 xmls2.create_lut_map();
315 for (
const auto& xml2 : xmls2) {
322 const auto& lut2 = xml2.second;
324 int D =
abs(tid.ieta()) < 29 ? (lut2.size() == 1024 ? 0 : 3) : tid.version() == 0 ? 1 : 2;
325 for (
size_t i = 0;
i < lut2.size(); ++
i) {
327 houtput[
D][1]->
Fill(
i, lut2[
i]);
332 int idet =
int(subdet);
333 const auto& lut2 = xml2.second;
335 for (
size_t i = 0;
i < lut2.size(); ++
i) {
336 hlut[
hbhe][1]->Fill(
i, lut2[
i]);
338 hlut[
hbhe][1]->Fill(
i, lut2[
i] & 0x3FF);
343 for (
const auto& xml1 : xmls1) {
345 const auto& lut1 = xml1.second;
351 int D =
abs(tid.ieta()) < 29 ? (lut1.size() == 1024 ? 0 : 3) : tid.version() == 0 ? 1 : 2;
352 for (
size_t i = 0;
i < lut1.size(); ++
i) {
354 houtput[
D][0]->
Fill(
i, lut1[
i]);
359 int idet =
int(subdet);
360 const auto& lut1 = xml1.second;
362 for (
size_t i = 0;
i < lut1.size(); ++
i) {
363 hlut[
hbhe][0]->Fill(
i, lut1[
i]);
365 hlut[
hbhe][0]->Fill(
i, lut1[
i] & 0x3FF);
369 auto xml2 = xmls2.find(detid.
rawId());
370 if (xml2 == xmls2.end())
379 int idet =
int(subdet);
380 int ieta =
id.ieta();
381 int iphi =
id.iphi();
382 int idep =
id.depth() - 1;
383 unsigned long int iraw =
id.rawId();
390 const auto& lut2 = xml2->second;
392 size_t size = lut1.size();
393 if (
size != lut2.size())
396 std::vector<unsigned int> llut1(
size);
397 std::vector<unsigned int> llut2(
size);
398 for (
size_t i = 0;
i <
size; ++
i) {
399 llut1[
i] =
hbhe == 0 ? lut1[
i] & 0x3FF : lut1[
i];
400 llut2[
i] =
hbhe == 0 ? lut2[
i] & 0x3FF : lut2[
i];
405 for (
size_t i = 0;
i <
size; ++
i) {
411 ZeroLuts[0].push_back(
id);
414 for (
size_t i = 0;
i <
size; ++
i) {
420 ZeroLuts[1].push_back(
id);
432 xfill = lutpede[1][iraw] - lutpede[0][iraw];
439 xfill = lutresp[1][iraw] / lutresp[0][iraw];
446 xfill = lutgain[1][iraw] / lutgain[0][iraw];
458 size_t maxvalue =
hbhe == 0 ? 1023 : 2047;
461 for (
size_t i = 0;
i <
size; ++
i) {
462 hlut[
hbhe][2]->Fill(
i, llut1[
i] == 0 ? 0 : (
double)llut2[
i] / llut1[
i]);
465 (llut1[
i] == maxvalue || llut2[
i] == maxvalue)) {
466 if (llut1[
i - 1] == 0 || llut2[
i - 1] == 0) {
469 double condratio = lutgain[1][iraw] / lutgain[0][iraw] * lutresp[1][iraw] / lutresp[0][iraw];
470 xfill = (double)llut2[
i - 1] / llut1[
i - 1];
471 hslope[
hbhe]->Fill(condratio, xfill);
484 gROOT->SetStyle(
"Plain");
485 gStyle->SetPalette(1);
486 gStyle->SetStatW(0.2);
487 gStyle->SetStatH(0.1);
488 gStyle->SetStatY(1.0);
489 gStyle->SetStatX(0.9);
490 gStyle->SetOptStat(110010);
491 gStyle->SetOptFit(111111);
494 TCanvas*
cc =
new TCanvas(
"cc",
"cc", 0, 0, 1600, 1200);
496 for (
int j = 0;
j < NVAR; ++
j) {
497 gSystem->mkdir(TString(
plotsDir) +
"/_" + titleVar[
j]);
498 for (
int d = 0;
d < NDET; ++
d) {
500 r[
j][
d]->Draw(
"colz");
501 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
r[
j][
d]->GetName()) +
".pdf");
509 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
p[
j][
d]->GetName()) +
".pdf");
511 for (
int i = 0;
i < NLEV; ++
i) {
512 for (
int p = 0;
p < DEP[
d]; ++
p) {
514 h[
j][
i][
d][
p]->Draw(
"colz");
521 h[
j][2][
d][
p]->SetMinimum(-3);
522 h[
j][2][
d][
p]->SetMaximum(3);
525 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
h[
j][
i][
d][
p]->GetName()) +
".pdf");
531 for (
int i = 0;
i < NLEV; ++
i) {
534 hlut[1][
i]->Draw(
"sames");
535 hlut[2][
i]->Draw(
"sames");
536 hlut[3][
i]->Draw(
"sames");
537 cc->Print(TString(
plotsDir) + Form(
"LUT_%d.gif",
i));
540 hslope[0]->Draw(
"colz");
543 cc->Print(TString(
plotsDir) +
"GainLutScatterHBHE.pdf");
545 hslope[1]->Draw(
"colz");
548 cc->Print(TString(
plotsDir) +
"GainLutScatterLutHF.pdf");
550 for (
int i = 0;
i < 2; ++
i) {
552 houtput[0][
i]->Draw(
"box");
553 houtput[1][
i]->Draw(
"samebox");
554 houtput[2][
i]->Draw(
"samebox");
555 houtput[3][
i]->Draw(
"samebox");
556 cc->Print(TString(
plotsDir) + Form(
"OUT_%d.gif",
i));