92 tok_htopo_ = esConsumes<HcalTopology, HcalRecNumberingRecord>();
100 typedef std::vector<std::string>
vstring;
101 typedef std::map<unsigned long int, float> LUTINPUT;
103 static const int NVAR = 5;
104 static const int NDET = 2;
105 static const int NDEP = 7;
106 static const int NLEV = 3;
108 const bool doRatio[NVAR] = {
false,
true,
true,
false,
true};
109 const char* titleVar[NVAR] = {
"Pedestals",
"RespCorrs",
"Gains",
"Threshold",
"LUTs"};
110 const char* titleHisR[NLEV] = {
"Old",
"New",
"Ratio"};
111 const char* titleHisD[NLEV] = {
"Old",
"New",
"Difference"};
112 const char* titleDet[4] = {
"HBHE",
"HF",
"HEP17",
"HO"};
113 const int DEP[NDET] = {7, 4};
114 const char* titleDep[NDEP] = {
"depth1",
"depth2",
"depth3",
"depth4",
"depth5",
"depth6",
"depth7"};
117 TProfile*
p[NVAR][NDET];
119 TH2D*
h[NVAR][NLEV][NDET][NDEP];
124 for (
int d = 0;
d < 4; ++
d) {
125 for (
int i = 0;
i < 3; ++
i) {
126 hlut[
d][
i] =
new TH2D(Form(
"Lut_%s_%s", titleDet[
d], titleHisR[
i]),
127 Form(
"Input LUT, %s", (
i == 2 ?
"Ratio" :
tags_[
i].c_str())),
133 i == NLEV - 1 ? 3 : 2400);
134 hlut[
d][
i]->SetMarkerColor(
d == 0 ? kBlue :
d == 1 ? kGreen + 2 :
d == 2 ? kRed : kCyan);
135 hlut[
d][
i]->SetXTitle(
"raw adc");
136 hlut[
d][
i]->SetYTitle(
"lin adc");
140 for (
int d = 0;
d < NDET; ++
d) {
141 hslope[
d] =
new TH2D(
142 Form(
"GainLutScatter_%s", titleDet[
d]), Form(
"Gain-Lutslope scatter, %s", titleDet[
d]), 200, 0, 2, 200, 0, 2);
143 hslope[
d]->SetXTitle(
"Gain x RespCorr ratio");
144 hslope[
d]->SetYTitle(
"Lut ratio");
146 for (
int j = 0;
j < NVAR; ++
j) {
149 r[
j][
d] =
new TH2D(Form(
"r%s_%s", titleVar[
j], titleDet[
d]),
150 Form(
"%s, %s", titleVar[
j], titleDet[
d]),
157 r[
j][
d]->SetXTitle(
"iEta");
158 r[
j][
d]->SetYTitle(
doRatio[
j] ?
"New / Old" :
"New - Old");
159 p[
j][
d] =
new TProfile(
160 Form(
"p%s_%s", titleVar[
j], titleDet[
d]), Form(
"%s, %s", titleVar[
j], titleDet[
d]), 83, -41.5, 41.5);
161 p[
j][
d]->SetXTitle(
"iEta");
162 p[
j][
d]->SetYTitle(
doRatio[
j] ?
"New / Old" :
"New - Old");
163 p[
j][
d]->SetMarkerStyle(20);
164 p[
j][
d]->SetMarkerSize(0.9);
165 p[
j][
d]->SetMarkerColor(kBlue);
167 for (
int p = 0;
p < DEP[
d]; ++
p) {
168 for (
int i = 0;
i < NLEV; ++
i) {
169 const char* titHist =
doRatio[
j] ? titleHisR[
i] : titleHisD[
i];
170 h[
j][
i][
d][
p] =
new TH2D(Form(
"h%s_%s_%s_%s", titleVar[
j], titHist, titleDet[
d], titleDep[
p]),
171 Form(
"%s, %s, %s, %s", titleVar[
j], titHist, titleDet[
d], titleDep[
p]),
178 h[
j][
i][
d][
p]->SetXTitle(
"iEta");
179 h[
j][
i][
d][
p]->SetYTitle(
"iPhi");
185 for (
int i = 0;
i < 4; ++
i) {
186 int color =
i == 0 ? kBlue :
i == 1 ? kViolet :
i == 2 ? kGreen + 2 : kRed;
188 new TH2D(Form(
"houtlut0_%d",
i), Form(
"Output LUT, %s",
tags_[0].c_str()), 2100, 0, 2100, 260, 0, 260);
190 new TH2D(Form(
"houtlut1_%d",
i), Form(
"Output LUT, %s",
tags_[1].c_str()), 2100, 0, 2100, 260, 0, 260);
191 for (
int j = 0;
j < 2; ++
j) {
192 houtput[
i][
j]->SetMarkerColor(color);
193 houtput[
i][
j]->SetLineColor(color);
207 unsigned long int iraw;
210 float val1, val2, val3, val4;
211 float wid1, wid2, wid3, wid4;
214 std::vector<HcalDetId> BadChans[2];
215 std::vector<HcalDetId> ZeroLuts[2];
218 for (
int ii = 0;
ii < 2; ++
ii) {
227 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> iraw;
228 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
231 float theval = (val1 + val2 + val3 + val4) / 4.0;
243 std::ifstream infped(
248 while (!infped.eof()) {
249 infped.getline(
buffer, 1024);
252 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> wid1 >> wid2 >>
253 wid3 >> wid4 >> iraw;
254 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
257 float theval = (val1 + val2 + val3 + val4) / 4.0;
269 std::ifstream inresp(
274 while (!inresp.eof()) {
275 inresp.getline(
buffer, 1024);
278 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> iraw;
279 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
294 std::ifstream inchan(
299 while (!inchan.eof()) {
300 inchan.getline(
buffer, 1024);
315 BadChans[
ii].push_back(
id);
323 xmls2.create_lut_map();
325 for (
const auto& xml2 : xmls2) {
332 const auto& lut2 = xml2.second;
334 int D =
abs(tid.ieta()) < 29 ? (lut2.size() == 1024 ? 0 : 3) : tid.version() == 0 ? 1 : 2;
335 for (
size_t i = 0;
i < lut2.size(); ++
i) {
337 houtput[
D][1]->
Fill(
i, lut2[
i]);
339 }
else if (topology->
valid(detid)) {
342 int idet =
int(subdet);
343 const auto& lut2 = xml2.second;
345 for (
size_t i = 0;
i < lut2.size(); ++
i) {
346 hlut[
hbhe][1]->Fill(
i, lut2[
i]);
348 hlut[
hbhe][1]->Fill(
i, lut2[
i] & 0x3FF);
353 for (
const auto& xml1 : xmls1) {
355 const auto& lut1 = xml1.second;
361 int D =
abs(tid.ieta()) < 29 ? (lut1.size() == 1024 ? 0 : 3) : tid.version() == 0 ? 1 : 2;
362 for (
size_t i = 0;
i < lut1.size(); ++
i) {
364 houtput[
D][0]->
Fill(
i, lut1[
i]);
366 }
else if (topology->
valid(detid)) {
369 int idet =
int(subdet);
370 const auto& lut1 = xml1.second;
372 for (
size_t i = 0;
i < lut1.size(); ++
i) {
373 hlut[
hbhe][0]->Fill(
i, lut1[
i]);
375 hlut[
hbhe][0]->Fill(
i, lut1[
i] & 0x3FF);
379 auto xml2 = xmls2.find(detid.
rawId());
380 if (xml2 == xmls2.end())
389 int idet =
int(subdet);
390 int ieta =
id.ieta();
391 int iphi =
id.iphi();
392 int idep =
id.depth() - 1;
393 unsigned long int iraw =
id.rawId();
395 if (!topology->
valid(detid))
400 const auto& lut2 = xml2->second;
402 size_t size = lut1.size();
403 if (
size != lut2.size())
406 std::vector<unsigned int> llut1(
size);
407 std::vector<unsigned int> llut2(
size);
408 for (
size_t i = 0;
i <
size; ++
i) {
409 llut1[
i] =
hbhe == 0 ? lut1[
i] & 0x3FF : lut1[
i];
410 llut2[
i] =
hbhe == 0 ? lut2[
i] & 0x3FF : lut2[
i];
415 for (
size_t i = 0;
i <
size; ++
i) {
421 ZeroLuts[0].push_back(
id);
424 for (
size_t i = 0;
i <
size; ++
i) {
430 ZeroLuts[1].push_back(
id);
442 xfill = lutpede[1][iraw] - lutpede[0][iraw];
449 xfill = lutresp[1][iraw] / lutresp[0][iraw];
456 xfill = lutgain[1][iraw] / lutgain[0][iraw];
468 size_t maxvalue =
hbhe == 0 ? 1023 : 2047;
471 for (
size_t i = 0;
i <
size; ++
i) {
472 hlut[
hbhe][2]->Fill(
i, llut1[
i] == 0 ? 0 : (
double)llut2[
i] / llut1[
i]);
475 (llut1[
i] == maxvalue || llut2[
i] == maxvalue)) {
476 if (llut1[
i - 1] == 0 || llut2[
i - 1] == 0) {
479 double condratio = lutgain[1][iraw] / lutgain[0][iraw] * lutresp[1][iraw] / lutresp[0][iraw];
480 xfill = (double)llut2[
i - 1] / llut1[
i - 1];
481 hslope[
hbhe]->Fill(condratio, xfill);
494 gROOT->SetStyle(
"Plain");
495 gStyle->SetPalette(1);
496 gStyle->SetStatW(0.2);
497 gStyle->SetStatH(0.1);
498 gStyle->SetStatY(1.0);
499 gStyle->SetStatX(0.9);
500 gStyle->SetOptStat(110010);
501 gStyle->SetOptFit(111111);
504 TCanvas*
cc =
new TCanvas(
"cc",
"cc", 0, 0, 1600, 1200);
506 for (
int j = 0;
j < NVAR; ++
j) {
507 gSystem->mkdir(TString(
plotsDir) +
"/_" + titleVar[
j]);
508 for (
int d = 0;
d < NDET; ++
d) {
510 r[
j][
d]->Draw(
"colz");
511 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
r[
j][
d]->GetName()) +
".pdf");
519 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
p[
j][
d]->GetName()) +
".pdf");
521 for (
int i = 0;
i < NLEV; ++
i) {
522 for (
int p = 0;
p < DEP[
d]; ++
p) {
524 h[
j][
i][
d][
p]->Draw(
"colz");
531 h[
j][2][
d][
p]->SetMinimum(-3);
532 h[
j][2][
d][
p]->SetMaximum(3);
535 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
h[
j][
i][
d][
p]->GetName()) +
".pdf");
541 for (
int i = 0;
i < NLEV; ++
i) {
544 hlut[1][
i]->Draw(
"sames");
545 hlut[2][
i]->Draw(
"sames");
546 hlut[3][
i]->Draw(
"sames");
547 cc->Print(TString(
plotsDir) + Form(
"LUT_%d.gif",
i));
550 hslope[0]->Draw(
"colz");
553 cc->Print(TString(
plotsDir) +
"GainLutScatterHBHE.pdf");
555 hslope[1]->Draw(
"colz");
558 cc->Print(TString(
plotsDir) +
"GainLutScatterLutHF.pdf");
560 for (
int i = 0;
i < 2; ++
i) {
562 houtput[0][
i]->Draw(
"box");
563 houtput[1][
i]->Draw(
"samebox");
564 houtput[2][
i]->Draw(
"samebox");
565 houtput[3][
i]->Draw(
"samebox");
566 cc->Print(TString(
plotsDir) + Form(
"OUT_%d.gif",
i));