17 #include "TPaveStats.h"
32 EcalTPGLinearizationConstPlot()
38 TH2F** barrel_m =
new TH2F*[
kGains];
39 TH2F** endc_p_m =
new TH2F*[
kGains];
40 TH2F** endc_m_m =
new TH2F*[
kGains];
41 TH2F** barrel_r =
new TH2F*[
kGains];
42 TH2F** endc_p_r =
new TH2F*[
kGains];
43 TH2F** endc_m_r =
new TH2F*[
kGains];
48 Form(
"EB mult_x%i ", gainValues[
gainId]),
56 Form(
"EE+ mult_x%i", gainValues[
gainId]),
64 Form(
"EE- mult_x%i", gainValues[
gainId]),
72 Form(
"EB shift_x%i", gainValues[
gainId]),
80 Form(
"EE+ shift_x%i", gainValues[
gainId]),
88 Form(
"EE- shift_x%i", gainValues[
gainId]),
107 auto iov =
iovs.front();
109 unsigned int run = std::get<0>(iov);
112 int thesign =
sign == 1 ? 1 : -1;
114 for (
int ieta = 0; ieta <
MAX_IETA; ieta++) {
115 for (
int iphi = 0; iphi <
MAX_IPHI; iphi++) {
116 EBDetId id((ieta + 1) * thesign, iphi + 1);
120 float val = (*payload)[
id.rawId()].mult_x12;
121 barrel_m[0]->Fill(iphi, y, val);
126 val = (*payload)[
id.rawId()].shift_x12;
127 barrel_r[0]->Fill(iphi, y, val);
132 val = (*payload)[
id.rawId()].mult_x6;
133 barrel_m[1]->Fill(iphi, y, val);
138 val = (*payload)[
id.rawId()].shift_x6;
139 barrel_r[1]->Fill(iphi, y, val);
144 val = (*payload)[
id.rawId()].mult_x1;
145 barrel_m[2]->Fill(iphi, y, val);
150 val = (*payload)[
id.rawId()].shift_x1;
151 barrel_r[2]->Fill(iphi, y, val);
159 for (
int ix = 0; ix <
IX_MAX; ix++) {
160 for (
int iy = 0; iy <
IY_MAX; iy++) {
164 float val = (*payload)[
id.rawId()].mult_x12;
166 endc_p_m[0]->Fill(ix + 1, iy + 1, val);
168 endc_m_m[0]->Fill(ix + 1, iy + 1, val);
173 val = (*payload)[
id.rawId()].shift_x12;
175 endc_p_r[0]->Fill(ix + 1, iy + 1, val);
177 endc_m_r[0]->Fill(ix + 1, iy + 1, val);
182 val = (*payload)[
id.rawId()].mult_x6;
184 endc_p_m[1]->Fill(ix + 1, iy + 1, val);
186 endc_m_m[1]->Fill(ix + 1, iy + 1, val);
191 val = (*payload)[
id.rawId()].shift_x6;
193 endc_p_r[1]->Fill(ix + 1, iy + 1, val);
195 endc_m_r[1]->Fill(ix + 1, iy + 1, val);
200 val = (*payload)[
id.rawId()].mult_x1;
202 endc_p_m[2]->Fill(ix + 1, iy + 1, val);
204 endc_m_m[2]->Fill(ix + 1, iy + 1, val);
209 val = (*payload)[
id.rawId()].shift_x1;
211 endc_p_r[2]->Fill(ix + 1, iy + 1, val);
213 endc_m_r[2]->Fill(ix + 1, iy + 1, val);
228 gStyle->SetPalette(1);
229 gStyle->SetOptStat(0);
230 TCanvas
canvas(
"CC map",
"CC map", 1200, 1800);
234 t1.SetTextSize(0.05);
235 t1.DrawLatex(0.5, 0.96, Form(
"Ecal Gain TPGLinearizationConst, IOV %i", run));
237 float xmi[3] = {0.0, 0.22, 0.78};
238 float xma[3] = {0.22, 0.78, 1.00};
239 TPad*** pad =
new TPad**[6];
240 for (
int gId = 0; gId < 6; gId++) {
241 pad[gId] =
new TPad*[3];
243 float yma = 0.94 - (0.16 * gId);
244 float ymi = yma - 0.14;
245 pad[gId][
obj] =
new TPad(Form(
"p_%i_%i",
obj, gId), Form(
"p_%i_%i",
obj, gId), xmi[
obj], ymi, xma[obj], yma);
246 pad[gId][
obj]->Draw();
250 for (
int gId = 0; gId <
kGains; gId++) {
252 DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
253 pad[gId + 3][0]->cd();
254 DrawEE(endc_m_r[gId], rEEmin[gId], rEEmax[gId]);
256 DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
257 pad[gId + 3][1]->cd();
258 DrawEB(barrel_r[gId], rEBmin[gId], rEBmax[gId]);
260 DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
261 pad[gId + 3][2]->cd();
262 DrawEE(endc_p_r[gId], rEEmin[gId], rEEmax[gId]);
266 canvas.SaveAs(ImageName.c_str());
274 template <cond::payloadInspector::IOVMultiplicity nIOVs,
int ntags,
int method>
275 class EcalTPGLinearizationConstBase
278 EcalTPGLinearizationConstBase()
281 bool fill()
override {
282 TH2F** barrel_m =
new TH2F*[
kGains];
283 TH2F** endc_p_m =
new TH2F*[
kGains];
284 TH2F** endc_m_m =
new TH2F*[
kGains];
285 TH2F** barrel_r =
new TH2F*[
kGains];
286 TH2F** endc_p_r =
new TH2F*[
kGains];
287 TH2F** endc_m_r =
new TH2F*[
kGains];
293 Form(
"EB mult_x%i ", gainValues[
gainId]),
301 Form(
"EE+ mult_x%i", gainValues[
gainId]),
309 Form(
"EE- mult_x%i", gainValues[
gainId]),
317 Form(
"EB shift_x%i", gainValues[
gainId]),
325 Form(
"EE+ shift_x%i", gainValues[
gainId]),
333 Form(
"EE- shift_x%i", gainValues[
gainId]),
353 auto iovs = cond::payloadInspector::PlotBase::getTag<0>().
iovs;
354 l_tagname[0] = cond::payloadInspector::PlotBase::getTag<0>().
name;
355 auto firstiov =
iovs.front();
356 run[0] = std::get<0>(firstiov);
357 std::tuple<cond::Time_t, cond::Hash> lastiov;
359 auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().
iovs;
360 l_tagname[1] = cond::payloadInspector::PlotBase::getTag<1>().
name;
361 lastiov = tag2iovs.front();
363 lastiov =
iovs.back();
364 l_tagname[1] = l_tagname[0];
366 run[1] = std::get<0>(lastiov);
367 for (
int irun = 0; irun < nIOVs; irun++) {
368 std::shared_ptr<EcalTPGLinearizationConst>
payload;
377 int thesign =
sign == 1 ? 1 : -1;
379 for (
int ieta = 0; ieta <
MAX_IETA; ieta++) {
380 for (
int iphi = 0; iphi <
MAX_IPHI; iphi++) {
381 EBDetId id((ieta + 1) * thesign, iphi + 1);
382 int hashindex =
id.hashedIndex();
386 float val = (*payload)[
id.rawId()].mult_x12;
388 mEB[0][hashindex] =
val;
391 dr = val - mEB[0][hashindex];
393 if (mEB[0][hashindex] == 0.) {
399 dr = val / mEB[0][hashindex];
401 barrel_m[0]->Fill(iphi, y, dr);
407 val = (*payload)[
id.rawId()].shift_x12;
409 rEB[0][hashindex] =
val;
412 dr = val - rEB[0][hashindex];
414 if (rEB[0][hashindex] == 0.) {
420 dr = val / rEB[0][hashindex];
422 barrel_r[0]->Fill(iphi, y, dr);
428 val = (*payload)[
id.rawId()].mult_x6;
430 mEB[1][hashindex] =
val;
433 dr = val - mEB[1][hashindex];
435 if (mEB[1][hashindex] == 0.) {
441 dr = val / mEB[1][hashindex];
443 barrel_m[1]->Fill(iphi, y, dr);
449 val = (*payload)[
id.rawId()].shift_x6;
451 rEB[1][hashindex] =
val;
454 dr = val - rEB[1][hashindex];
456 if (rEB[1][hashindex] == 0.) {
462 dr = val / rEB[1][hashindex];
464 barrel_r[1]->Fill(iphi, y, dr);
470 val = (*payload)[
id.rawId()].mult_x1;
472 mEB[2][hashindex] =
val;
475 dr = val - mEB[2][hashindex];
477 if (mEB[2][hashindex] == 0.) {
483 dr = val / mEB[2][hashindex];
485 barrel_m[2]->Fill(iphi, y, dr);
491 val = (*payload)[
id.rawId()].shift_x1;
493 rEB[2][hashindex] =
val;
496 dr = val - rEB[2][hashindex];
498 if (rEB[2][hashindex] == 0.) {
504 dr = val / rEB[2][hashindex];
506 barrel_r[2]->Fill(iphi, y, dr);
515 for (
int ix = 0; ix <
IX_MAX; ix++) {
516 for (
int iy = 0; iy <
IY_MAX; iy++) {
520 int hashindex =
id.hashedIndex();
521 float val = (*payload)[
id.rawId()].mult_x12;
523 mEE[0][hashindex] =
val;
526 dr = val - mEE[0][hashindex];
528 if (mEE[0][hashindex] == 0.) {
534 dr = val / mEE[0][hashindex];
537 endc_p_m[0]->Fill(ix + 1, iy + 1, dr);
539 endc_m_m[0]->Fill(ix + 1, iy + 1, dr);
545 val = (*payload)[
id.rawId()].shift_x12;
547 rEE[0][hashindex] =
val;
550 dr = val - rEE[0][hashindex];
552 if (rEE[0][hashindex] == 0.) {
558 dr = val / rEE[0][hashindex];
561 endc_p_r[0]->Fill(ix + 1, iy + 1, dr);
563 endc_m_r[0]->Fill(ix + 1, iy + 1, dr);
569 val = (*payload)[
id.rawId()].mult_x6;
571 mEE[1][hashindex] =
val;
574 dr = val - mEE[1][hashindex];
576 if (mEE[1][hashindex] == 0.) {
582 dr = val / mEE[1][hashindex];
585 endc_p_m[1]->Fill(ix + 1, iy + 1, dr);
587 endc_m_m[1]->Fill(ix + 1, iy + 1, dr);
593 val = (*payload)[
id.rawId()].shift_x6;
595 rEE[1][hashindex] =
val;
598 dr = val - rEE[1][hashindex];
600 if (rEE[1][hashindex] == 0.) {
606 dr = val / rEE[1][hashindex];
609 endc_p_r[1]->Fill(ix + 1, iy + 1, dr);
611 endc_m_r[1]->Fill(ix + 1, iy + 1, dr);
617 val = (*payload)[
id.rawId()].mult_x1;
619 mEE[2][hashindex] =
val;
622 dr = val - mEE[2][hashindex];
624 if (mEE[2][hashindex] == 0.) {
630 dr = val / mEE[2][hashindex];
633 endc_p_m[2]->Fill(ix + 1, iy + 1, dr);
635 endc_m_m[2]->Fill(ix + 1, iy + 1, dr);
641 val = (*payload)[
id.rawId()].shift_x1;
643 rEE[2][hashindex] =
val;
646 dr = val - rEE[2][hashindex];
648 if (rEE[2][hashindex] == 0.) {
654 dr = val / rEE[2][hashindex];
657 endc_p_r[2]->Fill(ix + 1, iy + 1, dr);
659 endc_m_r[2]->Fill(ix + 1, iy + 1, dr);
674 gStyle->SetPalette(1);
675 gStyle->SetOptStat(0);
676 TCanvas
canvas(
"CC map",
"CC map", 1200, 1800);
680 int len = l_tagname[0].length() + l_tagname[1].length();
684 t1.SetTextSize(0.03);
688 Form(
"%s %i %s %s %i", l_tagname[1].c_str(), run[1], dr[method].c_str(), l_tagname[0].c_str(), run[0]));
690 t1.SetTextSize(0.03);
691 t1.DrawLatex(0.5, 0.96, Form(
"Ecal TPGLinearizationConst, IOV %i %s %i", run[1], dr[method].c_str(), run[0]));
694 t1.SetTextSize(0.03);
695 t1.DrawLatex(0.5, 0.96, Form(
"%s, IOV %i %s %i", l_tagname[0].c_str(), run[1], dr[method].c_str(), run[0]));
698 float xmi[3] = {0.0, 0.22, 0.78};
699 float xma[3] = {0.22, 0.78, 1.00};
700 TPad*** pad =
new TPad**[6];
701 for (
int gId = 0; gId < 6; gId++) {
702 pad[gId] =
new TPad*[3];
704 float yma = 0.94 - (0.16 * gId);
705 float ymi = yma - 0.14;
706 pad[gId][
obj] =
new TPad(Form(
"p_%i_%i",
obj, gId), Form(
"p_%i_%i",
obj, gId), xmi[
obj], ymi, xma[obj], yma);
707 pad[gId][
obj]->Draw();
711 for (
int gId = 0; gId <
kGains; gId++) {
713 DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
714 pad[gId + 3][0]->cd();
715 DrawEE(endc_m_r[gId], rEEmin[gId], rEEmax[gId]);
717 DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
718 pad[gId + 3][1]->cd();
719 DrawEB(barrel_r[gId], rEBmin[gId], rEBmax[gId]);
721 DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
722 pad[gId + 3][2]->cd();
723 DrawEE(endc_p_r[gId], rEEmin[gId], rEEmax[gId]);
727 canvas.SaveAs(ImageName.c_str());
731 using EcalTPGLinearizationConstDiffOneTag = EcalTPGLinearizationConstBase<cond::payloadInspector::SINGLE_IOV, 1, 0>;
732 using EcalTPGLinearizationConstDiffTwoTags = EcalTPGLinearizationConstBase<cond::payloadInspector::SINGLE_IOV, 2, 0>;
733 using EcalTPGLinearizationConstRatioOneTag = EcalTPGLinearizationConstBase<cond::payloadInspector::SINGLE_IOV, 1, 1>;
734 using EcalTPGLinearizationConstRatioTwoTags = EcalTPGLinearizationConstBase<cond::payloadInspector::SINGLE_IOV, 2, 1>;
uint16_t *__restrict__ id
const Int_t gainValues[kGains]
void DrawEE(TH2F *endc, float min, float max)
void DrawEB(TH2F *ebmap, float min, float max)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)