CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalDAQTowerStatus_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 DAQ Tower Status Summary of 1 IOV
24  ******************************************/
25  class EcalDAQTowerStatusSummaryPlot : public cond::payloadInspector::PlotImage<EcalDAQTowerStatus> {
26  public:
27  EcalDAQTowerStatusSummaryPlot()
28  : cond::payloadInspector::PlotImage<EcalDAQTowerStatus>("Ecal DAQ Tower Status Summary - 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<EcalDAQTowerStatus> 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 = 3;
41 
42  if (payload.get()) { //payload is an iov retrieved from payload using hash.
43 
44  align = new TH2F("Ecal DAQ Tower Status Summary",
45  "EB/EE bit 0 -> towers excluded from the DAQ",
46  NbColumns,
47  0,
48  NbColumns,
49  NbRows,
50  0,
51  NbRows);
52 
53  float ebVals = 0.0f;
54  float eeVals = 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  align->Fill(1.5, row, ebVals);
67  align->Fill(2.5, row, ebTotal);
68 
69  row--;
70 
71  align->Fill(0.5, row, 2);
72  align->Fill(1.5, row, eeVals);
73  align->Fill(2.5, row, eeTotal);
74 
75  } // if payload.get()
76  else
77  return false;
78 
79  gStyle->SetPalette(1);
80  gStyle->SetOptStat(0);
81  TCanvas canvas("CC map", "CC map", 1000, 1000);
82  TLatex t1;
83  t1.SetNDC();
84  t1.SetTextAlign(26);
85  t1.SetTextSize(0.05);
86  t1.SetTextColor(2);
87  t1.DrawLatex(0.5, 0.96, Form("Ecal DAQTower Status Summary, IOV %i", run));
88 
89  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
90  pad->Draw();
91  pad->cd();
92  align->Draw("TEXT");
93 
94  drawTable(NbRows, NbColumns);
95 
96  align->GetXaxis()->SetTickLength(0.);
97  align->GetXaxis()->SetLabelSize(0.);
98  align->GetYaxis()->SetTickLength(0.);
99  align->GetYaxis()->SetLabelSize(0.);
100 
101  std::string ImageName(m_imageFileName);
102  canvas.SaveAs(ImageName.c_str());
103  return true;
104  } // fill method
105 
106  void getSummary(std::vector<EcalDAQStatusCode> vItems, float& vals, long unsigned int& total) {
107  for (std::vector<EcalDAQStatusCode>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++iItems) {
108  if (iItems->getStatusCode() > 0)
109  vals++;
110  }
111  }
112  };
113 
114 } // namespace
115 
116 // Register the classes as boost python plugin
def canvas
Definition: svgfig.py:482
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
tuple size
Write out results.
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)