94 tok_htopo_ = esConsumes<HcalTopology, HcalRecNumberingRecord>();
102 typedef std::vector<std::string>
vstring;
103 typedef std::map<unsigned long int, float> LUTINPUT;
105 static const int NVAR = 6;
106 static const int NDET = 2;
107 static const int NDEP = 7;
108 static const int NLEV = 3;
110 const bool doRatio[NVAR] = {
false,
true,
true,
false,
true,
false};
111 const char* titleVar[NVAR] = {
"Pedestals",
"RespCorrs",
"Gains",
"Threshold",
"LUTs",
"EffPedestals"};
112 const char* titleHisR[NLEV] = {
"Old",
"New",
"Ratio"};
113 const char* titleHisD[NLEV] = {
"Old",
"New",
"Difference"};
114 const char* titleDet[4] = {
"HBHE",
"HF",
"HEP17",
"HO"};
115 const int DEP[NDET] = {7, 4};
116 const char* titleDep[NDEP] = {
"depth1",
"depth2",
"depth3",
"depth4",
"depth5",
"depth6",
"depth7"};
119 TProfile*
p[NVAR][NDET];
121 TH2D*
h[NVAR][NLEV][NDET][NDEP];
126 for (
int d = 0;
d < 4; ++
d) {
127 for (
int i = 0;
i < 3; ++
i) {
128 hlut[
d][
i] =
new TH2D(Form(
"Lut_%s_%s", titleDet[
d], titleHisR[
i]),
129 Form(
"Input LUT, %s", (
i == 2 ?
"Ratio" :
tags_[
i].c_str())),
135 i == NLEV - 1 ? 3 : 2400);
136 hlut[
d][
i]->SetMarkerColor(
d == 0 ? kBlue :
d == 1 ? kGreen + 2 :
d == 2 ? kRed : kCyan);
137 hlut[
d][
i]->SetXTitle(
"raw adc");
138 hlut[
d][
i]->SetYTitle(
"lin adc");
142 for (
int d = 0;
d < NDET; ++
d) {
143 hslope[
d] =
new TH2D(
144 Form(
"GainLutScatter_%s", titleDet[
d]), Form(
"Gain-Lutslope scatter, %s", titleDet[
d]), 200, 0, 2, 200, 0, 2);
145 hslope[
d]->SetXTitle(
"Gain x RespCorr ratio");
146 hslope[
d]->SetYTitle(
"Lut ratio");
148 for (
int j = 0;
j < NVAR; ++
j) {
151 r[
j][
d] =
new TH2D(Form(
"r%s_%s", titleVar[
j], titleDet[
d]),
152 Form(
"%s, %s", titleVar[
j], titleDet[
d]),
159 r[
j][
d]->SetXTitle(
"iEta");
160 r[
j][
d]->SetYTitle(
doRatio[
j] ?
"New / Old" :
"New - Old");
161 p[
j][
d] =
new TProfile(
162 Form(
"p%s_%s", titleVar[
j], titleDet[
d]), Form(
"%s, %s", titleVar[
j], titleDet[
d]), 83, -41.5, 41.5);
163 p[
j][
d]->SetXTitle(
"iEta");
164 p[
j][
d]->SetYTitle(
doRatio[
j] ?
"New / Old" :
"New - Old");
165 p[
j][
d]->SetMarkerStyle(20);
166 p[
j][
d]->SetMarkerSize(0.9);
167 p[
j][
d]->SetMarkerColor(kBlue);
169 for (
int p = 0;
p < DEP[
d]; ++
p) {
170 for (
int i = 0;
i < NLEV; ++
i) {
171 const char* titHist =
doRatio[
j] ? titleHisR[
i] : titleHisD[
i];
172 h[
j][
i][
d][
p] =
new TH2D(Form(
"h%s_%s_%s_%s", titleVar[
j], titHist, titleDet[
d], titleDep[
p]),
173 Form(
"%s, %s, %s, %s", titleVar[
j], titHist, titleDet[
d], titleDep[
p]),
180 h[
j][
i][
d][
p]->SetXTitle(
"iEta");
181 h[
j][
i][
d][
p]->SetYTitle(
"iPhi");
187 for (
int i = 0;
i < 4; ++
i) {
188 int color =
i == 0 ? kBlue :
i == 1 ? kViolet :
i == 2 ? kGreen + 2 : kRed;
190 new TH2D(Form(
"houtlut0_%d",
i), Form(
"Output LUT, %s",
tags_[0].c_str()), 2100, 0, 2100, 260, 0, 260);
192 new TH2D(Form(
"houtlut1_%d",
i), Form(
"Output LUT, %s",
tags_[1].c_str()), 2100, 0, 2100, 260, 0, 260);
193 for (
int j = 0;
j < 2; ++
j) {
194 houtput[
i][
j]->SetMarkerColor(color);
195 houtput[
i][
j]->SetLineColor(color);
203 LUTINPUT luteffpede[2];
211 unsigned long int iraw;
214 float val1, val2, val3, val4;
215 float wid1, wid2, wid3, wid4;
218 std::vector<HcalDetId> BadChans[2];
219 std::vector<HcalDetId> ZeroLuts[2];
222 for (
int ii = 0;
ii < 2; ++
ii) {
231 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> iraw;
232 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
235 float theval = (val1 + val2 + val3 + val4) / 4.0;
247 std::ifstream infeffped(
252 assert(!infeffped.fail());
253 while (!infeffped.eof()) {
254 infeffped.getline(
buffer, 1024);
257 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> wid1 >> wid2 >>
258 wid3 >> wid4 >> iraw;
259 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
262 float theval = (val1 + val2 + val3 + val4) / 4.0;
274 std::ifstream infped(
279 while (!infped.eof()) {
280 infped.getline(
buffer, 1024);
283 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> wid1 >> wid2 >>
284 wid3 >> wid4 >> iraw;
285 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
288 float theval = (val1 + val2 + val3 + val4) / 4.0;
300 std::ifstream inresp(
305 while (!inresp.eof()) {
306 inresp.getline(
buffer, 1024);
309 std::istringstream(
buffer) >>
ieta >>
iphi >> idep >> det >> val1 >> iraw;
310 if (det !=
"HB" && det !=
"HE" && det !=
"HF")
325 std::ifstream inchan(
330 while (!inchan.eof()) {
331 inchan.getline(
buffer, 1024);
346 BadChans[
ii].push_back(
id);
354 xmls2.create_lut_map();
356 for (
const auto& xml2 : xmls2) {
363 const auto& lut2 = xml2.second;
365 int D =
abs(tid.ieta()) < 29 ? (lut2.size() == 1024 ? 0 : 3) : tid.version() == 0 ? 1 : 2;
366 for (
size_t i = 0;
i < lut2.size(); ++
i) {
368 houtput[
D][1]->
Fill(
i, lut2[
i]);
370 }
else if (topology->
valid(detid)) {
373 int idet =
int(subdet);
374 const auto& lut2 = xml2.second;
376 for (
size_t i = 0;
i < lut2.size(); ++
i) {
377 hlut[
hbhe][1]->Fill(
i, lut2[
i]);
379 hlut[
hbhe][1]->Fill(
i, lut2[
i] & 0x3FF);
384 for (
const auto& xml1 : xmls1) {
386 const auto& lut1 = xml1.second;
392 int D =
abs(tid.ieta()) < 29 ? (lut1.size() == 1024 ? 0 : 3) : tid.version() == 0 ? 1 : 2;
393 for (
size_t i = 0;
i < lut1.size(); ++
i) {
395 houtput[
D][0]->
Fill(
i, lut1[
i]);
397 }
else if (topology->
valid(detid)) {
400 int idet =
int(subdet);
401 const auto& lut1 = xml1.second;
403 for (
size_t i = 0;
i < lut1.size(); ++
i) {
404 hlut[
hbhe][0]->Fill(
i, lut1[
i]);
406 hlut[
hbhe][0]->Fill(
i, lut1[
i] & 0x3FF);
410 auto xml2 = xmls2.find(detid.
rawId());
411 if (xml2 == xmls2.end())
420 int idet =
int(subdet);
421 int ieta =
id.ieta();
422 int iphi =
id.iphi();
423 int idep =
id.depth() - 1;
424 unsigned long int iraw =
id.rawId();
426 if (!topology->
valid(detid))
431 const auto& lut2 = xml2->second;
433 size_t size = lut1.size();
434 if (
size != lut2.size())
437 std::vector<unsigned int> llut1(
size);
438 std::vector<unsigned int> llut2(
size);
439 for (
size_t i = 0;
i <
size; ++
i) {
440 llut1[
i] =
hbhe == 0 ? lut1[
i] & 0x3FF : lut1[
i];
441 llut2[
i] =
hbhe == 0 ? lut2[
i] & 0x3FF : lut2[
i];
446 for (
size_t i = 0;
i <
size; ++
i) {
452 ZeroLuts[0].push_back(
id);
455 for (
size_t i = 0;
i <
size; ++
i) {
461 ZeroLuts[1].push_back(
id);
473 xfill = lutpede[1][iraw] - lutpede[0][iraw];
480 xfill = lutresp[1][iraw] / lutresp[0][iraw];
487 xfill = lutgain[1][iraw] / lutgain[0][iraw];
501 xfill = luteffpede[1][iraw] - luteffpede[0][iraw];
506 size_t maxvalue =
hbhe == 0 ? 1023 : 2047;
509 for (
size_t i = 0;
i <
size; ++
i) {
510 hlut[
hbhe][2]->Fill(
i, llut1[
i] == 0 ? 0 : (
double)llut2[
i] / llut1[
i]);
513 (llut1[
i] == maxvalue || llut2[
i] == maxvalue)) {
514 if (llut1[
i - 1] == 0 || llut2[
i - 1] == 0) {
517 double condratio = lutgain[1][iraw] / lutgain[0][iraw] * lutresp[1][iraw] / lutresp[0][iraw];
518 xfill = (double)llut2[
i - 1] / llut1[
i - 1];
519 hslope[
hbhe]->Fill(condratio, xfill);
532 gROOT->SetStyle(
"Plain");
533 gStyle->SetPalette(1);
534 gStyle->SetStatW(0.2);
535 gStyle->SetStatH(0.1);
536 gStyle->SetStatY(1.0);
537 gStyle->SetStatX(0.9);
538 gStyle->SetOptStat(110010);
539 gStyle->SetOptFit(111111);
542 TCanvas* cc =
new TCanvas(
"cc",
"cc", 0, 0, 1600, 1200);
544 for (
int j = 0;
j < NVAR; ++
j) {
545 gSystem->mkdir(TString(
plotsDir) +
"/_" + titleVar[
j]);
546 for (
int d = 0;
d < NDET; ++
d) {
548 r[
j][
d]->Draw(
"colz");
549 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
r[
j][
d]->GetName()) +
".pdf");
557 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
p[
j][
d]->GetName()) +
".pdf");
559 for (
int i = 0;
i < NLEV; ++
i) {
560 for (
int p = 0;
p < DEP[
d]; ++
p) {
562 h[
j][
i][
d][
p]->Draw(
"colz");
569 h[
j][2][
d][
p]->SetMinimum(-3);
570 h[
j][2][
d][
p]->SetMaximum(3);
573 cc->Print(TString(
plotsDir) +
"/_" + titleVar[
j] +
"/" + TString(
h[
j][
i][
d][
p]->GetName()) +
".pdf");
579 for (
int i = 0;
i < NLEV; ++
i) {
582 hlut[1][
i]->Draw(
"sames");
583 hlut[2][
i]->Draw(
"sames");
584 hlut[3][
i]->Draw(
"sames");
585 cc->Print(TString(
plotsDir) + Form(
"LUT_%d.gif",
i));
588 hslope[0]->Draw(
"colz");
591 cc->Print(TString(
plotsDir) +
"GainLutScatterHBHE.pdf");
593 hslope[1]->Draw(
"colz");
596 cc->Print(TString(
plotsDir) +
"GainLutScatterLutHF.pdf");
598 for (
int i = 0;
i < 2; ++
i) {
600 houtput[0][
i]->Draw(
"box");
601 houtput[1][
i]->Draw(
"samebox");
602 houtput[2][
i]->Draw(
"samebox");
603 houtput[3][
i]->Draw(
"samebox");
604 cc->Print(TString(
plotsDir) + Form(
"OUT_%d.gif",
i));
bool validHT(const HcalTrigTowerDetId &id) const
T getParameter(std::string const &) const
std::string fullPath() const
bool valid(const DetId &id) const override
std::vector< std::string > effpedestals_
Container::value_type value_type
void addDefault(ParameterSetDescription const &psetDescription)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Abs< T >::type abs(const T &t)
std::vector< std::string > quality_
#define DEFINE_FWK_MODULE(type)
bool getData(T &iHolder) const
std::vector< std::string > gains_
HcalLutAnalyzer(const edm::ParameterSet &)
~HcalLutAnalyzer() override
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > tok_htopo_
std::vector< std::string > pedestals_
HcalGenericSubdetector genericSubdet() const
void analyze(const edm::Event &, const edm::EventSetup &) override
DecomposeProduct< arg, typename Div::arg > D
std::vector< std::string > respcorrs_
constexpr uint32_t rawId() const
get the raw id
std::vector< std::string > tags_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.