CMS 3D CMS Logo

EcalTPGWeightIdMap_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 Weight Id Map of 1 IOV
24  ******************************************/
25  class EcalTPGWeightIdMapPlot : public cond::payloadInspector::PlotImage<EcalTPGWeightIdMap> {
26  public:
27  EcalTPGWeightIdMapPlot() : cond::payloadInspector::PlotImage<EcalTPGWeightIdMap>("Ecal TPG Weight Id 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<EcalTPGWeightIdMap> 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  EcalTPGWeightIdMap::EcalTPGWeightMap map = (*payload).getMap();
40  NbRows = map.size();
41 
42  align = new TH2F("Ecal TPG Weight Id Map",
43  "MapKey w0 w1 w2 w3 "
44  " w4",
45  6,
46  0,
47  6,
48  NbRows,
49  0,
50  NbRows);
51 
52  double row = NbRows - 0.5;
53  for (EcalTPGWeightIdMap::EcalTPGWeightMapItr it = map.begin(); it != map.end(); it++) {
54  uint32_t mapKey = it->first;
55  EcalTPGWeights item = it->second;
56  uint32_t w0, w1, w2, w3, w4;
57  item.getValues(w0, w1, w2, w3, w4);
58 
59  align->Fill(0.5, row, mapKey + 1);
60  align->Fill(1.5, row, w0);
61  align->Fill(2.5, row, w1);
62  align->Fill(3.5, row, w2);
63  align->Fill(4.5, row, w3);
64  align->Fill(5.5, row, w4);
65 
66  row = row - 1.;
67  } //loop over EcalTPGWeightIdMap rows
68 
69  } else
70  return false;
71 
72  gStyle->SetPalette(1);
73  gStyle->SetOptStat(0);
74  TCanvas canvas("CC map", "CC map", 1000, 1000);
75  TLatex t1;
76  t1.SetNDC();
77  t1.SetTextAlign(26);
78  t1.SetTextSize(0.05);
79  t1.SetTextColor(2);
80  t1.DrawLatex(0.5, 0.96, Form("Ecal TPG Weight Id Map, IOV %i", run));
81 
82  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
83  pad->Draw();
84  pad->cd();
85  align->Draw("TEXT");
86 
87  drawTable(NbRows, 6);
88 
89  align->GetXaxis()->SetTickLength(0.);
90  align->GetXaxis()->SetLabelSize(0.);
91  align->GetYaxis()->SetTickLength(0.);
92  align->GetYaxis()->SetLabelSize(0.);
93 
94  std::string ImageName(m_imageFileName);
95  canvas.SaveAs(ImageName.c_str());
96 
97  return true;
98  }
99  };
100 
101 } // namespace
102 // Register the classes as boost python plugin
std::map< uint32_t, EcalTPGWeights >::const_iterator EcalTPGWeightMapItr
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
common ppss p3p6s2 common epss epspn46 common const1 w4
Definition: inclppp.h:1
std::map< uint32_t, EcalTPGWeights > EcalTPGWeightMap
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
weight_default_t w1[2000]
Definition: w1.h:9
common ppss p3p6s2 common epss epspn46 common const1 w3
Definition: inclppp.h:1
def canvas(sub, attr)
Definition: svgfig.py:482
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)