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. "
108 uint16_t channelLength =
channels_.back().length();
110 if (channelLength < minLength) {
112 std::ostringstream ss;
113 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
115 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
116 <<
"Channel length is " << uint16_t(channelLength) <<
". "
117 <<
"Min length is " << uint16_t(minLength) <<
". ";
122 std::ostringstream ss;
123 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
124 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
125 <<
"Channel length is " << uint16_t(channelLength) <<
". "
130 const size_t offsetEndOfChannel = offsetBeginningOfChannel+channelLength;
133 uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
134 if (numPaddingBytes == 8) numPaddingBytes = 0;
135 offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
137 offsetBeginningOfChannel = offsetEndOfChannel;
202 uint8_t lastEnabledFeUnit = 7;
203 while ( !(
fePresent(lastEnabledFeUnit) &&
feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit!=0 ) lastEnabledFeUnit--;
206 const size_t offsetLastChannel = lastChannel.
offset();
207 const size_t offsetEndOfChannelData = offsetLastChannel+lastChannel.
length();
208 const size_t channelDataLength = offsetEndOfChannelData;
210 size_t channelDataLengthInWords = channelDataLength/8;
211 if (channelDataLength % 8) channelDataLengthInWords++;
214 if (channelDataLengthInWords == payloadLengthInWords) {
225 if (!correctPacketCode)
return true;
235 if (
channels_[iCh].packetCode() != correctPacketCode)
return false;
247 if (goldenAddress == 0x00)
return true;
250 if (!fdHeader)
return true;
253 if (!
feGood(iFE))
continue;
265 if (!fdHeader)
return true;
268 if (!
feGood(iFE))
continue;
278 uint16_t lengthFromChannels = 0;
282 return lengthFromChannels;
297 summary <<
"Check FE unit payloads are all present: " << (
checkFEPayloadsPresent() ?
"passed" :
"FAILED" ) << std::endl;
299 summary <<
"FE units missing payloads: ";
301 if (!
fePresent(iFE)) summary << uint16_t(iFE) <<
" ";
303 summary << std::endl;
307 unsigned int badChannels = 0;
314 summary << uint16_t(iCh) <<
": " << fdHeader->
getChannelStatus(iCh) << std::endl;
320 summary <<
"Channels with errors: ";
324 summary << uint16_t(iCh) <<
" ";
328 summary << std::endl;
330 summary <<
"Number of channels with bad status bits: " << badChannels << std::endl;
335 summary <<
"Channels with bad packet codes: ";
339 summary << uint16_t(iCh) <<
" ";
342 summary <<
"Check FE unit lengths: " << (
checkFEUnitLengths() ?
"passed" :
"FAILED" ) << std::endl;
346 summary <<
"Bad FE units:" << std::endl;
348 if (!
feGood(iFE))
continue;
350 uint16_t lengthFromHeader = fdHeader->
feUnitLength(iFE);
351 if (lengthFromHeader != lengthFromChannels) {
352 summary <<
"FE unit: " << uint16_t(iFE)
353 <<
" length in header: " << lengthFromHeader
354 <<
" length from channel lengths: " << lengthFromChannels << std::endl;
359 summary <<
"Check FE unit APV addresses match APVe: " << (
checkFEUnitAPVAddresses() ?
"passed" :
"FAILED" ) << std::endl;
364 summary <<
"Address from APVe:" << uint16_t(goldenAddress) << std::endl;
365 summary <<
"Bad FE units:" << std::endl;
367 if (!
feGood(iFE))
continue;
369 summary <<
"FE unit: " << uint16_t(iFE)
375 return summary.str();
414 os <<
"FE units with data: " << uint16_t(
nFEUnitsPresent()) << std::endl;
415 os <<
"BE status register flags: ";
426 std::ostringstream ss;
427 ss <<
"Channel length is invalid. Raw channels have 3 header bytes and 2 bytes per sample. "
428 <<
"Channel length is " << uint16_t(length) <<
"."
438 std::ostringstream ss;
439 ss <<
"Channel length is longer than max allowed value. "
440 <<
"Channel length is " << uint16_t(length) <<
"."
447 std::ostringstream ss;
448 ss <<
"Cluster does not fit into channel. "
456 std::ostringstream ss;
457 ss <<
"First strip of new cluster is not greater than last strip of previous cluster. "
458 <<
"Last strip of previous cluster is " << uint16_t(currentStrip) <<
". "
459 <<
"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)
virtual bool doChecks() const
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
bool feGood(const uint8_t internalFEUnitNum) const
static const uint8_t PACKET_CODE_VIRGIN_RAW
FEDStatusRegister fedStatusRegister() const