95 if (slices <= 0) slices = 1;
104 if (slices == 0) slices = 1;
111 const std::vector<int>& fadc,
112 const std::vector<int>& bcidLut,
113 const std::vector<int>& bcidFadc)
117 const int slices = sliceL + sliceF;
121 dataSize = slices * chanPerSubBlock;
125 int offset = (chan % chanPerSubBlock) * slices;
126 if (offset + slices <= dataSize) {
127 for (
int pos = 0; pos < sliceL; ++pos) {
133 for (
int pos = 0; pos < sliceF; ++pos) {
134 const int adc = (fadc[pos] > 0) ? fadc[pos] : 0;
145 std::vector<int>& fadc,
146 std::vector<int>& bcidLut,
147 std::vector<int>& bcidFadc)
157 int end = beg + sliceL;
158 if (
size_t(end + sliceF) <=
m_datamap.size()) {
159 for (
int pos = beg; pos < end; ++pos) {
166 for (
int pos = beg; pos < end; ++pos) {
174 bcidLut.resize(sliceL);
175 bcidFadc.resize(sliceF);
185 const uint32_t chanDisabled = (errorWord & 0x1) <<
asic(chan);
318 std::vector<uint32_t>::const_iterator pos =
m_datamap.begin();
321 for (
int sl = 0; sl < slices; ++sl) {
345 for (
int sl = 0; sl < slices; ++sl) {
346 for (
int chan = 0; chan < channels; ++chan) {
382 for (
int sl = 0; sl < slices; ++sl) {
409 for (
int sl = 0; sl < slices; ++sl) {
410 for (
int chan = 0; chan < channels; ++chan) {
void packer(uint32_t datum, int nbits)
Pack given data into given number of bits.
uint32_t unpacker(int nbits)
Unpack given number of bits of data.
void setUnpackErrorCode(int code)
Set the unpacking error code.
bool unpackerSuccess() const
Return unpacker success flag.
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.
int dataWords() const
Return number of data words.
void clear()
Clear all data.
void packerNeutralParity(int pin)
Pack current G-Link parity bit for given pin.
void packerFlush()
Flush the current data word padded with zeros.
uint32_t unpackerNeutral(int pin, int nbits)
Unpack given number of bits of neutral data for given pin.
int bunchCrossing() const
Return the Bunch Crossing number (neutral format only)
void unpackerInit()
Initialise unpacker.
void packerNeutral(int pin, uint32_t datum, int nbits)
Pack given neutral data from given pin.
void setBunchCrossing(int bc)
Set the Bunch Crossing number (neutral format only)
static bool unpack(PpmSubBlockV1 &subBlock)
Unpack data.
static bool pack(PpmSubBlockV1 &subBlock)
Pack data.
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.
static const uint32_t s_bcidFadcMask
static const int s_dataBits
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.
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.
static const int s_fadcBit
static bool errorBlock(uint32_t word)
Check if a header word is for an error block.
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
static const int s_timeoutBit
bool channelDisabled(int chan) const
static const int s_glinkPins
static const uint32_t s_wordIdVal
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 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.
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
static const int s_lutBit
void fillPpmError(int chan, int errorWord)
Store an error word corresponding to a data channel.
static const int s_bcidLutBit
static const int s_fpgaCorruptBit
static const uint32_t s_bcidLutMask
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.
int channelsPerSubBlock()
static const int s_mcmAbsentBit