CMS 3D CMS Logo

EcalWeightSet_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  /*******************************************************
24  2d plot of Ecal Weight Set of 1 IOV
25  *******************************************************/
26  class EcalWeightSetPlot : public cond::payloadInspector::PlotImage<EcalWeightSet> {
27  public:
28  EcalWeightSetPlot() : cond::payloadInspector::PlotImage<EcalWeightSet>("Ecal Weight Set - 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<EcalWeightSet> 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  NbRows = 3;
41  align = new TH2F("Ecal Weight Set", "WeightsBeforeGainSwitch", 10, 0, 10, NbRows, 0, NbRows);
42 
43  EcalWeightSet::EcalWeightMatrix mat = (*payload).getWeightsBeforeGainSwitch();
44 
45  double rr = 9.5, cc = 0.5;
46  //x = *(m.**begin**()+7);
47  for (EcalWeightSet::EcalWeightMatrix::const_iterator it = mat.begin(); it != mat.end(); it++) {
48  align->Fill(cc, rr, *(it));
49 
50  cc++;
51  if (cc == 10.5) {
52  cc = 0.5;
53  rr--;
54  }
55  }
56 
57  } else
58  return false;
59 
60  gStyle->SetPalette(1);
61  gStyle->SetOptStat(0);
62  TCanvas canvas("CC map", "CC map", 1000, 1000);
63  TLatex t1;
64  t1.SetNDC();
65  t1.SetTextAlign(26);
66  t1.SetTextSize(0.05);
67  t1.SetTextColor(2);
68  t1.DrawLatex(0.5, 0.96, Form("Ecal Weight Set, IOV %i", run));
69 
70  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
71  pad->Draw();
72  pad->cd();
73  align->Draw("TEXT");
74 
75  drawTable(NbRows, 10);
76 
77  align->GetXaxis()->SetTickLength(0.);
78  align->GetXaxis()->SetLabelSize(0.);
79  align->GetYaxis()->SetTickLength(0.);
80  align->GetYaxis()->SetLabelSize(0.);
81 
82  std::string ImageName(m_imageFileName);
83  canvas.SaveAs(ImageName.c_str());
84 
85  return true;
86  }
87  };
88 
89 } // namespace
90 
91 // Register the classes as boost python plugin
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:19
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: plugin.cc:23
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)