17 #include "TPaveStats.h"
32 EcalTPGPedestalsPlot() : cond::payloadInspector::PlotImage<
EcalTPGPedestals>(
"ECAL Gain Ratios - map ") {
37 TH2F** barrel_m =
new TH2F*[
kGains];
38 TH2F** endc_p_m =
new TH2F*[
kGains];
39 TH2F** endc_m_m =
new TH2F*[
kGains];
43 Form(
"EB mean_x%i ", gainValues[
gainId]),
51 Form(
"EE+ mean_x%i", gainValues[
gainId]),
59 Form(
"EE- mean_x%i", gainValues[
gainId]),
74 auto iov =
iovs.front();
76 unsigned int run = std::get<0>(iov);
79 int thesign =
sign == 1 ? 1 : -1;
81 for (
int ieta = 0; ieta <
MAX_IETA; ieta++) {
82 for (
int iphi = 0; iphi <
MAX_IPHI; iphi++) {
83 EBDetId id((ieta + 1) * thesign, iphi + 1);
87 float val = (*payload)[
id.rawId()].mean_x12;
88 barrel_m[0]->Fill(iphi, y, val);
93 val = (*payload)[
id.rawId()].mean_x6;
94 barrel_m[1]->Fill(iphi, y, val);
99 val = (*payload)[
id.rawId()].mean_x1;
100 barrel_m[2]->Fill(iphi, y, val);
108 for (
int ix = 0; ix <
IX_MAX; ix++) {
109 for (
int iy = 0; iy <
IY_MAX; iy++) {
113 float val = (*payload)[
id.rawId()].mean_x12;
115 endc_p_m[0]->Fill(ix + 1, iy + 1, val);
117 endc_m_m[0]->Fill(ix + 1, iy + 1, val);
122 val = (*payload)[
id.rawId()].mean_x6;
124 endc_p_m[1]->Fill(ix + 1, iy + 1, val);
126 endc_m_m[1]->Fill(ix + 1, iy + 1, val);
131 val = (*payload)[
id.rawId()].mean_x1;
133 endc_p_m[2]->Fill(ix + 1, iy + 1, val);
135 endc_m_m[2]->Fill(ix + 1, iy + 1, val);
150 gStyle->SetPalette(1);
151 gStyle->SetOptStat(0);
152 TCanvas
canvas(
"CC map",
"CC map", 1200, 900);
156 t1.SetTextSize(0.05);
157 t1.DrawLatex(0.5, 0.96, Form(
"Ecal Gain TPGPedestals, IOV %i", run));
159 float xmi[3] = {0.0, 0.22, 0.78};
160 float xma[3] = {0.22, 0.78, 1.00};
161 TPad*** pad =
new TPad**[
kGains];
162 for (
int gId = 0; gId <
kGains; gId++) {
163 pad[gId] =
new TPad*[3];
165 float yma = 0.94 - (0.32 * gId);
166 float ymi = yma - 0.30;
167 pad[gId][
obj] =
new TPad(Form(
"p_%i_%i",
obj, gId), Form(
"p_%i_%i",
obj, gId), xmi[
obj], ymi, xma[obj], yma);
168 pad[gId][
obj]->Draw();
172 for (
int gId = 0; gId <
kGains; gId++) {
174 DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
176 DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
178 DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
182 canvas.SaveAs(ImageName.c_str());
190 template <cond::payloadInspector::IOVMultiplicity nIOVs,
int ntags,
int method>
193 EcalTPGPedestalsBase()
194 : cond::payloadInspector::PlotImage<
EcalTPGPedestals, nIOVs, ntags>(
"ECAL Gain Ratios comparison") {}
195 bool fill()
override {
196 TH2F** barrel_m =
new TH2F*[
kGains];
197 TH2F** endc_p_m =
new TH2F*[
kGains];
198 TH2F** endc_m_m =
new TH2F*[
kGains];
203 Form(
"EB mean_x%i ", gainValues[
gainId]),
211 Form(
"EE+ mean_x%i", gainValues[
gainId]),
219 Form(
"EE- mean_x%i", gainValues[
gainId]),
234 auto iovs = cond::payloadInspector::PlotBase::getTag<0>().
iovs;
235 l_tagname[0] = cond::payloadInspector::PlotBase::getTag<0>().
name;
236 auto firstiov =
iovs.front();
237 run[0] = std::get<0>(firstiov);
238 std::tuple<cond::Time_t, cond::Hash> lastiov;
240 auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().
iovs;
241 l_tagname[1] = cond::payloadInspector::PlotBase::getTag<1>().
name;
242 lastiov = tag2iovs.front();
244 lastiov =
iovs.back();
245 l_tagname[1] = l_tagname[0];
247 run[1] = std::get<0>(lastiov);
248 for (
int irun = 0; irun < nIOVs; irun++) {
249 std::shared_ptr<EcalTPGPedestals>
payload;
258 int thesign =
sign == 1 ? 1 : -1;
260 for (
int ieta = 0; ieta <
MAX_IETA; ieta++) {
261 for (
int iphi = 0; iphi <
MAX_IPHI; iphi++) {
262 EBDetId id((ieta + 1) * thesign, iphi + 1);
263 int hashindex =
id.hashedIndex();
267 float val = (*payload)[
id.rawId()].mean_x12;
269 mEB[0][hashindex] =
val;
272 dr = val - mEB[0][hashindex];
274 if (mEB[0][hashindex] == 0.) {
280 dr = val / mEB[0][hashindex];
282 barrel_m[0]->Fill(iphi, y, dr);
288 val = (*payload)[
id.rawId()].mean_x6;
290 mEB[1][hashindex] =
val;
293 dr = val - mEB[1][hashindex];
295 if (mEB[1][hashindex] == 0.) {
301 dr = val / mEB[1][hashindex];
303 barrel_m[1]->Fill(iphi, y, dr);
309 val = (*payload)[
id.rawId()].mean_x1;
311 mEB[2][hashindex] =
val;
314 dr = val - mEB[2][hashindex];
316 if (mEB[2][hashindex] == 0.) {
322 dr = val / mEB[2][hashindex];
324 barrel_m[2]->Fill(iphi, y, dr);
333 for (
int ix = 0; ix <
IX_MAX; ix++) {
334 for (
int iy = 0; iy <
IY_MAX; iy++) {
338 int hashindex =
id.hashedIndex();
339 float val = (*payload)[
id.rawId()].mean_x12;
341 mEE[0][hashindex] =
val;
344 dr = val - mEE[0][hashindex];
346 if (mEE[0][hashindex] == 0.) {
352 dr = val / mEE[0][hashindex];
355 endc_p_m[0]->Fill(ix + 1, iy + 1, dr);
357 endc_m_m[0]->Fill(ix + 1, iy + 1, dr);
363 val = (*payload)[
id.rawId()].mean_x6;
365 mEE[1][hashindex] =
val;
368 dr = val - mEE[1][hashindex];
370 if (mEE[1][hashindex] == 0.) {
376 dr = val / mEE[1][hashindex];
379 endc_p_m[1]->Fill(ix + 1, iy + 1, dr);
381 endc_m_m[1]->Fill(ix + 1, iy + 1, dr);
387 val = (*payload)[
id.rawId()].mean_x1;
389 mEE[2][hashindex] =
val;
392 dr = val - mEE[2][hashindex];
394 if (mEE[2][hashindex] == 0.) {
400 dr = val / mEE[2][hashindex];
403 endc_p_m[2]->Fill(ix + 1, iy + 1, dr);
405 endc_m_m[2]->Fill(ix + 1, iy + 1, dr);
420 gStyle->SetPalette(1);
421 gStyle->SetOptStat(0);
422 TCanvas
canvas(
"CC map",
"CC map", 1200, 900);
426 int len = l_tagname[0].length() + l_tagname[1].length();
430 t1.SetTextSize(0.03);
434 Form(
"%s %i %s %s %i", l_tagname[1].c_str(), run[1], dr[method].c_str(), l_tagname[0].c_str(), run[0]));
436 t1.SetTextSize(0.03);
437 t1.DrawLatex(0.5, 0.96, Form(
"Ecal TPGPedestals, IOV %i %s %i", run[1], dr[method].c_str(), run[0]));
440 t1.SetTextSize(0.03);
441 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]));
444 float xmi[3] = {0.0, 0.22, 0.78};
445 float xma[3] = {0.22, 0.78, 1.00};
446 TPad*** pad =
new TPad**[
kGains];
447 for (
int gId = 0; gId <
kGains; gId++) {
448 pad[gId] =
new TPad*[3];
450 float yma = 0.94 - (0.32 * gId);
451 float ymi = yma - 0.30;
452 pad[gId][
obj] =
new TPad(Form(
"p_%i_%i",
obj, gId), Form(
"p_%i_%i",
obj, gId), xmi[
obj], ymi, xma[obj], yma);
453 pad[gId][
obj]->Draw();
457 for (
int gId = 0; gId <
kGains; gId++) {
459 DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
461 DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
463 DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
467 canvas.SaveAs(ImageName.c_str());
471 using EcalTPGPedestalsDiffOneTag = EcalTPGPedestalsBase<cond::payloadInspector::SINGLE_IOV, 1, 0>;
472 using EcalTPGPedestalsDiffTwoTags = EcalTPGPedestalsBase<cond::payloadInspector::SINGLE_IOV, 2, 0>;
473 using EcalTPGPedestalsRatioOneTag = EcalTPGPedestalsBase<cond::payloadInspector::SINGLE_IOV, 1, 1>;
474 using EcalTPGPedestalsRatioTwoTags = EcalTPGPedestalsBase<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)