Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:12

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_ = {{"RP_45_210_FR_BT",
0008                                                                  "RP_45_210_FR_HR",
0009                                                                  "RP_45_210_FR_TP",
0010                                                                  "RP_45_220_C1",
0011                                                                  "RP_45_220_FR_BT",
0012                                                                  "RP_45_220_FR_HR",
0013                                                                  "RP_45_220_FR_TP",
0014                                                                  "RP_45_220_NR_BT",
0015                                                                  "RP_45_220_NR_TP",
0016                                                                  "RP_56_210_FR_BT",
0017                                                                  "RP_56_210_FR_HR",
0018                                                                  "RP_56_210_FR_TP",
0019                                                                  "RP_56_220_C1",
0020                                                                  "RP_56_220_FR_BT",
0021                                                                  "RP_56_220_FR_HR",
0022                                                                  "RP_56_220_FR_TP",
0023                                                                  "RP_56_220_NR_BT",
0024                                                                  "RP_56_220_NR_TP"}};
0025 
0026 const std::array<std::string, 4> CTPPSRecord::statusNames_ = {{"unused", "bad", "warning", "ok"}};
0027 
0028 CTPPSRecord::CTPPSRecord() : timestamp_(edm::Timestamp::invalidTimestamp()), status_(0) {}
0029 
0030 CTPPSRecord::CTPPSRecord(const online::CTPPS_v1& ctpps) {
0031   // DIP timestamp is in milliseconds
0032   const uint64_t seconds = ctpps.timestamp / 1000;
0033   const uint32_t microseconds = (ctpps.timestamp % 1000) * 1000;
0034   timestamp_ = edm::Timestamp((seconds << 32) | microseconds);
0035   status_ = ctpps.status;
0036 }
0037 
0038 CTPPSRecord::~CTPPSRecord() {}
0039 
0040 std::ostream& operator<<(std::ostream& s, const CTPPSRecord& ctpps) {
0041   const time_t ts = ctpps.timestamp().unixTime();
0042 
0043   s << "timeStamp:            " << asctime(localtime(&ts));
0044   s << "Roman pot states:" << std::endl;
0045 
0046   for (uint8_t i = 0; i < CTPPSRecord::RomanPot::Last; ++i) {
0047     s << "   " << std::setw(16) << std::left << ctpps.romanPotName(i) << ": " << ctpps.statusName(i) << std::endl;
0048   }
0049 
0050   return s;
0051 }