21 feHeader_ = std::unique_ptr<FEDFEHeader>();
74 uint16_t offsetBeginningOfChannel = 0;
87 LogDebug(
"FEDBuffer") <<
"Channel " << uint16_t(
i) <<
" (FE unit " <<
key.feUnit() <<
" channel " 88 <<
key.feChan() <<
" according to external numbering scheme) " 89 <<
"does not fit into buffer. " 90 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. " 98 uint16_t channelLength =
channels_.back().length();
101 if UNLIKELY (channelLength < minLength) {
103 LogDebug(
"FEDBuffer") <<
"Channel " << uint16_t(
i) <<
" (FE unit " <<
key.feUnit() <<
" channel " 104 <<
key.feChan() <<
" according to external numbering scheme)" 106 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. " 107 <<
"Channel length is " << uint16_t(channelLength) <<
". " 108 <<
"Min length is " << uint16_t(minLength) <<
". ";
114 LogDebug(
"FEDBuffer") <<
"Channel " << uint16_t(
i) <<
" (FE unit " <<
key.feUnit() <<
" channel " 115 <<
key.feChan() <<
" according to external numbering scheme)" 116 <<
"does not fit into buffer. " 117 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. " 118 <<
"Channel length is " << uint16_t(channelLength) <<
". " 125 const uint16_t offsetEndOfChannel = offsetBeginningOfChannel + channelLength;
128 uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
129 if (numPaddingBytes == 8)
131 offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
133 offsetBeginningOfChannel = offsetEndOfChannel;
176 uint8_t lastEnabledFeUnit = 7;
177 while (!(
fePresent(lastEnabledFeUnit) &&
feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit != 0)
181 const uint16_t offsetLastChannel = lastChannel.
offset();
182 const uint16_t offsetEndOfChannelData = offsetLastChannel + lastChannel.
length();
183 const uint16_t channelDataLength = offsetEndOfChannelData;
185 uint16_t channelDataLengthInWords = channelDataLength / 8;
186 if (channelDataLength % 8)
187 channelDataLengthInWords++;
190 if (channelDataLengthInWords == payloadLengthInWords) {
200 if (!correctPacketCode)
223 if (goldenAddress == 0x00)
259 uint16_t lengthFromChannels = 0;
263 return lengthFromChannels;
280 summary <<
"FE units missing payloads: ";
283 summary << uint16_t(iFE) <<
" ";
289 unsigned int badChannels = 0;
303 summary <<
"Channels with errors: ";
308 summary << uint16_t(iCh) <<
" ";
314 summary <<
"Number of channels with bad status bits: " << badChannels << std::endl;
316 summary <<
"Check channel lengths match buffer length: " 320 summary <<
"Channels with bad packet codes: ";
325 summary << uint16_t(iCh) <<
" ";
332 summary <<
"Bad FE units:" << std::endl;
337 uint16_t lengthFromHeader = fdHeader->
feUnitLength(iFE);
338 if (lengthFromHeader != lengthFromChannels) {
339 summary <<
"FE unit: " << uint16_t(iFE) <<
" length in header: " << lengthFromHeader
340 <<
" length from channel lengths: " << lengthFromChannels << std::endl;
351 summary <<
"Address from APVe:" << uint16_t(goldenAddress) << std::endl;
352 summary <<
"Bad FE units:" << std::endl;
357 summary <<
"FE unit: " << uint16_t(iFE)
378 os <<
"FE units with data: " << uint16_t(
nFEUnitsPresent()) << std::endl;
379 os <<
"BE status register flags: ";
391 return "Channel length is invalid.";
393 return "First strip of new cluster is not greater than last strip of previous cluster.";
395 return "Invalid packet code.";
397 return "Invalid packet code 0 for zero-suppressed data.";
FEDReadoutMode readoutMode() const
bool checkChannelLengthsMatchBufferLength() const
std::string checkSummary() const override
A container class for generic run and event-related info, information required by the commissioning a...
const FEDFEHeader * feHeader() const
FEDBuffer(const FEDRawData &fedBuffer, const bool allowBadBuffer=false)
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
bool checkFEUnitAPVAddresses() const
uint16_t calculateFEUnitLength(const uint8_t internalFEUnitNumber) const
FEDBufferStatusCode findChannels()
FEDHeaderType headerType() const
uint8_t nFEUnitsPresent() const
const uint8_t * getPointerToDataAfterTrackerSpecialHeader() const
virtual std::string checkSummary() const
bool checkFEUnitLengths() const
std::string toString(fedchannelunpacker::StatusCode status)
const uint8_t * getPointerToByteAfterEndOfPayload() const
bool feEnabled(const uint8_t internalFEUnitNum) const
bool feDataMissingFlag(const uint8_t internalFEUnitNum) const
virtual bool doCorruptBufferChecks() const
bool fePresent_[FEUNITS_PER_FED]
bool checkChannelPacketCodes() const
const uint8_t * payloadPointer_
static const uint16_t FEUNITS_PER_FED
bool checkFEPayloadsPresent() const
bool checkAllChannelStatusBits() const
std::vector< FEDChannel > channels_
uint8_t getCorrectPacketCode() const
bool channelGood(const uint8_t internalFEDannelNum, const bool doAPVeCheck) const
static const uint16_t FEDCH_PER_FEUNIT
bool checkStatusBits(const uint8_t internalFEDChannelNum) const
bool checkChannelLengths() const
std::unique_ptr< FEDFEHeader > feHeader_
static const uint16_t FEDCH_PER_FED
FEDStatusRegister fedStatusRegister() const
bool feGood(const uint8_t internalFEUnitNum) const
void print(std::ostream &os) const override
bool fePresent(uint8_t internalFEUnitNum) const
uint8_t apveAddress() const
uint8_t packetCode(bool legacy=false, const uint8_t internalFEDChannelNum=0) const
virtual void print(std::ostream &os) const