CMS 3D CMS Logo

EcalTPGLutIdMap_PayloadInspector.cc
Go to the documentation of this file.
7 
8 // the data format of the condition to be inspected
10 
11 #include "TH2F.h" // a 2-D histogram with four bytes per cell (float)
12 #include "TCanvas.h"
13 #include "TLine.h"
14 #include "TStyle.h"
15 #include "TLatex.h" //write mathematical equations.
16 #include "TPave.h"
17 #include "TPaveStats.h"
18 #include <string>
19 #include <fstream>
20 
21 namespace {
22  /*****************************************
23  2d plot of Ecal TPG LutId Map of 1 IOV
24  ******************************************/
25  class EcalTPGLutIdMapPlot : public cond::payloadInspector::PlotImage<EcalTPGLutIdMap> {
26  public:
27  EcalTPGLutIdMapPlot() : cond::payloadInspector::PlotImage<EcalTPGLutIdMap>("Ecal TPG LutId Map - map ") {
28  setSingleIov(true);
29  }
30 
31  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
32  auto iov = iovs.front();
33  std::shared_ptr<EcalTPGLutIdMap> payload = fetchPayload(std::get<1>(iov));
34  unsigned int run = std::get<0>(iov);
35  TH2F* align;
36  int NbRows;
37 
38  if (payload.get()) {
39  EcalTPGLutIdMap::EcalTPGLutMap map = (*payload).getMap();
40  NbRows = 30;
41 
42  align = new TH2F("Ecal TPG LutId Map",
43  "EB LutEcalTPGLut EE "
44  " LutEcalTPGLut",
45  4,
46  0,
47  4,
48  NbRows,
49  0,
50  NbRows);
51 
52  double row = NbRows - 0.5;
53  int columnBase = 0;
54  for (EcalTPGLutIdMap::EcalTPGLutMapItr it = map.begin(); it != map.end(); it++) {
55  EcalTPGLut ecaltpgLut = it->second;
56  uint32_t mapKey = it->first;
57 
58  const unsigned int* lut = (ecaltpgLut.getLut());
59 
60  for (int i = 0; i < 30; i++) {
61  if (i == (NbRows / 2 - 1))
62  align->Fill(0.5 + columnBase, row, mapKey + 1);
63 
64  align->Fill(1.5 + columnBase, row, *(lut + i));
65  row = row - 1.;
66  }
67 
68  columnBase += 2;
69  row = NbRows - 0.5;
70  } //loop over TPGLutIdMap rows
71 
72  } else
73  return false;
74 
75  gStyle->SetPalette(1);
76  gStyle->SetOptStat(0);
77  TCanvas canvas("CC map", "CC map", 1000, 1000);
78  TLatex t1;
79  t1.SetNDC();
80  t1.SetTextAlign(26);
81  t1.SetTextSize(0.05);
82  t1.SetTextColor(2);
83  t1.DrawLatex(0.5, 0.96, Form("ECAL TPG LutId Map, IOV %i", run));
84 
85  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
86  pad->Draw();
87  pad->cd();
88  align->Draw("TEXT");
89  TLine* l = new TLine;
90  l->SetLineWidth(1);
91  for (int i = 1; i < NbRows; i++) {
92  double y = (double)i;
93  l = new TLine(1., y, 2., y);
94  l->Draw();
95  }
96 
97  for (int i = 1; i < NbRows; i++) {
98  double y = (double)i;
99  l = new TLine(3., y, 4., y);
100  l->Draw();
101  }
102 
103  for (int i = 1; i < 4; i++) {
104  double x = (double)i;
105  double y = (double)NbRows;
106  l = new TLine(x, 0., x, y);
107  l->Draw();
108  }
109 
110  align->GetXaxis()->SetTickLength(0.);
111  align->GetXaxis()->SetLabelSize(0.);
112  align->GetYaxis()->SetTickLength(0.);
113  align->GetYaxis()->SetLabelSize(0.);
114 
115  std::string ImageName(m_imageFileName);
116  canvas.SaveAs(ImageName.c_str());
117 
118  return true;
119  }
120  };
121 
122 } // namespace
123 // Register the classes as boost python plugin
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
const unsigned int * getLut() const
Definition: EcalTPGLut.cc:13
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
Definition: plugin.cc:23
def canvas(sub, attr)
Definition: svgfig.py:482
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)