99 typedef std::vector<std::string>
vstring;
100 typedef std::map<unsigned long int, float> LUTINPUT;
102 static const int NVAR = 5;
103 static const int NDET = 2;
104 static const int NDEP = 7;
105 static const int NLEV = 3;
107 const bool doRatio[NVAR] = {
false,
true,
true,
false,
true};
108 const char* titleVar[NVAR] = {
"Pedestals",
"RespCorrs",
"Gains",
"Threshold",
"LUTs"};
109 const char* titleHisR[NLEV] = {
"Old",
"New",
"Ratio"};
110 const char* titleHisD[NLEV] = {
"Old",
"New",
"Difference"};
111 const char* titleDet[4] = {
"HBHE",
"HF",
"HEP17",
"HO"};
112 const int DEP[NDET] = {7, 4};
113 const char* titleDep[NDEP] = {
"depth1",
"depth2",
"depth3",
"depth4",
"depth5",
"depth6",
"depth7"};
116 TProfile*
p[NVAR][NDET];
118 TH2D*
h[NVAR][NLEV][NDET][NDEP];
123 for (
int d = 0;
d < 4; ++
d) {
124 for (
int i = 0;
i < 3; ++
i) {
125 hlut[
d][
i] =
new TH2D(Form(
"Lut_%s_%s", titleDet[
d], titleHisR[
i]),
126 Form(
"Input LUT, %s", (
i == 2 ?
"Ratio" :
tags_[
i].c_str())),
132 i == NLEV - 1 ? 3 : 2400);
133 hlut[
d][
i]->SetMarkerColor(
d == 0 ? kBlue :
d == 1 ? kGreen + 2 :
d == 2 ? kRed : kCyan);
134 hlut[
d][
i]->SetXTitle(
"raw adc");
135 hlut[
d][
i]->SetYTitle(
"lin adc");
139 for (
int d = 0;
d < NDET; ++
d) {
140 hslope[
d] =
new TH2D(
141 Form(
"GainLutScatter_%s", titleDet[
d]), Form(
"Gain-Lutslope scatter, %s", titleDet[
d]), 200, 0, 2, 200, 0, 2);
142 hslope[
d]->SetXTitle(
"Gain x RespCorr ratio");
143 hslope[
d]->SetYTitle(
"Lut ratio");
145 for (
int j = 0;
j < NVAR; ++
j) {
148 r[
j][
d] =
new TH2D(Form(
"r%s_%s", titleVar[
j], titleDet[
d]),
149 Form(
"%s, %s", titleVar[
j], titleDet[
d]),
156 r[
j][
d]->SetXTitle(
"iEta");
157 r[
j][
d]->SetYTitle(
doRatio[
j] ?
"New / Old" :
"New - Old");
158 p[
j][
d] =
new TProfile(
159 Form(
"p%s_%s", titleVar[
j], titleDet[
d]), Form(
"%s, %s", titleVar[
j], titleDet[
d]), 83, -41.5, 41.5);
160 p[
j][
d]->SetXTitle(
"iEta");
161 p[
j][
d]->SetYTitle(
doRatio[
j] ?
"New / Old" :
"New - Old");
162 p[
j][
d]->SetMarkerStyle(20);
163 p[
j][
d]->SetMarkerSize(0.9);
164 p[
j][
d]->SetMarkerColor(kBlue);
166 for (
int p = 0;
p < DEP[
d]; ++
p) {
167 for (
int i = 0;
i < NLEV; ++
i) {
168 const char* titHist =
doRatio[
j] ? titleHisR[
i] : titleHisD[
i];
169 h[
j][
i][
d][
p] =
new TH2D(Form(
"h%s_%s_%s_%s", titleVar[
j], titHist, titleDet[
d], titleDep[
p]),
170 Form(
"%s, %s, %s, %s", titleVar[
j], titHist, titleDet[
d], titleDep[
p]),
177 h[
j][
i][
d][
p]->SetXTitle(
"iEta");
178 h[
j][
i][
d][
p]->SetYTitle(
"iPhi");
184 for (
int i = 0;
i < 4; ++
i) {
185 int color =
i == 0 ? kBlue :
i == 1 ? kViolet :
i == 2 ? kGreen + 2 : kRed;
187 new TH2D(Form(
"houtlut0_%d",
i), Form(
"Output LUT, %s",
tags_[0].c_str()), 2100, 0, 2100, 260, 0, 260);
189 new TH2D(Form(
"houtlut1_%d",
i), Form(
"Output LUT, %s",
tags_[1].c_str()), 2100, 0, 2100, 260, 0, 260);
190 for (
int j = 0;
j < 2; ++
j) {
191 houtput[
i][
j]->SetMarkerColor(color);
192 houtput[
i][
j]->SetLineColor(color);
206 unsigned long int iraw;
209 float val1, val2, val3, val4;
210 float wid1, wid2, wid3, wid4;
213 std::vector<HcalDetId> BadChans[2];
214 std::vector<HcalDetId> ZeroLuts[2];
217 for (
int ii = 0;
ii < 2; ++
ii) {
226 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> iraw;
227 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
230 float theval = (val1 + val2 + val3 + val4) / 4.0;
240 std::ifstream infped(
245 while (!infped.eof()) {
246 infped.getline(
buffer, 1024);
249 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> wid1 >> wid2 >>
250 wid3 >> wid4 >> iraw;
251 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
254 float theval = (val1 + val2 + val3 + val4) / 4.0;
264 std::ifstream inresp(
269 while (!inresp.eof()) {
270 inresp.getline(
buffer, 1024);
273 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> iraw;
274 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
287 std::ifstream inchan(
292 while (!inchan.eof()) {
293 inchan.getline(
buffer, 1024);
306 BadChans[
ii].push_back(
id);
314 xmls2.create_lut_map();
316 for (
const auto& xml2 : xmls2) {
323 const auto& lut2 = xml2.second;
325 int D =
abs(tid.ieta()) < 29 ? (lut2.size() == 1024 ? 0 : 3) : tid.version() == 0 ? 1 : 2;
326 for (
size_t i = 0;
i < lut2.size(); ++
i) {
328 houtput[
D][1]->
Fill(
i, lut2[
i]);
333 int idet =
int(subdet);
334 const auto& lut2 = xml2.second;
336 for (
size_t i = 0;
i < lut2.size(); ++
i) {
337 hlut[
hbhe][1]->Fill(
i, lut2[
i]);
339 hlut[
hbhe][1]->Fill(
i, lut2[
i] & 0x3FF);
344 for (
const auto& xml1 : xmls1) {
346 const auto& lut1 = xml1.second;
352 int D =
abs(tid.ieta()) < 29 ? (lut1.size() == 1024 ? 0 : 3) : tid.version() == 0 ? 1 : 2;
353 for (
size_t i = 0;
i < lut1.size(); ++
i) {
355 houtput[
D][0]->
Fill(
i, lut1[
i]);
360 int idet =
int(subdet);
361 const auto& lut1 = xml1.second;
363 for (
size_t i = 0;
i < lut1.size(); ++
i) {
364 hlut[
hbhe][0]->Fill(
i, lut1[
i]);
366 hlut[
hbhe][0]->Fill(
i, lut1[
i] & 0x3FF);
370 auto xml2 = xmls2.find(detid.
rawId());
371 if (xml2 == xmls2.end())
380 int idet =
int(subdet);
381 int ieta =
id.ieta();
382 int iphi =
id.iphi();
383 int idep =
id.depth() - 1;
384 unsigned long int iraw =
id.rawId();
391 const auto& lut2 = xml2->second;
393 size_t size = lut1.size();
394 if (
size != lut2.size())
397 std::vector<unsigned int> llut1(
size);
398 std::vector<unsigned int> llut2(
size);
399 for (
size_t i = 0;
i <
size; ++
i) {
400 llut1[
i] =
hbhe == 0 ? lut1[
i] & 0x3FF : lut1[
i];
401 llut2[
i] =
hbhe == 0 ? lut2[
i] & 0x3FF : lut2[
i];
406 for (
size_t i = 0;
i <
size; ++
i) {
412 ZeroLuts[0].push_back(
id);
415 for (
size_t i = 0;
i <
size; ++
i) {
421 ZeroLuts[1].push_back(
id);
433 xfill = lutpede[1][iraw] - lutpede[0][iraw];
440 xfill = lutresp[1][iraw] / lutresp[0][iraw];
447 xfill = lutgain[1][iraw] / lutgain[0][iraw];
459 size_t maxvalue =
hbhe == 0 ? 1023 : 2047;
462 for (
size_t i = 0;
i <
size; ++
i) {
463 hlut[
hbhe][2]->Fill(
i, llut1[
i] == 0 ? 0 : (
double)llut2[
i] / llut1[
i]);
466 (llut1[
i] == maxvalue || llut2[
i] == maxvalue)) {
467 if (llut1[
i - 1] == 0 || llut2[
i - 1] == 0) {
470 double condratio = lutgain[1][iraw] / lutgain[0][iraw] * lutresp[1][iraw] / lutresp[0][iraw];
471 xfill = (double)llut2[
i - 1] / llut1[
i - 1];
472 hslope[
hbhe]->Fill(condratio, xfill);
485 gROOT->SetStyle(
"Plain");
486 gStyle->SetPalette(1);
487 gStyle->SetStatW(0.2);
488 gStyle->SetStatH(0.1);
489 gStyle->SetStatY(1.0);
490 gStyle->SetStatX(0.9);
491 gStyle->SetOptStat(110010);
492 gStyle->SetOptFit(111111);
495 TCanvas*
cc =
new TCanvas(
"cc",
"cc", 0, 0, 1600, 1200);
497 for (
int j = 0;
j < NVAR; ++
j) {
498 gSystem->mkdir(TString(
plotsDir) +
"/_" + titleVar[
j]);
499 for (
int d = 0;
d < NDET; ++
d) {
501 r[
j][
d]->Draw(
"colz");
502 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
r[
j][
d]->GetName()) +
".pdf");
510 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
p[
j][
d]->GetName()) +
".pdf");
512 for (
int i = 0;
i < NLEV; ++
i) {
513 for (
int p = 0;
p < DEP[
d]; ++
p) {
515 h[
j][
i][
d][
p]->Draw(
"colz");
522 h[
j][2][
d][
p]->SetMinimum(-3);
523 h[
j][2][
d][
p]->SetMaximum(3);
526 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
h[
j][
i][
d][
p]->GetName()) +
".pdf");
532 for (
int i = 0;
i < NLEV; ++
i) {
535 hlut[1][
i]->Draw(
"sames");
536 hlut[2][
i]->Draw(
"sames");
537 hlut[3][
i]->Draw(
"sames");
538 cc->Print(TString(
plotsDir) + Form(
"LUT_%d.gif",
i));
541 hslope[0]->Draw(
"colz");
544 cc->Print(TString(
plotsDir) +
"GainLutScatterHBHE.pdf");
546 hslope[1]->Draw(
"colz");
549 cc->Print(TString(
plotsDir) +
"GainLutScatterLutHF.pdf");
551 for (
int i = 0;
i < 2; ++
i) {
553 houtput[0][
i]->Draw(
"box");
554 houtput[1][
i]->Draw(
"samebox");
555 houtput[2][
i]->Draw(
"samebox");
556 houtput[3][
i]->Draw(
"samebox");
557 cc->Print(TString(
plotsDir) + Form(
"OUT_%d.gif",
i));