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