File indexing completed on 2024-04-06 12:01:30
0001
0002
0003
0004
0005
0006
0007 #ifndef CONDCORE_CTPPSPLUGINS_CTPPSRPALIGNMENTCORRECTIONSDATAHELPER_H
0008 #define CONDCORE_CTPPSPLUGINS_CTPPSRPALIGNMENTCORRECTIONSDATAHELPER_H
0009
0010
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0013 #include "CondCore/Utilities/interface/PayloadInspector.h"
0014 #include "CondCore/CondDB/interface/Time.h"
0015 #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h"
0016 #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
0017
0018
0019 #include <memory>
0020 #include <sstream>
0021
0022 class CTPPSRPAlignment {
0023 public:
0024 enum RP { RP3 = 3, RP23 = 23, RP103 = 103, RP123 = 123 };
0025
0026 enum Shift { x = 1, y = 2 };
0027
0028 static std::string getStringFromRPEnum(const RP& rp) {
0029 switch (rp) {
0030 case 3:
0031 return "RP 3";
0032 case 23:
0033 return "RP 23";
0034 case 103:
0035 return "RP 103";
0036 case 123:
0037 return "RP 123";
0038
0039 default:
0040 return "not here";
0041 }
0042 }
0043
0044 static std::string getStringFromShiftEnum(const Shift& sh, bool unc) {
0045 switch (sh) {
0046 case 1:
0047 if (unc)
0048 return "x shift uncertainty";
0049 else
0050 return "x shift";
0051 case 2:
0052 if (unc)
0053 return "y shift uncertainty";
0054 else
0055 return "y shift";
0056
0057 default:
0058 return "not here";
0059 }
0060 }
0061 };
0062
0063
0064
0065
0066 template <CTPPSRPAlignment::RP rp, CTPPSRPAlignment::Shift sh, bool unc, class PayloadType>
0067 class RPShift_History : public cond::payloadInspector::HistoryPlot<PayloadType, float> {
0068 public:
0069 RPShift_History()
0070 : cond::payloadInspector::HistoryPlot<PayloadType, float>(
0071 CTPPSRPAlignment::getStringFromRPEnum(rp) + " " + CTPPSRPAlignment::getStringFromShiftEnum(sh, unc) +
0072 " [mm] vs. Runs",
0073 CTPPSRPAlignment::getStringFromRPEnum(rp) + " " + CTPPSRPAlignment::getStringFromShiftEnum(sh, unc) +
0074 " [mm]") {}
0075
0076 uint decodeRP(uint r) {
0077 if (r == CTPPSRPAlignment::RP3 || r == CTPPSRPAlignment::RP23 || r == CTPPSRPAlignment::RP103 ||
0078 r == CTPPSRPAlignment::RP123)
0079 return r;
0080 else {
0081 CTPPSDetId* config = new CTPPSDetId(r);
0082 int potId = config->arm() * 100 + config->station() * 10 + config->rp();
0083 delete config;
0084 return potId;
0085 }
0086 }
0087
0088
0089
0090 float getFromPayload(PayloadType& payload) override {
0091 for (auto& configuration : payload.getRPMap()) {
0092 if (decodeRP(configuration.first) == rp) {
0093 if (unc) {
0094 if (sh == 1)
0095 return configuration.second.getShXUnc();
0096 if (sh == 2)
0097 return configuration.second.getShYUnc();
0098 } else {
0099 if (sh == 1)
0100 return configuration.second.getShX();
0101 if (sh == 2)
0102 return configuration.second.getShY();
0103 }
0104 }
0105 }
0106 if (unc)
0107 return -1;
0108 return 0;
0109 }
0110 };
0111
0112 #endif