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;
97 uint16_t offsetBeginningOfChannel = 0;
109 std::ostringstream
ss;
111 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
112 <<
" does not fit into buffer. "
113 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
120 uint16_t channelLength =
channels_.back().length();
123 if unlikely(channelLength < minLength) {
125 std::ostringstream
ss;
126 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
128 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
129 <<
"Channel length is " << uint16_t(channelLength) <<
". "
130 <<
"Min length is " << uint16_t(minLength) <<
". ";
135 std::ostringstream
ss;
136 ss <<
"Channel " << uint16_t(
i) <<
" (FE unit " << key.
feUnit() <<
" channel " << key.
feChan() <<
" according to external numbering scheme)"
137 <<
"Channel starts at " << uint16_t(offsetBeginningOfChannel) <<
" in payload. "
138 <<
"Channel length is " << uint16_t(channelLength) <<
". "
144 const uint16_t offsetEndOfChannel = offsetBeginningOfChannel+channelLength;
147 uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
148 if (numPaddingBytes == 8) numPaddingBytes = 0;
149 offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
151 offsetBeginningOfChannel = offsetEndOfChannel;
172 if (doCRC && !
checkCRC())
return false;
216 uint8_t lastEnabledFeUnit = 7;
217 while ( !(
fePresent(lastEnabledFeUnit) &&
feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit!=0 ) lastEnabledFeUnit--;
220 const uint16_t offsetLastChannel = lastChannel.
offset();
221 const uint16_t offsetEndOfChannelData = offsetLastChannel+lastChannel.
length();
222 const uint16_t channelDataLength = offsetEndOfChannelData;
224 uint16_t channelDataLengthInWords = channelDataLength/8;
225 if (channelDataLength % 8) channelDataLengthInWords++;
228 if (channelDataLengthInWords == payloadLengthInWords) {
239 if (!correctPacketCode)
return true;
261 if (goldenAddress == 0x00)
return true;
264 if (!fdHeader)
return true;
267 if (!
feGood(iFE))
continue;
279 if (!fdHeader)
return true;
282 if (!
feGood(iFE))
continue;
292 uint16_t lengthFromChannels = 0;
296 return lengthFromChannels;
311 summary <<
"Check FE unit payloads are all present: " << (
checkFEPayloadsPresent() ?
"passed" :
"FAILED" ) << std::endl;
313 summary <<
"FE units missing payloads: ";
315 if (!
fePresent(iFE)) summary << uint16_t(iFE) <<
" ";
317 summary << std::endl;
321 unsigned int badChannels = 0;
328 summary << uint16_t(iCh) <<
": " << fdHeader->
getChannelStatus(iCh) << std::endl;
334 summary <<
"Channels with errors: ";
338 summary << uint16_t(iCh) <<
" ";
342 summary << std::endl;
344 summary <<
"Number of channels with bad status bits: " << badChannels << std::endl;
349 summary <<
"Channels with bad packet codes: ";
353 summary << uint16_t(iCh) <<
" ";
356 summary <<
"Check FE unit lengths: " << (
checkFEUnitLengths() ?
"passed" :
"FAILED" ) << std::endl;
360 summary <<
"Bad FE units:" << std::endl;
362 if (!
feGood(iFE))
continue;
364 uint16_t lengthFromHeader = fdHeader->
feUnitLength(iFE);
365 if (lengthFromHeader != lengthFromChannels) {
366 summary <<
"FE unit: " << uint16_t(iFE)
367 <<
" length in header: " << lengthFromHeader
368 <<
" length from channel lengths: " << lengthFromChannels << std::endl;
373 summary <<
"Check FE unit APV addresses match APVe: " << (
checkFEUnitAPVAddresses() ?
"passed" :
"FAILED" ) << std::endl;
378 summary <<
"Address from APVe:" << uint16_t(goldenAddress) << std::endl;
379 summary <<
"Bad FE units:" << std::endl;
381 if (!
feGood(iFE))
continue;
383 summary <<
"FE unit: " << uint16_t(iFE)
389 return summary.str();
405 os <<
"FE units with data: " << uint16_t(
nFEUnitsPresent()) << std::endl;
406 os <<
"BE status register flags: ";
417 std::ostringstream
ss;
418 ss <<
"Channel length is invalid. Raw channels have 3 header bytes and 2 bytes per sample. "
419 <<
"Channel length is " << uint16_t(length) <<
"."
426 std::ostringstream
ss;
427 ss <<
"Channel length is invalid. "
428 <<
"Channel length is " << uint16_t(length) <<
"."
435 std::ostringstream
ss;
436 ss <<
"Word length is invalid. "
437 <<
"Word length is " << word_length <<
"."
444 std::ostringstream
ss;
445 ss <<
"First strip of new cluster is not greater than last strip of previous cluster. "
446 <<
"Last strip of previous cluster is " << uint16_t(currentStrip) <<
". "
447 <<
"First strip of new cluster is " << uint16_t(firstStripOfNewCluster) <<
"."
454 std::ostringstream
ss;
455 ss <<
"Channel length is longer than max allowed value. "
456 <<
"Channel length is " << uint16_t(length) <<
"."
463 std::ostringstream
ss;
464 ss <<
"Cluster does not fit into channel. "
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) <<
"."
virtual bool doChecks() const
std::auto_ptr< FEDFEHeader > feHeader_
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)
virtual void print(std::ostream &os) const
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
virtual std::string checkSummary() const
uint8_t valuesLeftInCluster_
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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
bool checkFEUnitAPVAddresses() const
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
volatile std::atomic< bool > shutdown_flag false
bool feGood(const uint8_t internalFEUnitNum) const
FEDStatusRegister fedStatusRegister() const