23 if (!allowBadBuffer) {
24 std::ostringstream ss;
25 ss <<
"Header type is invalid. "
26 <<
"Header type nibble is ";
34 throw cms::Exception(
"FEDBuffer") <<
"Unpacking of spy channel data with FEDBuffer is not supported" << std::endl;
60 if (!allowBadBuffer)
throw;
86 size_t offsetBeginningOfChannel = 0;
98 std::ostringstream ss;
100 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
101 <<
" does not fit into buffer. "
102 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
109 uint16_t channelLength =
channels_.back().length();
112 if unlikely(channelLength < minLength) {
114 std::ostringstream ss;
115 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
117 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
118 <<
"Channel length is " << uint16_t(channelLength) <<
". "
119 <<
"Min length is " << uint16_t(minLength) <<
". ";
124 std::ostringstream ss;
125 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
126 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
127 <<
"Channel length is " << uint16_t(channelLength) <<
". "
133 const size_t offsetEndOfChannel = offsetBeginningOfChannel+channelLength;
136 uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
137 if (numPaddingBytes == 8) numPaddingBytes = 0;
138 offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
140 offsetBeginningOfChannel = offsetEndOfChannel;
161 if (doCRC && !
checkCRC())
return false;
205 uint8_t lastEnabledFeUnit = 7;
206 while ( !(
fePresent(lastEnabledFeUnit) &&
feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit!=0 ) lastEnabledFeUnit--;
209 const size_t offsetLastChannel = lastChannel.
offset();
210 const size_t offsetEndOfChannelData = offsetLastChannel+lastChannel.
length();
211 const size_t channelDataLength = offsetEndOfChannelData;
213 size_t channelDataLengthInWords = channelDataLength/8;
214 if (channelDataLength % 8) channelDataLengthInWords++;
217 if (channelDataLengthInWords == payloadLengthInWords) {
228 if (!correctPacketCode)
return true;
238 if (
channels_[iCh].packetCode() != correctPacketCode)
return false;
250 if (goldenAddress == 0x00)
return true;
253 if (!fdHeader)
return true;
256 if (!
feGood(iFE))
continue;
268 if (!fdHeader)
return true;
271 if (!
feGood(iFE))
continue;
281 uint16_t lengthFromChannels = 0;
285 return lengthFromChannels;
300 summary <<
"Check FE unit payloads are all present: " << (
checkFEPayloadsPresent() ?
"passed" :
"FAILED" ) << std::endl;
302 summary <<
"FE units missing payloads: ";
304 if (!
fePresent(iFE)) summary << uint16_t(iFE) <<
" ";
306 summary << std::endl;
310 unsigned int badChannels = 0;
317 summary << uint16_t(iCh) <<
": " << fdHeader->
getChannelStatus(iCh) << std::endl;
323 summary <<
"Channels with errors: ";
327 summary << uint16_t(iCh) <<
" ";
331 summary << std::endl;
333 summary <<
"Number of channels with bad status bits: " << badChannels << std::endl;
338 summary <<
"Channels with bad packet codes: ";
342 summary << uint16_t(iCh) <<
" ";
345 summary <<
"Check FE unit lengths: " << (
checkFEUnitLengths() ?
"passed" :
"FAILED" ) << std::endl;
349 summary <<
"Bad FE units:" << std::endl;
351 if (!
feGood(iFE))
continue;
353 uint16_t lengthFromHeader = fdHeader->
feUnitLength(iFE);
354 if (lengthFromHeader != lengthFromChannels) {
355 summary <<
"FE unit: " << uint16_t(iFE)
356 <<
" length in header: " << lengthFromHeader
357 <<
" length from channel lengths: " << lengthFromChannels << std::endl;
362 summary <<
"Check FE unit APV addresses match APVe: " << (
checkFEUnitAPVAddresses() ?
"passed" :
"FAILED" ) << std::endl;
367 summary <<
"Address from APVe:" << uint16_t(goldenAddress) << std::endl;
368 summary <<
"Bad FE units:" << std::endl;
370 if (!
feGood(iFE))
continue;
372 summary <<
"FE unit: " << uint16_t(iFE)
378 return summary.str();
417 os <<
"FE units with data: " << uint16_t(
nFEUnitsPresent()) << std::endl;
418 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) <<
"."
441 std::ostringstream ss;
442 ss <<
"Channel length is longer than max allowed value. "
443 <<
"Channel length is " << uint16_t(length) <<
"."
450 std::ostringstream ss;
451 ss <<
"Cluster does not fit into channel. "
459 std::ostringstream ss;
460 ss <<
"First strip of new cluster is not greater than last strip of previous cluster. "
461 <<
"Last strip of previous cluster is " << uint16_t(currentStrip) <<
". "
462 <<
"First strip of new cluster is " << uint16_t(firstStripOfNewCluster) <<
"."
virtual bool doChecks() const
std::auto_ptr< FEDFEHeader > feHeader_
bool feDataMissingFlag(const uint8_t internalFEUnitNum) const
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...
FEDBuffer(const uint8_t *fedBuffer, const size_t fedBufferSize, const bool allowBadBuffer=false)
const uint8_t * getPointerToByteAfterEndOfPayload() const
virtual bool doCorruptBufferChecks() const
static const uint8_t PACKET_CODE_SCOPE
virtual void print(std::ostream &os) const
bool checkFEPayloadsPresent() const
FEDReadoutMode readoutMode() const
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
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_
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED
bool fePresent(uint8_t internalFEUnitNum) const
static const uint16_t FEUNITS_PER_FED
bool feEnabled(const uint8_t internalFEUnitNum) const
FEDHeaderType headerType() const
virtual std::string checkSummary() const
uint8_t valuesLeftInCluster_
std::vector< FEDChannel > channels_
bool checkChannelPacketCodes() const
static const uint8_t PACKET_CODE_PROC_RAW
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
bool checkFEUnitAPVAddresses() const
TrackerSpecialHeader trackerSpecialHeader() const
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
volatile std::atomic< bool > shutdown_flag false
bool feGood(const uint8_t internalFEUnitNum) const
static const uint8_t PACKET_CODE_VIRGIN_RAW
FEDStatusRegister fedStatusRegister() const