CMS 3D CMS Logo

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 
34  auto iov = iovs.front(); //get reference to 1st element in the vector iovs
35  std::shared_ptr < EcalDAQTowerStatus > 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=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","EB/EE bit 0 -> towers excluded from the DAQ",NbColumns, 0, NbColumns, NbRows, 0, NbRows);
45 
46  float ebVals=0.0f;
47  float eeVals=0.0f;
48 
49  long unsigned int ebTotal=(payload->barrelItems()).size();
50  long unsigned int eeTotal=(payload->endcapItems()).size();
51 
52  getSummary(payload->barrelItems(),ebVals,ebTotal);
53  getSummary(payload->endcapItems(),eeVals,eeTotal);
54 
55 
56  double row = NbRows - 0.5;
57 
58  //EB summary values
59  align->Fill(0.5, row, 1);
60  align->Fill(1.5, row, ebVals);
61  align->Fill(2.5, row, ebTotal);
62 
63  row--;
64 
65  align->Fill(0.5, row, 2);
66  align->Fill(1.5, row, eeVals);
67  align->Fill(2.5, row, eeTotal);
68 
69  } // if payload.get()
70  else
71  return false;
72 
73  gStyle->SetPalette(1);
74  gStyle->SetOptStat(0);
75  TCanvas canvas("CC map", "CC map", 1000, 1000);
76  TLatex t1;
77  t1.SetNDC();
78  t1.SetTextAlign(26);
79  t1.SetTextSize(0.05);
80  t1.SetTextColor(2);
81  t1.DrawLatex(0.5, 0.96,Form("Ecal DAQTower Status Summary, IOV %i", run));
82 
83 
84  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
85  pad->Draw();
86  pad->cd();
87  align->Draw("TEXT");
88 
89  drawTable(NbRows,NbColumns);
90 
91  align->GetXaxis()->SetTickLength(0.);
92  align->GetXaxis()->SetLabelSize(0.);
93  align->GetYaxis()->SetTickLength(0.);
94  align->GetYaxis()->SetLabelSize(0.);
95 
96  std::string ImageName(m_imageFileName);
97  canvas.SaveAs(ImageName.c_str());
98  return true;
99  }// fill method
100 
101  void getSummary(std::vector<EcalDAQStatusCode> vItems,float & vals,long unsigned int & total){
102 
103  for(std::vector<EcalDAQStatusCode>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++iItems){
104 
105  if(iItems->getStatusCode()>0)
106  vals ++;
107 
108  }
109 
110  }
111 
112 
113 };
114 
115 } // close namespace
116 
117 // Register the classes as boost python plugin
119  PAYLOAD_INSPECTOR_CLASS( EcalDAQTowerStatusSummaryPlot);
120 }
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
void drawTable(int nbRows, int nbColumns)