CMS 3D CMS Logo

EcalTimeOffsetConstant_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 Time Offset Constant of 1 IOV
25  *******************************************************/
26  class EcalTimeOffsetConstantPlot : public cond::payloadInspector::PlotImage<EcalTimeOffsetConstant> {
27  public:
28  EcalTimeOffsetConstantPlot()
29  : cond::payloadInspector::PlotImage<EcalTimeOffsetConstant>("Ecal Time Offset Constant - map ") {
30  setSingleIov(true);
31  }
32 
33  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
34  auto iov = iovs.front();
35  std::shared_ptr<EcalTimeOffsetConstant> payload = fetchPayload(std::get<1>(iov));
36  unsigned int run = std::get<0>(iov);
37  TH2F* align;
38  int NbRows;
39 
40  if (payload.get()) {
41  NbRows = 1;
42  align = new TH2F("Time Offset Constant [ns]", "EB EE", 2, 0, 2, NbRows, 0, NbRows);
43  EcalTimeOffsetConstant it = (*payload);
44 
45  double row = NbRows - 0.5;
46 
47  align->Fill(0.5, row, it.getEBValue());
48  align->Fill(1.5, row, it.getEEValue());
49  } else
50  return false;
51 
52  gStyle->SetPalette(1);
53  gStyle->SetOptStat(0);
54  TCanvas canvas("CC map", "CC map", 1000, 1000);
55  TLatex t1;
56  t1.SetNDC();
57  t1.SetTextAlign(26);
58  t1.SetTextSize(0.05);
59  t1.SetTextColor(2);
60  t1.DrawLatex(0.5, 0.96, Form("Ecal Time Offset Constant, IOV %i", run));
61 
62  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
63  pad->Draw();
64  pad->cd();
65  align->Draw("TEXT");
66 
67  drawTable(NbRows, 2);
68 
69  align->GetXaxis()->SetTickLength(0.);
70  align->GetXaxis()->SetLabelSize(0.);
71  align->GetYaxis()->SetTickLength(0.);
72  align->GetYaxis()->SetLabelSize(0.);
73 
74  std::string ImageName(m_imageFileName);
75  canvas.SaveAs(ImageName.c_str());
76 
77  return true;
78  }
79  };
80 
81  /*******************************************************
82  2d plot of Ecal Time Offset Constant difference between 2 IOVs
83 *******************************************************/
84 
85  class EcalTimeOffsetConstantDiff : public cond::payloadInspector::PlotImage<EcalTimeOffsetConstant> {
86  public:
87  EcalTimeOffsetConstantDiff()
88  : cond::payloadInspector::PlotImage<EcalTimeOffsetConstant>("Ecal Time Offset Constant difference") {
89  setSingleIov(false);
90  }
91 
92  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
93  unsigned int run[2], irun = 0;
94  float val[2] = {};
95  TH2F* align = new TH2F("", "", 1, 0., 1., 1, 0., 1.); // pseudo creation
96  int NbRows = 0;
97 
98  for (auto const& iov : iovs) {
99  std::shared_ptr<EcalTimeOffsetConstant> payload = fetchPayload(std::get<1>(iov));
100  run[irun] = std::get<0>(iov);
101 
102  if (payload.get()) {
103  NbRows = 1;
104 
105  if (irun == 1)
106  align = new TH2F("Ecal Time Offset Constant [ns]", "EB EE", 2, 0, 2, NbRows, 0, NbRows);
107 
108  EcalTimeOffsetConstant it = (*payload);
109 
110  if (irun == 0) {
111  val[0] = it.getEBValue();
112  val[1] = it.getEEValue();
113 
114  } else {
115  double row = NbRows - 0.5;
116  align->Fill(0.5, row, it.getEBValue() - val[0]);
117  align->Fill(1.5, row, it.getEEValue() - val[1]);
118  }
119 
120  } // if payload.get()
121  else
122  return false;
123 
124  irun++;
125  } // loop over IOVs
126 
127  gStyle->SetPalette(1);
128  gStyle->SetOptStat(0);
129  TCanvas canvas("CC map", "CC map", 1000, 1000);
130  TLatex t1;
131  t1.SetNDC();
132  t1.SetTextAlign(26);
133  t1.SetTextSize(0.05);
134  t1.SetTextColor(2);
135  t1.DrawLatex(0.5, 0.96, Form("Ecal Time Offset Constant, IOV %i - %i", run[1], run[0]));
136 
137  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
138  pad->Draw();
139  pad->cd();
140  align->Draw("TEXT");
141 
142  drawTable(NbRows, 2);
143 
144  align->GetXaxis()->SetTickLength(0.);
145  align->GetXaxis()->SetLabelSize(0.);
146  align->GetYaxis()->SetTickLength(0.);
147  align->GetYaxis()->SetLabelSize(0.);
148 
149  std::string ImageName(m_imageFileName);
150  canvas.SaveAs(ImageName.c_str());
151 
152  return true;
153  }
154  };
155 
156 } // namespace
157 
158 // Register the classes as boost python plugin
160  PAYLOAD_INSPECTOR_CLASS(EcalTimeOffsetConstantPlot);
161  PAYLOAD_INSPECTOR_CLASS(EcalTimeOffsetConstantDiff);
162 }
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
align
Definition: AlignableIndexer.h:30
PayloadInspector.h
EBDetId.h
EEDetId.h
EcalTimeOffsetConstant::getEEValue
float getEEValue() const
Definition: EcalTimeOffsetConstant.h:21
EcalTimeOffsetConstant
Definition: EcalTimeOffsetConstant.h:13
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
EcalTimeOffsetConstant::getEBValue
float getEBValue() const
Definition: EcalTimeOffsetConstant.h:20
PayloadInspectorModule.h
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
EcalTimeOffsetConstant.h
jets_cff.payload
payload
Definition: jets_cff.py:34
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
Time.h
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:840
EcalDrawUtils.h
heppy_batch.val
val
Definition: heppy_batch.py:351
writedatasetfile.run
run
Definition: writedatasetfile.py:27
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
drawTable
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:829