CMS 3D CMS Logo

DAQMappingPayloadInspectorHelper.h
Go to the documentation of this file.
1 #ifndef CONDCORE_CTPPSPLUGINS_PPSDAQMAPPINGPAYLOADINSPECTORHELPER_H
2 #define CONDCORE_CTPPSPLUGINS_PPSDAQMAPPINGPAYLOADINSPECTORHELPER_H
3 
4 // User includes
11 
12 // system includes
13 #include <memory>
14 #include <sstream>
15 
16 // ROOT includes
17 #include "TCanvas.h"
18 #include "TStyle.h"
19 #include "TH2F.h"
20 #include "TLatex.h"
21 #include "TGraph.h"
22 
23 namespace DAQMappingPI {
24  inline std::string resolveDetIDForDAQMapping(int detIDNumber) {
25  static const std::map<int, std::string> mapping = {{CTPPSDetId::SubDetector::sdTrackingStrip, "Strip"},
26  {CTPPSDetId::SubDetector::sdTrackingPixel, "Pixel"},
27  {CTPPSDetId::SubDetector::sdTimingDiamond, "Diamond"},
28  {CTPPSDetId::SubDetector::sdTimingFastSilicon, "FastSilicon"},
29  {CTPPSDetId::SubDetector::sdTotemT2, "TotemT2"}};
30 
31  auto it = mapping.find(detIDNumber);
32  if (it != mapping.end()) {
33  return it->second;
34  } else {
35  return "not defined";
36  }
37  }
38 } // namespace DAQMappingPI
39 
40 template <class PayloadType>
42  : public cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV> {
43 public:
45  : cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV>(
46  "DAQMappingPayloadInfo text") {}
47 
48  bool fill() override {
49  auto tag = cond::payloadInspector::PlotBase::getTag<0>();
50  auto tagname = tag.name;
51  auto iov = tag.iovs.back();
52  auto m_payload = this->fetchPayload(std::get<1>(iov));
53 
54  if (m_payload != nullptr) {
55  std::stringstream payloadInfo, lineCountStream;
56  int subDet = CTPPSDetId(m_payload->VFATMapping.begin()->second.symbolicID.symbolicID).subdetId();
57  payloadInfo << "TAG: " << tagname << ", the mapping for: " << DAQMappingPI::resolveDetIDForDAQMapping(subDet)
58  << std::endl;
59  payloadInfo << *m_payload;
60  lineCountStream << *m_payload;
62 
63  //created to dynamically set canvas height
64  int lineCounter = 0;
65  while (std::getline(lineCountStream, line)) {
66  lineCounter++;
67  }
68 
69  TCanvas canvas("canvas", "Canvas", 800, 20 * lineCounter);
70 
71  TLatex latex;
72  latex.SetNDC();
73  latex.SetTextSize(0.015);
74  double yPos = 0.95;
75 
76  while (std::getline(payloadInfo, line)) {
77  yPos -= 0.015;
78  latex.DrawLatex(0.1, yPos, line.c_str());
79  }
80 
82  canvas.SaveAs(fileName.c_str());
83 
84  return true;
85  } else {
86  return false;
87  }
88  }
89 };
90 
91 #endif
std::string resolveDetIDForDAQMapping(int detIDNumber)
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
def canvas(sub, attr)
Definition: svgfig.py:482
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)