CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalSRSettings_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 SR Settings Summary of 1 IOV
24  *******************************************************/
25  class EcalSRSettingsSummaryPlot : public cond::payloadInspector::PlotImage<EcalSRSettings> {
26  public:
27  EcalSRSettingsSummaryPlot() : cond::payloadInspector::PlotImage<EcalSRSettings>("Ecal SR Settings Summary - map ") {
28  setSingleIov(true);
29  }
30 
31  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
32  const int maxInCol = 27;
33 
34  auto iov = iovs.front();
35  std::shared_ptr<EcalSRSettings> payload = fetchPayload(std::get<1>(iov));
36  unsigned int run = std::get<0>(iov);
37 
38  TH2F* align;
39 
40  int NbRows, gridRows;
41  int NbColumns, offset;
42 
43  if (payload.get()) {
44  EcalSRSettings ecalSR = (*payload);
45 
46  NbRows = ecalSR.srpLowInterestChannelZS_.size();
47 
48  gridRows = (NbRows <= maxInCol) ? NbRows : maxInCol;
49  offset = ceil(1.0 * NbRows / maxInCol);
50  NbColumns = offset * 2 + 3;
51 
52  align =
53  new TH2F("Ecal SR Settings Summary",
54  "ebDccAdcToGeV eeDccAdcToGeV Rows# srpLowInterestChannelZS srpHighInterestChannelZS",
55  NbColumns,
56  0,
57  NbColumns,
58  gridRows,
59  0,
60  gridRows);
61 
62  double row = gridRows - 0.5;
63  double column = 3.5;
64  int cnt = 0;
65 
66  align->Fill(0.5, gridRows - 0.5, ecalSR.ebDccAdcToGeV_);
67  align->Fill(1.5, gridRows - 0.5, ecalSR.eeDccAdcToGeV_);
68 
69  for (int i = 0; i < gridRows; i++) {
70  align->Fill(2.5, gridRows - i - 0.5, i + 1);
71  }
72 
73  for (std::vector<float>::const_iterator it = ecalSR.srpLowInterestChannelZS_.begin();
74  it != ecalSR.srpLowInterestChannelZS_.end();
75  it++) {
76  align->Fill(column, row, *it);
77 
78  cnt++;
79  column = floor(1.0 * cnt / maxInCol) + 3.5;
80  row = (row == 0.5 ? (gridRows - 0.5) : row - 1);
81  }
82 
83  row = gridRows - 0.5;
84  column = 3.5;
85  cnt = 0;
86 
87  for (std::vector<float>::const_iterator it = ecalSR.srpHighInterestChannelZS_.begin();
88  it != ecalSR.srpHighInterestChannelZS_.end();
89  it++) {
90  align->Fill(column + offset, row, *it);
91 
92  cnt++;
93  column = floor(1.0 * cnt / maxInCol) + 3.5;
94  row = (row == 0.5 ? (gridRows - 0.5) : row - 1);
95  }
96 
97  } else
98  return false;
99 
100  gStyle->SetPalette(1);
101  gStyle->SetOptStat(0);
102  TCanvas canvas("CC map", "CC map", 1000, 1000);
103  TLatex t1;
104  t1.SetNDC();
105  t1.SetTextAlign(26);
106  t1.SetTextSize(0.05);
107  t1.SetTextColor(2);
108  t1.DrawLatex(0.5, 0.96, Form("Ecal SRSettings Summary, IOV %i", run));
109 
110  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
111  pad->Draw();
112  pad->cd();
113  align->Draw("TEXT");
114 
115  drawTable(NbRows, NbColumns);
116 
117  align->GetXaxis()->SetTickLength(0.);
118  align->GetXaxis()->SetLabelSize(0.);
119  align->GetYaxis()->SetTickLength(0.);
120  align->GetYaxis()->SetLabelSize(0.);
121 
122  std::string ImageName(m_imageFileName);
123  canvas.SaveAs(ImageName.c_str());
124 
125  return true;
126  }
127  };
128 
129 } // namespace
130 
131 // Register the classes as boost python plugin
constexpr int32_t ceil(float num)
std::vector< float > srpHighInterestChannelZS_
def canvas
Definition: svgfig.py:482
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
float ebDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EB.
std::vector< float > srpLowInterestChannelZS_
float eeDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EE.
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)