File indexing completed on 2024-04-06 12:01:30
0001 #ifndef CONDCORE_CTPPSPLUGINS_PPSDAQMAPPINGPAYLOADINSPECTORHELPER_H
0002 #define CONDCORE_CTPPSPLUGINS_PPSDAQMAPPINGPAYLOADINSPECTORHELPER_H
0003
0004
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0007 #include "CondCore/Utilities/interface/PayloadInspector.h"
0008 #include "CondCore/CondDB/interface/Time.h"
0009 #include "CondFormats/PPSObjects/interface/TotemDAQMapping.h"
0010 #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
0011
0012
0013 #include <memory>
0014 #include <sstream>
0015
0016
0017 #include "TCanvas.h"
0018 #include "TStyle.h"
0019 #include "TH2F.h"
0020 #include "TLatex.h"
0021 #include "TGraph.h"
0022
0023 namespace DAQMappingPI {
0024 inline std::string resolveDetIDForDAQMapping(int detIDNumber) {
0025 static const std::map<int, std::string> mapping = {{CTPPSDetId::SubDetector::sdTrackingStrip, "Strip"},
0026 {CTPPSDetId::SubDetector::sdTrackingPixel, "Pixel"},
0027 {CTPPSDetId::SubDetector::sdTimingDiamond, "Diamond"},
0028 {CTPPSDetId::SubDetector::sdTimingFastSilicon, "FastSilicon"},
0029 {CTPPSDetId::SubDetector::sdTotemT2, "TotemT2"}};
0030
0031 auto it = mapping.find(detIDNumber);
0032 if (it != mapping.end()) {
0033 return it->second;
0034 } else {
0035 return "not defined";
0036 }
0037 }
0038 }
0039
0040 template <class PayloadType>
0041 class DAQMappingPayloadInfo
0042 : public cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV> {
0043 public:
0044 DAQMappingPayloadInfo()
0045 : cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV>(
0046 "DAQMappingPayloadInfo text") {}
0047
0048 bool fill() override {
0049 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
0050 auto tagname = tag.name;
0051 auto iov = tag.iovs.back();
0052 auto m_payload = this->fetchPayload(std::get<1>(iov));
0053
0054 if (m_payload != nullptr) {
0055 std::stringstream payloadInfo, lineCountStream;
0056 int subDet = CTPPSDetId(m_payload->VFATMapping.begin()->second.symbolicID.symbolicID).subdetId();
0057 payloadInfo << "TAG: " << tagname << ", the mapping for: " << DAQMappingPI::resolveDetIDForDAQMapping(subDet)
0058 << std::endl;
0059 payloadInfo << *m_payload;
0060 lineCountStream << *m_payload;
0061 std::string line;
0062
0063
0064 int lineCounter = 0;
0065 while (std::getline(lineCountStream, line)) {
0066 lineCounter++;
0067 }
0068
0069 TCanvas canvas("canvas", "Canvas", 800, 20 * lineCounter);
0070
0071 TLatex latex;
0072 latex.SetNDC();
0073 latex.SetTextSize(0.015);
0074 double yPos = 0.95;
0075
0076 while (std::getline(payloadInfo, line)) {
0077 yPos -= 0.015;
0078 latex.DrawLatex(0.1, yPos, line.c_str());
0079 }
0080
0081 std::string fileName(this->m_imageFileName);
0082 canvas.SaveAs(fileName.c_str());
0083
0084 return true;
0085 } else {
0086 return false;
0087 }
0088 }
0089 };
0090
0091 #endif