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():
28  cond::payloadInspector::PlotImage<EcalTPGLutIdMap>("Ecal TPG LutId Map - 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();
34  std::shared_ptr <EcalTPGLutIdMap> payload = fetchPayload(std::get<1> (iov));
35  unsigned int run=std::get<0> (iov);
36  TH2F* align;
37  int NbRows;
38 
39  if(payload.get()){
40  EcalTPGLutIdMap::EcalTPGLutMap map=(*payload).getMap();
41  NbRows=30;
42 
43 
44  align =new TH2F("Ecal TPG LutId Map","EB LutEcalTPGLut EE LutEcalTPGLut",
45  4, 0, 4, NbRows, 0, NbRows);
46 
47  double row = NbRows - 0.5;
48  int columnBase=0;
49  for (EcalTPGLutIdMap::EcalTPGLutMapItr it = map.begin();it != map.end();it++) {
50 
51  EcalTPGLut ecaltpgLut=it->second;
52  uint32_t mapKey=it->first;
53 
54  const unsigned int* lut=(ecaltpgLut.getLut());
55 
56  for(int i=0;i<30;i++){
57  if(i==(NbRows/2-1))
58  align->Fill(0.5+columnBase, row, mapKey+1);
59 
60  align->Fill(1.5+columnBase, row, *(lut+i));
61  row = row - 1.;
62  }
63 
64  columnBase +=2;
65  row = NbRows - 0.5;
66  }//loop over TPGLutIdMap rows
67 
68 
69  }else
70  return false;
71 
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 TPG LutId Map, IOV %i", run));
82 
83  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
84  pad->Draw();
85  pad->cd();
86  align->Draw("TEXT");
87  TLine* l = new TLine;
88  l->SetLineWidth(1);
89  for (int i = 1; i < NbRows; i++) {
90  double y = (double) i;
91  l = new TLine(1., y, 2., y);
92  l->Draw();
93  }
94 
95  for (int i = 1; i < NbRows; i++) {
96  double y = (double) i;
97  l = new TLine(3., y, 4., y);
98  l->Draw();
99  }
100 
101  for (int i = 1; i < 4; i++) {
102  double x = (double) i;
103  double y = (double) NbRows;
104  l = new TLine(x, 0., x, y);
105  l->Draw();
106  }
107 
108  align->GetXaxis()->SetTickLength(0.);
109  align->GetXaxis()->SetLabelSize(0.);
110  align->GetYaxis()->SetTickLength(0.);
111  align->GetYaxis()->SetLabelSize(0.);
112 
113  std::string ImageName(m_imageFileName);
114  canvas.SaveAs(ImageName.c_str());
115 
116  return true;
117  }
118 
119 
120 };
121 
122 }
123 // Register the classes as boost python plugin
125  PAYLOAD_INSPECTOR_CLASS(EcalTPGLutIdMapPlot);
126 }
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)
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
Definition: plugin.cc:24
def canvas(sub, attr)
Definition: svgfig.py:481
const unsigned int * getLut() const
Definition: EcalTPGLut.cc:15
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr