CMS 3D CMS Logo

PPSAlignmentConfigurationHelper.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of PPS PI software.
4  *
5  ****************************************************************************/
6 
7 #ifndef CONDCORE_CTPPSPLUGINS_PPSALIGNMENTCONFIGURATIONHELPER_H
8 #define CONDCORE_CTPPSPLUGINS_PPSALIGNMENTCONFIGURATIONHELPER_H
9 
10 // User includes
16 
17 // system includes
18 #include <memory>
19 #include <sstream>
20 #include <fstream>
21 
22 // ROOT includes
23 #include "TCanvas.h"
24 #include "TStyle.h"
25 #include "TH2F.h"
26 #include "TLatex.h"
27 #include "TGraph.h"
28 
29 template <class PayloadType>
30 class AlignmentPayloadInfo : public cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV> {
31 public:
33  : cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV>(
34  "PPSAlignmentConfiguration payload information") {}
35 
36  bool fill() override {
37  auto tag = cond::payloadInspector::PlotBase::getTag<0>();
38  auto tagname = tag.name;
39  auto iov = tag.iovs.back();
40  auto m_payload = this->fetchPayload(std::get<1>(iov));
41 
42  if (m_payload != nullptr) {
44  std::vector<std::string> lines;
45  std::stringstream ss;
46  ss << *m_payload;
47  while (getline(ss, line)) {
48  lines.push_back(line);
49  }
50 
51  TCanvas canvas(
52  "PPSAlignmentConfiguration payload information", "PPSAlignmentConfiguration payload information", 1000, 1400);
53  canvas.cd(1);
54  TLatex t;
55  t.SetTextSize(0.018);
56 
57  int index = 0;
58  for (float y = 0.98; index < int(lines.size()); y -= 0.02) {
59  if (index < int(lines.size() / 2) + 3)
60  t.DrawLatex(0.02, y, lines[index++].c_str());
61  else if (index == int(lines.size() / 2) + 3) {
62  y = 0.98;
63  t.DrawLatex(0.5, y, lines[index++].c_str());
64  } else
65  t.DrawLatex(0.5, y, lines[index++].c_str());
66  }
67  t.Draw();
68 
70  canvas.SaveAs(fileName.c_str());
71 
72  return true;
73  } else {
74  return false;
75  }
76  }
77 };
78 
79 #endif
Definition: plugin.cc:23
def canvas(sub, attr)
Definition: svgfig.py:482
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)