CMS 3D CMS Logo

EcalChannelStatus_PayloadInspector.cc
Go to the documentation of this file.
8 // the data format of the condition to be inspected
10 
11 #include <memory>
12 #include <sstream>
13 
14 #include "TStyle.h"
15 #include "TH2F.h"
16 #include "TCanvas.h"
17 #include "TLine.h"
18 #include "TLatex.h"
19 
20 namespace {
21  enum { kEBChannels = 61200, kEEChannels = 14648, NRGBs = 5, NCont = 255 };
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  2d plot of ECAL barrel channel status of 1 IOV
27  *******************************************************/
28  class EcalChannelStatusEBMap : public cond::payloadInspector::PlotImage<EcalChannelStatus> {
29  public:
30  EcalChannelStatusEBMap() : cond::payloadInspector::PlotImage<EcalChannelStatus>("ECAL Barrel channel status") {
31  setSingleIov(true);
32  }
33  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
34  TH2F *ebmap = new TH2F("ebmap", "", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
35  TH2F *ebmap_coarse = new TH2F("ebmap_coarse", "", MAX_IPHI / 20, 0, MAX_IPHI, 2, -MAX_IETA, MAX_IETA);
36  Int_t ebcount = 0;
37  unsigned int run = 0;
38  // for ( auto const & iov: iovs) {
39  auto iov = iovs.front();
40  std::shared_ptr<EcalChannelStatus> payload = fetchPayload(std::get<1>(iov));
41  run = std::get<0>(iov);
42  if (payload.get()) {
43  // looping over the EB channels, via the dense-index, mapped into EBDetId's
44  if (payload->barrelItems().empty())
45  return false;
46  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
47  uint32_t rawid = EBDetId::unhashIndex(cellid);
48  // check the existence of ECAL channel status, for a given ECAL barrel channel
49  if (payload->find(rawid) == payload->end())
50  continue;
51  // if (!(*payload)[rawid].getEncodedStatusCode()) continue;
52  Double_t weight = (Double_t)(*payload)[rawid].getEncodedStatusCode();
53  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
54  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
55  if (eta > 0.)
56  eta = eta - 0.5; // 0.5 to 84.5
57  else
58  eta = eta + 0.5; // -84.5 to -0.5
59  ebmap->Fill(phi, eta, weight);
60  if (weight > 0) {
61  ebcount++;
62  ebmap_coarse->Fill(phi, eta);
63  }
64  } // loop over cellid
65  } // if payload.get()
66  else
67  return false;
68 
69  gStyle->SetOptStat(0);
70  //set the background color to white
71  gStyle->SetFillColor(10);
72  gStyle->SetFrameFillColor(10);
73  gStyle->SetCanvasColor(10);
74  gStyle->SetPadColor(10);
75  gStyle->SetTitleFillColor(0);
76  gStyle->SetStatColor(10);
77  //dont put a colored frame around the plots
78  gStyle->SetFrameBorderMode(0);
79  gStyle->SetCanvasBorderMode(0);
80  gStyle->SetPadBorderMode(0);
81  //use the primary color palette
82  gStyle->SetPalette(1);
83 
84  Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
85  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
86  Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
87  Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
88  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
89  gStyle->SetNumberContours(NCont);
90 
91  TCanvas c1("c1", "c1", 1200, 700);
92  c1.SetGridx(1);
93  c1.SetGridy(1);
94 
95  TLatex t1;
96  t1.SetNDC();
97  t1.SetTextAlign(26);
98  t1.SetTextSize(0.06);
99 
100  ebmap->SetXTitle("i#phi");
101  ebmap->SetYTitle("i#eta");
102  ebmap->GetXaxis()->SetNdivisions(-418, kFALSE);
103  ebmap->GetYaxis()->SetNdivisions(-1702, kFALSE);
104  ebmap->GetXaxis()->SetLabelSize(0.03);
105  ebmap->GetYaxis()->SetLabelSize(0.03);
106  ebmap->GetXaxis()->SetTickLength(0.01);
107  ebmap->GetYaxis()->SetTickLength(0.01);
108  ebmap->SetMaximum(15);
109 
110  c1.cd();
111  ebmap->Draw("colz");
112 
113  ebmap_coarse->SetMarkerSize(1.3);
114  ebmap_coarse->Draw("text,same");
115 
116  t1.SetTextSize(0.05);
117  t1.DrawLatex(0.5, 0.96, Form("EB Channel Status Masks, IOV %i", run));
118 
119  char txt[80];
120  Double_t prop = (Double_t)ebcount / kEBChannels * 100.;
121  sprintf(txt, "%d/61200 (%4.3f%%)", ebcount, prop);
122  t1.SetTextColor(2);
123  t1.SetTextSize(0.045);
124  t1.DrawLatex(0.5, 0.91, txt);
125 
126  std::string ImageName(m_imageFileName);
127  c1.SaveAs(ImageName.c_str());
128  return true;
129  }
130  };
131 
132  /*********************************************************
133  2d plot of ECAL endcaps channel status of 1 IOV
134  *********************************************************/
135  class EcalChannelStatusEEMap : public cond::payloadInspector::PlotImage<EcalChannelStatus> {
136  public:
137  EcalChannelStatusEEMap() : cond::payloadInspector::PlotImage<EcalChannelStatus>("ECAL Barrel channel status") {
138  setSingleIov(true);
139  }
140  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
141  // TH2F *eemap = new TH2F("eemap","", 2*IX_MAX, IX_MIN, 2*IX_MAX+1, IY_MAX, IY_MIN, IY_MAX+IY_MIN);
142  TH2F *eemap = new TH2F("eemap", "", 2 * IX_MAX, 0, 2 * IX_MAX, IY_MAX, 0, IY_MAX);
143  TH2F *eemap_coarse = new TH2F("eemap_coarse", "", 2, 0, 2 * IX_MAX, 1, 0, IY_MAX);
144  TH2F *eetemp = new TH2F("eetemp", "", 2 * IX_MAX, 0, 2 * IX_MAX, IY_MAX, 0, IY_MAX);
145  Int_t eecount = 0;
146  unsigned int run = 0;
147  auto iov = iovs.front();
148  std::shared_ptr<EcalChannelStatus> payload = fetchPayload(std::get<1>(iov));
149  run = std::get<0>(iov);
150  if (payload.get()) {
151  if (payload->endcapItems().empty())
152  return false;
153 
154  // looping over the EE channels
155  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
156  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
157  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
158  if (EEDetId::validDetId(ix, iy, iz)) {
159  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
160  uint32_t rawid = myEEId.rawId();
161  // check the existence of ECAL channel status, for a given ECAL endcap channel
162  if (payload->find(rawid) == payload->end())
163  continue;
164  // if (!(*payload)[rawid].getEncodedStatusCode()) continue;
165  float weight = (float)(*payload)[rawid].getEncodedStatusCode();
166  if (iz == -1) {
167  // eemap->Fill(ix, iy, weight);
168  eemap->Fill(ix - 1, iy - 1, weight);
169  if (weight > 0) {
170  eecount++;
171  eemap_coarse->Fill(ix - 1, iy - 1);
172  }
173  } else {
174  // eemap->Fill(ix+IX_MAX, iy, weight);
175  eemap->Fill(ix + IX_MAX - 1, iy - 1, weight);
176  if (weight > 0) {
177  eecount++;
178  eemap_coarse->Fill(ix + IX_MAX - 1, iy - 1);
179  }
180  }
181  } // validDetId
182  } // payload
183 
184  gStyle->SetOptStat(0);
185  //set the background color to white
186  gStyle->SetFillColor(10);
187  gStyle->SetFrameFillColor(10);
188  gStyle->SetCanvasColor(10);
189  gStyle->SetPadColor(10);
190  gStyle->SetTitleFillColor(0);
191  gStyle->SetStatColor(10);
192  //dont put a colored frame around the plots
193  gStyle->SetFrameBorderMode(0);
194  gStyle->SetCanvasBorderMode(0);
195  gStyle->SetPadBorderMode(0);
196  //use the primary color palette
197  gStyle->SetPalette(1);
198 
199  Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
200  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
201  Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
202  Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
203  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
204  gStyle->SetNumberContours(NCont);
205 
206  // set the EE contours
207  for (Int_t i = 1; i <= IX_MAX; i++) {
208  for (Int_t j = 1; j <= IY_MAX; j++) {
209  if (EEDetId::validDetId(i, j, 1)) {
210  // eetemp->SetBinContent(i + 1, j + 1, 2);
211  // eetemp->SetBinContent(i + IX_MAX + 1, j +1, 2);
212  eetemp->SetBinContent(i, j, 2);
213  eetemp->SetBinContent(i + IX_MAX, j, 2);
214  }
215  }
216  }
217 
218  eetemp->SetFillColor(920);
219  TCanvas c1("c1", "c1", 1200, 600);
220  c1.SetGridx(1);
221  c1.SetGridy(1);
222 
223  TLatex t1;
224  t1.SetNDC();
225  t1.SetTextAlign(26);
226  t1.SetTextSize(0.06);
227 
228  eetemp->GetXaxis()->SetNdivisions(40, kFALSE);
229  eetemp->GetYaxis()->SetNdivisions(20, kFALSE);
230  eetemp->GetXaxis()->SetLabelSize(0.00);
231  eetemp->GetYaxis()->SetLabelSize(0.00);
232  eetemp->GetXaxis()->SetTickLength(0.01);
233  eetemp->GetYaxis()->SetTickLength(0.01);
234  eetemp->SetMaximum(1.15);
235 
236  eemap->GetXaxis()->SetNdivisions(40, kFALSE);
237  eemap->GetYaxis()->SetNdivisions(20, kFALSE);
238  eemap->GetXaxis()->SetLabelSize(0.00);
239  eemap->GetYaxis()->SetLabelSize(0.00);
240  eemap->GetXaxis()->SetTickLength(0.01);
241  eemap->GetYaxis()->SetTickLength(0.01);
242  eemap->SetMaximum(15);
243 
244  eetemp->Draw("box");
245  eemap->Draw("same,colz");
246 
247  eemap_coarse->SetMarkerSize(2);
248  eemap_coarse->Draw("same,text");
249 
250  t1.SetTextColor(1);
251  t1.SetTextSize(0.055);
252  t1.DrawLatex(0.5, 0.96, Form("EE Channel Status Masks, IOV %i", run));
253 
254  char txt[80];
255  Double_t prop = (Double_t)eecount / kEEChannels * 100.;
256  sprintf(txt, "%d/14648 (%4.3f%%)", eecount, prop);
257  t1.SetTextColor(2);
258  t1.SetTextSize(0.045);
259  t1.DrawLatex(0.5, 0.91, txt);
260  t1.SetTextColor(1);
261  t1.SetTextSize(0.05);
262  t1.DrawLatex(0.14, 0.84, "EE-");
263  t1.DrawLatex(0.86, 0.84, "EE+");
264 
265  std::string ImageName(m_imageFileName);
266  c1.SaveAs(ImageName.c_str());
267  return true;
268  } // fill method
269  };
270 
271  /**********************************************************************
272  2d plot of ECAL barrel channel status difference between 2 IOVs
273  ***********************************************************************/
274  template <cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
275  class EcalChannelStatusEBDiffBase : public cond::payloadInspector::PlotImage<EcalChannelStatus, nIOVs, ntags> {
276  public:
277  EcalChannelStatusEBDiffBase()
278  : cond::payloadInspector::PlotImage<EcalChannelStatus, nIOVs, ntags>("ECAL Barrel channel status difference") {}
279  bool fill() override {
280  TH2F *ebmap = new TH2F("ebmap", "", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
281  TH2F *ebmap_coarse = new TH2F("ebmap_coarse", "", MAX_IPHI / 20, 0, MAX_IPHI, 2, -MAX_IETA, MAX_IETA);
282  Int_t ebcount = 0;
283  unsigned int run[2] = {0, 0}, status[kEBChannels];
284  std::string l_tagname[2];
285  auto iovs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
286  l_tagname[0] = cond::payloadInspector::PlotBase::getTag<0>().name;
287  auto firstiov = iovs.front();
288  run[0] = std::get<0>(firstiov);
289  std::tuple<cond::Time_t, cond::Hash> lastiov;
290  if (ntags == 2) {
291  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
292  l_tagname[1] = cond::payloadInspector::PlotBase::getTag<1>().name;
293  lastiov = tag2iovs.front();
294  } else {
295  lastiov = iovs.back();
296  l_tagname[1] = l_tagname[0];
297  }
298  run[1] = std::get<0>(lastiov);
299  for (int irun = 0; irun < nIOVs; irun++) {
300  std::shared_ptr<EcalChannelStatus> payload;
301  if (irun == 0) {
302  payload = this->fetchPayload(std::get<1>(firstiov));
303  } else {
304  payload = this->fetchPayload(std::get<1>(lastiov));
305  }
306  if (payload.get()) {
307  // looping over the EB channels, via the dense-index, mapped into EBDetId's
308  if (payload->barrelItems().empty())
309  return false;
310  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
311  uint32_t rawid = EBDetId::unhashIndex(cellid);
312  // check the existence of ECAL channel status, for a given ECAL barrel channel
313  if (payload->find(rawid) == payload->end())
314  continue;
315  // if (!(*payload)[rawid].getEncodedStatusCode()) continue;
316  if (irun == 0) {
317  status[cellid] = (*payload)[rawid].getEncodedStatusCode();
318  } else {
319  unsigned int new_status = (*payload)[rawid].getEncodedStatusCode();
320  if (new_status != status[cellid]) {
321  int tmp3 = 0;
322  if (new_status > status[cellid])
323  tmp3 = 1;
324  else
325  tmp3 = -1;
326  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
327  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
328  if (eta > 0.)
329  eta = eta - 0.5; // 0.5 to 84.5
330  else
331  eta = eta + 0.5; // -84.5 to -0.5
332  ebmap->Fill(phi, eta, 0.05 + 0.95 * (tmp3 > 0));
333  ebcount++;
334  ebmap_coarse->Fill(phi, eta, tmp3);
335  }
336  }
337  } // loop over cellid
338  } // if payload.get()
339  else
340  return false;
341  } // loop over IOV's
342 
343  gStyle->SetOptStat(0);
344  //set the background color to white
345  gStyle->SetFillColor(10);
346  gStyle->SetFrameFillColor(10);
347  gStyle->SetCanvasColor(10);
348  gStyle->SetPadColor(10);
349  gStyle->SetTitleFillColor(0);
350  gStyle->SetStatColor(10);
351  //dont put a colored frame around the plots
352  gStyle->SetFrameBorderMode(0);
353  gStyle->SetCanvasBorderMode(0);
354  gStyle->SetPadBorderMode(0);
355  //use the primary color palette
356  gStyle->SetPalette(1);
357 
358  Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
359  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
360  Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
361  Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
362  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
363  gStyle->SetNumberContours(NCont);
364 
365  TCanvas c1("c1", "c1", 1200, 700);
366  c1.SetGridx(1);
367  c1.SetGridy(1);
368 
369  TLatex t1;
370  t1.SetNDC();
371  t1.SetTextAlign(26);
372  t1.SetTextSize(0.06);
373 
374  ebmap->SetXTitle("i#phi");
375  ebmap->SetYTitle("i#eta");
376  ebmap->GetXaxis()->SetNdivisions(-418, kFALSE);
377  ebmap->GetYaxis()->SetNdivisions(-1702, kFALSE);
378  ebmap->GetXaxis()->SetLabelSize(0.03);
379  ebmap->GetYaxis()->SetLabelSize(0.03);
380  ebmap->GetXaxis()->SetTickLength(0.01);
381  ebmap->GetYaxis()->SetTickLength(0.01);
382  ebmap->SetMaximum(1.15);
383 
384  c1.cd();
385  ebmap->Draw("colz");
386 
387  ebmap_coarse->SetMarkerSize(1.3);
388  ebmap_coarse->Draw("text,same");
389 
390  int len = l_tagname[0].length() + l_tagname[1].length();
391  if (ntags == 2) {
392  if (len < 60) {
393  t1.SetTextSize(0.03);
394  t1.DrawLatex(
395  0.5, 0.96, Form("%s IOV %i - %s IOV %i", l_tagname[1].c_str(), run[1], l_tagname[0].c_str(), run[0]));
396  } else
397  t1.SetTextSize(0.05);
398  t1.DrawLatex(0.5, 0.96, Form("EB Channel Status Masks (Diff), IOV %i - IOV %i", run[1], run[0]));
399  } else {
400  t1.SetTextSize(0.05);
401  t1.DrawLatex(0.5, 0.96, Form("%s IOV: %i - %i", l_tagname[0].c_str(), run[1], run[0]));
402  }
403 
404  char txt[80];
405  sprintf(txt, "Net difference: %d channel(s)", ebcount);
406  t1.SetTextColor(2);
407  t1.SetTextSize(0.045);
408  t1.DrawLatex(0.5, 0.91, txt);
409 
410  std::string ImageName(this->m_imageFileName);
411  c1.SaveAs(ImageName.c_str());
412  return true;
413  } // fill method
414  };
415  using EcalChannelStatusEBDiffOneTag = EcalChannelStatusEBDiffBase<cond::payloadInspector::SINGLE_IOV, 1>;
416  using EcalChannelStatusEBDiffTwoTags = EcalChannelStatusEBDiffBase<cond::payloadInspector::SINGLE_IOV, 2>;
417 
418  /************************************************************************
419  2d plot of ECAL endcaps channel status difference between 2 IOVs
420  ************************************************************************/
421  template <cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
422  class EcalChannelStatusEEDiffBase : public cond::payloadInspector::PlotImage<EcalChannelStatus, nIOVs, ntags> {
423  public:
424  EcalChannelStatusEEDiffBase()
425  : cond::payloadInspector::PlotImage<EcalChannelStatus, nIOVs, ntags>("ECAL Endcaps channel status difference") {
426  }
427  bool fill() override {
428  TH2F *eemap = new TH2F("eemap", "", 2 * IX_MAX, 0, 2 * IX_MAX, IY_MAX, 0, IY_MAX);
429  TH2F *eemap_coarse = new TH2F("eemap_coarse", "", 2, 0, 2 * IX_MAX, 1, 0, IY_MAX);
430  TH2F *eetemp = new TH2F("eetemp", "", 2 * IX_MAX, 0, 2 * IX_MAX, IY_MAX, 0, IY_MAX);
431  Int_t eecount = 0;
432  unsigned int run[2]{0, 0}, status[kEEChannels];
433  std::string l_tagname[2];
434  auto iovs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
435  l_tagname[0] = cond::payloadInspector::PlotBase::getTag<0>().name;
436  auto firstiov = iovs.front();
437  run[0] = std::get<0>(firstiov);
438  std::tuple<cond::Time_t, cond::Hash> lastiov;
439  if (ntags == 2) {
440  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
441  l_tagname[1] = cond::payloadInspector::PlotBase::getTag<1>().name;
442  lastiov = tag2iovs.front();
443  lastiov = tag2iovs.front();
444  } else {
445  lastiov = iovs.back();
446  l_tagname[1] = l_tagname[0];
447  }
448  run[1] = std::get<0>(lastiov);
449  for (int irun = 0; irun < nIOVs; irun++) {
450  std::shared_ptr<EcalChannelStatus> payload;
451  if (irun == 0) {
452  payload = this->fetchPayload(std::get<1>(firstiov));
453  } else {
454  payload = this->fetchPayload(std::get<1>(lastiov));
455  }
456  if (payload.get()) {
457  if (payload->endcapItems().empty())
458  return false;
459 
460  // looping over the EE channels
461  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
462  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
463  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
464  if (EEDetId::validDetId(ix, iy, iz)) {
465  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
466  uint32_t rawid = myEEId.rawId();
467  int channel = myEEId.hashedIndex();
468  // check the existence of ECAL channel status, for a given ECAL endcap channel
469  if (payload->find(rawid) == payload->end())
470  continue;
471  if (irun == 0) {
472  status[channel] = (*payload)[rawid].getEncodedStatusCode();
473  } else {
474  unsigned int new_status = (*payload)[rawid].getEncodedStatusCode();
475  if (new_status != status[channel]) {
476  int tmp3 = 0;
477  if (new_status > status[channel])
478  tmp3 = 1;
479  else
480  tmp3 = -1;
481  if (iz == -1) {
482  eemap->Fill(ix - 1, iy - 1, 0.05 + 0.95 * (tmp3 > 0));
483  eecount++;
484  eemap_coarse->Fill(ix - 1, iy - 1, tmp3);
485  } else {
486  eemap->Fill(ix + IX_MAX - 1, iy - 1, 0.05 + 0.95 * (tmp3 > 0));
487  eecount++;
488  eemap_coarse->Fill(ix + IX_MAX - 1, iy - 1, tmp3);
489  } // z side
490  } // any difference ?
491  } // 2nd IOV, fill the plots
492  } // validDetId
493  } // get the payload
494  } // loop over payloads
495 
496  gStyle->SetOptStat(0);
497  //set the background color to white
498  gStyle->SetFillColor(10);
499  gStyle->SetFrameFillColor(10);
500  gStyle->SetCanvasColor(10);
501  gStyle->SetPadColor(10);
502  gStyle->SetTitleFillColor(0);
503  gStyle->SetStatColor(10);
504  //dont put a colored frame around the plots
505  gStyle->SetFrameBorderMode(0);
506  gStyle->SetCanvasBorderMode(0);
507  gStyle->SetPadBorderMode(0);
508  //use the primary color palette
509  gStyle->SetPalette(1);
510 
511  Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
512  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
513  Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
514  Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
515  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
516  gStyle->SetNumberContours(NCont);
517 
518  // set the EE contours
519  for (Int_t i = 1; i <= IX_MAX; i++) {
520  for (Int_t j = 1; j <= IY_MAX; j++) {
521  if (EEDetId::validDetId(i, j, 1)) {
522  eetemp->SetBinContent(i, j, 2);
523  eetemp->SetBinContent(i + IX_MAX, j, 2);
524  }
525  }
526  }
527 
528  eetemp->SetFillColor(920);
529  TCanvas c1("c1", "c1", 1200, 600);
530  c1.SetGridx(1);
531  c1.SetGridy(1);
532 
533  TLatex t1;
534  t1.SetNDC();
535  t1.SetTextAlign(26);
536  t1.SetTextSize(0.06);
537 
538  eetemp->GetXaxis()->SetNdivisions(40, kFALSE);
539  eetemp->GetYaxis()->SetNdivisions(20, kFALSE);
540  eetemp->GetXaxis()->SetLabelSize(0.00);
541  eetemp->GetYaxis()->SetLabelSize(0.00);
542  eetemp->GetXaxis()->SetTickLength(0.01);
543  eetemp->GetYaxis()->SetTickLength(0.01);
544  eetemp->SetMaximum(1.15);
545 
546  eemap->GetXaxis()->SetNdivisions(40, kFALSE);
547  eemap->GetYaxis()->SetNdivisions(20, kFALSE);
548  eemap->GetXaxis()->SetLabelSize(0.00);
549  eemap->GetYaxis()->SetLabelSize(0.00);
550  eemap->GetXaxis()->SetTickLength(0.01);
551  eemap->GetYaxis()->SetTickLength(0.01);
552  eemap->SetMaximum(1.15);
553 
554  eetemp->Draw("box");
555  eemap->Draw("same,colz");
556 
557  eemap_coarse->SetMarkerSize(2);
558  eemap_coarse->Draw("same,text");
559 
560  t1.SetTextColor(1);
561  int len = l_tagname[0].length() + l_tagname[1].length();
562  if (ntags == 2) {
563  if (len < 60) {
564  t1.SetTextSize(0.03);
565  t1.DrawLatex(
566  0.5, 0.96, Form("%s IOV %i - %s IOV %i", l_tagname[1].c_str(), run[1], l_tagname[0].c_str(), run[0]));
567  } else {
568  t1.SetTextSize(0.05);
569  t1.DrawLatex(0.5, 0.96, Form("EE Channel Status Masks (Diff), IOV %i - IOV %i", run[1], run[0]));
570  }
571  } else {
572  t1.SetTextSize(0.05);
573  t1.DrawLatex(0.5, 0.96, Form("%s IOV: %i - %i", l_tagname[0].c_str(), run[1], run[0]));
574  }
575 
576  char txt[80];
577  sprintf(txt, "Net difference: %d channel(s)", eecount);
578  t1.SetTextColor(2);
579  t1.SetTextSize(0.045);
580  t1.DrawLatex(0.5, 0.91, txt);
581  t1.SetTextColor(1);
582  t1.SetTextSize(0.05);
583  t1.DrawLatex(0.14, 0.84, "EE-");
584  t1.DrawLatex(0.86, 0.84, "EE+");
585 
586  std::string ImageName(this->m_imageFileName);
587  c1.SaveAs(ImageName.c_str());
588  return true;
589  } // fill method
590  };
591  using EcalChannelStatusEEDiffOneTag = EcalChannelStatusEEDiffBase<cond::payloadInspector::SINGLE_IOV, 1>;
592  using EcalChannelStatusEEDiffTwoTags = EcalChannelStatusEEDiffBase<cond::payloadInspector::SINGLE_IOV, 2>;
593 
594  /********************************************************
595  2d plot of EcalChannelStatus Error Summary of 1 IOV
596  ********************************************************/
597  class EcalChannelStatusSummaryPlot : public cond::payloadInspector::PlotImage<EcalChannelStatus> {
598  public:
599  EcalChannelStatusSummaryPlot()
600  : cond::payloadInspector::PlotImage<EcalChannelStatus>("Ecal Channel Status Error Summary - map ") {
601  setSingleIov(true);
602  }
603 
604  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
605  auto iov = iovs.front(); //get reference to 1st element in the vector iovs
606  std::shared_ptr<EcalChannelStatus> payload =
607  fetchPayload(std::get<1>(iov)); //std::get<1>(iov) refers to the Hash in the tuple iov
608  unsigned int run = std::get<0>(iov); //referes to Time_t in iov.
609  TH2F *align; //pointer to align which is a 2D histogram
610 
611  int NbRows = 3;
612  int NbColumns = 3;
613 
614  if (payload.get()) { //payload is an iov retrieved from payload using hash.
615 
616  align = new TH2F("Ecal Channel Status Error Summary",
617  "EB/EE-/EE+ ErrorCount Total Number",
618  NbColumns,
619  0,
620  NbColumns,
621  NbRows,
622  0,
623  NbRows);
624 
625  long unsigned int ebErrorCount = 0;
626  long unsigned int ee1ErrorCount = 0;
627  long unsigned int ee2ErrorCount = 0;
628 
629  long unsigned int ebTotal = (payload->barrelItems()).size();
630  long unsigned int ee1Total = 0;
631  long unsigned int ee2Total = 0;
632 
633  getBarrelErrorSummary<EcalChannelStatusCode>(payload->barrelItems(), ebErrorCount);
634  getEndCapErrorSummary<EcalChannelStatusCode>(
635  payload->endcapItems(), ee1ErrorCount, ee2ErrorCount, ee1Total, ee2Total);
636 
637  double row = NbRows - 0.5;
638 
639  //EB summary values
640  align->Fill(0.5, row, 1);
641  align->Fill(1.5, row, ebErrorCount);
642  align->Fill(2.5, row, ebTotal);
643 
644  row--;
645 
646  align->Fill(0.5, row, 2);
647  align->Fill(1.5, row, ee1ErrorCount);
648  align->Fill(2.5, row, ee1Total);
649 
650  row--;
651 
652  align->Fill(0.5, row, 3);
653  align->Fill(1.5, row, ee2ErrorCount);
654  align->Fill(2.5, row, ee2Total);
655 
656  } // if payload.get()
657  else
658  return false;
659 
660  gStyle->SetPalette(1);
661  gStyle->SetOptStat(0);
662  TCanvas canvas("CC map", "CC map", 1000, 1000);
663  TLatex t1;
664  t1.SetNDC();
665  t1.SetTextAlign(26);
666  t1.SetTextSize(0.045);
667  t1.SetTextColor(2);
668  t1.DrawLatex(0.5, 0.96, Form("EcalChannelStatus Error Summary, IOV %i", run));
669 
670  TPad *pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
671  pad->Draw();
672  pad->cd();
673  align->Draw("TEXT");
674 
675  drawTable(NbRows, NbColumns);
676 
677  align->GetXaxis()->SetTickLength(0.);
678  align->GetXaxis()->SetLabelSize(0.);
679  align->GetYaxis()->SetTickLength(0.);
680  align->GetYaxis()->SetLabelSize(0.);
681 
682  std::string ImageName(m_imageFileName);
683  canvas.SaveAs(ImageName.c_str());
684  return true;
685  } // fill method
686  };
687 
688 } // namespace
689 
690 // Register the classes as boost python plugin
692  PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEBMap);
693  PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEEMap);
694  PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEBDiffOneTag);
695  PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEBDiffTwoTags);
696  PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEEDiffOneTag);
697  PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEEDiffTwoTags);
698  PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusSummaryPlot);
699 }
size
Write out results.
static const int XYMODE
Definition: EEDetId.h:335
Definition: weight.py:1
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
static const int MIN_HASH
Definition: EBDetId.h:149
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
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
Definition: plugin.cc:23
def canvas(sub, attr)
Definition: svgfig.py:482
int hashedIndex() const
Definition: EEDetId.h:183
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)