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;
87 size_t offsetBeginningOfChannel = 0;
99 std::ostringstream
ss;
101 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
102 <<
" does not fit into buffer. "
103 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
110 uint16_t channelLength =
channels_.back().length();
113 if unlikely(channelLength < minLength) {
115 std::ostringstream
ss;
116 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
118 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
119 <<
"Channel length is " << uint16_t(channelLength) <<
". "
120 <<
"Min length is " << uint16_t(minLength) <<
". ";
125 std::ostringstream
ss;
126 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
127 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
128 <<
"Channel length is " << uint16_t(channelLength) <<
". "
134 const size_t offsetEndOfChannel = offsetBeginningOfChannel+channelLength;
137 uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
138 if (numPaddingBytes == 8) numPaddingBytes = 0;
139 offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
141 offsetBeginningOfChannel = offsetEndOfChannel;
162 if (doCRC && !
checkCRC())
return false;
206 uint8_t lastEnabledFeUnit = 7;
207 while ( !(
fePresent(lastEnabledFeUnit) &&
feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit!=0 ) lastEnabledFeUnit--;
210 const size_t offsetLastChannel = lastChannel.
offset();
211 const size_t offsetEndOfChannelData = offsetLastChannel+lastChannel.
length();
212 const size_t channelDataLength = offsetEndOfChannelData;
214 size_t channelDataLengthInWords = channelDataLength/8;
215 if (channelDataLength % 8) channelDataLengthInWords++;
218 if (channelDataLengthInWords == payloadLengthInWords) {
229 if (!correctPacketCode)
return true;
239 if (
channels_[iCh].packetCode() != correctPacketCode)
return false;
251 if (goldenAddress == 0x00)
return true;
254 if (!fdHeader)
return true;
257 if (!
feGood(iFE))
continue;
269 if (!fdHeader)
return true;
272 if (!
feGood(iFE))
continue;
282 uint16_t lengthFromChannels = 0;
286 return lengthFromChannels;
301 summary <<
"Check FE unit payloads are all present: " << (
checkFEPayloadsPresent() ?
"passed" :
"FAILED" ) << std::endl;
303 summary <<
"FE units missing payloads: ";
305 if (!
fePresent(iFE)) summary << uint16_t(iFE) <<
" ";
307 summary << std::endl;
311 unsigned int badChannels = 0;
318 summary << uint16_t(iCh) <<
": " << fdHeader->
getChannelStatus(iCh) << std::endl;
324 summary <<
"Channels with errors: ";
328 summary << uint16_t(iCh) <<
" ";
332 summary << std::endl;
334 summary <<
"Number of channels with bad status bits: " << badChannels << std::endl;
339 summary <<
"Channels with bad packet codes: ";
343 summary << uint16_t(iCh) <<
" ";
346 summary <<
"Check FE unit lengths: " << (
checkFEUnitLengths() ?
"passed" :
"FAILED" ) << std::endl;
350 summary <<
"Bad FE units:" << std::endl;
352 if (!
feGood(iFE))
continue;
354 uint16_t lengthFromHeader = fdHeader->
feUnitLength(iFE);
355 if (lengthFromHeader != lengthFromChannels) {
356 summary <<
"FE unit: " << uint16_t(iFE)
357 <<
" length in header: " << lengthFromHeader
358 <<
" length from channel lengths: " << lengthFromChannels << std::endl;
363 summary <<
"Check FE unit APV addresses match APVe: " << (
checkFEUnitAPVAddresses() ?
"passed" :
"FAILED" ) << std::endl;
368 summary <<
"Address from APVe:" << uint16_t(goldenAddress) << std::endl;
369 summary <<
"Bad FE units:" << std::endl;
371 if (!
feGood(iFE))
continue;
373 summary <<
"FE unit: " << uint16_t(iFE)
379 return summary.str();
419 os <<
"FE units with data: " << uint16_t(
nFEUnitsPresent()) << std::endl;
420 os <<
"BE status register flags: ";
431 std::ostringstream
ss;
432 ss <<
"Channel length is invalid. Raw channels have 3 header bytes and 2 bytes per sample. "
433 <<
"Channel length is " << uint16_t(length) <<
"."
443 std::ostringstream
ss;
444 ss <<
"Channel length is longer than max allowed value. "
445 <<
"Channel length is " << uint16_t(length) <<
"."
452 std::ostringstream
ss;
453 ss <<
"Cluster does not fit into channel. "
461 std::ostringstream
ss;
462 ss <<
"First strip of new cluster is not greater than last strip of previous cluster. "
463 <<
"Last strip of previous cluster is " << uint16_t(currentStrip) <<
". "
464 <<
"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