CMS 3D CMS Logo

CTPPSRecord.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <ctime>
3 
6 
8 {{
9  "RP_45_210_FR_BT",
10  "RP_45_210_FR_HR",
11  "RP_45_210_FR_TP",
12  "RP_45_220_C1",
13  "RP_45_220_FR_BT",
14  "RP_45_220_FR_HR",
15  "RP_45_220_FR_TP",
16  "RP_45_220_NR_BT",
17  "RP_45_220_NR_TP",
18  "RP_56_210_FR_BT",
19  "RP_56_210_FR_HR",
20  "RP_56_210_FR_TP",
21  "RP_56_220_C1",
22  "RP_56_220_FR_BT",
23  "RP_56_220_FR_HR",
24  "RP_56_220_FR_TP",
25  "RP_56_220_NR_BT",
26  "RP_56_220_NR_TP"
27  }};
28 
29 
30 const std::array<std::string,4> CTPPSRecord::statusNames_ =
31 {{"unused","bad","warning","ok"}};
32 
33 
35  timestamp_(edm::Timestamp::invalidTimestamp()),
36  status_(0)
37 {}
38 
39 
41 {
42  // DIP timestamp is in milliseconds
43  const uint64_t seconds = ctpps.timestamp / 1000;
44  const uint32_t microseconds = (ctpps.timestamp % 1000) * 1000;
45  timestamp_ = edm::Timestamp((seconds<<32) | microseconds );
46  status_ = ctpps.status;
47 }
48 
49 
51 
52 
53 std::ostream& operator<<(std::ostream& s, const CTPPSRecord& ctpps)
54 {
55  const time_t ts = ctpps.timestamp().unixTime();
56 
57  s << "timeStamp: " << asctime(localtime(&ts));
58  s << "Roman pot states:" << std::endl;
59 
60  for (uint8_t i = 0; i < CTPPSRecord::RomanPot::Last; ++i) {
61  s << " " << std::setw(16) << std::left << ctpps.romanPotName(i)
62  << ": " << ctpps.statusName(i)
63  << std::endl;
64  }
65 
66  return s;
67 }
double seconds()
const std::string & statusName(const uint8_t rp) const
Return the status as string.
Definition: CTPPSRecord.h:73
std::ostream & operator<<(std::ostream &s, const CTPPSRecord &ctpps)
Pretty-print operator for CTPPSRecord.
Definition: CTPPSRecord.cc:53
static const RomanPotNames romanPotNames_
Definition: CTPPSRecord.h:81
unsigned int unixTime() const
Time in seconds since January 1, 1970.
Definition: Timestamp.h:46
const std::string & romanPotName(const uint8_t rp) const
Return the name of the roman pot.
Definition: CTPPSRecord.h:67
const edm::Timestamp & timestamp() const
Return the time of the last change.
Definition: CTPPSRecord.h:60
unsigned long long uint64_t
Definition: Time.h:15
uint64_t status_
Definition: CTPPSRecord.h:79
virtual ~CTPPSRecord()
Definition: CTPPSRecord.cc:50
std::array< std::string, Last > RomanPotNames
Get the names of all roman pots.
Definition: CTPPSRecord.h:63
Class to contain CTPPS information from soft FED 1022.
Definition: CTPPSRecord.h:22
HLT enums.
static const std::array< std::string, 4 > statusNames_
Definition: CTPPSRecord.h:80
edm::Timestamp timestamp_
Definition: CTPPSRecord.h:78