ATLAS Offline Software
Loading...
Searching...
No Matches
PpmSubBlockV1.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGT1CALOBYTESTREAM_PPMSUBBLOCKV1_H
6#define TRIGT1CALOBYTESTREAM_PPMSUBBLOCKV1_H
7
8#include <stdint.h>
9#include <vector>
10
11#include "L1CaloSubBlock.h"
12
13namespace LVL1BS {
14
19
21
22 public:
25
27 // cppcheck-suppress duplInheritedMember
28 void clear();
29
31 void setPpmHeader(int version, int format, int seqno, int crate,
32 int module, int slicesFadc, int slicesLut);
34 void setPpmErrorHeader(int version, int format, int crate,
35 int module, int slicesFadc, int slicesLut);
36
37 // Return PPM-specific header data
38 int slicesFadc() const;
39 int slicesLut() const;
40
42 void fillPpmData(int chan, const std::vector<int>& lut,
43 const std::vector<int>& fadc,
44 const std::vector<int>& bcidLut,
45 const std::vector<int>& bcidFadc);
47 void ppmData(int chan, std::vector<int>& lut,
48 std::vector<int>& fadc,
49 std::vector<int>& bcidLut,
50 std::vector<int>& bcidFadc);
51
53 void fillPpmError(int chan, int errorWord);
55 void fillPpmPinError(int pin, int errorWord);
56
58 int ppmError(int chan) const;
60 int ppmPinError(int pin) const;
61
62 // Return individual error bits
63 bool glinkPinParity(int chan) const;
64 bool fpgaCorrupt(int chan) const;
65 bool bunchMismatch(int chan) const;
66 bool eventMismatch(int chan) const;
67 bool asicFull(int chan) const;
68 bool timeout(int chan) const;
69 bool mcmAbsent(int chan) const;
70 bool channelDisabled(int chan) const;
71 bool channelDisabledA(int pin) const;
72 bool channelDisabledB(int pin) const;
73 bool channelDisabledC(int pin) const;
74 bool channelDisabledD(int pin) const;
75 // Ditto ORed over all pins
76 bool glinkPinParity() const;
77 bool fpgaCorrupt() const;
78 bool bunchMismatch() const;
79 bool eventMismatch() const;
80 bool asicFull() const;
81 bool timeout() const;
82 bool mcmAbsent() const;
83 bool channelDisabledA() const;
84 bool channelDisabledB() const;
85 bool channelDisabledC() const;
86 bool channelDisabledD() const;
87
88 // Set triggered slice offsets, pedestal value
89 void setLutOffset(int offset);
90 void setFadcOffset(int offset);
91 void setPedestal(int pedval);
92 void setFadcBaseline(int baseline);
94 void setRunNumber(int run);
95 // Return triggered slice offsets, pedestal value
96 int lutOffset() const;
97 int fadcOffset() const;
98 int pedestal() const;
99 int fadcBaseline() const;
100 int fadcThreshold() const;
101 int runNumber() const;
102
104 bool pack();
106 bool unpack();
107
109 int channelsPerSubBlock(int version, int format);
111
113 static bool errorBlock(uint32_t word);
114
116 void setCompStats(const std::vector<uint32_t>& stats);
118 const std::vector<uint32_t>& compStats() const;
119
120 private:
121 // Header word data
122 static const uint32_t s_wordIdVal = 0xc;
123 static const int s_errorMarker = 63;
124 // Data word positions and masks
125 static const int s_wordLen = 16;
126 static const int s_lutBit = 0;
127 static const int s_bcidLutBit = 8;
128 static const int s_fadcBit = 1;
129 static const int s_bcidFadcBit = 0;
130 static const uint32_t s_lutMask = 0xff;
131 static const uint32_t s_bcidLutMask = 0x7;
132 static const uint32_t s_fadcMask = 0x3ff;
133 static const uint32_t s_bcidFadcMask = 0x1;
134 // For neutral format
135 static const int s_channels = 64;
136 static const int s_glinkPins = 16;
137 static const int s_asicChannels = 4;
138 static const int s_dataBits = 11;
139 static const int s_errorBits = 10;
140 static const int s_bunchCrossingBits = 12;
141 // Error word masks and bit positions
142 static const uint32_t s_errorMask = 0x7ff;
143 static const int s_glinkPinParityBit = 10;
144 static const int s_fpgaCorruptBit = 9;
145 static const int s_bunchMismatchBit = 8;
146 static const int s_eventMismatchBit = 7;
147 static const int s_asicFullBit = 6;
148 static const int s_timeoutBit = 5;
149 static const int s_mcmAbsentBit = 4;
150 static const int s_channelDisabledBit = 0;
151
153 int asic(int chan) const;
155 int pin(int chan) const;
156
158 bool errorBit(int pin, int bit) const;
160 bool errorBit(int bit) const;
161
162 // Packing/unpacking for specific formats
164 bool packNeutral();
170 bool unpackNeutral();
175
176 // Global error flags
178
179 // Triggered slice offsets, pedestal value
186
188 std::vector<uint32_t> m_compStats;
189
191 std::vector<uint32_t> m_datamap;
192
194 std::vector<uint32_t> m_errormap;
195
196};
197
198inline bool PpmSubBlockV1::glinkPinParity(const int chan) const
199{
200 return errorBit(pin(chan), s_glinkPinParityBit);
201}
202
203inline bool PpmSubBlockV1::fpgaCorrupt(const int chan) const
204{
205 return errorBit(pin(chan), s_fpgaCorruptBit);
206}
207
208inline bool PpmSubBlockV1::bunchMismatch(const int chan) const
209{
210 return errorBit(pin(chan), s_bunchMismatchBit);
211}
212
213inline bool PpmSubBlockV1::eventMismatch(const int chan) const
214{
215 return errorBit(pin(chan), s_eventMismatchBit);
216}
217
218inline bool PpmSubBlockV1::asicFull(const int chan) const
219{
220 return errorBit(pin(chan), s_asicFullBit);
221}
222
223inline bool PpmSubBlockV1::timeout(const int chan) const
224{
225 return errorBit(pin(chan), s_timeoutBit);
226}
227
228inline bool PpmSubBlockV1::mcmAbsent(const int chan) const
229{
230 return errorBit(pin(chan), s_mcmAbsentBit);
231}
232
233inline bool PpmSubBlockV1::channelDisabled(const int chan) const
234{
235 return errorBit(pin(chan), s_channelDisabledBit + asic(chan));
236}
237
238inline bool PpmSubBlockV1::channelDisabledA(const int pin) const
239{
241}
242
243inline bool PpmSubBlockV1::channelDisabledB(const int pin) const
244{
245 return errorBit(pin, s_channelDisabledBit + 1);
246}
247
248inline bool PpmSubBlockV1::channelDisabledC(const int pin) const
249{
250 return errorBit(pin, s_channelDisabledBit + 2);
251}
252
253inline bool PpmSubBlockV1::channelDisabledD(const int pin) const
254{
255 return errorBit(pin, s_channelDisabledBit + 3);
256}
257
259{
261}
262
263inline bool PpmSubBlockV1::fpgaCorrupt() const
264{
266}
267
269{
271}
272
274{
276}
277
278inline bool PpmSubBlockV1::asicFull() const
279{
280 return errorBit(s_asicFullBit);
281}
282
283inline bool PpmSubBlockV1::timeout() const
284{
285 return errorBit(s_timeoutBit);
286}
287
288inline bool PpmSubBlockV1::mcmAbsent() const
289{
290 return errorBit(s_mcmAbsentBit);
291}
292
294{
296}
297
299{
300 return errorBit(s_channelDisabledBit + 1);
301}
302
304{
305 return errorBit(s_channelDisabledBit + 2);
306}
307
309{
310 return errorBit(s_channelDisabledBit + 3);
311}
312
313inline void PpmSubBlockV1::setLutOffset(const int offset)
314{
315 m_lutOffset = offset;
316}
317
318inline void PpmSubBlockV1::setFadcOffset(const int offset)
319{
320 m_fadcOffset = offset;
321}
322
323inline void PpmSubBlockV1::setPedestal(const int pedval)
324{
325 m_pedestal = pedval;
326}
327
329{
331}
332
337
338inline void PpmSubBlockV1::setRunNumber(const int run)
339{
341}
342
343inline int PpmSubBlockV1::lutOffset() const
344{
345 return (m_lutOffset < 0) ? slicesLut()/2 : m_lutOffset;
346}
347
349{
350 return (m_fadcOffset < 0) ? slicesFadc()/2 : m_fadcOffset;
351}
352
353inline int PpmSubBlockV1::pedestal() const
354{
355 return m_pedestal;
356}
357
359{
360 return m_fadcBaseline;
361}
362
364{
365 return m_fadcThreshold;
366}
367
368inline int PpmSubBlockV1::runNumber() const
369{
370 return m_runNumber;
371}
372
373inline const std::vector<uint32_t>& PpmSubBlockV1::compStats() const
374{
375 return m_compStats;
376}
377
378inline void PpmSubBlockV1::setCompStats(const std::vector<uint32_t>& stats)
379{
380 m_compStats = stats;
381}
382
383inline int PpmSubBlockV1::asic(const int chan) const
384{
385 return chan / s_glinkPins;
386}
387
388inline int PpmSubBlockV1::pin(const int chan) const
389{
390 return chan % s_glinkPins;
391}
392
393inline bool PpmSubBlockV1::errorBit(const int pin, const int bit) const
394{
395 return m_errormap[pin] & (0x1 << bit);
396}
397
398} // end namespace
399
400#endif
@ baseline
int asic(int chan) const
Return the ASIC channel corresponding to a data channel.
void clear()
Clear all data.
bool packUncompressedData()
Pack uncompressed data.
int pin(int chan) const
Return the G-Link pin corresponding to a data channel.
void setFadcOffset(int offset)
static const uint32_t s_bcidFadcMask
static const int s_dataBits
bool bunchMismatch() const
static const int s_bcidFadcBit
static const uint32_t s_errorMask
static const int s_wordLen
int ppmPinError(int pin) const
Return the error word for a G-Link pin.
bool channelDisabledC() const
void fillPpmPinError(int pin, int errorWord)
Store an error word corresponding to a G-Link pin.
static const int s_channels
static const uint32_t s_fadcMask
static const int s_eventMismatchBit
bool packUncompressedErrors()
Pack uncompressed error data.
void setPpmErrorHeader(int version, int format, int crate, int module, int slicesFadc, int slicesLut)
Store PPM error block header.
const std::vector< uint32_t > & compStats() const
Return reference to compression stats.
static const int s_fadcBit
static bool errorBlock(uint32_t word)
Check if a header word is for an error block.
void setPedestal(int pedval)
std::vector< uint32_t > m_errormap
Vector for intermediate error data.
int ppmError(int chan) const
Return the error word for a data channel.
bool errorBit(int pin, int bit) const
Error bit extraction.
static const int s_bunchCrossingBits
bool unpackUncompressedData()
Unpack uncompressed data.
static const uint32_t s_lutMask
void setCompStats(const std::vector< uint32_t > &stats)
Set compression stats.
std::vector< uint32_t > m_compStats
Vector for compression statistics.
static const int s_timeoutBit
void setRunNumber(int run)
bool channelDisabled(int chan) const
bool channelDisabledB() const
bool eventMismatch() const
static const int s_glinkPins
static const uint32_t s_wordIdVal
bool pack()
Pack data.
bool unpackUncompressedErrors()
Unpack uncompressed error data.
static const int s_errorMarker
static const int s_bunchMismatchBit
void setPpmHeader(int version, int format, int seqno, int crate, int module, int slicesFadc, int slicesLut)
Store PPM header.
bool glinkPinParity() const
bool unpackNeutral()
Unpack neutral data.
void fillPpmData(int chan, const std::vector< int > &lut, const std::vector< int > &fadc, const std::vector< int > &bcidLut, const std::vector< int > &bcidFadc)
Store PPM data for later packing.
void setFadcThreshold(int threshold)
std::vector< uint32_t > m_datamap
Vector for intermediate data.
void ppmData(int chan, std::vector< int > &lut, std::vector< int > &fadc, std::vector< int > &bcidLut, std::vector< int > &bcidFadc)
Return unpacked data for given channel.
static const int s_channelDisabledBit
bool channelDisabledD() const
static const int s_lutBit
void fillPpmError(int chan, int errorWord)
Store an error word corresponding to a data channel.
void setFadcBaseline(int baseline)
static const int s_bcidLutBit
static const int s_fpgaCorruptBit
static const uint32_t s_bcidLutMask
bool channelDisabledA() const
void setLutOffset(int offset)
static const int s_errorBits
static const int s_asicFullBit
static const int s_asicChannels
bool packNeutral()
Pack neutral data.
static const int s_glinkPinParityBit
bool unpack()
Unpack data.
static const int s_mcmAbsentBit
Definition run.py:1