52const int ZdcPpmSubBlock::s_ppmChannel[64] = {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60,
53 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63,
54 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61,
55 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62 };
114 if (slices <= 0) slices = 1;
123 if (slices == 0) slices = 1;
130 const std::vector<int>& fadc,
131 const std::vector<int>& bcidLut,
132 const std::vector<int>& bcidFadc)
136 const int slices = sliceL + sliceF;
138 if (chanPerSubBlock == 0) {
145 dataSize = slices * chanPerSubBlock;
148 int offset = (chan % chanPerSubBlock) * slices;
149 if (offset + slices <= dataSize) {
150 for (
int pos = 0; pos < sliceL; ++pos) {
156 for (
int pos = 0; pos < sliceF; ++pos) {
157 const int adc = (fadc[pos] > 0) ? fadc[pos] : 0;
168 std::vector<int>& fadc,
169 std::vector<int>& bcidLut,
170 std::vector<int>& bcidFadc)
const
182 int beg = (chan % chans) * (sliceL + sliceF);
183 int end = beg + sliceL;
184 if (
size_t(end + sliceF) <=
m_datamap.size()) {
185 for (
int pos = beg; pos < end; ++pos) {
192 for (
int pos = beg; pos < end; ++pos) {
200 bcidLut.resize(sliceL);
201 bcidFadc.resize(sliceF);
211 const uint32_t chanDisabled = (errorWord & 0x1) <<
asic(chan);
344 std::vector<uint32_t>::const_iterator pos =
m_datamap.begin();
347 for (
int sl = 0; sl < slices; ++sl) {
371 for (
int sl = 0; sl < slices; ++sl) {
372 for (
int chan = 0; chan < channels; ++chan) {
408 for (
int sl = 0; sl < slices; ++sl) {
435 for (
int sl = 0; sl < slices; ++sl) {
436 for (
int chan = 0; chan < channels; ++chan) {
static bool unpack(ZdcPpmSubBlock &subBlock)
Unpack data.
static bool pack(ZdcPpmSubBlock &subBlock)
Pack data.
int pin(int chan) const
Return the G-Link pin corresponding to a data channel.
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.
int channelsPerSubBlock() const
static const uint32_t s_bcidFadcMask
static const int s_glinkPins
static const int s_eventMismatchBit
int ppmPinError(int pin) const
Return the error word for a G-Link pin.
bool unpackUncompressedData()
Unpack uncompressed data.
void ppmData(int chan, std::vector< int > &lut, std::vector< int > &fadc, std::vector< int > &bcidLut, std::vector< int > &bcidFadc) const
Return unpacked data for given channel.
static const int s_ppmChannel[]
static const uint32_t s_bcidLutMask
bool packNeutral()
Pack neutral data.
static const int s_dataBits
static const uint32_t s_fadcMask
void fillPpmPinError(int pin, int errorWord)
Store an error word corresponding to a G-Link pin.
static const int s_fpgaCorruptBit
bool channelDisabled(int chan) const
bool unpack()
Unpack data.
static const int s_glinkPinParityBit
int asic(int chan) const
Return the ASIC channel corresponding to a data channel.
static const int s_bunchMismatchBit
bool packUncompressedErrors()
Pack uncompressed error data.
static const int s_bcidLutBit
static const int s_asicChannels
static const int s_bunchCrossingBits
std::vector< uint32_t > m_datamap
Vector for intermediate data.
bool packUncompressedData()
Pack uncompressed data.
int ppmError(int chan) const
Return the error word for a data channel.
static const int s_asicFullBit
static bool errorBlock(uint32_t word)
Check if a header word is for an error block.
static const int s_wordLen
void fillPpmError(int chan, int errorWord)
Store an error word corresponding to a data channel.
static const uint32_t s_wordIdVal
Sub-Block class for PPM data.
static const int s_errorBits
static const int s_errorMarker
static const int s_timeoutBit
static const int s_channelDisabledBit
static const int s_fadcBit
bool errorBit(int pin, int bit) const
Error bit extraction.
void clear()
Clear all data.
void setPpmErrorHeader(int version, int format, int crate, int module, int slicesFadc, int slicesLut)
Store PPM error block header.
std::vector< uint32_t > m_errormap
Vector for intermediate error data.
void setPpmHeader(int version, int format, int seqno, int crate, int module, int slicesFadc, int slicesLut)
Store PPM header.
bool unpackUncompressedErrors()
Unpack uncompressed error data.
static const int s_mcmAbsentBit
static const uint32_t s_lutMask
static const int s_channels
static const int s_bcidFadcBit
static const int s_lutBit
static const uint32_t s_errorMask
uint32_t unpackerNeutral(int pin, int nbits)
Unpack given number of bits of neutral data for given pin.
void unpackerInit()
Initialise unpacker.
uint32_t unpacker(int nbits)
Unpack given number of bits of data.
int bunchCrossing() const
Return the Bunch Crossing number (neutral format only)
void packerNeutral(int pin, uint32_t datum, int nbits)
Pack given neutral data from given pin.
int dataWords() const
Return number of data words.
bool unpackerSuccess() const
Return unpacker success flag.
void setUnpackErrorCode(int code)
Set the unpacking error code.
void setHeader(int wordId, int version, int format, int seqno, int crate, int module, int slices2, int slices1)
Store header data.
bool unpackerNeutralParityError(int pin)
Unpack and test G-Link parity bit for given pin.
void packer(uint32_t datum, int nbits)
Pack given data into given number of bits.
void setBunchCrossing(int bc)
Set the Bunch Crossing number (neutral format only)
void packerNeutralParity(int pin)
Pack current G-Link parity bit for given pin.
void packerFlush()
Flush the current data word padded with zeros.
void clear()
Clear all data.