LDMX Software
ECONDEventPacket.h
1#ifndef PACKING_ECONDEVENTPACKET_H
2#define PACKING_ECONDEVENTPACKET_H
3
4#include <array>
5#include <cstdint>
6#include <span>
7#include <vector>
8
9#include "Framework/Logger.h"
10
11namespace packing {
12
24 uint32_t stat_{0};
26 uint32_t hamming_{0};
28 bool is_empty_{false};
32 int adc_cm0_{0};
34 int adc_cm1_{0};
36 uint64_t channel_map_{0};
38 std::array<uint32_t, 36> channels_{};
40 uint32_t calib_{0};
41
43 bool badStat() const { return stat_ != 0b111; }
44};
45
65 public:
83
85 std::array<bool, N_CORRUPTION> corruption_{};
86
88 uint32_t header_marker_{0};
90 uint32_t payload_length_{0};
92 bool passthrough_{false};
94 bool expected_{false};
96 uint32_t ht_{0};
98 uint32_t ebo_{0};
100 bool match_{false};
102 bool truncated_{false};
104 uint32_t hamming_{0};
106 uint32_t bx_{0};
108 uint32_t l1a_{0};
110 uint32_t orbit_{0};
112 bool subpacket_error_{false};
114 uint32_t reset_request_{0};
116 uint32_t crc8_{0};
117
124 std::vector<ECONDLinkSubpacket> links_;
125
127 explicit ECONDEventPacket(std::size_t n_links);
128
130 bool isEmpty() const { return payload_length_ == 0; }
131
133 bool isCorrupt() const;
134
145 bool from(std::span<const uint32_t> data);
146
148 static const uint32_t HEADER_MARKER_SPEC{0xaa << 1};
149 static const uint32_t HEADER_MARKER_CMS{0xf3 << 1};
150
151 private:
161 std::size_t unpackLinkSubpacket(std::span<const uint32_t> data,
162 ECONDLinkSubpacket& link) const;
163
165 enableLogging("ECONDEventPacket");
166};
167
168} // namespace packing
169
170#endif // PACKING_ECONDEVENTPACKET_H
Single ECON-D event packet.
std::array< bool, N_CORRUPTION > corruption_
corruption flags indexed by Corruption
bool subpacket_error_
S: error in a link sub-packet.
uint32_t payload_length_
payload length in 32b words (not including the two header words)
std::vector< ECONDLinkSubpacket > links_
storage of unpacked link data
uint32_t ht_
H/T: status of HGCROC header/trailer reconstruction.
bool passthrough_
P: pass through mode.
bool match_
M: transmitted E/B/O matches the L1A FIFO.
bool truncated_
T: packet truncated for buffer overflow.
uint32_t reset_request_
RR: reset request.
bool isEmpty() const
payload length of zero, no link sub-packets
uint32_t header_marker_
9b header marker
bool isCorrupt() const
any of the corruption flags are set
Corruption
index of corruption flags
@ TRUNCATED
T flag set, link sub-packets not transmitted.
@ BAD_HEADER_CRC
8b header CRC mismatch
@ BAD_HEADER_MARKER
9b header marker is not the ECOND spec or common CMS config
@ BAD_PAYLOAD
link sub-packets do not fit or do not end at the CRC word
@ BAD_LENGTH
stored payload length does not equal packet length
@ BAD_CRC32
32b sub-packet CRC mismatch
@ N_CORRUPTION
number of corruption flags
enableLogging("ECONDEventPacket")
handle to logging source
std::size_t unpackLinkSubpacket(std::span< const uint32_t > data, ECONDLinkSubpacket &link) const
Unpack a eRx ("link") sub-packet.
bool from(std::span< const uint32_t > data)
parse into the packet from the passed data span
uint32_t hamming_
6b Hamming code of the header
uint32_t ebo_
E/B/O: status of event/BX/orbit reconstruction.
uint32_t crc8_
transmitted 8b header CRC
static const uint32_t HEADER_MARKER_SPEC
spec default and common CMS header markers (8b marker + 0)
uint32_t l1a_
6b L1A (event) number
bool expected_
E: HGCROC event header/trailer expected.
uint32_t bx_
bunch crossing
ECONDEventPacket(std::size_t n_links)
construct an event packet with the number of eRx "links"
uint32_t orbit_
3b orbit number
Data from a single eRx ("link") sub-packet of an ECON-D event packet.
bool error_caused_empty_
E flag of an empty sub-packet: suppressed due to unmasked Stat errors.
bool badStat() const
any of the three Stat bits are bad (not 1)
std::array< uint32_t, 36 > channels_
sample words of the 36 normal channels
uint32_t hamming_
3-bit Hamming code of the sub-packet header
uint32_t calib_
sample word of the calibration channel
int adc_cm1_
ADC readout of common mode 1.
uint64_t channel_map_
37-bit channel map (bit 18 is the calibration channel)
bool is_empty_
F flag: sub-packet is a single header word without channel data.
int adc_cm0_
ADC readout of common mode 0.
uint32_t stat_
3-bit Stat field (HT, EBO, CRC match), all ones is good