CMS 3D CMS Logo

EcalDCSTowerStatus_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 
22  /*****************************************
23  2d plot of Ecal DCS Tower Status Errors Total of 1 IOV
24  ******************************************/
25  class EcalDCSTowerStatusSummaryPlot : public cond::payloadInspector::PlotImage<EcalDCSTowerStatus> {
26  public:
27  EcalDCSTowerStatusSummaryPlot()
28  : cond::payloadInspector::PlotImage<EcalDCSTowerStatus>("Ecal DCS Tower Status Errors Total - map ") {
29  setSingleIov(true);
30  }
31 
32  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
33  auto iov = iovs.front(); //get reference to 1st element in the vector iovs
34  std::shared_ptr<EcalDCSTowerStatus> payload =
35  fetchPayload(std::get<1>(iov)); //std::get<1>(iov) refers to the Hash in the tuple iov
36  unsigned int run = std::get<0>(iov); //referes to Time_t in iov.
37  TH2F* align; //pointer to align which is a 2D histogram
38 
39  int NbRows = 2;
40  int NbColumns = 8;
41 
42  if (payload.get()) { //payload is an iov retrieved from payload using hash.
43 
44  align = new TH2F("Ecal DCS Tower Status Errors Total",
45  "EB/EE LV LVNOMINAL HV HVNOMINAL HVEED HVEEDNOMINAL TotalItems",
46  NbColumns,
47  0,
48  NbColumns,
49  NbRows,
50  0,
51  NbRows);
52 
53  float ebVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
54  float eeVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
55 
56  long unsigned int ebTotal = (payload->barrelItems()).size();
57  long unsigned int eeTotal = (payload->endcapItems()).size();
58 
59  getSummary(payload->barrelItems(), ebVals, ebTotal);
60  getSummary(payload->endcapItems(), eeVals, eeTotal);
61 
62  double row = NbRows - 0.5;
63 
64  //EB summary values
65  align->Fill(0.5, row, 1);
66 
67  for (int i = 0; i < 6; i++) {
68  align->Fill(1.5 + i, row, ebVals[i]);
69  }
70  align->Fill(7.5, row, ebTotal);
71 
72  row--;
73 
74  align->Fill(0.5, row, 2);
75 
76  for (int i = 0; i < 6; i++) {
77  align->Fill(1.5 + i, row, eeVals[i]);
78  }
79  align->Fill(7.5, row, eeTotal);
80 
81  } // if payload.get()
82  else
83  return false;
84 
85  gStyle->SetPalette(1);
86  gStyle->SetOptStat(0);
87  TCanvas canvas("CC map", "CC map", 1000, 1000);
88  TLatex t1;
89  t1.SetNDC();
90  t1.SetTextAlign(26);
91  t1.SetTextSize(0.04);
92  t1.SetTextColor(2);
93  t1.DrawLatex(0.5, 0.96, Form("Ecal DCSTower Status Errors Total, IOV %i", run));
94 
95  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
96  pad->Draw();
97  pad->cd();
98  align->Draw("TEXT");
99 
100  drawTable(NbRows, NbColumns);
101 
102  align->GetXaxis()->SetTickLength(0.);
103  align->GetXaxis()->SetLabelSize(0.);
104  align->GetYaxis()->SetTickLength(0.);
105  align->GetYaxis()->SetLabelSize(0.);
106 
107  std::string ImageName(m_imageFileName);
108  canvas.SaveAs(ImageName.c_str());
109  return true;
110  } // fill method
111 
112  void getSummary(std::vector<EcalChannelStatusCode> vItems, float vals[], long unsigned int& total) {
113  unsigned int shift = 0, mask = 1;
114  unsigned int statusCode;
115 
116  for (std::vector<EcalChannelStatusCode>::const_iterator iItems = vItems.begin(); iItems != vItems.end();
117  ++iItems) {
118  statusCode = iItems->getStatusCode();
119  for (shift = 0; shift < 6; ++shift) {
120  mask = 1 << (shift);
121  if (statusCode & mask) {
122  vals[shift] += 1;
123  }
124  }
125  }
126  }
127  };
128 
129 } // namespace
130 
131 // Register the classes as boost python plugin
size
Write out results.
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
def canvas(sub, attr)
Definition: svgfig.py:482
static unsigned int const shift
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)