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 
34  auto iov = iovs.front(); //get reference to 1st element in the vector iovs
35  std::shared_ptr < EcalDCSTowerStatus > payload = 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 
45  align =new TH2F("Ecal DCS Tower Status Errors Total","EB/EE LV LVNOMINAL HV HVNOMINAL HVEED HVEEDNOMINAL TotalItems",
46  NbColumns, 0, NbColumns, NbRows, 0, NbRows);
47 
48  float ebVals[]={0.0f,0.0f,0.0f,0.0f,0.0f,0.0f};
49  float eeVals[]={0.0f,0.0f,0.0f,0.0f,0.0f,0.0f};
50 
51  long unsigned int ebTotal=(payload->barrelItems()).size();
52  long unsigned int eeTotal=(payload->endcapItems()).size();
53 
54  getSummary(payload->barrelItems(),ebVals,ebTotal);
55  getSummary(payload->endcapItems(),eeVals,eeTotal);
56 
57 
58  double row = NbRows - 0.5;
59 
60  //EB summary values
61  align->Fill(0.5, row, 1);
62 
63  for(int i=0;i<6;i++){
64  align->Fill(1.5+i, row, ebVals[i]);
65  }
66  align->Fill(7.5, row, ebTotal);
67 
68 
69  row--;
70 
71 
72  align->Fill(0.5, row, 2);
73 
74  for(int i=0;i<6;i++){
75  align->Fill(1.5+i, row, eeVals[i]);
76  }
77  align->Fill(7.5, row, eeTotal);
78 
79 
80  } // if payload.get()
81  else
82  return false;
83 
84  gStyle->SetPalette(1);
85  gStyle->SetOptStat(0);
86  TCanvas canvas("CC map", "CC map", 1000, 1000);
87  TLatex t1;
88  t1.SetNDC();
89  t1.SetTextAlign(26);
90  t1.SetTextSize(0.04);
91  t1.SetTextColor(2);
92  t1.DrawLatex(0.5, 0.96,Form("Ecal DCSTower Status Errors Total, IOV %i", run));
93 
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 
101  drawTable(NbRows,NbColumns);
102 
103  align->GetXaxis()->SetTickLength(0.);
104  align->GetXaxis()->SetLabelSize(0.);
105  align->GetYaxis()->SetTickLength(0.);
106  align->GetYaxis()->SetLabelSize(0.);
107 
108  std::string ImageName(m_imageFileName);
109  canvas.SaveAs(ImageName.c_str());
110  return true;
111  } // fill method
112 
113  void getSummary(std::vector<EcalChannelStatusCode> vItems,float vals[],long unsigned int & total){
114  unsigned int shift = 0, mask = 1;
115  unsigned int statusCode;
116 
117  for(std::vector<EcalChannelStatusCode>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++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 
130 };
131 
132 } // close namespace
133 
134 // Register the classes as boost python plugin
136  PAYLOAD_INSPECTOR_CLASS( EcalDCSTowerStatusSummaryPlot);
137 }
size
Write out results.
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
virtual bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs)=0
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: plugin.cc:24
def canvas(sub, attr)
Definition: svgfig.py:482
static unsigned int const shift
void drawTable(int nbRows, int nbColumns)