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] = {2.2, 1.3, 0.7};
39  float emin[kGains] = {1.5, 0.8, 0.4};
40  float emax[kGains] = {2.5, 1.5, 0.8};
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], 175., 225.);
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], 175., 225.);
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], 175., 225.);
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 between 2 IOVs
397  *************************************************************/
398  class EcalPedestalsDiff : public cond::payloadInspector::PlotImage<EcalPedestals> {
399  public:
400  EcalPedestalsDiff() : cond::payloadInspector::PlotImage<EcalPedestals>("ECAL Barrel channel status difference") {
401  setSingleIov(false);
402  }
403  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
404  uint32_t gainValues[kGains] = {12, 6, 1};
405  TH2F** barrel_m = new TH2F*[kGains];
406  TH2F** endc_p_m = new TH2F*[kGains];
407  TH2F** endc_m_m = new TH2F*[kGains];
408  TH2F** barrel_r = new TH2F*[kGains];
409  TH2F** endc_p_r = new TH2F*[kGains];
410  TH2F** endc_m_r = new TH2F*[kGains];
411  double EBmean[kGains], EBrms[kGains], EEmean[kGains], EErms[kGains], pEBmin[kGains], pEBmax[kGains],
412  pEEmin[kGains], pEEmax[kGains];
413  int EBtot[kGains], EEtot[kGains];
414  for (int gId = 0; gId < kGains; gId++) {
415  barrel_m[gId] = new TH2F(Form("EBm%i", gId),
416  Form("mean %i EB", gainValues[gId]),
417  MAX_IPHI,
418  0,
419  MAX_IPHI,
420  2 * MAX_IETA,
421  -MAX_IETA,
422  MAX_IETA);
423  endc_p_m[gId] = new TH2F(Form("EE+m%i", gId),
424  Form("mean %i EE+", gainValues[gId]),
425  IX_MAX,
426  IX_MIN,
427  IX_MAX + 1,
428  IY_MAX,
429  IY_MIN,
430  IY_MAX + 1);
431  endc_m_m[gId] = new TH2F(Form("EE-m%i", gId),
432  Form("mean %i EE-", gainValues[gId]),
433  IX_MAX,
434  IX_MIN,
435  IX_MAX + 1,
436  IY_MAX,
437  IY_MIN,
438  IY_MAX + 1);
439  barrel_r[gId] = new TH2F(Form("EBr%i", gId),
440  Form("rms %i EB", gainValues[gId]),
441  MAX_IPHI,
442  0,
443  MAX_IPHI,
444  2 * MAX_IETA,
445  -MAX_IETA,
446  MAX_IETA);
447  endc_p_r[gId] = new TH2F(Form("EE+r%i", gId),
448  Form("rms %i EE+", gainValues[gId]),
449  IX_MAX,
450  IX_MIN,
451  IX_MAX + 1,
452  IY_MAX,
453  IY_MIN,
454  IY_MAX + 1);
455  endc_m_r[gId] = new TH2F(Form("EE-r%i", gId),
456  Form("rms %i EE-", gainValues[gId]),
457  IX_MAX,
458  IX_MIN,
459  IX_MAX + 1,
460  IY_MAX,
461  IY_MIN,
462  IY_MAX + 1);
463  EBmean[gId] = 0.;
464  EBrms[gId] = 0.;
465  EEmean[gId] = 0.;
466  EErms[gId] = 0.;
467  EBtot[gId] = 0;
468  EEtot[gId] = 0;
469  }
470  unsigned int run[2], irun = 0;
471  // unsigned int irun = 0;
472  double meanEB[kGains][kEBChannels], rmsEB[kGains][kEBChannels], meanEE[kGains][kEEChannels],
473  rmsEE[kGains][kEEChannels];
474  for (auto const& iov : iovs) {
475  std::shared_ptr<EcalPedestals> payload = fetchPayload(std::get<1>(iov));
476  run[irun] = std::get<0>(iov);
477  // std::cout << "run " << irun << " : " << run[irun] << std::endl;
478  if (payload.get()) {
479  if (payload->barrelItems().empty())
480  return false;
481  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
482  uint32_t rawid = EBDetId::unhashIndex(cellid);
483  if (payload->find(rawid) == payload->end())
484  continue;
485 
486  if (irun == 0) {
487  meanEB[0][cellid] = (*payload)[rawid].mean_x12;
488  rmsEB[0][cellid] = (*payload)[rawid].rms_x12;
489  meanEB[1][cellid] = (*payload)[rawid].mean_x6;
490  rmsEB[1][cellid] = (*payload)[rawid].rms_x6;
491  meanEB[2][cellid] = (*payload)[rawid].mean_x1;
492  rmsEB[2][cellid] = (*payload)[rawid].rms_x1;
493  } else {
494  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
495  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
496  if (eta > 0.)
497  eta = eta - 0.5; // 0.5 to 84.5
498  else
499  eta = eta + 0.5; // -84.5 to -0.5
500  barrel_m[0]->Fill(phi, eta, (*payload)[rawid].mean_x12 - meanEB[0][cellid]);
501  double diff = (*payload)[rawid].rms_x12 - rmsEB[0][cellid];
502  barrel_r[0]->Fill(phi, eta, diff);
503  if (std::abs(diff) < 1.) {
504  EBmean[0] = EBmean[0] + diff;
505  EBrms[0] = EBrms[0] + diff * diff;
506  EBtot[0]++;
507  }
508  // else std::cout << " gain 12 chan " << cellid << " diff " << diff << std::endl;
509  barrel_m[1]->Fill(phi, eta, (*payload)[rawid].mean_x6 - meanEB[1][cellid]);
510  diff = (*payload)[rawid].rms_x6 - rmsEB[1][cellid];
511  barrel_r[1]->Fill(phi, eta, diff);
512  if (std::abs(diff) < 1.) {
513  EBmean[1] = EBmean[1] + diff;
514  EBrms[1] = EBrms[1] + diff * diff;
515  EBtot[1]++;
516  }
517  // else std::cout << " gain 6 chan " << cellid << " diff " << diff << std::endl;
518  barrel_m[2]->Fill(phi, eta, (*payload)[rawid].mean_x1 - meanEB[2][cellid]);
519  diff = (*payload)[rawid].rms_x1 - rmsEB[2][cellid];
520  barrel_r[2]->Fill(phi, eta, diff);
521  if (std::abs(diff) < 1.) {
522  EBmean[2] = EBmean[2] + diff;
523  EBrms[2] = EBrms[2] + diff * diff;
524  EBtot[2]++;
525  }
526  // else std::cout << " gain 1 chan " << cellid << " diff " << diff << std::endl;
527  }
528  } // loop over cellid
529 
530  if (payload->endcapItems().empty())
531  return false;
532  // looping over the EE channels
533  for (int iz = -1; iz < 2; iz = iz + 2) { // -1 or +1
534  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++) {
535  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++) {
536  if (EEDetId::validDetId(ix, iy, iz)) {
537  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
538  uint32_t rawid = myEEId.rawId();
539  uint32_t index = myEEId.hashedIndex();
540  if (payload->find(rawid) == payload->end())
541  continue;
542  if (irun == 0) {
543  meanEE[0][index] = (*payload)[rawid].mean_x12;
544  rmsEE[0][index] = (*payload)[rawid].rms_x12;
545  meanEE[1][index] = (*payload)[rawid].mean_x6;
546  rmsEE[1][index] = (*payload)[rawid].rms_x6;
547  meanEE[2][index] = (*payload)[rawid].mean_x1;
548  rmsEE[2][index] = (*payload)[rawid].rms_x1;
549  } // fist run
550  else {
551  if (iz == 1) {
552  endc_p_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12 - meanEE[0][index]);
553  double diff = (*payload)[rawid].rms_x12 - rmsEE[0][index];
554  endc_p_r[0]->Fill(ix, iy, rmsEE[0][index] - (*payload)[rawid].rms_x12);
555  if (std::abs(diff) < 1.) {
556  EEmean[0] = EEmean[0] + diff;
557  EErms[0] = EErms[0] + diff * diff;
558  EEtot[0]++;
559  }
560  //else std::cout << " gain 12 chan " << index << " diff " << diff << std::endl;
561  endc_p_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6 - meanEE[1][index]);
562  diff = (*payload)[rawid].rms_x6 - rmsEE[1][index];
563  endc_p_r[1]->Fill(ix, iy, diff);
564  if (std::abs(diff) < 1.) {
565  EEmean[1] = EEmean[1] + diff;
566  EErms[1] = EErms[1] + diff * diff;
567  EEtot[1]++;
568  }
569  //else std::cout << " gain 6 chan " << index << " diff " << diff << std::endl;
570  endc_p_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1 - meanEE[2][index]);
571  diff = (*payload)[rawid].rms_x1 - rmsEE[2][index];
572  endc_p_r[2]->Fill(ix, iy, diff);
573  if (std::abs(diff) < 1.) {
574  EEmean[2] = EEmean[2] + diff;
575  EErms[2] = EErms[2] + diff * diff;
576  EEtot[2]++;
577  }
578  //else std::cout << " gain 1 chan " << index << " diff " << diff << std::endl;
579  } // EE+
580  else {
581  endc_m_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12 - meanEE[0][index]);
582  double diff = (*payload)[rawid].rms_x12 - rmsEE[0][index];
583  endc_m_r[0]->Fill(ix, iy, rmsEE[0][index] - (*payload)[rawid].rms_x12);
584  if (std::abs(diff) < 1.) {
585  EEmean[0] = EEmean[0] + diff;
586  EErms[0] = EErms[0] + diff * diff;
587  EEtot[0]++;
588  }
589  //else std::cout << " gain 12 chan " << index << " diff " << diff << std::endl;
590  endc_m_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6 - meanEE[1][index]);
591  diff = (*payload)[rawid].rms_x6 - rmsEE[1][index];
592  endc_m_r[1]->Fill(ix, iy, diff);
593  if (std::abs(diff) < 1.) {
594  EEmean[1] = EEmean[1] + diff;
595  EErms[1] = EErms[1] + diff * diff;
596  EEtot[1]++;
597  }
598  //else std::cout << " gain 6 chan " << index << " diff " << diff << std::endl;
599  endc_m_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1 - meanEE[2][index]);
600  diff = (*payload)[rawid].rms_x1 - rmsEE[2][index];
601  endc_m_r[2]->Fill(ix, iy, diff);
602  if (std::abs(diff) < 1.) {
603  EEmean[2] = EEmean[2] + diff;
604  EErms[2] = EErms[2] + diff * diff;
605  EEtot[2]++;
606  }
607  //else std::cout << " gain 1 chan " << index << " diff " << diff << std::endl;
608  } // EE-
609  } // second run
610  } // validDetId
611  } // loop over ix
612  } // loop over iy
613  } // loop over iz
614  } // if payload.get()
615  else
616  return false;
617  irun++;
618  } // loop over IOVs
619 
620  gStyle->SetPalette(1);
621  gStyle->SetOptStat(0);
622  TCanvas canvas("CC map", "CC map", 1600, 2600);
623  TLatex t1;
624  t1.SetNDC();
625  t1.SetTextAlign(26);
626  t1.SetTextSize(0.05);
627  t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i - %i", run[1], run[0]));
628 
629  float xmi[3] = {0.0, 0.24, 0.76};
630  float xma[3] = {0.24, 0.76, 1.00};
631  TPad*** pad = new TPad**[6];
632  int view = 0;
633  for (int gId = 0; gId < kGains; gId++) {
634  for (int val = 0; val < 2; val++) { // mean and sigma
635  pad[view] = new TPad*[3];
636  for (int obj = 0; obj < 3; obj++) {
637  float yma = 0.94 - (0.16 * view);
638  float ymi = yma - 0.14;
639  pad[view][obj] =
640  new TPad(Form("p_%i_%i", obj, view), Form("p_%i_%i", obj, view), xmi[obj], ymi, xma[obj], yma);
641  pad[view][obj]->Draw();
642  }
643  view++;
644  }
645  double vt = (double)EBtot[gId];
646  EBmean[gId] = EBmean[gId] / vt;
647  EBrms[gId] = (EBrms[gId] / vt) - (EBmean[gId] * EBmean[gId]);
648  EBrms[gId] = sqrt(EBrms[gId]);
649  if (EBrms[gId] == 0.)
650  EBrms[gId] = 0.001;
651  pEBmin[gId] = EBmean[gId] - kRMS * EBrms[gId];
652  pEBmax[gId] = EBmean[gId] + kRMS * EBrms[gId];
653  // std::cout << " mean " << EBmean[gId] << " rms " << EBrms[gId] << " entries " << EBtot[gId] << " min " << pEBmin[gId]
654  // << " max " << pEBmax[gId] << std::endl;
655  vt = (double)EEtot[gId];
656  EEmean[gId] = EEmean[gId] / vt;
657  EErms[gId] = (EErms[gId] / vt) - (EEmean[gId] * EEmean[gId]);
658  EErms[gId] = sqrt(EErms[gId]);
659  if (EErms[gId] == 0.)
660  EErms[gId] = 0.001;
661  pEEmin[gId] = EEmean[gId] - kRMS * EErms[gId];
662  pEEmax[gId] = EEmean[gId] + kRMS * EErms[gId];
663  // std::cout << " mean " << EEmean[gId] << " rms " << EErms[gId] << " entries " << EEtot[gId] << " min " << pEEmin[gId]
664  // << " max " << pEEmax[gId] << std::endl;
665  }
666  for (int gId = 0; gId < kGains; gId++) {
667  pad[gId][0]->cd();
668  DrawEE(endc_m_m[gId], -2., 2.);
669  pad[gId + kGains][0]->cd();
670  DrawEE(endc_m_r[gId], pEEmin[gId], pEEmax[gId]);
671  pad[gId][1]->cd();
672  DrawEB(barrel_m[gId], -2., 2.);
673  pad[gId + kGains][1]->cd();
674  DrawEB(barrel_r[gId], pEBmin[gId], pEBmax[gId]);
675  pad[gId][2]->cd();
676  DrawEE(endc_p_m[gId], -2., 2.);
677  pad[gId + kGains][2]->cd();
678  DrawEE(endc_p_r[gId], pEEmin[gId], pEEmax[gId]);
679  }
680 
681  std::string ImageName(m_imageFileName);
682  canvas.SaveAs(ImageName.c_str());
683  return true;
684  } // fill method
685  }; // class EcalPedestalsDiff
686 
687  /*************************************************
688  2d histogram of ECAL barrel pedestal of 1 IOV
689  *************************************************/
690 
691  // inherit from one of the predefined plot class: Histogram2D
692  class EcalPedestalsEBMean12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
693  public:
694  EcalPedestalsEBMean12Map()
695  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain12 - map",
696  "iphi",
697  MAX_IPHI,
698  MIN_IPHI,
699  MAX_IPHI + MIN_IPHI,
700  "ieta",
701  2 * MAX_IETA + 1,
702  -1 * MAX_IETA,
703  MAX_IETA + 1) {
704  Base::setSingleIov(true);
705  }
706 
707  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
708  bool fill() override {
709  auto tag = PlotBase::getTag<0>();
710  for (auto const& iov : tag.iovs) {
711  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
712  if (payload.get()) {
713  // looping over the EB channels, via the dense-index, mapped into EBDetId's
714  if (payload->barrelItems().empty())
715  return false;
716  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
717  uint32_t rawid = EBDetId::unhashIndex(cellid);
718 
719  // check the existence of ECAL pedestal, for a given ECAL barrel channel
720  if (payload->find(rawid) == payload->end())
721  continue;
722  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
723  continue;
724 
725  // there's no ieta==0 in the EB numbering
726  // int delta = (EBDetId(rawid)).ieta() > 0 ? -1 : 0 ;
727  // fill the Histogram2D here
728  // fillWithValue( (EBDetId(rawid)).iphi() , (EBDetId(rawid)).ieta()+0.5+delta, (*payload)[rawid].mean_x12 );
729  // set min and max on 2d plots
730  float valped = (*payload)[rawid].mean_x12;
731  if (valped > 250.)
732  valped = 250.;
733  // if(valped < 150.) valped = 150.;
734  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
735  } // loop over cellid
736  } // if payload.get()
737  } // loop over IOV's (1 in this case)
738  return true;
739  } // fill method
740  };
741 
742  class EcalPedestalsEBMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
743  public:
744  EcalPedestalsEBMean6Map()
745  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain6 - map",
746  "iphi",
747  MAX_IPHI,
748  MIN_IPHI,
749  MAX_IPHI + MIN_IPHI,
750  "ieta",
751  2 * MAX_IETA + 1,
752  -MAX_IETA,
753  MAX_IETA + 1) {
754  Base::setSingleIov(true);
755  }
756 
757  bool fill() override {
758  auto tag = PlotBase::getTag<0>();
759  for (auto const& iov : tag.iovs) {
760  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
761  if (payload.get()) {
762  // looping over the EB channels, via the dense-index, mapped into EBDetId's
763  if (payload->barrelItems().empty())
764  return false;
765  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
766  uint32_t rawid = EBDetId::unhashIndex(cellid);
767 
768  // check the existence of ECAL pedestal, for a given ECAL barrel channel
769  if (payload->find(rawid) == payload->end())
770  continue;
771  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
772  continue;
773 
774  // set min and max on 2d plots
775  float valped = (*payload)[rawid].mean_x6;
776  if (valped > 250.)
777  valped = 250.;
778  // if(valped < 150.) valped = 150.;
779  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
780  } // loop over cellid
781  } // if payload.get()
782  } // loop over IOV's (1 in this case)
783  return true;
784  } // fill method
785  };
786 
787  class EcalPedestalsEBMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
788  public:
789  EcalPedestalsEBMean1Map()
790  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain1 - map",
791  "iphi",
792  MAX_IPHI,
793  MIN_IPHI,
794  MAX_IPHI + MIN_IPHI,
795  "ieta",
796  2 * MAX_IETA + 1,
797  -MAX_IETA,
798  MAX_IETA + 1) {
799  Base::setSingleIov(true);
800  }
801 
802  bool fill() override {
803  auto tag = PlotBase::getTag<0>();
804  for (auto const& iov : tag.iovs) {
805  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
806  if (payload.get()) {
807  // looping over the EB channels, via the dense-index, mapped into EBDetId's
808  if (payload->barrelItems().empty())
809  return false;
810  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
811  uint32_t rawid = EBDetId::unhashIndex(cellid);
812 
813  // check the existence of ECAL pedestal, for a given ECAL barrel channel
814  if (payload->find(rawid) == payload->end())
815  continue;
816  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1)
817  continue;
818 
819  // set min and max on 2d plots
820  float valped = (*payload)[rawid].mean_x1;
821  if (valped > 250.)
822  valped = 250.;
823  // if(valped < 150.) valped = 150.;
824  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
825  } // loop over cellid
826  } // if payload.get()
827  } // loop over IOV's (1 in this case)
828  return true;
829  } // fill method
830  };
831 
832  class EcalPedestalsEEMean12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
833  public:
834  EcalPedestalsEEMean12Map()
835  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain12 - map",
836  "ix",
837  2.2 * IX_MAX,
838  IX_MIN,
839  2.2 * IX_MAX + 1,
840  "iy",
841  IY_MAX,
842  IY_MIN,
843  IY_MAX + IY_MIN) {
844  Base::setSingleIov(true);
845  }
846 
847  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
848  bool fill() override {
849  auto tag = PlotBase::getTag<0>();
850  for (auto const& iov : tag.iovs) {
851  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
852  if (payload.get()) {
853  if (payload->endcapItems().empty())
854  return false;
855 
856  // looping over the EE channels
857  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
858  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
859  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
860  if (EEDetId::validDetId(ix, iy, iz)) {
861  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
862  uint32_t rawid = myEEId.rawId();
863  // check the existence of ECAL pedestal, for a given ECAL endcap channel
864  if (payload->find(rawid) == payload->end())
865  continue;
866  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
867  continue;
868  // set min and max on 2d plots
869  float valped = (*payload)[rawid].mean_x12;
870  if (valped > 250.)
871  valped = 250.;
872  // if(valped < 150.) valped = 150.;
873  if (iz == -1)
874  fillWithValue(ix, iy, valped);
875  else
876  fillWithValue(ix + IX_MAX + 20, iy, valped);
877 
878  } // validDetId
879  } // payload
880  } // loop over IOV's (1 in this case)
881  return true;
882  } // fill method
883  };
884 
885  class EcalPedestalsEEMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
886  public:
887  EcalPedestalsEEMean6Map()
888  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain6 - map",
889  "ix",
890  2.2 * IX_MAX,
891  IX_MIN,
892  2.2 * IX_MAX + 1,
893  "iy",
894  IY_MAX,
895  IY_MIN,
896  IY_MAX + IY_MIN) {
897  Base::setSingleIov(true);
898  }
899 
900  bool fill() override {
901  auto tag = PlotBase::getTag<0>();
902  for (auto const& iov : tag.iovs) {
903  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
904  if (payload.get()) {
905  if (payload->endcapItems().empty())
906  return false;
907 
908  // looping over the EE channels
909  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
910  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
911  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
912  if (EEDetId::validDetId(ix, iy, iz)) {
913  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
914  uint32_t rawid = myEEId.rawId();
915  // check the existence of ECAL pedestal, for a given ECAL endcap channel
916  if (payload->find(rawid) == payload->end())
917  continue;
918  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
919  continue;
920  // set min and max on 2d plots
921  float valped = (*payload)[rawid].mean_x6;
922  if (valped > 250.)
923  valped = 250.;
924  // if(valped < 150.) valped = 150.;
925  if (iz == -1)
926  fillWithValue(ix, iy, valped);
927  else
928  fillWithValue(ix + IX_MAX + 20, iy, valped);
929  } // validDetId
930  } // payload
931  } // loop over IOV's (1 in this case)
932  return true;
933  } // fill method
934  };
935 
936  class EcalPedestalsEEMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
937  public:
938  EcalPedestalsEEMean1Map()
939  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain1 - map",
940  "ix",
941  2.2 * IX_MAX,
942  IX_MIN,
943  2.2 * IX_MAX + 1,
944  "iy",
945  IY_MAX,
946  IY_MIN,
947  IY_MAX + IY_MIN) {
948  Base::setSingleIov(true);
949  }
950 
951  bool fill() override {
952  auto tag = PlotBase::getTag<0>();
953  for (auto const& iov : tag.iovs) {
954  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
955  if (payload.get()) {
956  if (payload->endcapItems().empty())
957  return false;
958 
959  // looping over the EE channels
960  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
961  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
962  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
963  if (EEDetId::validDetId(ix, iy, iz)) {
964  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
965  uint32_t rawid = myEEId.rawId();
966  // check the existence of ECAL pedestal, for a given ECAL endcap channel
967  if (payload->find(rawid) == payload->end())
968  continue;
969  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12)
970  continue;
971  // set min and max on 2d plots
972  float valped = (*payload)[rawid].mean_x1;
973  if (valped > 250.)
974  valped = 250.;
975  // if(valped < 150.) valped = 150.;
976  if (iz == -1)
977  fillWithValue(ix, iy, valped);
978  else
979  fillWithValue(ix + IX_MAX + 20, iy, valped);
980  } // validDetId
981  } // if payload.get()
982  } // loop over IOV's (1 in this case)
983  return true;
984  } // fill method
985  };
986 
987  class EcalPedestalsEBRMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
988  public:
989  EcalPedestalsEBRMS12Map()
990  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain12 - map",
991  "iphi",
992  MAX_IPHI,
993  MIN_IPHI,
994  MAX_IPHI + MIN_IPHI,
995  "ieta",
996  2 * MAX_IETA + 1,
997  -1 * MAX_IETA,
998  MAX_IETA + 1) {
999  Base::setSingleIov(true);
1000  }
1001 
1002  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
1003  bool fill() override {
1004  auto tag = PlotBase::getTag<0>();
1005  for (auto const& iov : tag.iovs) {
1006  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1007  if (payload.get()) {
1008  // looping over the EB channels, via the dense-index, mapped into EBDetId's
1009  if (payload->barrelItems().empty())
1010  return false;
1011  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1012  uint32_t rawid = EBDetId::unhashIndex(cellid);
1013 
1014  // check the existence of ECAL pedestal, for a given ECAL barrel channel
1015  if (payload->find(rawid) == payload->end())
1016  continue;
1017  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1018  continue;
1019 
1020  // there's no ieta==0 in the EB numbering
1021  // int delta = (EBDetId(rawid)).ieta() > 0 ? -1 : 0 ;
1022  // fill the Histogram2D here
1023  // fillWithValue( (EBDetId(rawid)).iphi() , (EBDetId(rawid)).ieta()+0.5+delta, (*payload)[rawid].mean_x12 );
1024  // set max on noise 2d plots
1025  float valrms = (*payload)[rawid].rms_x12;
1026  if (valrms > 2.2)
1027  valrms = 2.2;
1028  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1029  } // loop over cellid
1030  } // if payload.get()
1031  } // loop over IOV's (1 in this case)
1032  return true;
1033  } // fill method
1034  };
1035 
1036  class EcalPedestalsEBRMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1037  public:
1038  EcalPedestalsEBRMS6Map()
1039  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain6 - map",
1040  "iphi",
1041  MAX_IPHI,
1042  MIN_IPHI,
1043  MAX_IPHI + MIN_IPHI,
1044  "ieta",
1045  2 * MAX_IETA + 1,
1046  -1 * MAX_IETA,
1047  MAX_IETA + 1) {
1048  Base::setSingleIov(true);
1049  }
1050 
1051  bool fill() override {
1052  auto tag = PlotBase::getTag<0>();
1053  for (auto const& iov : tag.iovs) {
1054  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1055  if (payload.get()) {
1056  // looping over the EB channels, via the dense-index, mapped into EBDetId's
1057  if (payload->barrelItems().empty())
1058  return false;
1059  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1060  uint32_t rawid = EBDetId::unhashIndex(cellid);
1061 
1062  // check the existence of ECAL pedestal, for a given ECAL barrel channel
1063  if (payload->find(rawid) == payload->end())
1064  continue;
1065  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1066  continue;
1067 
1068  // set max on noise 2d plots
1069  float valrms = (*payload)[rawid].rms_x6;
1070  if (valrms > 1.5)
1071  valrms = 1.5;
1072  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1073  } // loop over cellid
1074  } // if payload.get()
1075  } // loop over IOV's (1 in this case)
1076  return true;
1077  } // fill method
1078  };
1079 
1080  class EcalPedestalsEBRMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1081  public:
1082  EcalPedestalsEBRMS1Map()
1083  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain1 - map",
1084  "iphi",
1085  MAX_IPHI,
1086  MIN_IPHI,
1087  MAX_IPHI + MIN_IPHI,
1088  "ieta",
1089  2 * MAX_IETA + 1,
1090  -1 * MAX_IETA,
1091  MAX_IETA + 1) {
1092  Base::setSingleIov(true);
1093  }
1094 
1095  bool fill() override {
1096  auto tag = PlotBase::getTag<0>();
1097  for (auto const& iov : tag.iovs) {
1098  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1099  if (payload.get()) {
1100  // looping over the EB channels, via the dense-index, mapped into EBDetId's
1101  if (payload->barrelItems().empty())
1102  return false;
1103  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1104  uint32_t rawid = EBDetId::unhashIndex(cellid);
1105 
1106  // check the existence of ECAL pedestal, for a given ECAL barrel channel
1107  if (payload->find(rawid) == payload->end())
1108  continue;
1109  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1)
1110  continue;
1111 
1112  // set max on noise 2d plots
1113  float valrms = (*payload)[rawid].rms_x1;
1114  if (valrms > 1.0)
1115  valrms = 1.0;
1116  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1117  } // loop over cellid
1118  } // if payload.get()
1119  } // loop over IOV's (1 in this case)
1120  return true;
1121  } // fill method
1122  };
1123 
1124  class EcalPedestalsEERMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1125  public:
1126  EcalPedestalsEERMS12Map()
1127  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain12 - map",
1128  "ix",
1129  2.2 * IX_MAX,
1130  IX_MIN,
1131  2.2 * IX_MAX + 1,
1132  "iy",
1133  IY_MAX,
1134  IY_MIN,
1135  IY_MAX + IY_MIN) {
1136  Base::setSingleIov(true);
1137  }
1138 
1139  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
1140  bool fill() override {
1141  auto tag = PlotBase::getTag<0>();
1142  for (auto const& iov : tag.iovs) {
1143  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1144  if (payload.get()) {
1145  if (payload->endcapItems().empty())
1146  return false;
1147 
1148  // looping over the EE channels
1149  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1150  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1151  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1152  if (EEDetId::validDetId(ix, iy, iz)) {
1153  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1154  uint32_t rawid = myEEId.rawId();
1155  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1156  if (payload->find(rawid) == payload->end())
1157  continue;
1158  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1159  continue;
1160  // set max on noise 2d plots
1161  float valrms = (*payload)[rawid].rms_x12;
1162  if (valrms > 3.5)
1163  valrms = 3.5;
1164  if (iz == -1)
1165  fillWithValue(ix, iy, valrms);
1166  else
1167  fillWithValue(ix + IX_MAX + 20, iy, valrms);
1168 
1169  } // validDetId
1170  } // payload
1171  } // loop over IOV's (1 in this case)
1172  return true;
1173  } // fill method
1174  };
1175 
1176  class EcalPedestalsEERMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1177  public:
1178  EcalPedestalsEERMS6Map()
1179  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain6 - map",
1180  "ix",
1181  2.2 * IX_MAX,
1182  IX_MIN,
1183  2.2 * IX_MAX + 1,
1184  "iy",
1185  IY_MAX,
1186  IY_MIN,
1187  IY_MAX + IY_MIN) {
1188  Base::setSingleIov(true);
1189  }
1190 
1191  bool fill() override {
1192  auto tag = PlotBase::getTag<0>();
1193  for (auto const& iov : tag.iovs) {
1194  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1195  if (payload.get()) {
1196  if (payload->endcapItems().empty())
1197  return false;
1198 
1199  // looping over the EE channels
1200  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1201  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1202  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1203  if (EEDetId::validDetId(ix, iy, iz)) {
1204  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1205  uint32_t rawid = myEEId.rawId();
1206  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1207  if (payload->find(rawid) == payload->end())
1208  continue;
1209  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1210  continue;
1211  // set max on noise 2d plots
1212  float valrms = (*payload)[rawid].rms_x6;
1213  if (valrms > 2.0)
1214  valrms = 2.0;
1215  if (iz == -1)
1216  fillWithValue(ix, iy, valrms);
1217  else
1218  fillWithValue(ix + IX_MAX + 20, iy, valrms);
1219  } // validDetId
1220  } // payload
1221  } // loop over IOV's (1 in this case)
1222  return true;
1223  } // fill method
1224  };
1225 
1226  class EcalPedestalsEERMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1227  public:
1228  EcalPedestalsEERMS1Map()
1229  : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain1 - map",
1230  "ix",
1231  2.2 * IX_MAX,
1232  IX_MIN,
1233  2.2 * IX_MAX + 1,
1234  "iy",
1235  IY_MAX,
1236  IY_MIN,
1237  IY_MAX + IY_MIN) {
1238  Base::setSingleIov(true);
1239  }
1240 
1241  bool fill() override {
1242  auto tag = PlotBase::getTag<0>();
1243  for (auto const& iov : tag.iovs) {
1244  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1245  if (payload.get()) {
1246  if (payload->endcapItems().empty())
1247  return false;
1248 
1249  // looping over the EE channels
1250  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1251  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1252  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1253  if (EEDetId::validDetId(ix, iy, iz)) {
1254  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1255  uint32_t rawid = myEEId.rawId();
1256  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1257  if (payload->find(rawid) == payload->end())
1258  continue;
1259  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12)
1260  continue;
1261  // set max on noise 2d plots
1262  float valrms = (*payload)[rawid].rms_x1;
1263  if (valrms > 1.5)
1264  valrms = 1.5;
1265  if (iz == -1)
1266  fillWithValue(ix, iy, valrms);
1267  else
1268  fillWithValue(ix + IX_MAX + 20, iy, valrms);
1269  } // validDetId
1270  } // if payload.get()
1271  } // loop over IOV's (1 in this case)
1272  return true;
1273  } // fill method
1274  };
1275 
1276  /*****************************************
1277  2d plot of Ecal Pedestals Summary of 1 IOV
1278  ******************************************/
1279  class EcalPedestalsSummaryPlot : public cond::payloadInspector::PlotImage<EcalPedestals> {
1280  public:
1281  EcalPedestalsSummaryPlot() : cond::payloadInspector::PlotImage<EcalPedestals>("Ecal Pedestals Summary - map ") {
1282  setSingleIov(true);
1283  }
1284 
1285  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
1286  auto iov = iovs.front(); //get reference to 1st element in the vector iovs
1287  std::shared_ptr<EcalPedestals> payload =
1288  fetchPayload(std::get<1>(iov)); //std::get<1>(iov) refers to the Hash in the tuple iov
1289  unsigned int run = std::get<0>(iov); //referes to Time_t in iov.
1290  TH2F* align; //pointer to align which is a 2D histogram
1291 
1292  int NbRows = 6;
1293  int NbColumns = 5;
1294 
1295  if (payload.get()) { //payload is an iov retrieved from payload using hash.
1296 
1297  align = new TH2F("Ecal Pedestals Summary",
1298  "EB/EE Gain Mean RMS Total Items",
1299  NbColumns,
1300  0,
1301  NbColumns,
1302  NbRows,
1303  0,
1304  NbRows);
1305 
1306  float ebVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
1307  float eeVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
1308 
1309  long unsigned int ebTotal = (payload->barrelItems()).size();
1310  long unsigned int eeTotal = (payload->endcapItems()).size();
1311 
1312  pedestalsSummary(payload->barrelItems(), ebVals, ebTotal);
1313  pedestalsSummary(payload->endcapItems(), eeVals, eeTotal);
1314 
1315  double row = NbRows - 0.5;
1316 
1317  //EB summary values
1318  align->Fill(1.5, row, 12); //Gain
1319  align->Fill(2.5, row, ebVals[0]); //mean12
1320  align->Fill(3.5, row, ebVals[1]); //rms12
1321 
1322  row--;
1323 
1324  align->Fill(0.5, row, 1);
1325  align->Fill(1.5, row, 6); //Gain
1326  align->Fill(2.5, row, ebVals[2]); //mean6
1327  align->Fill(3.5, row, ebVals[3]); //rms6
1328  align->Fill(4.5, row, ebTotal);
1329 
1330  row--;
1331 
1332  align->Fill(1.5, row, 1); //Gain
1333  align->Fill(2.5, row, ebVals[4]); //mean1
1334  align->Fill(3.5, row, ebVals[5]); //rms1
1335 
1336  row--;
1337 
1338  //EE summary values
1339  align->Fill(1.5, row, 12); //Gain
1340  align->Fill(2.5, row, eeVals[0]); //mean12
1341  align->Fill(3.5, row, eeVals[1]); //rms12
1342 
1343  row--;
1344 
1345  align->Fill(0.5, row, 2);
1346  align->Fill(1.5, row, 6); //Gain
1347  align->Fill(2.5, row, eeVals[2]); //mean6
1348  align->Fill(3.5, row, eeVals[3]); //rms6
1349  align->Fill(4.5, row, eeTotal);
1350 
1351  row--;
1352 
1353  align->Fill(1.5, row, 1); //Gain
1354  align->Fill(2.5, row, eeVals[4]); //mean1
1355  align->Fill(3.5, row, eeVals[5]); //rms1
1356 
1357  } // if payload.get()
1358  else
1359  return false;
1360 
1361  gStyle->SetPalette(1);
1362  gStyle->SetOptStat(0);
1363  TCanvas canvas("CC map", "CC map", 1000, 1000);
1364  TLatex t1;
1365  t1.SetNDC();
1366  t1.SetTextAlign(26);
1367  t1.SetTextSize(0.05);
1368  t1.SetTextColor(2);
1369  t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals Summary, IOV %i", run));
1370 
1371  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
1372  pad->Draw();
1373  pad->cd();
1374  align->Draw("TEXT");
1375  TLine* l = new TLine;
1376  l->SetLineWidth(1);
1377 
1378  for (int i = 1; i < NbRows; i++) {
1379  double y = (double)i;
1380  if (i == NbRows / 2)
1381  l = new TLine(0., y, NbColumns, y);
1382  else
1383  l = new TLine(1., y, NbColumns - 1, y);
1384  l->Draw();
1385  }
1386 
1387  for (int i = 1; i < NbColumns; i++) {
1388  double x = (double)i;
1389  double y = (double)NbRows;
1390  l = new TLine(x, 0., x, y);
1391  l->Draw();
1392  }
1393 
1394  align->GetXaxis()->SetTickLength(0.);
1395  align->GetXaxis()->SetLabelSize(0.);
1396  align->GetYaxis()->SetTickLength(0.);
1397  align->GetYaxis()->SetLabelSize(0.);
1398 
1399  std::string ImageName(m_imageFileName);
1400  canvas.SaveAs(ImageName.c_str());
1401  return true;
1402  } // fill method
1403 
1404  void pedestalsSummary(std::vector<EcalPedestal> vItems, float vals[], long unsigned int& total) {
1405  for (std::vector<EcalPedestal>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++iItems) {
1406  //vals[0]=100;
1407  vals[0] += iItems->mean(1); //G12
1408  vals[1] += iItems->rms(1);
1409  vals[2] += iItems->mean(2); //G6
1410  vals[3] += iItems->rms(2);
1411  vals[4] += iItems->mean(3); //G1
1412  vals[5] += iItems->rms(3);
1413  }
1414 
1415  vals[0] = vals[0] / total;
1416  vals[1] = vals[1] / total;
1417  vals[2] = vals[2] / total;
1418  vals[3] = vals[3] / total;
1419  vals[4] = vals[4] / total;
1420  vals[5] = vals[5] / total;
1421  }
1422  };
1423 
1424 } // namespace
1425 
1426 // Register the classes as boost python plugin
1428  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsHist);
1429  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsPlot);
1430  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsDiff);
1431  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean12Map);
1432  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean6Map);
1433  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean1Map);
1434  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean12Map);
1435  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean6Map);
1436  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean1Map);
1437  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS12Map);
1438  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS6Map);
1439  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS1Map);
1440  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS12Map);
1441  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS6Map);
1442  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS1Map);
1443  PAYLOAD_INSPECTOR_CLASS(EcalPedestalsSummaryPlot);
1444 }
change_name.diff
diff
Definition: change_name.py:13
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:355
EcalPedestals.h
align
Definition: AlignableIndexer.h:30
kEEChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
ReggeGribovPartonMC_AdvancedParameters_cfi.bmin
bmin
Definition: ReggeGribovPartonMC_AdvancedParameters_cfi.py:4
MAX_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:14
IX_MAX
Definition: EcalFloatCondObjectContainerUtils.h:20
IY_MAX
Definition: EcalFloatCondObjectContainerUtils.h:21
EBDetId
Definition: EBDetId.h:17
PayloadInspector.h
EBDetId.h
EEDetId.h
EBDetId::unhashIndex
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
DDAxes::x
EcalCondObjectContainer< EcalPedestal >
PayloadInspectorModule.h
DrawEE
void DrawEE(TH2F *endc, float min, float max)
Definition: EcalDrawUtils.h:29
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
DrawEB
void DrawEB(TH2F *ebmap, float min, float max)
Definition: EcalDrawUtils.h:4
PVValHelper::eta
Definition: PVValidationHelpers.h:69
MIN_IETA
Definition: EcalFloatCondObjectContainerUtils.h:11
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
jets_cff.payload
payload
Definition: jets_cff.py:34
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
cond::payloadInspector::Histogram2D
Definition: PayloadInspector.h:748
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
Time.h
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
ReggeGribovPartonMC_AdvancedParameters_cfi.bmax
bmax
Definition: ReggeGribovPartonMC_AdvancedParameters_cfi.py:5
EEDetId::hashedIndex
int hashedIndex() const
Definition: EEDetId.h:183
MIN_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:12
EcalDrawUtils.h
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
DDAxes::phi
heppy_batch.val
val
Definition: heppy_batch.py:351
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
writedatasetfile.run
run
Definition: writedatasetfile.py:27
gainValues
const Int_t gainValues[kGains]
Definition: EcalPedestalsHandler.cc:15
kGains
const Int_t kGains
Definition: EcalPedestalsHandler.cc:13
EEDetId::XYMODE
static const int XYMODE
Definition: EEDetId.h:335
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:829
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
EBDetId::MIN_HASH
static const int MIN_HASH
Definition: EBDetId.h:149
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ecalMGPA::gainId
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
Definition: EcalMGPASample.h:13
kEBChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
IX_MIN
Definition: EcalFloatCondObjectContainerUtils.h:18
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13