CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalTPGLinearizationConst_PayloadInspector.cc
Go to the documentation of this file.
7 
8 // the data format of the condition to be inspected
10 
11 #include "TH2F.h"
12 #include "TCanvas.h"
13 #include "TLine.h"
14 #include "TStyle.h"
15 #include "TLatex.h"
16 #include "TPave.h"
17 #include "TPaveStats.h"
18 #include <string>
19 #include <fstream>
20 
21 namespace {
22  enum { kEBChannels = 61200, kEEChannels = 14648, kGains = 3, kSides = 2 };
23  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 85, MAX_IPHI = 360 }; // barrel lower and upper bounds on eta and phi
24  enum { IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100 }; // endcaps lower and upper bounds on x and y
25  int gainValues[kGains] = {12, 6, 1};
26 
27  /**************************************************
28  2d plot of ECAL TPGLinearizationConst of 1 IOV
29  **************************************************/
30  class EcalTPGLinearizationConstPlot : public cond::payloadInspector::PlotImage<EcalTPGLinearizationConst> {
31  public:
32  EcalTPGLinearizationConstPlot()
33  : cond::payloadInspector::PlotImage<EcalTPGLinearizationConst>("ECAL Gain Ratios - map ") {
34  setSingleIov(true);
35  }
36 
37  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
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];
44  float mEBmin[kGains], mEEmin[kGains], mEBmax[kGains], mEEmax[kGains], rEBmin[kGains], rEEmin[kGains],
45  rEBmax[kGains], rEEmax[kGains];
46  for (int gainId = 0; gainId < kGains; gainId++) {
47  barrel_m[gainId] = new TH2F(Form("EBm%i", gainId),
48  Form("EB mult_x%i ", gainValues[gainId]),
49  MAX_IPHI,
50  0,
51  MAX_IPHI,
52  2 * MAX_IETA,
53  -MAX_IETA,
54  MAX_IETA);
55  endc_p_m[gainId] = new TH2F(Form("EE+m%i", gainId),
56  Form("EE+ mult_x%i", gainValues[gainId]),
57  IX_MAX,
58  IX_MIN,
59  IX_MAX + 1,
60  IY_MAX,
61  IY_MIN,
62  IY_MAX + 1);
63  endc_m_m[gainId] = new TH2F(Form("EE-m%i", gainId),
64  Form("EE- mult_x%i", gainValues[gainId]),
65  IX_MAX,
66  IX_MIN,
67  IX_MAX + 1,
68  IY_MAX,
69  IY_MIN,
70  IY_MAX + 1);
71  barrel_r[gainId] = new TH2F(Form("EBr%i", gainId),
72  Form("EB shift_x%i", gainValues[gainId]),
73  MAX_IPHI,
74  0,
75  MAX_IPHI,
76  2 * MAX_IETA,
77  -MAX_IETA,
78  MAX_IETA);
79  endc_p_r[gainId] = new TH2F(Form("EE+r%i", gainId),
80  Form("EE+ shift_x%i", gainValues[gainId]),
81  IX_MAX,
82  IX_MIN,
83  IX_MAX + 1,
84  IY_MAX,
85  IY_MIN,
86  IY_MAX + 1);
87  endc_m_r[gainId] = new TH2F(Form("EE-r%i", gainId),
88  Form("EE- shift_x%i", gainValues[gainId]),
89  IX_MAX,
90  IX_MIN,
91  IX_MAX + 1,
92  IY_MAX,
93  IY_MIN,
94  IY_MAX + 1);
95  mEBmin[gainId] = 10.;
96  mEEmin[gainId] = 10.;
97  mEBmax[gainId] = -10.;
98  mEEmax[gainId] = -10.;
99  rEBmin[gainId] = 10.;
100  rEEmin[gainId] = 10.;
101  rEBmax[gainId] = -10.;
102  rEEmax[gainId] = -10.;
103  }
104 
105  // std::ofstream fout;
106  // fout.open("./bid.txt");
107  auto iov = iovs.front();
108  std::shared_ptr<EcalTPGLinearizationConst> payload = fetchPayload(std::get<1>(iov));
109  unsigned int run = std::get<0>(iov);
110  if (payload.get()) {
111  for (int sign = 0; sign < kSides; sign++) {
112  int thesign = sign == 1 ? 1 : -1;
113 
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);
117  float y = -1 - ieta;
118  if (sign == 1)
119  y = ieta;
120  float val = (*payload)[id.rawId()].mult_x12;
121  barrel_m[0]->Fill(iphi, y, val);
122  if (val < mEBmin[0])
123  mEBmin[0] = val;
124  if (val > mEBmax[0])
125  mEBmax[0] = val;
126  val = (*payload)[id.rawId()].shift_x12;
127  barrel_r[0]->Fill(iphi, y, val);
128  if (val < rEBmin[0])
129  rEBmin[0] = val;
130  if (val > rEBmax[0])
131  rEBmax[0] = val;
132  val = (*payload)[id.rawId()].mult_x6;
133  barrel_m[1]->Fill(iphi, y, val);
134  if (val < mEBmin[1])
135  mEBmin[1] = val;
136  if (val > mEBmax[1])
137  mEBmax[1] = val;
138  val = (*payload)[id.rawId()].shift_x6;
139  barrel_r[1]->Fill(iphi, y, val);
140  if (val < rEBmin[1])
141  rEBmin[1] = val;
142  if (val > rEBmax[1])
143  rEBmax[1] = val;
144  val = (*payload)[id.rawId()].mult_x1;
145  barrel_m[2]->Fill(iphi, y, val);
146  if (val < mEBmin[2])
147  mEBmin[2] = val;
148  if (val > mEBmax[2])
149  mEBmax[2] = val;
150  val = (*payload)[id.rawId()].shift_x1;
151  barrel_r[2]->Fill(iphi, y, val);
152  if (val < rEBmin[2])
153  rEBmin[2] = val;
154  if (val > rEBmax[2])
155  rEBmax[2] = val;
156  } // iphi
157  } // ieta
158 
159  for (int ix = 0; ix < IX_MAX; ix++) {
160  for (int iy = 0; iy < IY_MAX; iy++) {
161  if (!EEDetId::validDetId(ix + 1, iy + 1, thesign))
162  continue;
163  EEDetId id(ix + 1, iy + 1, thesign);
164  float val = (*payload)[id.rawId()].mult_x12;
165  if (thesign == 1)
166  endc_p_m[0]->Fill(ix + 1, iy + 1, val);
167  else
168  endc_m_m[0]->Fill(ix + 1, iy + 1, val);
169  if (val < mEEmin[0])
170  mEEmin[0] = val;
171  if (val > mEEmax[0])
172  mEEmax[0] = val;
173  val = (*payload)[id.rawId()].shift_x12;
174  if (thesign == 1)
175  endc_p_r[0]->Fill(ix + 1, iy + 1, val);
176  else
177  endc_m_r[0]->Fill(ix + 1, iy + 1, val);
178  if (val < rEEmin[0])
179  rEEmin[0] = val;
180  if (val > rEEmax[0])
181  rEEmax[0] = val;
182  val = (*payload)[id.rawId()].mult_x6;
183  if (thesign == 1)
184  endc_p_m[1]->Fill(ix + 1, iy + 1, val);
185  else
186  endc_m_m[1]->Fill(ix + 1, iy + 1, val);
187  if (val < mEEmin[1])
188  mEEmin[1] = val;
189  if (val > mEEmax[1])
190  mEEmax[1] = val;
191  val = (*payload)[id.rawId()].shift_x6;
192  if (thesign == 1)
193  endc_p_r[1]->Fill(ix + 1, iy + 1, val);
194  else
195  endc_m_r[1]->Fill(ix + 1, iy + 1, val);
196  if (val < rEEmin[1])
197  rEEmin[1] = val;
198  if (val > rEEmax[1])
199  rEEmax[1] = val;
200  val = (*payload)[id.rawId()].mult_x1;
201  if (thesign == 1)
202  endc_p_m[2]->Fill(ix + 1, iy + 1, val);
203  else
204  endc_m_m[2]->Fill(ix + 1, iy + 1, val);
205  if (val < mEEmin[2])
206  mEEmin[2] = val;
207  if (val > mEEmax[2])
208  mEEmax[2] = val;
209  val = (*payload)[id.rawId()].shift_x1;
210  if (thesign == 1)
211  endc_p_r[2]->Fill(ix + 1, iy + 1, val);
212  else
213  endc_m_r[2]->Fill(ix + 1, iy + 1, val);
214  if (val < rEEmin[2])
215  rEEmin[2] = val;
216  if (val > rEEmax[2])
217  rEEmax[2] = val;
218  // fout << " x " << ix << " y " << " val " << val << std::endl;
219  } // iy
220  } // ix
221  } // side
222  } // if payload.get()
223  else
224  return false;
225  // std::cout << " min " << rEEmin[2] << " max " << rEEmax[2] << std::endl;
226  // fout.close();
227 
228  gStyle->SetPalette(1);
229  gStyle->SetOptStat(0);
230  TCanvas canvas("CC map", "CC map", 1200, 1800);
231  TLatex t1;
232  t1.SetNDC();
233  t1.SetTextAlign(26);
234  t1.SetTextSize(0.05);
235  t1.DrawLatex(0.5, 0.96, Form("Ecal Gain TPGLinearizationConst, IOV %i", run));
236 
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];
242  for (int obj = 0; obj < 3; obj++) {
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();
247  }
248  }
249 
250  for (int gId = 0; gId < kGains; gId++) {
251  pad[gId][0]->cd();
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]);
255  pad[gId][1]->cd();
256  DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
257  pad[gId + 3][1]->cd();
258  DrawEB(barrel_r[gId], rEBmin[gId], rEBmax[gId]);
259  pad[gId][2]->cd();
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]);
263  }
264 
265  std::string ImageName(m_imageFileName);
266  canvas.SaveAs(ImageName.c_str());
267  return true;
268  } // fill method
269  };
270 
271  /******************************************************************
272  2d plot of ECAL TPGLinearizationConst difference between 2 IOVs
273  ******************************************************************/
274  template <cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, int method>
275  class EcalTPGLinearizationConstBase
276  : public cond::payloadInspector::PlotImage<EcalTPGLinearizationConst, nIOVs, ntags> {
277  public:
278  EcalTPGLinearizationConstBase()
279  : cond::payloadInspector::PlotImage<EcalTPGLinearizationConst, nIOVs, ntags>("ECAL Gain Ratios comparison") {}
280 
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];
288  float mEBmin[kGains], mEEmin[kGains], mEBmax[kGains], mEEmax[kGains], rEBmin[kGains], rEEmin[kGains],
289  rEBmax[kGains], rEEmax[kGains];
290  float mEB[kGains][kEBChannels], mEE[kGains][kEEChannels], rEB[kGains][kEBChannels], rEE[kGains][kEEChannels];
291  for (int gainId = 0; gainId < kGains; gainId++) {
292  barrel_m[gainId] = new TH2F(Form("EBm%i", gainId),
293  Form("EB mult_x%i ", gainValues[gainId]),
294  MAX_IPHI,
295  0,
296  MAX_IPHI,
297  2 * MAX_IETA,
298  -MAX_IETA,
299  MAX_IETA);
300  endc_p_m[gainId] = new TH2F(Form("EE+m%i", gainId),
301  Form("EE+ mult_x%i", gainValues[gainId]),
302  IX_MAX,
303  IX_MIN,
304  IX_MAX + 1,
305  IY_MAX,
306  IY_MIN,
307  IY_MAX + 1);
308  endc_m_m[gainId] = new TH2F(Form("EE-m%i", gainId),
309  Form("EE- mult_x%i", gainValues[gainId]),
310  IX_MAX,
311  IX_MIN,
312  IX_MAX + 1,
313  IY_MAX,
314  IY_MIN,
315  IY_MAX + 1);
316  barrel_r[gainId] = new TH2F(Form("EBr%i", gainId),
317  Form("EB shift_x%i", gainValues[gainId]),
318  MAX_IPHI,
319  0,
320  MAX_IPHI,
321  2 * MAX_IETA,
322  -MAX_IETA,
323  MAX_IETA);
324  endc_p_r[gainId] = new TH2F(Form("EE+r%i", gainId),
325  Form("EE+ shift_x%i", gainValues[gainId]),
326  IX_MAX,
327  IX_MIN,
328  IX_MAX + 1,
329  IY_MAX,
330  IY_MIN,
331  IY_MAX + 1);
332  endc_m_r[gainId] = new TH2F(Form("EE-r%i", gainId),
333  Form("EE- shift_x%i", gainValues[gainId]),
334  IX_MAX,
335  IX_MIN,
336  IX_MAX + 1,
337  IY_MAX,
338  IY_MIN,
339  IY_MAX + 1);
340  mEBmin[gainId] = 10.;
341  mEEmin[gainId] = 10.;
342  mEBmax[gainId] = -10.;
343  mEEmax[gainId] = -10.;
344  rEBmin[gainId] = 10.;
345  rEEmin[gainId] = 10.;
346  rEBmax[gainId] = -10.;
347  rEEmax[gainId] = -10.;
348  }
349 
350  unsigned int run[2];
351  //float gEB[3][kEBChannels], gEE[3][kEEChannels];
352  std::string l_tagname[2];
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;
358  if (ntags == 2) {
359  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
360  l_tagname[1] = cond::payloadInspector::PlotBase::getTag<1>().name;
361  lastiov = tag2iovs.front();
362  } else {
363  lastiov = iovs.back();
364  l_tagname[1] = l_tagname[0];
365  }
366  run[1] = std::get<0>(lastiov);
367  for (int irun = 0; irun < nIOVs; irun++) {
368  std::shared_ptr<EcalTPGLinearizationConst> payload;
369  if (irun == 0) {
370  payload = this->fetchPayload(std::get<1>(firstiov));
371  } else {
372  payload = this->fetchPayload(std::get<1>(lastiov));
373  }
374  if (payload.get()) {
375  float dr;
376  for (int sign = 0; sign < kSides; sign++) {
377  int thesign = sign == 1 ? 1 : -1;
378 
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();
383  float y = -1 - ieta;
384  if (sign == 1)
385  y = ieta;
386  float val = (*payload)[id.rawId()].mult_x12;
387  if (irun == 0) {
388  mEB[0][hashindex] = val;
389  } else {
390  if (method == 0)
391  dr = val - mEB[0][hashindex];
392  else { // ratio
393  if (mEB[0][hashindex] == 0.) {
394  if (val == 0.)
395  dr = 1.;
396  else
397  dr = 9999.;
398  } else
399  dr = val / mEB[0][hashindex];
400  }
401  barrel_m[0]->Fill(iphi, y, dr);
402  if (dr < mEBmin[0])
403  mEBmin[0] = dr;
404  if (dr > mEBmax[0])
405  mEBmax[0] = dr;
406  }
407  val = (*payload)[id.rawId()].shift_x12;
408  if (irun == 0) {
409  rEB[0][hashindex] = val;
410  } else {
411  if (method == 0)
412  dr = val - rEB[0][hashindex];
413  else { // ratio
414  if (rEB[0][hashindex] == 0.) {
415  if (val == 0.)
416  dr = 1.;
417  else
418  dr = 9999.;
419  } else
420  dr = val / rEB[0][hashindex];
421  }
422  barrel_r[0]->Fill(iphi, y, dr);
423  if (dr < rEBmin[0])
424  rEBmin[0] = dr;
425  if (dr > rEBmax[0])
426  rEBmax[0] = dr;
427  }
428  val = (*payload)[id.rawId()].mult_x6;
429  if (irun == 0) {
430  mEB[1][hashindex] = val;
431  } else {
432  if (method == 0)
433  dr = val - mEB[1][hashindex];
434  else { // ratio
435  if (mEB[1][hashindex] == 0.) {
436  if (val == 0.)
437  dr = 1.;
438  else
439  dr = 9999.;
440  } else
441  dr = val / mEB[1][hashindex];
442  }
443  barrel_m[1]->Fill(iphi, y, dr);
444  if (dr < mEBmin[1])
445  mEBmin[1] = dr;
446  if (dr > mEBmax[1])
447  mEBmax[1] = dr;
448  }
449  val = (*payload)[id.rawId()].shift_x6;
450  if (irun == 0) {
451  rEB[1][hashindex] = val;
452  } else {
453  if (method == 0)
454  dr = val - rEB[1][hashindex];
455  else { // ratio
456  if (rEB[1][hashindex] == 0.) {
457  if (val == 0.)
458  dr = 1.;
459  else
460  dr = 9999.;
461  } else
462  dr = val / rEB[1][hashindex];
463  }
464  barrel_r[1]->Fill(iphi, y, dr);
465  if (dr < rEBmin[1])
466  rEBmin[1] = dr;
467  if (dr > rEBmax[1])
468  rEBmax[1] = dr;
469  }
470  val = (*payload)[id.rawId()].mult_x1;
471  if (irun == 0) {
472  mEB[2][hashindex] = val;
473  } else {
474  if (method == 0)
475  dr = val - mEB[2][hashindex];
476  else { // ratio
477  if (mEB[2][hashindex] == 0.) {
478  if (val == 0.)
479  dr = 1.;
480  else
481  dr = 9999.;
482  } else
483  dr = val / mEB[2][hashindex];
484  }
485  barrel_m[2]->Fill(iphi, y, dr);
486  if (dr < mEBmin[2])
487  mEBmin[2] = dr;
488  if (dr > mEBmax[2])
489  mEBmax[2] = dr;
490  }
491  val = (*payload)[id.rawId()].shift_x1;
492  if (irun == 0) {
493  rEB[2][hashindex] = val;
494  } else {
495  if (method == 0)
496  dr = val - rEB[2][hashindex];
497  else { // ratio
498  if (rEB[2][hashindex] == 0.) {
499  if (val == 0.)
500  dr = 1.;
501  else
502  dr = 9999.;
503  } else
504  dr = val / rEB[2][hashindex];
505  }
506  barrel_r[2]->Fill(iphi, y, dr);
507  if (dr < rEBmin[2])
508  rEBmin[2] = dr;
509  if (dr > rEBmax[2])
510  rEBmax[2] = dr;
511  }
512  } // iphi
513  } // ieta
514 
515  for (int ix = 0; ix < IX_MAX; ix++) {
516  for (int iy = 0; iy < IY_MAX; iy++) {
517  if (!EEDetId::validDetId(ix + 1, iy + 1, thesign))
518  continue;
519  EEDetId id(ix + 1, iy + 1, thesign);
520  int hashindex = id.hashedIndex();
521  float val = (*payload)[id.rawId()].mult_x12;
522  if (irun == 0) {
523  mEE[0][hashindex] = val;
524  } else {
525  if (method == 0)
526  dr = val - mEE[0][hashindex];
527  else { // ratio
528  if (mEE[0][hashindex] == 0.) {
529  if (val == 0.)
530  dr = 1.;
531  else
532  dr = 9999.;
533  } else
534  dr = val / mEE[0][hashindex];
535  }
536  if (thesign == 1)
537  endc_p_m[0]->Fill(ix + 1, iy + 1, dr);
538  else
539  endc_m_m[0]->Fill(ix + 1, iy + 1, dr);
540  if (dr < mEEmin[0])
541  mEEmin[0] = dr;
542  if (dr > mEEmax[0])
543  mEEmax[0] = dr;
544  }
545  val = (*payload)[id.rawId()].shift_x12;
546  if (irun == 0) {
547  rEE[0][hashindex] = val;
548  } else {
549  if (method == 0)
550  dr = val - rEE[0][hashindex];
551  else { // ratio
552  if (rEE[0][hashindex] == 0.) {
553  if (val == 0.)
554  dr = 1.;
555  else
556  dr = 9999.;
557  } else
558  dr = val / rEE[0][hashindex];
559  }
560  if (thesign == 1)
561  endc_p_r[0]->Fill(ix + 1, iy + 1, dr);
562  else
563  endc_m_r[0]->Fill(ix + 1, iy + 1, dr);
564  if (dr < rEEmin[0])
565  rEEmin[0] = dr;
566  if (dr > rEEmax[0])
567  rEEmax[0] = dr;
568  }
569  val = (*payload)[id.rawId()].mult_x6;
570  if (irun == 0) {
571  mEE[1][hashindex] = val;
572  } else {
573  if (method == 0)
574  dr = val - mEE[1][hashindex];
575  else { // ratio
576  if (mEE[1][hashindex] == 0.) {
577  if (val == 0.)
578  dr = 1.;
579  else
580  dr = 9999.;
581  } else
582  dr = val / mEE[1][hashindex];
583  }
584  if (thesign == 1)
585  endc_p_m[1]->Fill(ix + 1, iy + 1, dr);
586  else
587  endc_m_m[1]->Fill(ix + 1, iy + 1, dr);
588  if (dr < mEEmin[1])
589  mEEmin[1] = dr;
590  if (dr > mEEmax[1])
591  mEEmax[1] = dr;
592  }
593  val = (*payload)[id.rawId()].shift_x6;
594  if (irun == 0) {
595  rEE[1][hashindex] = val;
596  } else {
597  if (method == 0)
598  dr = val - rEE[1][hashindex];
599  else { // ratio
600  if (rEE[1][hashindex] == 0.) {
601  if (val == 0.)
602  dr = 1.;
603  else
604  dr = 9999.;
605  } else
606  dr = val / rEE[1][hashindex];
607  }
608  if (thesign == 1)
609  endc_p_r[1]->Fill(ix + 1, iy + 1, dr);
610  else
611  endc_m_r[1]->Fill(ix + 1, iy + 1, dr);
612  if (dr < rEEmin[1])
613  rEEmin[1] = dr;
614  if (dr > rEEmax[1])
615  rEEmax[1] = dr;
616  }
617  val = (*payload)[id.rawId()].mult_x1;
618  if (irun == 0) {
619  mEE[2][hashindex] = val;
620  } else {
621  if (method == 0)
622  dr = val - mEE[2][hashindex];
623  else { // ratio
624  if (mEE[2][hashindex] == 0.) {
625  if (val == 0.)
626  dr = 1.;
627  else
628  dr = 9999.;
629  } else
630  dr = val / mEE[2][hashindex];
631  }
632  if (thesign == 1)
633  endc_p_m[2]->Fill(ix + 1, iy + 1, dr);
634  else
635  endc_m_m[2]->Fill(ix + 1, iy + 1, dr);
636  if (dr < mEEmin[2])
637  mEEmin[2] = dr;
638  if (dr > mEEmax[2])
639  mEEmax[2] = dr;
640  }
641  val = (*payload)[id.rawId()].shift_x1;
642  if (irun == 0) {
643  rEE[2][hashindex] = val;
644  } else {
645  if (method == 0)
646  dr = val - rEE[2][hashindex];
647  else { // ratio
648  if (rEE[2][hashindex] == 0.) {
649  if (val == 0.)
650  dr = 1.;
651  else
652  dr = 9999.;
653  } else
654  dr = val / rEE[2][hashindex];
655  }
656  if (thesign == 1)
657  endc_p_r[2]->Fill(ix + 1, iy + 1, dr);
658  else
659  endc_m_r[2]->Fill(ix + 1, iy + 1, dr);
660  if (dr < rEEmin[2])
661  rEEmin[2] = dr;
662  if (dr > rEEmax[2])
663  rEEmax[2] = dr;
664  }
665  // fout << " x " << ix << " y " << " dr " << dr << std::endl;
666  } // iy
667  } // ix
668  } // side
669  } // if payload.get()
670  else
671  return false;
672  } // loop over IOVs
673 
674  gStyle->SetPalette(1);
675  gStyle->SetOptStat(0);
676  TCanvas canvas("CC map", "CC map", 1200, 1800);
677  TLatex t1;
678  t1.SetNDC();
679  t1.SetTextAlign(26);
680  int len = l_tagname[0].length() + l_tagname[1].length();
681  std::string dr[2] = {"-", "/"};
682  if (ntags == 2) {
683  if (len < 70) {
684  t1.SetTextSize(0.03);
685  t1.DrawLatex(
686  0.5,
687  0.96,
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]));
689  } else {
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]));
692  }
693  } else {
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]));
696  }
697 
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];
703  for (int obj = 0; obj < 3; obj++) {
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();
708  }
709  }
710 
711  for (int gId = 0; gId < kGains; gId++) {
712  pad[gId][0]->cd();
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]);
716  pad[gId][1]->cd();
717  DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
718  pad[gId + 3][1]->cd();
719  DrawEB(barrel_r[gId], rEBmin[gId], rEBmax[gId]);
720  pad[gId][2]->cd();
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]);
724  }
725 
726  std::string ImageName(this->m_imageFileName);
727  canvas.SaveAs(ImageName.c_str());
728  return true;
729  } // fill method
730  }; // class EcalPedestalsDiffBase
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>;
735 
736 } // namespace
737 
738 // Register the classes as boost python plugin
740  PAYLOAD_INSPECTOR_CLASS(EcalTPGLinearizationConstPlot);
741  PAYLOAD_INSPECTOR_CLASS(EcalTPGLinearizationConstDiffOneTag);
742  PAYLOAD_INSPECTOR_CLASS(EcalTPGLinearizationConstDiffTwoTags);
743  PAYLOAD_INSPECTOR_CLASS(EcalTPGLinearizationConstRatioOneTag);
744  PAYLOAD_INSPECTOR_CLASS(EcalTPGLinearizationConstRatioTwoTags);
745 }
uint16_t *__restrict__ id
double sign(double x)
static const int kSides
const Int_t gainValues[kGains]
void DrawEE(TH2F *endc, float min, float max)
Definition: EcalDrawUtils.h:29
void DrawEB(TH2F *ebmap, float min, float max)
Definition: EcalDrawUtils.h:4
def canvas
Definition: svgfig.py:482
#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)
Definition: EEDetId.h:248
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
const Int_t kGains