File indexing completed on 2024-04-06 12:04:49
0001 #include <iomanip>
0002 #include <ctime>
0003
0004 #include "DataFormats/OnlineMetaData/interface/CTPPSRecord.h"
0005 #include "DataFormats/OnlineMetaData/interface/OnlineMetaDataRaw.h"
0006
0007 const CTPPSRecord::RomanPotNames CTPPSRecord::romanPotNames_ = {
0008 {"RP_45_210_FR_BT", "RP_45_210_FR_HR", "RP_45_210_FR_TP", "RP_45_220_C1", "RP_45_220_FR_BT",
0009 "RP_45_220_FR_HR", "RP_45_220_FR_TP", "RP_45_220_NR_BT", "RP_45_220_NR_HR", "RP_45_220_NR_TP",
0010 "RP_56_210_FR_BT", "RP_56_210_FR_HR", "RP_56_210_FR_TP", "RP_56_220_C1", "RP_56_220_FR_BT",
0011 "RP_56_220_FR_HR", "RP_56_220_FR_TP", "RP_56_220_NR_BT", "RP_56_220_NR_HR", "RP_56_220_NR_TP"}};
0012
0013 const std::array<std::string, 4> CTPPSRecord::statusNames_ = {{"unused", "bad", "warning", "ok"}};
0014
0015 CTPPSRecord::CTPPSRecord() : timestamp_(edm::Timestamp::invalidTimestamp()), status_(0) {}
0016
0017 CTPPSRecord::CTPPSRecord(const online::CTPPS_v1& ctpps) {
0018
0019 const uint64_t seconds = ctpps.timestamp / 1000;
0020 const uint32_t microseconds = (ctpps.timestamp % 1000) * 1000;
0021 timestamp_ = edm::Timestamp((seconds << 32) | microseconds);
0022 status_ = ctpps.status;
0023 }
0024
0025 CTPPSRecord::~CTPPSRecord() {}
0026
0027 std::ostream& operator<<(std::ostream& s, const CTPPSRecord& ctpps) {
0028 const time_t ts = ctpps.timestamp().unixTime();
0029
0030 s << "timeStamp: " << asctime(localtime(&ts));
0031 s << "Roman pot states:" << std::endl;
0032
0033 for (uint8_t i = 0; i < CTPPSRecord::RomanPot::Last; ++i) {
0034 s << " " << std::setw(16) << std::left << ctpps.romanPotName(i) << ": " << ctpps.statusName(i) << std::endl;
0035 }
0036
0037 return s;
0038 }