20 feHeader_ = std::unique_ptr<FEDFEHeader>();
22 if (!allowBadBuffer) {
23 std::ostringstream
ss;
24 ss <<
"Header type is invalid. " 25 <<
"Header type nibble is ";
33 throw cms::Exception(
"FEDBuffer") <<
"Unpacking of spy channel data with FEDBuffer is not supported" << std::endl;
98 uint16_t offsetBeginningOfChannel = 0;
112 std::ostringstream
ss;
114 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan()
115 <<
" according to external numbering scheme)" 116 <<
" does not fit into buffer. " 117 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. " 124 uint16_t channelLength =
channels_.back().length();
128 UNLIKELY(channelLength < minLength) {
130 std::ostringstream
ss;
131 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan()
132 <<
" according to external numbering scheme)" 134 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. " 135 <<
"Channel length is " << uint16_t(channelLength) <<
". " 136 <<
"Min length is " << uint16_t(minLength) <<
". ";
142 std::ostringstream
ss;
143 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan()
144 <<
" according to external numbering scheme)" 145 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. " 146 <<
"Channel length is " << uint16_t(channelLength) <<
". " 152 const uint16_t offsetEndOfChannel = offsetBeginningOfChannel + channelLength;
155 uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
156 if (numPaddingBytes == 8)
158 offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
160 offsetBeginningOfChannel = offsetEndOfChannel;
219 uint8_t lastEnabledFeUnit = 7;
220 while (!(
fePresent(lastEnabledFeUnit) &&
feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit != 0)
224 const uint16_t offsetLastChannel = lastChannel.
offset();
225 const uint16_t offsetEndOfChannelData = offsetLastChannel + lastChannel.
length();
226 const uint16_t channelDataLength = offsetEndOfChannelData;
228 uint16_t channelDataLengthInWords = channelDataLength / 8;
229 if (channelDataLength % 8)
230 channelDataLengthInWords++;
233 if (channelDataLengthInWords == payloadLengthInWords) {
243 if (!correctPacketCode)
266 if (goldenAddress == 0x00)
302 uint16_t lengthFromChannels = 0;
306 return lengthFromChannels;
323 summary <<
"FE units missing payloads: ";
326 summary << uint16_t(iFE) <<
" ";
328 summary << std::endl;
332 unsigned int badChannels = 0;
340 summary << uint16_t(iCh) <<
": " << fdHeader->
getChannelStatus(iCh) << std::endl;
346 summary <<
"Channels with errors: ";
351 summary << uint16_t(iCh) <<
" ";
355 summary << std::endl;
357 summary <<
"Number of channels with bad status bits: " << badChannels << std::endl;
359 summary <<
"Check channel lengths match buffer length: " 363 summary <<
"Channels with bad packet codes: ";
368 summary << uint16_t(iCh) <<
" ";
371 summary <<
"Check FE unit lengths: " << (
checkFEUnitLengths() ?
"passed" :
"FAILED") << std::endl;
375 summary <<
"Bad FE units:" << std::endl;
380 uint16_t lengthFromHeader = fdHeader->
feUnitLength(iFE);
381 if (lengthFromHeader != lengthFromChannels) {
382 summary <<
"FE unit: " << uint16_t(iFE) <<
" length in header: " << lengthFromHeader
383 <<
" length from channel lengths: " << lengthFromChannels << std::endl;
394 summary <<
"Address from APVe:" << uint16_t(goldenAddress) << std::endl;
395 summary <<
"Bad FE units:" << std::endl;
400 summary <<
"FE unit: " << uint16_t(iFE)
406 return summary.str();
421 os <<
"FE units with data: " << uint16_t(
nFEUnitsPresent()) << std::endl;
422 os <<
"BE status register flags: ";
429 std::ostringstream
ss;
430 ss <<
"Channel length is invalid. Raw channels have 3 header bytes and 2 bytes per sample. " 431 <<
"Channel length is " << uint16_t(length) <<
"." << std::endl;
436 std::ostringstream
ss;
437 ss <<
"Channel length is invalid. " 438 <<
"Channel length is " << uint16_t(length) <<
"." << std::endl;
443 std::ostringstream
ss;
444 ss <<
"Word length is invalid. " 445 <<
"Word length is " << word_length <<
"." << std::endl;
450 std::ostringstream
ss;
451 ss <<
"First strip of new cluster is not greater than last strip of previous cluster. " 452 <<
"Last strip of previous cluster is " << uint16_t(currentStrip) <<
". " 453 <<
"First strip of new cluster is " << uint16_t(firstStripOfNewCluster) <<
"." << std::endl;
458 std::ostringstream
ss;
459 ss <<
"Channel length is longer than max allowed value. " 460 <<
"Channel length is " << uint16_t(length) <<
"." << std::endl;
465 std::ostringstream
ss;
466 ss <<
"Cluster does not fit into channel. " 467 <<
"Cluster length is " << uint16_t(valuesLeftInCluster_) <<
"." << std::endl;
472 std::ostringstream
ss;
473 ss <<
"First strip of new cluster is not greater than last strip of previous cluster. " 474 <<
"Last strip of previous cluster is " << uint16_t(currentStrip) <<
". " 475 <<
"First strip of new cluster is " << uint16_t(firstStripOfNewCluster) <<
"." << std::endl;
virtual bool doChecks() const
bool feDataMissingFlag(const uint8_t internalFEUnitNum) const
static void throwUnorderedData(const uint8_t currentStrip, const uint8_t firstStripOfNewCluster)
bool checkFEUnitLengths() const
bool checkStatusBits(const uint8_t internalFEDChannelNum) const
static void throwBadChannelLength(const uint16_t length)
virtual std::string checkSummary() const
uint8_t apveAddress() const
A container class for generic run and event-related info, information required by the commissioning a...
const uint8_t * getPointerToByteAfterEndOfPayload() const
virtual bool doCorruptBufferChecks() const
static void throwBadWordLength(const uint16_t word_length)
bool checkFEPayloadsPresent() const
FEDReadoutMode readoutMode() const
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
static void throwBadChannelLength(const uint16_t length)
void throwBadClusterLength()
const uint8_t * getPointerToDataAfterTrackerSpecialHeader() const
static void throwUnorderedData(const uint8_t currentStrip, const uint8_t firstStripOfNewCluster)
const FEDFEHeader * feHeader() const
virtual bool channelGood(const uint8_t internalFEDannelNum, const bool doAPVeCheck=true) const
bool feGoodWithoutAPVEmulatorCheck(const uint8_t internalFEUnitNum) const
bool fePresent_[FEUNITS_PER_FED]
const uint8_t * payloadPointer_
bool fePresent(uint8_t internalFEUnitNum) const
static const uint16_t FEUNITS_PER_FED
bool feEnabled(const uint8_t internalFEUnitNum) const
FEDHeaderType headerType() const
uint8_t packetCode(bool legacy=false, const uint8_t internalFEDChannelNum=0) const
std::vector< FEDChannel > channels_
bool checkChannelPacketCodes() const
void printHex(const void *pointer, const size_t length, std::ostream &os)
const uint16_t & feUnit() const
uint8_t nFEUnitsPresent() const
static const uint16_t FEDCH_PER_FEUNIT
std::unique_ptr< FEDFEHeader > feHeader_
bool checkFEUnitAPVAddresses() const
std::string checkSummary() const override
TrackerSpecialHeader trackerSpecialHeader() const
FEDBuffer(const uint8_t *fedBuffer, const uint16_t fedBufferSize, const bool allowBadBuffer=false)
uint8_t getCorrectPacketCode() const
bool checkChannelLengthsMatchBufferLength() const
virtual void print(std::ostream &os) const
static const uint16_t FEDCH_PER_FED
const uint16_t & feChan() const
bool checkAllChannelStatusBits() const
static void throwBadChannelLength(const uint16_t length)
uint16_t calculateFEUnitLength(const uint8_t internalFEUnitNumber) const
bool checkChannelLengths() const
bool feGood(const uint8_t internalFEUnitNum) const
void print(std::ostream &os) const override
FEDStatusRegister fedStatusRegister() const