LDMX Software
ECONDEventInfo.h
Go to the documentation of this file.
1
7#ifndef RECON_EVENT_ECONDEVENTINFO_H_
8#define RECON_EVENT_ECONDEVENTINFO_H_
9
10// ROOT
11#include <Rtypes.h> // For ClassDef
12
13// STL
14#include <cstdint>
15#include <iostream>
16#include <vector>
17
18namespace ldmx {
19
26 public:
27 ECONDLinkInfo() = default;
28 virtual ~ECONDLinkInfo() = default;
29
39 void set(int stat, bool is_empty, int adc_cm0, int adc_cm1, uint32_t calib) {
40 stat_ = stat;
41 is_empty_ = is_empty;
42 adc_cm0_ = adc_cm0;
43 adc_cm1_ = adc_cm1;
44 calib_ = calib;
45 }
46
48 int getStat() const { return stat_; }
50 bool hasBadStat() const { return stat_ != 0b111; }
52 bool isEmpty() const { return is_empty_; }
54 int getADCCM0() const { return adc_cm0_; }
56 int getADCCM1() const { return adc_cm1_; }
58 uint32_t getCalib() const { return calib_; }
59
60 friend std::ostream& operator<<(std::ostream& o, const ECONDLinkInfo& l);
61
62 private:
64 int stat_{0};
66 bool is_empty_{false};
68 int adc_cm0_{0};
70 int adc_cm1_{0};
72 uint32_t calib_{0};
73
74 ClassDef(ECONDLinkInfo, 1);
75};
76
82 public:
89 BAD_HEADER_MARKER = 0,
90 BAD_LENGTH = 1,
91 BAD_HEADER_CRC = 2,
92 BAD_CRC32 = 3,
93 BAD_PAYLOAD = 4,
94 TRUNCATED = 5
95 };
96
97 ECONDSampleInfo() = default;
98 virtual ~ECONDSampleInfo() = default;
99
108 void setCaptureHeader(int econ_id, int i_sample, bool is_soi, int length) {
109 econ_id_ = econ_id;
110 i_sample_ = i_sample;
111 is_soi_ = is_soi;
112 capture_length_ = length;
113 }
114
121 void setHeader(int payload_length, int flags, int ht, int ebo, int bx,
122 int l1a, int orbit, int reset_request) {
123 payload_length_ = payload_length;
124 flags_ = flags;
125 ht_ = ht;
126 ebo_ = ebo;
127 bx_ = bx;
128 l1a_ = l1a;
129 orbit_ = orbit;
130 reset_request_ = reset_request;
131 }
132
134 void setCorruption(int mask) { corruption_ = mask; }
135
137 void addLink(const ECONDLinkInfo& link) { links_.push_back(link); }
138
140 int getEconID() const { return econ_id_; }
142 int getSampleIndex() const { return i_sample_; }
144 bool isSOI() const { return is_soi_; }
146 int getCaptureLength() const { return capture_length_; }
148 int getPayloadLength() const { return payload_length_; }
150 bool isPassthrough() const { return flags_ & 0b1; }
152 bool isExpected() const { return (flags_ >> 1) & 0b1; }
154 bool isMatch() const { return (flags_ >> 2) & 0b1; }
156 bool isTruncated() const { return (flags_ >> 3) & 0b1; }
158 bool hasSubpacketError() const { return (flags_ >> 4) & 0b1; }
160 int getHT() const { return ht_; }
162 int getEBO() const { return ebo_; }
164 int getBX() const { return bx_; }
166 int getL1A() const { return l1a_; }
168 int getOrbit() const { return orbit_; }
170 int getResetRequest() const { return reset_request_; }
172 int getCorruption() const { return corruption_; }
174 bool isCorrupt(Corruption c) const { return (corruption_ >> c) & 0b1; }
176 bool isCorrupt() const { return corruption_ != 0; }
178 const std::vector<ECONDLinkInfo>& getLinks() const { return links_; }
179
180 friend std::ostream& operator<<(std::ostream& o, const ECONDSampleInfo& s);
181
182 private:
184 int econ_id_{-1};
186 int i_sample_{-1};
188 bool is_soi_{false};
194 int flags_{0};
196 int ht_{0};
198 int ebo_{0};
200 int bx_{0};
202 int l1a_{0};
204 int orbit_{0};
210 std::vector<ECONDLinkInfo> links_;
211
212 ClassDef(ECONDSampleInfo, 1);
213};
214
223 public:
230 RESYNC = 0,
231 LOST_SYNC = 1,
232 NO_TRAILER = 2,
233 TRAILER_COUNT_MISMATCH = 3,
234 ECON_ID_MISMATCH = 4,
235 SAMPLE_INDEX_MISMATCH = 5,
236 TRUNCATED_FRAME = 6,
237 EXTRA_WORDS = 7,
238 NO_SOI = 8,
239 BAD_FRAME_SIZE = 9,
240 NO_FRAME = 10
241 };
242
243 ECONDEventInfo() = default;
244 virtual ~ECONDEventInfo() = default;
245
247 void clear();
248
250 void setFrame(int corruption, int trailer_n_samples, int i_soi,
251 int n_skipped_words) {
252 corruption_ = corruption;
253 trailer_n_samples_ = trailer_n_samples;
254 i_soi_ = i_soi;
255 n_skipped_words_ = n_skipped_words;
256 }
257
259 void setDigisFilled(bool filled) { digis_filled_ = filled; }
260
262 void addSample(const ECONDSampleInfo& sample) { samples_.push_back(sample); }
263
265 int getCorruption() const { return corruption_; }
267 bool isCorrupt(Corruption c) const { return (corruption_ >> c) & 0b1; }
271 int getSOIIndex() const { return i_soi_; }
273 int getNumSkippedWords() const { return n_skipped_words_; }
275 bool areDigisFilled() const { return digis_filled_; }
277 const std::vector<ECONDSampleInfo>& getSamples() const { return samples_; }
278
279 friend std::ostream& operator<<(std::ostream& o, const ECONDEventInfo& e);
280
281 private:
287 int i_soi_{0};
291 bool digis_filled_{false};
293 std::vector<ECONDSampleInfo> samples_;
294
295 ClassDef(ECONDEventInfo, 1);
296};
297
298} // namespace ldmx
299
300#endif // RECON_EVENT_ECONDEVENTINFO_H_
Supporting data for one event decoded from a single ECON-D.
void setDigisFilled(bool filled)
set if the digis were filled from this event
int getTrailerNumSamples() const
number of samples in the ending trailer (-1 if missing)
int getNumSkippedWords() const
number of words skipped searching for capture headers
int getCorruption() const
frame corruption mask, bits from Corruption
void setFrame(int corruption, int trailer_n_samples, int i_soi, int n_skipped_words)
set the frame-level data
void clear()
reset to the default state
int corruption_
frame corruption mask
const std::vector< ECONDSampleInfo > & getSamples() const
samples in order of transmission
bool isCorrupt(Corruption c) const
check a single frame corruption bit
int n_skipped_words_
words skipped while searching for capture headers
Corruption
Bits of the frame corruption mask.
void addSample(const ECONDSampleInfo &sample)
add the next sample
bool areDigisFilled() const
were all samples good so the digis were filled
int getSOIIndex() const
index of the sample of interest
int i_soi_
index of the sample of interest
int trailer_n_samples_
number of samples in the trailer
bool digis_filled_
digis were filled from this event
std::vector< ECONDSampleInfo > samples_
per-sample data
Data from one eRx ("link") sub-packet of an ECON-D packet that is not a normal channel.
int getADCCM1() const
common mode 1 ADC
void set(int stat, bool is_empty, int adc_cm0, int adc_cm1, uint32_t calib)
Set the link data.
int getADCCM0() const
common mode 0 ADC
bool isEmpty() const
sub-packet had no channel data
uint32_t calib_
calibration channel sample word
int adc_cm1_
common mode 1 ADC
int getStat() const
3-bit Stat field, all ones is good
uint32_t getCalib() const
calibration channel sample word (HgcrocDigiCollection::Sample format)
int stat_
3-bit Stat field
bool hasBadStat() const
any of the Stat bits are bad
int adc_cm0_
common mode 0 ADC
Capture header and ECON-D header data for one sample (L1A)
int getResetRequest() const
2-bit reset request
int getBX() const
bunch crossing
bool isTruncated() const
T flag, truncated.
int orbit_
orbit number
void setHeader(int payload_length, int flags, int ht, int ebo, int bx, int l1a, int orbit, int reset_request)
Set the ECON-D event header data.
std::vector< ECONDLinkInfo > links_
link data
int corruption_
corruption mask
int i_sample_
sample index
int bx_
bunch crossing
bool isMatch() const
M flag, E/B/O match with the L1A FIFO.
void setCaptureHeader(int econ_id, int i_sample, bool is_soi, int length)
Set the capture header data.
bool hasSubpacketError() const
S flag, sub-packet error.
int getEconID() const
ECON ID from the capture header.
int capture_length_
ECON-D packet length from capture header.
int getCorruption() const
corruption mask, bits from Corruption
void addLink(const ECONDLinkInfo &link)
add the data from the next link
bool isExpected() const
E flag, HGCROC event header/trailer expected.
int ebo_
E/B/O status.
int getSampleIndex() const
sample index from the capture header
bool isSOI() const
sample of interest flag from the capture header
int reset_request_
reset request
int getEBO() const
2-bit E/B/O status
bool is_soi_
sample of interest flag
int getOrbit() const
3-bit orbit number
int getCaptureLength() const
ECON-D packet length from the capture header.
int payload_length_
payload length from ECON-D header
bool isCorrupt() const
any corruption bit is set
Corruption
Bits of the corruption mask.
int getL1A() const
6-bit L1A number
bool isCorrupt(Corruption c) const
check a single corruption bit
int getHT() const
2-bit H/T status
const std::vector< ECONDLinkInfo > & getLinks() const
link data in order of transmission
int flags_
packed P, E, M, T, S flags
bool isPassthrough() const
P flag, pass through mode.
void setCorruption(int mask)
set the corruption mask
int getPayloadLength() const
payload length from the ECON-D header