CMS 3D CMS Logo

EcalPedestals_PayloadInspector.cc
Go to the documentation of this file.
4 
5 // the data format of the condition to be inspected
10 
11 #include "TH2F.h"
12 #include "TCanvas.h"
13 #include "TStyle.h"
14 #include "TLine.h"
15 #include "TLatex.h"
16 
17 #include <memory>
18 #include <sstream>
19 
20 namespace {
21  enum { kEBChannels = 61200, kEEChannels = 14648, kGains = 3, kRMS = 5 };
22  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 85, MAX_IPHI = 360 }; // barrel lower and upper bounds on eta and phi
23  enum { IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100 }; // endcaps lower and upper bounds on x and y
24 
25  /**************************************
26  1d plot of ECAL pedestal of 1 IOV
27  ***************************************/
28  class EcalPedestalsHist : public cond::payloadInspector::PlotImage<EcalPedestals> {
29  public:
30  EcalPedestalsHist() : cond::payloadInspector::PlotImage<EcalPedestals>("ECAL pedestal map") { setSingleIov(true); }
31  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
32  uint32_t gainValues[kGains] = {12, 6, 1};
33  TH1F** barrel_m = new TH1F*[kGains];
34  TH1F** endcap_m = new TH1F*[kGains];
35  TH1F** barrel_r = new TH1F*[kGains];
36  TH1F** endcap_r = new TH1F*[kGains];
37  float bmin[kGains] = {0.7, 0.5, 0.4};
38  float bmax[kGains] = {3.3, 2.0, 1.0}; // 11/01/2023
39  float emin[kGains] = {1.5, 0.8, 0.4};
40  float emax[kGains] = {3.0, 2.0, 1.0}; // 11/01/2023
41  for (int gainId = 0; gainId < kGains; gainId++) {
42  barrel_m[gainId] = new TH1F(Form("EBm%i", gainId), Form("mean %i EB", gainValues[gainId]), 100, 150., 250.);
43  endcap_m[gainId] = new TH1F(Form("EEm%i", gainId), Form("mean %i EE", gainValues[gainId]), 100, 150., 250.);
44  barrel_r[gainId] =
45  new TH1F(Form("EBr%i", gainId), Form("rms %i EB", gainValues[gainId]), 100, bmin[gainId], bmax[gainId]);
46  endcap_r[gainId] =
47  new TH1F(Form("EEr%i", gainId), Form("rms %i EE", gainValues[gainId]), 100, emin[gainId], emax[gainId]);
48  }
49  auto iov = iovs.front();
50  std::shared_ptr<EcalPedestals> payload = fetchPayload(std::get<1>(iov));
51  unsigned int run = std::get<0>(iov);
52  if (payload.get()) {
53  // looping over the EB channels, via the dense-index, mapped into EBDetId's
54  if (payload->barrelItems().empty())
55  return false;
56  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
57  uint32_t rawid = EBDetId::unhashIndex(cellid);
58  if (payload->find(rawid) == payload->end())
59  continue;
60  barrel_m[0]->Fill((*payload)[rawid].mean_x12);
61  barrel_r[0]->Fill((*payload)[rawid].rms_x12);
62  barrel_m[1]->Fill((*payload)[rawid].mean_x6);
63  barrel_r[1]->Fill((*payload)[rawid].rms_x6);
64  barrel_m[2]->Fill((*payload)[rawid].mean_x1);
65  barrel_r[2]->Fill((*payload)[rawid].rms_x1);
66  } // loop over cellid
67  if (payload->endcapItems().empty())
68  return false;
69 
70  // looping over the EE channels
71  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
72  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
73  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
74  if (EEDetId::validDetId(ix, iy, iz)) {
75  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
76  uint32_t rawid = myEEId.rawId();
77  if (payload->find(rawid) == payload->end())
78  continue;
79  endcap_m[0]->Fill((*payload)[rawid].mean_x12);
80  endcap_r[0]->Fill((*payload)[rawid].rms_x12);
81  endcap_m[1]->Fill((*payload)[rawid].mean_x6);
82  endcap_r[1]->Fill((*payload)[rawid].rms_x6);
83  endcap_m[2]->Fill((*payload)[rawid].mean_x1);
84  endcap_r[2]->Fill((*payload)[rawid].rms_x1);
85  } // validDetId
86  } // if payload.get()
87  else
88  return false;
89 
90  gStyle->SetPalette(1);
91  gStyle->SetOptStat(111110);
92  TCanvas canvas("CC map", "CC map", 1600, 2600);
93  TLatex t1;
94  t1.SetNDC();
95  t1.SetTextAlign(26);
96  t1.SetTextSize(0.05);
97  t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i", run));
98 
99  float xmi[2] = {0.0, 0.50};
100  float xma[2] = {0.50, 1.00};
101  TPad*** pad = new TPad**[6];
102  for (int gId = 0; gId < 6; gId++) {
103  pad[gId] = new TPad*[2];
104  for (int obj = 0; obj < 2; obj++) {
105  // float yma = 1.- (0.17 * gId);
106  // float ymi = yma - 0.15;
107  float yma = 0.94 - (0.16 * gId);
108  float ymi = yma - 0.14;
109  pad[gId][obj] = new TPad(Form("p_%i_%i", obj, gId), Form("p_%i_%i", obj, gId), xmi[obj], ymi, xma[obj], yma);
110  pad[gId][obj]->Draw();
111  }
112  }
113  for (int gId = 0; gId < kGains; gId++) {
114  pad[gId][0]->cd();
115  barrel_m[gId]->Draw();
116  pad[gId + kGains][0]->cd();
117  barrel_r[gId]->Draw();
118  pad[gId][1]->cd();
119  endcap_m[gId]->Draw();
120  pad[gId + kGains][1]->cd();
121  endcap_r[gId]->Draw();
122  }
123 
124  std::string ImageName(m_imageFileName);
125  canvas.SaveAs(ImageName.c_str());
126  return true;
127  } // fill method
128  }; // class EcalPedestalsHist
129 
130  /**************************************
131  2d plot of ECAL pedestal of 1 IOV
132  ***************************************/
133 
134  class EcalPedestalsPlot : public cond::payloadInspector::PlotImage<EcalPedestals> {
135  public:
136  EcalPedestalsPlot() : cond::payloadInspector::PlotImage<EcalPedestals>("ECAL pedestal map") { setSingleIov(true); }
137  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
138  uint32_t gainValues[kGains] = {12, 6, 1};
139  TH2F** barrel_m = new TH2F*[kGains];
140  TH2F** endc_p_m = new TH2F*[kGains];
141  TH2F** endc_m_m = new TH2F*[kGains];
142  TH2F** barrel_r = new TH2F*[kGains];
143  TH2F** endc_p_r = new TH2F*[kGains];
144  TH2F** endc_m_r = new TH2F*[kGains];
145  double EBmean[kGains], EBrms[kGains], EEmean[kGains], EErms[kGains], pEBmin[kGains], pEBmax[kGains],
146  pEEmin[kGains], pEEmax[kGains];
147  int EBtot[kGains], EEtot[kGains];
148  for (int gId = 0; gId < kGains; gId++) {
149  barrel_m[gId] = new TH2F(Form("EBm%i", gId),
150  Form("mean %i EB", gainValues[gId]),
151  MAX_IPHI,
152  0,
153  MAX_IPHI,
154  2 * MAX_IETA,
155  -MAX_IETA,
156  MAX_IETA);
157  endc_p_m[gId] = new TH2F(Form("EE+m%i", gId),
158  Form("mean %i EE+", gainValues[gId]),
159  IX_MAX,
160  IX_MIN,
161  IX_MAX + 1,
162  IY_MAX,
163  IY_MIN,
164  IY_MAX + 1);
165  endc_m_m[gId] = new TH2F(Form("EE-m%i", gId),
166  Form("mean %i EE-", gainValues[gId]),
167  IX_MAX,
168  IX_MIN,
169  IX_MAX + 1,
170  IY_MAX,
171  IY_MIN,
172  IY_MAX + 1);
173  barrel_r[gId] = new TH2F(Form("EBr%i", gId),
174  Form("rms %i EB", gainValues[gId]),
175  MAX_IPHI,
176  0,
177  MAX_IPHI,
178  2 * MAX_IETA,
179  -MAX_IETA,
180  MAX_IETA);
181  endc_p_r[gId] = new TH2F(Form("EE+r%i", gId),
182  Form("rms %i EE+", gainValues[gId]),
183  IX_MAX,
184  IX_MIN,
185  IX_MAX + 1,
186  IY_MAX,
187  IY_MIN,
188  IY_MAX + 1);
189  endc_m_r[gId] = new TH2F(Form("EE-r%i", gId),
190  Form("rms %i EE-", gainValues[gId]),
191  IX_MAX,
192  IX_MIN,
193  IX_MAX + 1,
194  IY_MAX,
195  IY_MIN,
196  IY_MAX + 1);
197  EBmean[gId] = 0.;
198  EBrms[gId] = 0.;
199  EEmean[gId] = 0.;
200  EErms[gId] = 0.;
201  EBtot[gId] = 0;
202  EEtot[gId] = 0;
203  }
204  auto iov = iovs.front();
205  std::shared_ptr<EcalPedestals> payload = fetchPayload(std::get<1>(iov));
206  unsigned int run = std::get<0>(iov);
207  if (payload.get()) {
208  // looping over the EB channels, via the dense-index, mapped into EBDetId's
209  if (payload->barrelItems().empty())
210  return false;
211  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) { // loop on EE cells
212  uint32_t rawid = EBDetId::unhashIndex(cellid);
213  if (payload->find(rawid) == payload->end())
214  continue;
215  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
216  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
217  if (eta > 0.)
218  eta = eta - 0.5; // 0.5 to 84.5
219  else
220  eta = eta + 0.5; // -84.5 to -0.5
221  barrel_m[0]->Fill(phi, eta, (*payload)[rawid].mean_x12);
222  Double_t val = (*payload)[rawid].rms_x12;
223  barrel_r[0]->Fill(phi, eta, val);
224  if (val < 10) {
225  EBmean[0] = EBmean[0] + val;
226  EBrms[0] = EBrms[0] + val * val;
227  EBtot[0]++;
228  }
229  // else std::cout << " gain 12 chan " << cellid << " val " << val << std::endl;
230  barrel_m[1]->Fill(phi, eta, (*payload)[rawid].mean_x6);
231  val = (*payload)[rawid].rms_x6;
232  barrel_r[1]->Fill(phi, eta, val);
233  if (val < 10) {
234  EBmean[1] = EBmean[1] + val;
235  EBrms[1] = EBrms[1] + val * val;
236  EBtot[1]++;
237  }
238  // else std::cout << " gain 6 chan " << cellid << " val " << val << std::endl;
239  barrel_m[2]->Fill(phi, eta, (*payload)[rawid].mean_x1);
240  val = (*payload)[rawid].rms_x1;
241  barrel_r[2]->Fill(phi, eta, val);
242  if (val < 10) {
243  EBmean[2] = EBmean[2] + val;
244  EBrms[2] = EBrms[2] + val * val;
245  EBtot[2]++;
246  }
247  // else std::cout << " gain 1 chan " << cellid << " val " << val << std::endl;
248  } // loop over cellid
249  if (payload->endcapItems().empty())
250  return false;
251 
252  // looping over the EE channels
253  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
254  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
255  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
256  if (EEDetId::validDetId(ix, iy, iz)) {
257  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
258  uint32_t rawid = myEEId.rawId();
259  if (payload->find(rawid) == payload->end())
260  continue;
261  if (iz == 1) {
262  endc_p_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12);
263  Double_t val = (*payload)[rawid].rms_x12;
264  endc_p_r[0]->Fill(ix, iy, val);
265  if (val < 10) {
266  EEmean[0] = EEmean[0] + val;
267  EErms[0] = EErms[0] + val * val;
268  EEtot[0]++;
269  }
270  endc_p_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6);
271  val = (*payload)[rawid].rms_x6;
272  endc_p_r[1]->Fill(ix, iy, val);
273  if (val < 10) {
274  EEmean[1] = EEmean[1] + val;
275  EErms[1] = EErms[1] + val * val;
276  EEtot[1]++;
277  }
278  endc_p_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1);
279  val = (*payload)[rawid].rms_x1;
280  endc_p_r[2]->Fill(ix, iy, val);
281  if (val < 10) {
282  EEmean[2] = EEmean[2] + val;
283  EErms[2] = EErms[2] + val * val;
284  EEtot[2]++;
285  }
286  } else {
287  endc_m_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12);
288  Double_t val = (*payload)[rawid].rms_x12;
289  endc_m_r[0]->Fill(ix, iy, val);
290  if (val < 10) {
291  EEmean[0] = EEmean[0] + val;
292  EErms[0] = EErms[0] + val * val;
293  EEtot[0]++;
294  }
295  endc_m_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6);
296  val = (*payload)[rawid].rms_x6;
297  endc_m_r[1]->Fill(ix, iy, val);
298  if (val < 10) {
299  EEmean[1] = EEmean[1] + val;
300  EErms[1] = EErms[1] + val * val;
301  EEtot[1]++;
302  }
303  endc_m_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1);
304  val = (*payload)[rawid].rms_x1;
305  endc_m_r[2]->Fill(ix, iy, val);
306  if (val < 10) {
307  EEmean[2] = EEmean[2] + val;
308  EErms[2] = EErms[2] + val * val;
309  EEtot[2]++;
310  }
311  }
312  } // validDetId
313  } // if payload.get()
314  else
315  return false;
316 
317  gStyle->SetPalette(1);
318  gStyle->SetOptStat(0);
319  TCanvas canvas("CC map", "CC map", 1600, 2600);
320  TLatex t1;
321  t1.SetNDC();
322  t1.SetTextAlign(26);
323  t1.SetTextSize(0.05);
324  t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i", run));
325 
326  float xmi[3] = {0.0, 0.24, 0.76};
327  float xma[3] = {0.24, 0.76, 1.00};
328  TPad*** pad = new TPad**[6];
329  int view = 0;
330  for (int gId = 0; gId < kGains; gId++) {
331  for (int val = 0; val < 2; val++) { // mean and sigma
332  pad[view] = new TPad*[3];
333  for (int obj = 0; obj < 3; obj++) {
334  float yma = 0.94 - (0.16 * view);
335  float ymi = yma - 0.14;
336  pad[view][obj] =
337  new TPad(Form("p_%i_%i", obj, view), Form("p_%i_%i", obj, view), xmi[obj], ymi, xma[obj], yma);
338  pad[view][obj]->Draw();
339  }
340  view++;
341  }
342  double vt = (double)EBtot[gId];
343  EBmean[gId] = EBmean[gId] / vt;
344  EBrms[gId] = (EBrms[gId] / vt) - (EBmean[gId] * EBmean[gId]);
345  EBrms[gId] = sqrt(EBrms[gId]);
346  if (EBrms[gId] == 0.)
347  EBrms[gId] = 0.001;
348  pEBmin[gId] = EBmean[gId] - kRMS * EBrms[gId];
349  pEBmax[gId] = EBmean[gId] + kRMS * EBrms[gId];
350  // std::cout << " mean " << EBmean[gId] << " rms " << EBrms[gId] << " entries " << EBtot[gId] << " min " << pEBmin[gId]
351  // << " max " << pEBmax[gId] << std::endl;
352  if (pEBmin[gId] < 0.)
353  pEBmin[gId] = 0.;
354  vt = (double)EEtot[gId];
355  EEmean[gId] = EEmean[gId] / vt;
356  EErms[gId] = (EErms[gId] / vt) - (EEmean[gId] * EEmean[gId]);
357  EErms[gId] = sqrt(EErms[gId]);
358  if (EErms[gId] == 0.)
359  EErms[gId] = 0.001;
360  pEEmin[gId] = EEmean[gId] - kRMS * EErms[gId];
361  pEEmax[gId] = EEmean[gId] + kRMS * EErms[gId];
362  // std::cout << " mean " << EEmean[gId] << " rms " << EErms[gId] << " entries " << EEtot[gId] << " min " << pEEmin[gId]
363  // << " max " << pEEmax[gId] << std::endl;
364  if (pEEmin[gId] < 0.)
365  pEEmin[gId] = 0.;
366  }
367  //float bmin[kGains] ={0.7, 0.5, 0.4};
368  //float bmax[kGains] ={2.2, 1.3, 0.7};
369  //float emin[kGains] ={1.5, 0.8, 0.4};
370  //float emax[kGains] ={2.5, 1.5, 0.8};
371  // TLine* l = new TLine(0., 0., 0., 0.);
372  // l->SetLineWidth(1);
373  for (int gId = 0; gId < kGains; gId++) {
374  pad[gId][0]->cd();
375  DrawEE(endc_m_m[gId], 185., 235.); // 11/01/2023
376  pad[gId + kGains][0]->cd();
377  DrawEE(endc_m_r[gId], pEEmin[gId], pEEmax[gId]);
378  pad[gId][1]->cd();
379  DrawEB(barrel_m[gId], 185., 235.); // 11/01/2023
380  pad[gId + kGains][1]->cd();
381  DrawEB(barrel_r[gId], pEBmin[gId], pEBmax[gId]);
382  pad[gId][2]->cd();
383  DrawEE(endc_p_m[gId], 185., 235.); // 11/01/2023
384  pad[gId + kGains][2]->cd();
385  DrawEE(endc_p_r[gId], pEEmin[gId], pEEmax[gId]);
386  }
387 
388  std::string ImageName(m_imageFileName);
389  canvas.SaveAs(ImageName.c_str());
390  return true;
391  } // fill method
392 
393  }; // class EcalPedestalsPlot
394 
395  /*****************************************************************
396  2d plot of ECAL pedestals difference or ratio between 2 IOVs
397  ******************************************************************/
398  template <cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, int method>
399  class EcalPedestalsBase : public cond::payloadInspector::PlotImage<EcalPedestals, nIOVs, ntags> {
400  public:
401  EcalPedestalsBase() : cond::payloadInspector::PlotImage<EcalPedestals, nIOVs, ntags>("ECAL pedestals comparison") {}
402  bool fill() override {
403  uint32_t gainValues[kGains] = {12, 6, 1};
404  TH2F** barrel_m = new TH2F*[kGains];
405  TH2F** endc_p_m = new TH2F*[kGains];
406  TH2F** endc_m_m = new TH2F*[kGains];
407  TH2F** barrel_r = new TH2F*[kGains];
408  TH2F** endc_p_r = new TH2F*[kGains];
409  TH2F** endc_m_r = new TH2F*[kGains];
410  double EBmean[kGains], EBrms[kGains], EEmean[kGains], EErms[kGains], pEBmin[kGains], pEBmax[kGains],
411  pEEmin[kGains], pEEmax[kGains];
412  int EBtot[kGains], EEtot[kGains];
413  for (int gId = 0; gId < kGains; gId++) {
414  barrel_m[gId] = new TH2F(Form("EBm%i", gId),
415  Form("mean %i EB", gainValues[gId]),
416  MAX_IPHI,
417  0,
418  MAX_IPHI,
419  2 * MAX_IETA,
420  -MAX_IETA,
421  MAX_IETA);
422  endc_p_m[gId] = new TH2F(Form("EE+m%i", gId),
423  Form("mean %i EE+", gainValues[gId]),
424  IX_MAX,
425  IX_MIN,
426  IX_MAX + 1,
427  IY_MAX,
428  IY_MIN,
429  IY_MAX + 1);
430  endc_m_m[gId] = new TH2F(Form("EE-m%i", gId),
431  Form("mean %i EE-", gainValues[gId]),
432  IX_MAX,
433  IX_MIN,
434  IX_MAX + 1,
435  IY_MAX,
436  IY_MIN,
437  IY_MAX + 1);
438  barrel_r[gId] = new TH2F(Form("EBr%i", gId),
439  Form("rms %i EB", gainValues[gId]),
440  MAX_IPHI,
441  0,
442  MAX_IPHI,
443  2 * MAX_IETA,
444  -MAX_IETA,
445  MAX_IETA);
446  endc_p_r[gId] = new TH2F(Form("EE+r%i", gId),
447  Form("rms %i EE+", gainValues[gId]),
448  IX_MAX,
449  IX_MIN,
450  IX_MAX + 1,
451  IY_MAX,
452  IY_MIN,
453  IY_MAX + 1);
454  endc_m_r[gId] = new TH2F(Form("EE-r%i", gId),
455  Form("rms %i EE-", gainValues[gId]),
456  IX_MAX,
457  IX_MIN,
458  IX_MAX + 1,
459  IY_MAX,
460  IY_MIN,
461  IY_MAX + 1);
462  EBmean[gId] = 0.;
463  EBrms[gId] = 0.;
464  EEmean[gId] = 0.;
465  EErms[gId] = 0.;
466  EBtot[gId] = 0;
467  EEtot[gId] = 0;
468  }
469  unsigned int run[2] = {0, 0};
470  std::string l_tagname[2];
471  double meanEB[kGains][kEBChannels], rmsEB[kGains][kEBChannels], meanEE[kGains][kEEChannels],
472  rmsEE[kGains][kEEChannels];
473 
474  // std::cout << " running with " << nIOVs << " IOVs and " << ntags << " tags " << std::endl;
475  auto iovs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
476  l_tagname[0] = cond::payloadInspector::PlotBase::getTag<0>().name;
477  auto firstiov = iovs.front();
478  run[0] = std::get<0>(firstiov);
479  std::tuple<cond::Time_t, cond::Hash> lastiov;
480  if (ntags == 2) {
481  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
482  l_tagname[1] = cond::payloadInspector::PlotBase::getTag<1>().name;
483  lastiov = tag2iovs.front();
484  } else {
485  lastiov = iovs.back();
486  l_tagname[1] = l_tagname[0];
487  }
488  run[1] = std::get<0>(lastiov);
489  for (int irun = 0; irun < nIOVs; irun++) {
490  std::shared_ptr<EcalPedestals> payload;
491  if (irun == 0) {
492  payload = this->fetchPayload(std::get<1>(firstiov));
493  } else {
494  payload = this->fetchPayload(std::get<1>(lastiov));
495  }
496  // std::cout << " irun " << irun << " tag " << l_tagname[irun] << " IOV " << run[irun] << std ::endl;
497  if (payload.get()) {
498  if (!payload->barrelItems().empty()) {
499  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
500  uint32_t rawid = EBDetId::unhashIndex(cellid);
501  if (payload->find(rawid) == payload->end())
502  continue;
503 
504  if (irun == 0) {
505  meanEB[0][cellid] = (*payload)[rawid].mean_x12;
506  rmsEB[0][cellid] = (*payload)[rawid].rms_x12;
507  meanEB[1][cellid] = (*payload)[rawid].mean_x6;
508  rmsEB[1][cellid] = (*payload)[rawid].rms_x6;
509  meanEB[2][cellid] = (*payload)[rawid].mean_x1;
510  rmsEB[2][cellid] = (*payload)[rawid].rms_x1;
511  } else {
512  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
513  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
514  if (eta > 0.)
515  eta = eta - 0.5; // 0.5 to 84.5
516  else
517  eta = eta + 0.5; // -84.5 to -0.5
518  double dr, drms;
519  // gain 12
520  float val = (*payload)[rawid].mean_x12;
521  float valr = (*payload)[rawid].rms_x12;
522  if (method == 0) {
523  dr = val - meanEB[0][cellid];
524  drms = valr - rmsEB[0][cellid];
525  } else { // ratio
526  if (meanEB[0][cellid] == 0) {
527  if (val == 0.)
528  dr = 1.;
529  else
530  dr = 9999.; // use a large value
531  } else
532  dr = val / meanEB[0][cellid];
533  if (rmsEB[0][cellid] == 0) {
534  if (valr == 0.)
535  drms = 1.;
536  else
537  drms = 9999.; // use a large value
538  } else
539  drms = valr / rmsEB[0][cellid];
540  }
541  barrel_m[0]->Fill(phi, eta, dr);
542  barrel_r[0]->Fill(phi, eta, drms);
543  if (std::abs(drms) < 1.) {
544  EBmean[0] = EBmean[0] + drms;
545  EBrms[0] = EBrms[0] + drms * drms;
546  EBtot[0]++;
547  }
548  // gain 6
549  val = (*payload)[rawid].mean_x6;
550  valr = (*payload)[rawid].rms_x6;
551  if (method == 0) {
552  dr = val - meanEB[1][cellid];
553  drms = valr - rmsEB[1][cellid];
554  } else { // ratio
555  if (meanEB[1][cellid] == 0) {
556  if (val == 0.)
557  dr = 1.;
558  else
559  dr = 9999.; // use a large value
560  } else
561  dr = val / meanEB[1][cellid];
562  if (rmsEB[1][cellid] == 0) {
563  if (valr == 0.)
564  drms = 1.;
565  else
566  drms = 9999.; // use a large value
567  } else
568  drms = valr / rmsEB[1][cellid];
569  }
570  barrel_m[1]->Fill(phi, eta, dr);
571  barrel_r[1]->Fill(phi, eta, drms);
572  if (std::abs(drms) < 1.) {
573  EBmean[1] = EBmean[1] + drms;
574  EBrms[1] = EBrms[1] + drms * drms;
575  EBtot[1]++;
576  }
577  // gain 1
578  val = (*payload)[rawid].mean_x1;
579  valr = (*payload)[rawid].rms_x1;
580  if (method == 0) {
581  dr = val - meanEB[2][cellid];
582  drms = valr - rmsEB[2][cellid];
583  } else { // ratio
584  if (meanEB[2][cellid] == 0) {
585  if (val == 0.)
586  dr = 1.;
587  else
588  dr = 9999.; // use a large value
589  } else
590  dr = val / meanEB[2][cellid];
591  if (rmsEB[2][cellid] == 0) {
592  if (valr == 0.)
593  drms = 1.;
594  else
595  drms = 9999.; // use a large value
596  } else
597  drms = valr / rmsEB[2][cellid];
598  }
599  barrel_m[2]->Fill(phi, eta, dr);
600  barrel_r[2]->Fill(phi, eta, drms);
601  if (std::abs(drms) < 1.) {
602  EBmean[2] = EBmean[2] + drms;
603  EBrms[2] = EBrms[2] + drms * drms;
604  EBtot[2]++;
605  }
606  }
607  } // loop over cellid
608  } // barrel data present
609  if (payload->endcapItems().empty()) {
610  // looping over the EE channels
611  for (int iz = -1; iz < 2; iz = iz + 2) { // -1 or +1
612  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++) {
613  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++) {
614  if (EEDetId::validDetId(ix, iy, iz)) {
615  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
616  uint32_t rawid = myEEId.rawId();
617  uint32_t index = myEEId.hashedIndex();
618  if (payload->find(rawid) == payload->end())
619  continue;
620  if (irun == 0) {
621  meanEE[0][index] = (*payload)[rawid].mean_x12;
622  rmsEE[0][index] = (*payload)[rawid].rms_x12;
623  meanEE[1][index] = (*payload)[rawid].mean_x6;
624  rmsEE[1][index] = (*payload)[rawid].rms_x6;
625  meanEE[2][index] = (*payload)[rawid].mean_x1;
626  rmsEE[2][index] = (*payload)[rawid].rms_x1;
627  } // fist run
628  else {
629  double dr, drms;
630  // gain 12
631  float val = (*payload)[rawid].mean_x12;
632  float valr = (*payload)[rawid].rms_x12;
633  if (method == 0) {
634  dr = val - meanEE[0][index];
635  drms = valr - rmsEE[0][index];
636  } else { // ratio
637  if (meanEE[0][index] == 0) {
638  if (val == 0.)
639  dr = 1.;
640  else
641  dr = 9999.; // use a large value
642  } else
643  dr = val / meanEE[0][index];
644  if (rmsEE[0][index] == 0) {
645  if (valr == 0.)
646  drms = 1.;
647  else
648  drms = 9999.; // use a large value
649  } else
650  drms = valr / rmsEE[0][index];
651  }
652  if (iz == 1) { // EE+
653  endc_p_m[0]->Fill(ix, iy, dr);
654  endc_p_r[0]->Fill(ix, iy, drms);
655  } else { // EE-
656  endc_m_m[0]->Fill(ix, iy, dr);
657  endc_m_r[0]->Fill(ix, iy, drms);
658  }
659  if (std::abs(drms) < 1.) {
660  EEmean[0] = EEmean[0] + drms;
661  EErms[0] = EErms[0] + drms * drms;
662  EEtot[0]++;
663  }
664  // gain 6
665  val = (*payload)[rawid].mean_x6;
666  valr = (*payload)[rawid].rms_x6;
667  if (method == 0) {
668  dr = val - meanEE[1][index];
669  drms = valr - rmsEE[1][index];
670  } else { // ratio
671  if (meanEE[1][index] == 0) {
672  if (val == 0.)
673  dr = 1.;
674  else
675  dr = 9999.; // use a large value
676  } else
677  dr = val / meanEE[1][index];
678  if (rmsEE[1][index] == 0) {
679  if (valr == 0.)
680  drms = 1.;
681  else
682  drms = 9999.; // use a large value
683  } else
684  drms = valr / rmsEE[1][index];
685  }
686  if (iz == 1) { // EE+
687  endc_p_m[1]->Fill(ix, iy, dr);
688  endc_p_r[1]->Fill(ix, iy, drms);
689  } else { // EE-
690  endc_m_m[1]->Fill(ix, iy, dr);
691  endc_m_r[1]->Fill(ix, iy, drms);
692  }
693  if (std::abs(drms) < 1.) {
694  EEmean[1] = EEmean[1] + drms;
695  EErms[1] = EErms[1] + drms * drms;
696  EEtot[1]++;
697  }
698  // gain 1
699  val = (*payload)[rawid].mean_x1;
700  valr = (*payload)[rawid].rms_x1;
701  if (method == 0) {
702  dr = val - meanEE[2][index];
703  drms = valr - rmsEE[2][index];
704  } else { // ratio
705  if (meanEE[2][index] == 0) {
706  if (val == 0.)
707  dr = 1.;
708  else
709  dr = 9999.; // use a large value
710  } else
711  dr = val / meanEE[2][index];
712  if (rmsEE[2][index] == 0) {
713  if (valr == 0.)
714  drms = 1.;
715  else
716  drms = 9999.; // use a large value
717  } else
718  drms = valr / rmsEE[2][index];
719  }
720  if (iz == 1) { // EE+
721  endc_p_m[2]->Fill(ix, iy, dr);
722  endc_p_r[2]->Fill(ix, iy, drms);
723  } else { // EE-
724  endc_m_m[2]->Fill(ix, iy, dr);
725  endc_m_r[2]->Fill(ix, iy, drms);
726  }
727  if (std::abs(drms) < 1.) {
728  EEmean[2] = EEmean[2] + drms;
729  EErms[2] = EErms[2] + drms * drms;
730  EEtot[2]++;
731  }
732  } // second run
733  } // validDetId
734  } // loop over ix
735  } // loop over iy
736  } // loop over iz
737  } // endcap data present
738  } // if payload.get()
739  else
740  return false;
741  } // loop over IOVs
742 
743  gStyle->SetPalette(1);
744  gStyle->SetOptStat(0);
745  TCanvas canvas("CC map", "CC map", 1600, 2600);
746  TLatex t1;
747  t1.SetNDC();
748  t1.SetTextAlign(26);
749  int len = l_tagname[0].length() + l_tagname[1].length();
750  std::string dr[2] = {"-", "/"};
751  if (ntags == 2) {
752  if (len < 58) {
753  t1.SetTextSize(0.025);
754  t1.DrawLatex(0.5,
755  0.96,
756  Form("%s IOV %i %s %s IOV %i",
757  l_tagname[1].c_str(),
758  run[1],
759  dr[method].c_str(),
760  l_tagname[0].c_str(),
761  run[0]));
762  } else {
763  t1.SetTextSize(0.05);
764  t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i %s %i", run[1], dr[method].c_str(), run[0]));
765  }
766  } else {
767  t1.SetTextSize(0.05);
768  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]));
769  }
770  float xmi[3] = {0.0, 0.24, 0.76};
771  float xma[3] = {0.24, 0.76, 1.00};
772  TPad*** pad = new TPad**[6];
773  int view = 0;
774  for (int gId = 0; gId < kGains; gId++) {
775  for (int val = 0; val < 2; val++) { // mean and sigma
776  pad[view] = new TPad*[3];
777  for (int obj = 0; obj < 3; obj++) {
778  float yma = 0.94 - (0.16 * view);
779  float ymi = yma - 0.14;
780  pad[view][obj] =
781  new TPad(Form("p_%i_%i", obj, view), Form("p_%i_%i", obj, view), xmi[obj], ymi, xma[obj], yma);
782  pad[view][obj]->Draw();
783  }
784  view++;
785  }
786  double vt = (double)EBtot[gId];
787  EBmean[gId] = EBmean[gId] / vt;
788  EBrms[gId] = (EBrms[gId] / vt) - (EBmean[gId] * EBmean[gId]);
789  EBrms[gId] = sqrt(EBrms[gId]);
790  if (EBrms[gId] == 0.)
791  EBrms[gId] = 0.001;
792  pEBmin[gId] = EBmean[gId] - kRMS * EBrms[gId];
793  pEBmax[gId] = EBmean[gId] + kRMS * EBrms[gId];
794  // std::cout << " mean " << EBmean[gId] << " rms " << EBrms[gId] << " entries " << EBtot[gId] << " min " << pEBmin[gId]
795  // << " max " << pEBmax[gId] << std::endl;
796  vt = (double)EEtot[gId];
797  EEmean[gId] = EEmean[gId] / vt;
798  EErms[gId] = (EErms[gId] / vt) - (EEmean[gId] * EEmean[gId]);
799  EErms[gId] = sqrt(EErms[gId]);
800  if (EErms[gId] == 0.)
801  EErms[gId] = 0.001;
802  pEEmin[gId] = EEmean[gId] - kRMS * EErms[gId];
803  pEEmax[gId] = EEmean[gId] + kRMS * EErms[gId];
804  // std::cout << " mean " << EEmean[gId] << " rms " << EErms[gId] << " entries " << EEtot[gId] << " min " << pEEmin[gId]
805  // << " max " << pEEmax[gId] << std::endl;
806  }
807  for (int gId = 0; gId < kGains; gId++) {
808  pad[gId][0]->cd();
809  DrawEE(endc_m_m[gId], -2., 2.);
810  pad[gId + kGains][0]->cd();
811  DrawEE(endc_m_r[gId], pEEmin[gId], pEEmax[gId]);
812  pad[gId][1]->cd();
813  DrawEB(barrel_m[gId], -2., 2.);
814  pad[gId + kGains][1]->cd();
815  DrawEB(barrel_r[gId], pEBmin[gId], pEBmax[gId]);
816  pad[gId][2]->cd();
817  DrawEE(endc_p_m[gId], -2., 2.);
818  pad[gId + kGains][2]->cd();
819  DrawEE(endc_p_r[gId], pEEmin[gId], pEEmax[gId]);
820  }
821 
822  std::string ImageName(this->m_imageFileName);
823  canvas.SaveAs(ImageName.c_str());
824  return true;
825  } // fill method
826  }; // class EcalPedestalsBase
827  using EcalPedestalsDiffOneTag = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 1, 0>;
828  using EcalPedestalsDiffTwoTags = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 2, 0>;
829  using EcalPedestalsRatioOneTag = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 1, 1>;
830  using EcalPedestalsRatioTwoTags = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 2, 1>;
831 
832  /*************************************************
833  2d histogram of ECAL barrel pedestal of 1 IOV
834  *************************************************/
835 
836  // inherit from one of the predefined plot class: Histogram2D
837  class EcalPedestalsEBMean12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
838  public:
839  EcalPedestalsEBMean12Map()
840  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain12 - map",
841  "iphi",
842  MAX_IPHI,
843  MIN_IPHI,
844  MAX_IPHI + MIN_IPHI,
845  "ieta",
846  2 * MAX_IETA + 1,
847  -1 * MAX_IETA,
848  MAX_IETA + 1) {
849  Base::setSingleIov(true);
850  }
851 
852  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
853  bool fill() override {
854  auto tag = PlotBase::getTag<0>();
855  for (auto const& iov : tag.iovs) {
856  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
857  if (payload.get()) {
858  // looping over the EB channels, via the dense-index, mapped into EBDetId's
859  if (payload->barrelItems().empty())
860  return false;
861  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
862  uint32_t rawid = EBDetId::unhashIndex(cellid);
863 
864  // check the existence of ECAL pedestal, for a given ECAL barrel channel
865  if (payload->find(rawid) == payload->end())
866  continue;
867  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
868  continue;
869 
870  // there's no ieta==0 in the EB numbering
871  // int delta = (EBDetId(rawid)).ieta() > 0 ? -1 : 0 ;
872  // fill the Histogram2D here
873  // fillWithValue( (EBDetId(rawid)).iphi() , (EBDetId(rawid)).ieta()+0.5+delta, (*payload)[rawid].mean_x12 );
874  // set min and max on 2d plots
875  float valped = (*payload)[rawid].mean_x12;
876  if (valped > 250.)
877  valped = 250.;
878  // if(valped < 150.) valped = 150.;
879  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
880  } // loop over cellid
881  } // if payload.get()
882  } // loop over IOV's (1 in this case)
883  return true;
884  } // fill method
885  };
886 
887  class EcalPedestalsEBMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
888  public:
889  EcalPedestalsEBMean6Map()
890  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain6 - map",
891  "iphi",
892  MAX_IPHI,
893  MIN_IPHI,
894  MAX_IPHI + MIN_IPHI,
895  "ieta",
896  2 * MAX_IETA + 1,
897  -MAX_IETA,
898  MAX_IETA + 1) {
899  Base::setSingleIov(true);
900  }
901 
902  bool fill() override {
903  auto tag = PlotBase::getTag<0>();
904  for (auto const& iov : tag.iovs) {
905  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
906  if (payload.get()) {
907  // looping over the EB channels, via the dense-index, mapped into EBDetId's
908  if (payload->barrelItems().empty())
909  return false;
910  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
911  uint32_t rawid = EBDetId::unhashIndex(cellid);
912 
913  // check the existence of ECAL pedestal, for a given ECAL barrel channel
914  if (payload->find(rawid) == payload->end())
915  continue;
916  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
917  continue;
918 
919  // set min and max on 2d plots
920  float valped = (*payload)[rawid].mean_x6;
921  if (valped > 250.)
922  valped = 250.;
923  // if(valped < 150.) valped = 150.;
924  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
925  } // loop over cellid
926  } // if payload.get()
927  } // loop over IOV's (1 in this case)
928  return true;
929  } // fill method
930  };
931 
932  class EcalPedestalsEBMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
933  public:
934  EcalPedestalsEBMean1Map()
935  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain1 - map",
936  "iphi",
937  MAX_IPHI,
938  MIN_IPHI,
939  MAX_IPHI + MIN_IPHI,
940  "ieta",
941  2 * MAX_IETA + 1,
942  -MAX_IETA,
943  MAX_IETA + 1) {
944  Base::setSingleIov(true);
945  }
946 
947  bool fill() override {
948  auto tag = PlotBase::getTag<0>();
949  for (auto const& iov : tag.iovs) {
950  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
951  if (payload.get()) {
952  // looping over the EB channels, via the dense-index, mapped into EBDetId's
953  if (payload->barrelItems().empty())
954  return false;
955  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
956  uint32_t rawid = EBDetId::unhashIndex(cellid);
957 
958  // check the existence of ECAL pedestal, for a given ECAL barrel channel
959  if (payload->find(rawid) == payload->end())
960  continue;
961  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1)
962  continue;
963 
964  // set min and max on 2d plots
965  float valped = (*payload)[rawid].mean_x1;
966  if (valped > 250.)
967  valped = 250.;
968  // if(valped < 150.) valped = 150.;
969  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
970  } // loop over cellid
971  } // if payload.get()
972  } // loop over IOV's (1 in this case)
973  return true;
974  } // fill method
975  };
976 
977  class EcalPedestalsEEMean12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
978  public:
979  EcalPedestalsEEMean12Map()
980  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain12 - map",
981  "ix",
982  2.2 * IX_MAX,
983  IX_MIN,
984  2.2 * IX_MAX + 1,
985  "iy",
986  IY_MAX,
987  IY_MIN,
988  IY_MAX + IY_MIN) {
989  Base::setSingleIov(true);
990  }
991 
992  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
993  bool fill() override {
994  auto tag = PlotBase::getTag<0>();
995  for (auto const& iov : tag.iovs) {
996  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
997  if (payload.get()) {
998  if (payload->endcapItems().empty())
999  return false;
1000 
1001  // looping over the EE channels
1002  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1003  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1004  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1005  if (EEDetId::validDetId(ix, iy, iz)) {
1006  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1007  uint32_t rawid = myEEId.rawId();
1008  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1009  if (payload->find(rawid) == payload->end())
1010  continue;
1011  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1012  continue;
1013  // set min and max on 2d plots
1014  float valped = (*payload)[rawid].mean_x12;
1015  if (valped > 250.)
1016  valped = 250.;
1017  // if(valped < 150.) valped = 150.;
1018  if (iz == -1)
1019  fillWithValue(ix, iy, valped);
1020  else
1021  fillWithValue(ix + IX_MAX + 20, iy, valped);
1022 
1023  } // validDetId
1024  } // payload
1025  } // loop over IOV's (1 in this case)
1026  return true;
1027  } // fill method
1028  };
1029 
1030  class EcalPedestalsEEMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1031  public:
1032  EcalPedestalsEEMean6Map()
1033  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain6 - map",
1034  "ix",
1035  2.2 * IX_MAX,
1036  IX_MIN,
1037  2.2 * IX_MAX + 1,
1038  "iy",
1039  IY_MAX,
1040  IY_MIN,
1041  IY_MAX + IY_MIN) {
1042  Base::setSingleIov(true);
1043  }
1044 
1045  bool fill() override {
1046  auto tag = PlotBase::getTag<0>();
1047  for (auto const& iov : tag.iovs) {
1048  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1049  if (payload.get()) {
1050  if (payload->endcapItems().empty())
1051  return false;
1052 
1053  // looping over the EE channels
1054  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1055  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1056  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1057  if (EEDetId::validDetId(ix, iy, iz)) {
1058  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1059  uint32_t rawid = myEEId.rawId();
1060  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1061  if (payload->find(rawid) == payload->end())
1062  continue;
1063  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1064  continue;
1065  // set min and max on 2d plots
1066  float valped = (*payload)[rawid].mean_x6;
1067  if (valped > 250.)
1068  valped = 250.;
1069  // if(valped < 150.) valped = 150.;
1070  if (iz == -1)
1071  fillWithValue(ix, iy, valped);
1072  else
1073  fillWithValue(ix + IX_MAX + 20, iy, valped);
1074  } // validDetId
1075  } // payload
1076  } // loop over IOV's (1 in this case)
1077  return true;
1078  } // fill method
1079  };
1080 
1081  class EcalPedestalsEEMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1082  public:
1083  EcalPedestalsEEMean1Map()
1084  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain1 - map",
1085  "ix",
1086  2.2 * IX_MAX,
1087  IX_MIN,
1088  2.2 * IX_MAX + 1,
1089  "iy",
1090  IY_MAX,
1091  IY_MIN,
1092  IY_MAX + IY_MIN) {
1093  Base::setSingleIov(true);
1094  }
1095 
1096  bool fill() override {
1097  auto tag = PlotBase::getTag<0>();
1098  for (auto const& iov : tag.iovs) {
1099  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1100  if (payload.get()) {
1101  if (payload->endcapItems().empty())
1102  return false;
1103 
1104  // looping over the EE channels
1105  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1106  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1107  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1108  if (EEDetId::validDetId(ix, iy, iz)) {
1109  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1110  uint32_t rawid = myEEId.rawId();
1111  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1112  if (payload->find(rawid) == payload->end())
1113  continue;
1114  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12)
1115  continue;
1116  // set min and max on 2d plots
1117  float valped = (*payload)[rawid].mean_x1;
1118  if (valped > 250.)
1119  valped = 250.;
1120  // if(valped < 150.) valped = 150.;
1121  if (iz == -1)
1122  fillWithValue(ix, iy, valped);
1123  else
1124  fillWithValue(ix + IX_MAX + 20, iy, valped);
1125  } // validDetId
1126  } // if payload.get()
1127  } // loop over IOV's (1 in this case)
1128  return true;
1129  } // fill method
1130  };
1131 
1132  class EcalPedestalsEBRMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1133  public:
1134  EcalPedestalsEBRMS12Map()
1135  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain12 - map",
1136  "iphi",
1137  MAX_IPHI,
1138  MIN_IPHI,
1139  MAX_IPHI + MIN_IPHI,
1140  "ieta",
1141  2 * MAX_IETA + 1,
1142  -1 * MAX_IETA,
1143  MAX_IETA + 1) {
1144  Base::setSingleIov(true);
1145  }
1146 
1147  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
1148  bool fill() override {
1149  auto tag = PlotBase::getTag<0>();
1150  for (auto const& iov : tag.iovs) {
1151  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1152  if (payload.get()) {
1153  // looping over the EB channels, via the dense-index, mapped into EBDetId's
1154  if (payload->barrelItems().empty())
1155  return false;
1156  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1157  uint32_t rawid = EBDetId::unhashIndex(cellid);
1158 
1159  // check the existence of ECAL pedestal, for a given ECAL barrel channel
1160  if (payload->find(rawid) == payload->end())
1161  continue;
1162  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1163  continue;
1164 
1165  // there's no ieta==0 in the EB numbering
1166  // int delta = (EBDetId(rawid)).ieta() > 0 ? -1 : 0 ;
1167  // fill the Histogram2D here
1168  // fillWithValue( (EBDetId(rawid)).iphi() , (EBDetId(rawid)).ieta()+0.5+delta, (*payload)[rawid].mean_x12 );
1169  // set max on noise 2d plots
1170  float valrms = (*payload)[rawid].rms_x12;
1171  if (valrms > 2.2)
1172  valrms = 2.2;
1173  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1174  } // loop over cellid
1175  } // if payload.get()
1176  } // loop over IOV's (1 in this case)
1177  return true;
1178  } // fill method
1179  };
1180 
1181  class EcalPedestalsEBRMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1182  public:
1183  EcalPedestalsEBRMS6Map()
1184  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain6 - map",
1185  "iphi",
1186  MAX_IPHI,
1187  MIN_IPHI,
1188  MAX_IPHI + MIN_IPHI,
1189  "ieta",
1190  2 * MAX_IETA + 1,
1191  -1 * MAX_IETA,
1192  MAX_IETA + 1) {
1193  Base::setSingleIov(true);
1194  }
1195 
1196  bool fill() override {
1197  auto tag = PlotBase::getTag<0>();
1198  for (auto const& iov : tag.iovs) {
1199  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1200  if (payload.get()) {
1201  // looping over the EB channels, via the dense-index, mapped into EBDetId's
1202  if (payload->barrelItems().empty())
1203  return false;
1204  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1205  uint32_t rawid = EBDetId::unhashIndex(cellid);
1206 
1207  // check the existence of ECAL pedestal, for a given ECAL barrel channel
1208  if (payload->find(rawid) == payload->end())
1209  continue;
1210  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1211  continue;
1212 
1213  // set max on noise 2d plots
1214  float valrms = (*payload)[rawid].rms_x6;
1215  if (valrms > 1.5)
1216  valrms = 1.5;
1217  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1218  } // loop over cellid
1219  } // if payload.get()
1220  } // loop over IOV's (1 in this case)
1221  return true;
1222  } // fill method
1223  };
1224 
1225  class EcalPedestalsEBRMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1226  public:
1227  EcalPedestalsEBRMS1Map()
1228  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain1 - map",
1229  "iphi",
1230  MAX_IPHI,
1231  MIN_IPHI,
1232  MAX_IPHI + MIN_IPHI,
1233  "ieta",
1234  2 * MAX_IETA + 1,
1235  -1 * MAX_IETA,
1236  MAX_IETA + 1) {
1237  Base::setSingleIov(true);
1238  }
1239 
1240  bool fill() override {
1241  auto tag = PlotBase::getTag<0>();
1242  for (auto const& iov : tag.iovs) {
1243  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1244  if (payload.get()) {
1245  // looping over the EB channels, via the dense-index, mapped into EBDetId's
1246  if (payload->barrelItems().empty())
1247  return false;
1248  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1249  uint32_t rawid = EBDetId::unhashIndex(cellid);
1250 
1251  // check the existence of ECAL pedestal, for a given ECAL barrel channel
1252  if (payload->find(rawid) == payload->end())
1253  continue;
1254  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1)
1255  continue;
1256 
1257  // set max on noise 2d plots
1258  float valrms = (*payload)[rawid].rms_x1;
1259  if (valrms > 1.0)
1260  valrms = 1.0;
1261  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1262  } // loop over cellid
1263  } // if payload.get()
1264  } // loop over IOV's (1 in this case)
1265  return true;
1266  } // fill method
1267  };
1268 
1269  class EcalPedestalsEERMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1270  public:
1271  EcalPedestalsEERMS12Map()
1272  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain12 - map",
1273  "ix",
1274  2.2 * IX_MAX,
1275  IX_MIN,
1276  2.2 * IX_MAX + 1,
1277  "iy",
1278  IY_MAX,
1279  IY_MIN,
1280  IY_MAX + IY_MIN) {
1281  Base::setSingleIov(true);
1282  }
1283 
1284  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
1285  bool fill() override {
1286  auto tag = PlotBase::getTag<0>();
1287  for (auto const& iov : tag.iovs) {
1288  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1289  if (payload.get()) {
1290  if (payload->endcapItems().empty())
1291  return false;
1292 
1293  // looping over the EE channels
1294  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1295  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1296  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1297  if (EEDetId::validDetId(ix, iy, iz)) {
1298  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1299  uint32_t rawid = myEEId.rawId();
1300  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1301  if (payload->find(rawid) == payload->end())
1302  continue;
1303  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1304  continue;
1305  // set max on noise 2d plots
1306  float valrms = (*payload)[rawid].rms_x12;
1307  if (valrms > 3.5)
1308  valrms = 3.5;
1309  if (iz == -1)
1310  fillWithValue(ix, iy, valrms);
1311  else
1312  fillWithValue(ix + IX_MAX + 20, iy, valrms);
1313 
1314  } // validDetId
1315  } // payload
1316  } // loop over IOV's (1 in this case)
1317  return true;
1318  } // fill method
1319  };
1320 
1321  class EcalPedestalsEERMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1322  public:
1323  EcalPedestalsEERMS6Map()
1324  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain6 - map",
1325  "ix",
1326  2.2 * IX_MAX,
1327  IX_MIN,
1328  2.2 * IX_MAX + 1,
1329  "iy",
1330  IY_MAX,
1331  IY_MIN,
1332  IY_MAX + IY_MIN) {
1333  Base::setSingleIov(true);
1334  }
1335 
1336  bool fill() override {
1337  auto tag = PlotBase::getTag<0>();
1338  for (auto const& iov : tag.iovs) {
1339  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1340  if (payload.get()) {
1341  if (payload->endcapItems().empty())
1342  return false;
1343 
1344  // looping over the EE channels
1345  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1346  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1347  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1348  if (EEDetId::validDetId(ix, iy, iz)) {
1349  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1350  uint32_t rawid = myEEId.rawId();
1351  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1352  if (payload->find(rawid) == payload->end())
1353  continue;
1354  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1355  continue;
1356  // set max on noise 2d plots
1357  float valrms = (*payload)[rawid].rms_x6;
1358  if (valrms > 2.0)
1359  valrms = 2.0;
1360  if (iz == -1)
1361  fillWithValue(ix, iy, valrms);
1362  else
1363  fillWithValue(ix + IX_MAX + 20, iy, valrms);
1364  } // validDetId
1365  } // payload
1366  } // loop over IOV's (1 in this case)
1367  return true;
1368  } // fill method
1369  };
1370 
1371  class EcalPedestalsEERMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1372  public:
1373  EcalPedestalsEERMS1Map()
1374  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain1 - map",
1375  "ix",
1376  2.2 * IX_MAX,
1377  IX_MIN,
1378  2.2 * IX_MAX + 1,
1379  "iy",
1380  IY_MAX,
1381  IY_MIN,
1382  IY_MAX + IY_MIN) {
1383  Base::setSingleIov(true);
1384  }
1385 
1386  bool fill() override {
1387  auto tag = PlotBase::getTag<0>();
1388  for (auto const& iov : tag.iovs) {
1389  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1390  if (payload.get()) {
1391  if (payload->endcapItems().empty())
1392  return false;
1393 
1394  // looping over the EE channels
1395  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1396  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1397  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1398  if (EEDetId::validDetId(ix, iy, iz)) {
1399  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1400  uint32_t rawid = myEEId.rawId();
1401  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1402  if (payload->find(rawid) == payload->end())
1403  continue;
1404  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12)
1405  continue;
1406  // set max on noise 2d plots
1407  float valrms = (*payload)[rawid].rms_x1;
1408  if (valrms > 1.5)
1409  valrms = 1.5;
1410  if (iz == -1)
1411  fillWithValue(ix, iy, valrms);
1412  else
1413  fillWithValue(ix + IX_MAX + 20, iy, valrms);
1414  } // validDetId
1415  } // if payload.get()
1416  } // loop over IOV's (1 in this case)
1417  return true;
1418  } // fill method
1419  };
1420 
1421  /*****************************************
1422  2d plot of Ecal Pedestals Summary of 1 IOV
1423  ******************************************/
1424  class EcalPedestalsSummaryPlot : public cond::payloadInspector::PlotImage<EcalPedestals> {
1425  public:
1426  EcalPedestalsSummaryPlot() : cond::payloadInspector::PlotImage<EcalPedestals>("Ecal Pedestals Summary - map ") {
1427  setSingleIov(true);
1428  }
1429 
1430  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
1431  auto iov = iovs.front(); //get reference to 1st element in the vector iovs
1432  std::shared_ptr<EcalPedestals> payload =
1433  fetchPayload(std::get<1>(iov)); //std::get<1>(iov) refers to the Hash in the tuple iov
1434  unsigned int run = std::get<0>(iov); //referes to Time_t in iov.
1435  TH2F* align; //pointer to align which is a 2D histogram
1436 
1437  int NbRows = 6;
1438  int NbColumns = 5;
1439 
1440  if (payload.get()) { //payload is an iov retrieved from payload using hash.
1441 
1442  align = new TH2F("Ecal Pedestals Summary",
1443  "EB/EE Gain Mean RMS Total Items",
1444  NbColumns,
1445  0,
1446  NbColumns,
1447  NbRows,
1448  0,
1449  NbRows);
1450 
1451  float ebVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
1452  float eeVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
1453 
1454  long unsigned int ebTotal = (payload->barrelItems()).size();
1455  long unsigned int eeTotal = (payload->endcapItems()).size();
1456 
1457  pedestalsSummary(payload->barrelItems(), ebVals, ebTotal);
1458  pedestalsSummary(payload->endcapItems(), eeVals, eeTotal);
1459 
1460  double row = NbRows - 0.5;
1461 
1462  //EB summary values
1463  align->Fill(1.5, row, 12); //Gain
1464  align->Fill(2.5, row, ebVals[0]); //mean12
1465  align->Fill(3.5, row, ebVals[1]); //rms12
1466 
1467  row--;
1468 
1469  align->Fill(0.5, row, 1);
1470  align->Fill(1.5, row, 6); //Gain
1471  align->Fill(2.5, row, ebVals[2]); //mean6
1472  align->Fill(3.5, row, ebVals[3]); //rms6
1473  align->Fill(4.5, row, ebTotal);
1474 
1475  row--;
1476 
1477  align->Fill(1.5, row, 1); //Gain
1478  align->Fill(2.5, row, ebVals[4]); //mean1
1479  align->Fill(3.5, row, ebVals[5]); //rms1
1480 
1481  row--;
1482 
1483  //EE summary values
1484  align->Fill(1.5, row, 12); //Gain
1485  align->Fill(2.5, row, eeVals[0]); //mean12
1486  align->Fill(3.5, row, eeVals[1]); //rms12
1487 
1488  row--;
1489 
1490  align->Fill(0.5, row, 2);
1491  align->Fill(1.5, row, 6); //Gain
1492  align->Fill(2.5, row, eeVals[2]); //mean6
1493  align->Fill(3.5, row, eeVals[3]); //rms6
1494  align->Fill(4.5, row, eeTotal);
1495 
1496  row--;
1497 
1498  align->Fill(1.5, row, 1); //Gain
1499  align->Fill(2.5, row, eeVals[4]); //mean1
1500  align->Fill(3.5, row, eeVals[5]); //rms1
1501 
1502  } // if payload.get()
1503  else
1504  return false;
1505 
1506  gStyle->SetPalette(1);
1507  gStyle->SetOptStat(0);
1508  TCanvas canvas("CC map", "CC map", 1000, 1000);
1509  TLatex t1;
1510  t1.SetNDC();
1511  t1.SetTextAlign(26);
1512  t1.SetTextSize(0.05);
1513  t1.SetTextColor(2);
1514  t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals Summary, IOV %i", run));
1515 
1516  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
1517  pad->Draw();
1518  pad->cd();
1519  align->Draw("TEXT");
1520  TLine* l = new TLine;
1521  l->SetLineWidth(1);
1522 
1523  for (int i = 1; i < NbRows; i++) {
1524  double y = (double)i;
1525  if (i == NbRows / 2)
1526  l = new TLine(0., y, NbColumns, y);
1527  else
1528  l = new TLine(1., y, NbColumns - 1, y);
1529  l->Draw();
1530  }
1531 
1532  for (int i = 1; i < NbColumns; i++) {
1533  double x = (double)i;
1534  double y = (double)NbRows;
1535  l = new TLine(x, 0., x, y);
1536  l->Draw();
1537  }
1538 
1539  align->GetXaxis()->SetTickLength(0.);
1540  align->GetXaxis()->SetLabelSize(0.);
1541  align->GetYaxis()->SetTickLength(0.);
1542  align->GetYaxis()->SetLabelSize(0.);
1543 
1544  std::string ImageName(m_imageFileName);
1545  canvas.SaveAs(ImageName.c_str());
1546  return true;
1547  } // fill method
1548 
1549  void pedestalsSummary(std::vector<EcalPedestal> vItems, float vals[], long unsigned int& total) {
1550  for (std::vector<EcalPedestal>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++iItems) {
1551  //vals[0]=100;
1552  vals[0] += iItems->mean(1); //G12
1553  vals[1] += iItems->rms(1);
1554  vals[2] += iItems->mean(2); //G6
1555  vals[3] += iItems->rms(2);
1556  vals[4] += iItems->mean(3); //G1
1557  vals[5] += iItems->rms(3);
1558  }
1559 
1560  vals[0] = vals[0] / total;
1561  vals[1] = vals[1] / total;
1562  vals[2] = vals[2] / total;
1563  vals[3] = vals[3] / total;
1564  vals[4] = vals[4] / total;
1565  vals[5] = vals[5] / total;
1566  }
1567  };
1568 
1569 } // namespace
1570 
1571 // Register the classes as boost python plugin
1573  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsHist);
1574  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsPlot);
1575  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsDiffOneTag);
1576  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsDiffTwoTags);
1577  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsRatioOneTag);
1578  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsRatioTwoTags);
1579  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean12Map);
1580  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean6Map);
1581  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean1Map);
1582  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean12Map);
1583  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean6Map);
1584  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean1Map);
1585  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS12Map);
1586  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS6Map);
1587  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS1Map);
1588  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS12Map);
1589  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS6Map);
1590  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS1Map);
1591  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsSummaryPlot);
1592 }
size
Write out results.
static const int XYMODE
Definition: EEDetId.h:335
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
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
T sqrt(T t)
Definition: SSEVec.h:19
static const int MIN_HASH
Definition: EBDetId.h:149
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
def canvas(sub, attr)
Definition: svgfig.py:482
int hashedIndex() const
Definition: EEDetId.h:183
const Int_t kGains