CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
sistrip::FEDBuffer Class Referencefinal

#include <SiStripFEDBuffer.h>

Inheritance diagram for sistrip::FEDBuffer:
sistrip::FEDBufferBase

Public Member Functions

virtual bool channelGood (const uint8_t internalFEDannelNum, const bool doAPVeCheck=true) const
 
bool checkAllChannelStatusBits () const
 
bool checkChannelLengths () const
 
bool checkChannelLengthsMatchBufferLength () const
 
bool checkChannelPacketCodes () const
 
bool checkFEPayloadsPresent () const
 
bool checkFEUnitAPVAddresses () const
 
bool checkFEUnitLengths () const
 
bool checkStatusBits (const uint8_t internalFEDChannelNum) const
 
bool checkStatusBits (const uint8_t internalFEUnitNum, const uint8_t internalChannelNum) const
 
std::string checkSummary () const override
 
virtual bool doChecks (bool doCRC=true) const
 
virtual bool doCorruptBufferChecks () const
 
 FEDBuffer (const uint8_t *fedBuffer, const uint16_t fedBufferSize, const bool allowBadBuffer=false)
 
bool feGood (const uint8_t internalFEUnitNum) const
 
bool feGoodWithoutAPVEmulatorCheck (const uint8_t internalFEUnitNum) const
 
const FEDFEHeaderfeHeader () const
 
bool fePresent (uint8_t internalFEUnitNum) const
 
void print (std::ostream &os) const override
 
void setLegacyMode (bool legacy)
 
 ~FEDBuffer () override
 
- Public Member Functions inherited from sistrip::FEDBufferBase
uint8_t apveAddress () const
 
FEDBufferFormat bufferFormat () const
 
size_t bufferSize () const
 
uint16_t calcCRC () const
 
const FEDChannelchannel (const uint8_t internalFEDChannelNum) const
 
const FEDChannelchannel (const uint8_t internalFEUnitNum, const uint8_t internalChannelNum) const
 
virtual bool channelGood (const uint8_t internalFEDChannelNum) const
 
bool channelGood (const uint8_t internalFEUnitNum, const uint8_t internalChannelNum) const
 
bool checkAPVEAddressValid () const
 
bool checkBufferFormat () const
 
bool checkCRC () const
 
bool checkHeaderType () const
 
bool checkLengthFromTrailer () const
 
bool checkMajorityAddresses () const
 
bool checkNoExtraHeadersOrTrailers () const
 
bool checkNoFEOverflows () const
 
bool checkNoSlinkCRCError () const
 
bool checkNoSLinkTransmissionError () const
 
bool checkNoUnexpectedSourceID () const
 
bool checkReadoutMode () const
 
bool checkSourceIDs () const
 
uint16_t daqBXID () const
 
uint16_t daqCRC () const
 
uint32_t daqEventLengthIn64bitWords () const
 
uint32_t daqEventLengthInBytes () const
 
FEDDAQEventType daqEventType () const
 
FEDDAQHeader daqHeader () const
 
uint32_t daqLvl1ID () const
 
uint16_t daqSourceID () const
 
FEDDAQTrailer daqTrailer () const
 
FEDTTSBits daqTTSState () const
 
virtual bool doChecks () const
 
bool doDAQHeaderAndTrailerChecks () const
 
bool doTrackerSpecialHeaderChecks () const
 
void dump (std::ostream &os) const
 
void dumpOriginalBuffer (std::ostream &os) const
 
 FEDBufferBase (const uint8_t *fedBuffer, const size_t fedBufferSize, const bool allowUnrecognizedFormat=false)
 
FEDStatusRegister fedStatusRegister () const
 
bool feEnabled (const uint8_t internalFEUnitNum) const
 
bool feOverflow (const uint8_t internalFEUnitNum) const
 
FEDHeaderType headerType () const
 
FEDLegacyReadoutMode legacyReadoutMode () const
 
bool majorityAddressErrorForFEUnit (const uint8_t internalFEUnitNum) const
 
uint8_t nFEUnitsEnabled () const
 
uint8_t packetCode (bool legacy=false, const uint8_t internalFEDChannelNum=0) const
 
FEDReadoutMode readoutMode () const
 
uint16_t sourceID () const
 
TrackerSpecialHeader trackerSpecialHeader () const
 
virtual ~FEDBufferBase ()
 

Private Member Functions

uint16_t calculateFEUnitLength (const uint8_t internalFEUnitNumber) const
 
void findChannels ()
 
uint8_t getCorrectPacketCode () const
 
uint8_t nFEUnitsPresent () const
 

Private Attributes

std::unique_ptr< FEDFEHeaderfeHeader_
 
bool fePresent_ [FEUNITS_PER_FED]
 
bool legacyUnpacker_ = false
 
uint16_t payloadLength_
 
const uint8_t * payloadPointer_
 
uint8_t validChannels_
 

Additional Inherited Members

- Protected Member Functions inherited from sistrip::FEDBufferBase
 FEDBufferBase (const uint8_t *fedBuffer, const size_t fedBufferSize, const bool allowUnrecognizedFormat, const bool fillChannelVector)
 
const uint8_t * getPointerToByteAfterEndOfPayload () const
 
const uint8_t * getPointerToDataAfterTrackerSpecialHeader () const
 
- Protected Attributes inherited from sistrip::FEDBufferBase
std::vector< FEDChannelchannels_
 

Detailed Description

Definition at line 23 of file SiStripFEDBuffer.h.

Constructor & Destructor Documentation

sistrip::FEDBuffer::FEDBuffer ( const uint8_t *  fedBuffer,
const uint16_t  fedBufferSize,
const bool  allowBadBuffer = false 
)

Definition at line 12 of file SiStripFEDBuffer.cc.

References sistrip::FEDBufferBase::channels_, MillePedeFileConverter_cfg::e, Exception, sistrip::FEDStatusRegister::feDataMissingFlag(), sistrip::FEDCH_PER_FED, sistrip::FEDBufferBase::fedStatusRegister(), feHeader_, sistrip::FEDFullDebugHeader::fePresent(), fePresent_, sistrip::FEUNITS_PER_FED, findChannels(), sistrip::FEDBufferBase::getPointerToByteAfterEndOfPayload(), sistrip::FEDBufferBase::getPointerToDataAfterTrackerSpecialHeader(), sistrip::HEADER_TYPE_INVALID, sistrip::HEADER_TYPE_NONE, sistrip::FEDBufferBase::headerType(), sistrip::TrackerSpecialHeader::headerTypeNibble(), sistrip::FEDFEHeader::newFEHeader(), payloadLength_, payloadPointer_, sistrip::printHex(), sistrip::READOUT_MODE_SPY, sistrip::FEDBufferBase::readoutMode(), contentValuesCheck::ss, sistrip::FEDBufferBase::trackerSpecialHeader(), and validChannels_.

13  : FEDBufferBase(fedBuffer, fedBufferSize, allowBadBuffer, false) {
14  channels_.reserve(FEDCH_PER_FED);
15  //build the correct type of FE header object
19  } else {
20  feHeader_ = std::unique_ptr<FEDFEHeader>();
22  if (!allowBadBuffer) {
23  std::ostringstream ss;
24  ss << "Header type is invalid. "
25  << "Header type nibble is ";
26  uint8_t headerNibble = trackerSpecialHeader().headerTypeNibble();
27  printHex(&headerNibble, 1, ss);
28  ss << ". ";
29  throw cms::Exception("FEDBuffer") << ss.str();
30  }
31  }
32  if (readoutMode() == READOUT_MODE_SPY) {
33  throw cms::Exception("FEDBuffer") << "Unpacking of spy channel data with FEDBuffer is not supported" << std::endl;
34  }
36  //check if FE units are present in data
37  //in Full Debug mode, use the lengths from the header
38  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
39  if (fdHeader) {
40  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
41  if (fdHeader->fePresent(iFE))
42  fePresent_[iFE] = true;
43  else
44  fePresent_[iFE] = false;
45  }
46  }
47  //in APV error mode, use the FE present byte in the FED status register
48  // a value of '1' means a FE unit's data is missing (in old firmware versions it is always 0)
49  else {
50  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
52  fePresent_[iFE] = false;
53  else
54  fePresent_[iFE] = true;
55  }
56  }
57  //try to find channels
58  validChannels_ = 0;
59  try {
60  findChannels();
61  } catch (const cms::Exception& e) {
62  //if there was a problem either rethrow the exception or just mark channel pointers NULL
63  if (!allowBadBuffer)
64  throw;
65  else {
66  channels_.insert(channels_.end(), uint16_t(FEDCH_PER_FED - validChannels_), FEDChannel(payloadPointer_, 0, 0));
67  }
68  }
69  }
bool feDataMissingFlag(const uint8_t internalFEUnitNum) const
const uint8_t * getPointerToByteAfterEndOfPayload() const
static std::unique_ptr< FEDFEHeader > newFEHeader(const FEDHeaderType headerType, const uint8_t *headerBuffer)
FEDReadoutMode readoutMode() const
const uint8_t * getPointerToDataAfterTrackerSpecialHeader() const
bool fePresent_[FEUNITS_PER_FED]
const uint8_t * payloadPointer_
static const uint16_t FEUNITS_PER_FED
FEDBufferBase(const uint8_t *fedBuffer, const size_t fedBufferSize, const bool allowUnrecognizedFormat=false)
FEDHeaderType headerType() const
std::vector< FEDChannel > channels_
void printHex(const void *pointer, const size_t length, std::ostream &os)
std::unique_ptr< FEDFEHeader > feHeader_
TrackerSpecialHeader trackerSpecialHeader() const
static const uint16_t FEDCH_PER_FED
FEDStatusRegister fedStatusRegister() const
sistrip::FEDBuffer::~FEDBuffer ( )
override

Definition at line 71 of file SiStripFEDBuffer.cc.

71 {}

Member Function Documentation

uint16_t sistrip::FEDBuffer::calculateFEUnitLength ( const uint8_t  internalFEUnitNumber) const
private

Definition at line 300 of file SiStripFEDBuffer.cc.

References sistrip::FEDBufferBase::channels_, sistrip::FEDCH_PER_FEUNIT, and sistrip::internalFEDChannelNum().

Referenced by checkFEUnitLengths(), checkSummary(), and getCorrectPacketCode().

300  {
301  //get length from channels
302  uint16_t lengthFromChannels = 0;
303  for (uint8_t iCh = 0; iCh < FEDCH_PER_FEUNIT; iCh++) {
304  lengthFromChannels += channels_[internalFEDChannelNum(internalFEUnitNumber, iCh)].length();
305  }
306  return lengthFromChannels;
307  }
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
std::vector< FEDChannel > channels_
static const uint16_t FEDCH_PER_FEUNIT
bool sistrip::FEDBuffer::channelGood ( const uint8_t  internalFEDannelNum,
const bool  doAPVeCheck = true 
) const
virtual

Definition at line 165 of file SiStripFEDBuffer.cc.

References checkStatusBits(), sistrip::FEDCH_PER_FEUNIT, feGood(), feGoodWithoutAPVEmulatorCheck(), sistrip::READOUT_MODE_SCOPE, sistrip::FEDBufferBase::readoutMode(), and validChannels_.

Referenced by checkChannelPacketCodes(), and SiStripClusterizerFromRaw::run().

165  {
167  ((doAPVeCheck && feGood(internalFEDChannelNum / FEDCH_PER_FEUNIT)) ||
170  }
bool checkStatusBits(const uint8_t internalFEDChannelNum) const
FEDReadoutMode readoutMode() const
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
bool feGoodWithoutAPVEmulatorCheck(const uint8_t internalFEUnitNum) const
static const uint16_t FEDCH_PER_FEUNIT
bool feGood(const uint8_t internalFEUnitNum) const
bool sistrip::FEDBuffer::checkAllChannelStatusBits ( ) const

Definition at line 192 of file SiStripFEDBuffer.cc.

References checkStatusBits(), sistrip::FEDCH_PER_FED, sistrip::FEDCH_PER_FEUNIT, and feGood().

Referenced by checkSummary(), and setLegacyMode().

192  {
193  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
194  //if FE unit is disabled then skip all channels on it
195  if (!feGood(iCh / FEDCH_PER_FEUNIT)) {
196  iCh += FEDCH_PER_FEUNIT;
197  continue;
198  }
199  //channel is bad then return false
200  if (!checkStatusBits(iCh))
201  return false;
202  }
203  //if no bad channels have been found then they are all fine
204  return true;
205  }
bool checkStatusBits(const uint8_t internalFEDChannelNum) const
static const uint16_t FEDCH_PER_FEUNIT
static const uint16_t FEDCH_PER_FED
bool feGood(const uint8_t internalFEUnitNum) const
bool sistrip::FEDBuffer::checkChannelLengths ( ) const

Definition at line 207 of file SiStripFEDBuffer.cc.

References sistrip::FEDCH_PER_FED, and validChannels_.

Referenced by checkChannelLengthsMatchBufferLength(), and setLegacyMode().

207 { return (validChannels_ == FEDCH_PER_FED); }
static const uint16_t FEDCH_PER_FED
bool sistrip::FEDBuffer::checkChannelLengthsMatchBufferLength ( ) const

Definition at line 209 of file SiStripFEDBuffer.cc.

References sistrip::FEDBufferBase::channels_, checkChannelLengths(), sistrip::FEDCH_PER_FEUNIT, sistrip::FEDBufferBase::feEnabled(), fePresent(), sistrip::internalFEDChannelNum(), sistrip::FEDChannel::length(), sistrip::FEDChannel::offset(), and payloadLength_.

Referenced by checkSummary(), doCorruptBufferChecks(), and setLegacyMode().

209  {
210  //check they fit into buffer
211  if (!checkChannelLengths())
212  return false;
213 
214  //payload length from length of data buffer
215  const uint16_t payloadLengthInWords = payloadLength_ / 8;
216 
217  //find channel length
218  //find last enabled FE unit
219  uint8_t lastEnabledFeUnit = 7;
220  while (!(fePresent(lastEnabledFeUnit) && feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit != 0)
221  lastEnabledFeUnit--;
222  //last channel is last channel on last enabled FE unit
223  const FEDChannel& lastChannel = channels_[internalFEDChannelNum(lastEnabledFeUnit, FEDCH_PER_FEUNIT - 1)];
224  const uint16_t offsetLastChannel = lastChannel.offset();
225  const uint16_t offsetEndOfChannelData = offsetLastChannel + lastChannel.length();
226  const uint16_t channelDataLength = offsetEndOfChannelData;
227  //channel length in words is length in bytes rounded up to nearest word
228  uint16_t channelDataLengthInWords = channelDataLength / 8;
229  if (channelDataLength % 8)
230  channelDataLengthInWords++;
231 
232  //check lengths match
233  if (channelDataLengthInWords == payloadLengthInWords) {
234  return true;
235  } else {
236  return false;
237  }
238  }
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
bool fePresent(uint8_t internalFEUnitNum) const
bool feEnabled(const uint8_t internalFEUnitNum) const
std::vector< FEDChannel > channels_
static const uint16_t FEDCH_PER_FEUNIT
bool checkChannelLengths() const
bool sistrip::FEDBuffer::checkChannelPacketCodes ( ) const

Definition at line 240 of file SiStripFEDBuffer.cc.

References channelGood(), sistrip::FEDBufferBase::channels_, sistrip::FEDCH_PER_FED, sistrip::FEDCH_PER_FEUNIT, feGood(), getCorrectPacketCode(), and sistrip::FEDBufferBase::packetCode().

Referenced by checkSummary(), doCorruptBufferChecks(), and setLegacyMode().

240  {
241  const uint8_t correctPacketCode = getCorrectPacketCode();
242  //if the readout mode if not one which has a packet code then this is set to zero. in this case return true
243  if (!correctPacketCode)
244  return true;
245  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
246  //if FE unit is disabled then skip all channels on it
247  if (!feGood(iCh / FEDCH_PER_FEUNIT)) {
248  iCh += FEDCH_PER_FEUNIT;
249  continue;
250  }
251  //only check enabled, working channels
252  if (FEDBuffer::channelGood(iCh, true)) {
253  //if a channel is bad then return false
254  if (channels_[iCh].packetCode() != correctPacketCode)
255  return false;
256  }
257  }
258  //if no bad channels were found the they are all ok
259  return true;
260  }
virtual bool channelGood(const uint8_t internalFEDannelNum, const bool doAPVeCheck=true) const
uint8_t packetCode(bool legacy=false, const uint8_t internalFEDChannelNum=0) const
std::vector< FEDChannel > channels_
static const uint16_t FEDCH_PER_FEUNIT
uint8_t getCorrectPacketCode() const
static const uint16_t FEDCH_PER_FED
bool feGood(const uint8_t internalFEUnitNum) const
bool sistrip::FEDBuffer::checkFEPayloadsPresent ( ) const

Definition at line 309 of file SiStripFEDBuffer.cc.

References fePresent(), and sistrip::FEUNITS_PER_FED.

Referenced by checkSummary(), and setLegacyMode().

309  {
310  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
311  if (!fePresent(iFE))
312  return false;
313  }
314  return true;
315  }
bool fePresent(uint8_t internalFEUnitNum) const
static const uint16_t FEUNITS_PER_FED
bool sistrip::FEDBuffer::checkFEUnitAPVAddresses ( ) const

Definition at line 262 of file SiStripFEDBuffer.cc.

References sistrip::FEDBufferBase::apveAddress(), feGood(), feHeader_, sistrip::FEDFullDebugHeader::feUnitMajorityAddress(), and sistrip::FEUNITS_PER_FED.

Referenced by checkSummary(), and setLegacyMode().

262  {
263  //get golden address
264  const uint8_t goldenAddress = apveAddress();
265  //don't check if the address is 00 since APVe is probably not connected
266  if (goldenAddress == 0x00)
267  return true;
268  //check can only be done for full debug headers
269  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
270  if (!fdHeader)
271  return true;
272  //check all enabled FE units
273  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
274  if (!feGood(iFE))
275  continue;
276  //if address is bad then return false
277  if (fdHeader->feUnitMajorityAddress(iFE) != goldenAddress)
278  return false;
279  }
280  //if no bad addresses were found then return true
281  return true;
282  }
static const uint16_t FEUNITS_PER_FED
std::unique_ptr< FEDFEHeader > feHeader_
bool feGood(const uint8_t internalFEUnitNum) const
bool sistrip::FEDBuffer::checkFEUnitLengths ( ) const

Definition at line 284 of file SiStripFEDBuffer.cc.

References calculateFEUnitLength(), feGood(), feHeader_, sistrip::FEDFullDebugHeader::feUnitLength(), and sistrip::FEUNITS_PER_FED.

Referenced by checkSummary(), doCorruptBufferChecks(), and setLegacyMode().

284  {
285  //check can only be done for full debug headers
286  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
287  if (!fdHeader)
288  return true;
289  //check lengths for enabled FE units
290  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
291  if (!feGood(iFE))
292  continue;
293  if (calculateFEUnitLength(iFE) != fdHeader->feUnitLength(iFE))
294  return false;
295  }
296  //if no errors were encountered then return true
297  return true;
298  }
static const uint16_t FEUNITS_PER_FED
std::unique_ptr< FEDFEHeader > feHeader_
uint16_t calculateFEUnitLength(const uint8_t internalFEUnitNumber) const
bool feGood(const uint8_t internalFEUnitNum) const
bool sistrip::FEDBuffer::checkStatusBits ( const uint8_t  internalFEDChannelNum) const
inline

Definition at line 201 of file SiStripFEDBuffer.h.

References feHeader_.

Referenced by channelGood(), checkAllChannelStatusBits(), checkStatusBits(), checkSummary(), and setLegacyMode().

201  {
202  return feHeader_->checkChannelStatusBits(internalFEDChannelNum);
203  }
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
std::unique_ptr< FEDFEHeader > feHeader_
bool sistrip::FEDBuffer::checkStatusBits ( const uint8_t  internalFEUnitNum,
const uint8_t  internalChannelNum 
) const
inline

Definition at line 205 of file SiStripFEDBuffer.h.

References checkStatusBits(), and sistrip::internalFEDChannelNum().

205  {
206  return checkStatusBits(internalFEDChannelNum(internalFEUnitNum, internalChannelNum));
207  }
bool checkStatusBits(const uint8_t internalFEDChannelNum) const
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
std::string sistrip::FEDBuffer::checkSummary ( ) const
overridevirtual

Reimplemented from sistrip::FEDBufferBase.

Definition at line 317 of file SiStripFEDBuffer.cc.

References sistrip::FEDBufferBase::apveAddress(), calculateFEUnitLength(), sistrip::FEDBufferBase::channels_, checkAllChannelStatusBits(), checkChannelLengthsMatchBufferLength(), checkChannelPacketCodes(), checkFEPayloadsPresent(), checkFEUnitAPVAddresses(), checkFEUnitLengths(), checkStatusBits(), sistrip::FEDBufferBase::checkSummary(), sistrip::FEDCH_PER_FED, sistrip::FEDCH_PER_FEUNIT, feGood(), feHeader_, fePresent(), sistrip::FEDFullDebugHeader::feUnitLength(), sistrip::FEDFullDebugHeader::feUnitMajorityAddress(), sistrip::FEUNITS_PER_FED, sistrip::FEDFullDebugHeader::getChannelStatus(), getCorrectPacketCode(), sistrip::HEADER_TYPE_FULL_DEBUG, sistrip::FEDBufferBase::headerType(), sistrip::FEDBufferBase::packetCode(), and edmLumisInFiles::summary.

Referenced by setLegacyMode().

317  {
318  std::ostringstream summary;
319  summary << FEDBufferBase::checkSummary();
320  summary << "Check FE unit payloads are all present: " << (checkFEPayloadsPresent() ? "passed" : "FAILED")
321  << std::endl;
322  if (!checkFEPayloadsPresent()) {
323  summary << "FE units missing payloads: ";
324  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
325  if (!fePresent(iFE))
326  summary << uint16_t(iFE) << " ";
327  }
328  summary << std::endl;
329  }
330  summary << "Check channel status bits: " << (checkAllChannelStatusBits() ? "passed" : "FAILED") << std::endl;
331  if (!checkAllChannelStatusBits()) {
332  unsigned int badChannels = 0;
334  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
335  if (fdHeader) {
336  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
337  if (!feGood(iCh / FEDCH_PER_FEUNIT))
338  continue;
339  if (!checkStatusBits(iCh)) {
340  summary << uint16_t(iCh) << ": " << fdHeader->getChannelStatus(iCh) << std::endl;
341  badChannels++;
342  }
343  }
344  }
345  } else {
346  summary << "Channels with errors: ";
347  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
348  if (!feGood(iCh / FEDCH_PER_FEUNIT))
349  continue;
350  if (!checkStatusBits(iCh)) {
351  summary << uint16_t(iCh) << " ";
352  badChannels++;
353  }
354  }
355  summary << std::endl;
356  }
357  summary << "Number of channels with bad status bits: " << badChannels << std::endl;
358  }
359  summary << "Check channel lengths match buffer length: "
360  << (checkChannelLengthsMatchBufferLength() ? "passed" : "FAILED") << std::endl;
361  summary << "Check channel packet codes: " << (checkChannelPacketCodes() ? "passed" : "FAILED") << std::endl;
362  if (!checkChannelPacketCodes()) {
363  summary << "Channels with bad packet codes: ";
364  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
365  if (!feGood(iCh / FEDCH_PER_FEUNIT))
366  continue;
367  if (channels_[iCh].packetCode() != getCorrectPacketCode())
368  summary << uint16_t(iCh) << " ";
369  }
370  }
371  summary << "Check FE unit lengths: " << (checkFEUnitLengths() ? "passed" : "FAILED") << std::endl;
372  if (!checkFEUnitLengths()) {
373  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
374  if (fdHeader) {
375  summary << "Bad FE units:" << std::endl;
376  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
377  if (!feGood(iFE))
378  continue;
379  uint16_t lengthFromChannels = calculateFEUnitLength(iFE);
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;
384  }
385  }
386  }
387  }
388  summary << "Check FE unit APV addresses match APVe: " << (checkFEUnitAPVAddresses() ? "passed" : "FAILED")
389  << std::endl;
390  if (!checkFEUnitAPVAddresses()) {
391  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
392  if (fdHeader) {
393  const uint8_t goldenAddress = apveAddress();
394  summary << "Address from APVe:" << uint16_t(goldenAddress) << std::endl;
395  summary << "Bad FE units:" << std::endl;
396  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
397  if (!feGood(iFE))
398  continue;
399  if (fdHeader->feUnitMajorityAddress(iFE) != goldenAddress) {
400  summary << "FE unit: " << uint16_t(iFE)
401  << " majority address: " << uint16_t(fdHeader->feUnitMajorityAddress(iFE)) << std::endl;
402  }
403  }
404  }
405  }
406  return summary.str();
407  }
bool checkFEUnitLengths() const
bool checkStatusBits(const uint8_t internalFEDChannelNum) const
virtual std::string checkSummary() const
bool checkFEPayloadsPresent() const
bool fePresent(uint8_t internalFEUnitNum) const
static const uint16_t FEUNITS_PER_FED
FEDHeaderType headerType() const
uint8_t packetCode(bool legacy=false, const uint8_t internalFEDChannelNum=0) const
std::vector< FEDChannel > channels_
bool checkChannelPacketCodes() const
static const uint16_t FEDCH_PER_FEUNIT
std::unique_ptr< FEDFEHeader > feHeader_
bool checkFEUnitAPVAddresses() const
uint8_t getCorrectPacketCode() const
bool checkChannelLengthsMatchBufferLength() const
static const uint16_t FEDCH_PER_FED
bool checkAllChannelStatusBits() const
uint16_t calculateFEUnitLength(const uint8_t internalFEUnitNumber) const
bool feGood(const uint8_t internalFEUnitNum) const
bool sistrip::FEDBuffer::doChecks ( bool  doCRC = true) const
virtual

Definition at line 172 of file SiStripFEDBuffer.cc.

References sistrip::FEDBufferBase::checkCRC(), sistrip::FEDBufferBase::doChecks(), sistrip::FEDCH_PER_FED, and validChannels_.

172  {
173  //check that all channels were unpacked properly
175  return false;
176  //do checks from base class
178  return false;
179  //check CRC
180  if (doCRC && !checkCRC())
181  return false;
182  return true;
183  }
static const uint16_t FEDCH_PER_FED
bool sistrip::FEDBuffer::doCorruptBufferChecks ( ) const
virtual

Definition at line 185 of file SiStripFEDBuffer.cc.

References checkChannelLengthsMatchBufferLength(), checkChannelPacketCodes(), sistrip::FEDBufferBase::checkCRC(), and checkFEUnitLengths().

Referenced by setLegacyMode().

185  {
187  //checkClusterLengths() &&
189  //checkFEUnitAPVAddresses() );
190  }
bool checkFEUnitLengths() const
bool checkChannelPacketCodes() const
bool checkChannelLengthsMatchBufferLength() const
bool sistrip::FEDBuffer::feGood ( const uint8_t  internalFEUnitNum) const
inline

Definition at line 190 of file SiStripFEDBuffer.h.

References sistrip::FEDBufferBase::feOverflow(), fePresent(), and sistrip::FEDBufferBase::majorityAddressErrorForFEUnit().

Referenced by channelGood(), checkAllChannelStatusBits(), checkChannelPacketCodes(), checkFEUnitAPVAddresses(), checkFEUnitLengths(), and checkSummary().

190  {
191  return (!majorityAddressErrorForFEUnit(internalFEUnitNum) && !feOverflow(internalFEUnitNum) &&
192  fePresent(internalFEUnitNum));
193  }
bool fePresent(uint8_t internalFEUnitNum) const
bool majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const
bool feOverflow(const uint8_t internalFEUnitNum) const
bool sistrip::FEDBuffer::feGoodWithoutAPVEmulatorCheck ( const uint8_t  internalFEUnitNum) const
inline

Definition at line 195 of file SiStripFEDBuffer.h.

References sistrip::FEDBufferBase::feOverflow(), and fePresent().

Referenced by channelGood().

195  {
196  return (!feOverflow(internalFEUnitNum) && fePresent(internalFEUnitNum));
197  }
bool fePresent(uint8_t internalFEUnitNum) const
bool feOverflow(const uint8_t internalFEUnitNum) const
const FEDFEHeader * sistrip::FEDBuffer::feHeader ( ) const
inline

Definition at line 188 of file SiStripFEDBuffer.h.

References feHeader_.

Referenced by print(), and sistrip::RawToDigiUnpacker::updateEventSummary().

188 { return feHeader_.get(); }
std::unique_ptr< FEDFEHeader > feHeader_
bool sistrip::FEDBuffer::fePresent ( uint8_t  internalFEUnitNum) const
inline
void sistrip::FEDBuffer::findChannels ( )
private

Definition at line 73 of file SiStripFEDBuffer.cc.

References sistrip::FEDBufferBase::channels_, Exception, SiStripFedKey::feChan(), sistrip::FEDCH_PER_FED, sistrip::FEDCH_PER_FEUNIT, sistrip::FEDBufferBase::feEnabled(), fePresent(), SiStripFedKey::feUnit(), mps_fire::i, crabWrapper::key, payloadLength_, payloadPointer_, sistrip::READOUT_MODE_PREMIX_RAW, sistrip::READOUT_MODE_ZERO_SUPPRESSED, sistrip::READOUT_MODE_ZERO_SUPPRESSED_FAKE, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10_CMOVERRIDE, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT_CMOVERRIDE, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_CMOVERRIDE, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT_CMOVERRIDE, sistrip::FEDBufferBase::readoutMode(), contentValuesCheck::ss, UNLIKELY, and validChannels_.

Referenced by FEDBuffer(), and setLegacyMode().

73  {
74  //set min length to 2 for ZSLite, 7 for ZS and 3 for raw
75  uint16_t minLength;
76  switch (readoutMode()) {
79  minLength = 7;
80  break;
82  minLength = 2;
83  break;
92  minLength = 2;
93  break;
94  default:
95  minLength = 3;
96  break;
97  }
98  uint16_t offsetBeginningOfChannel = 0;
99  for (uint16_t i = 0; i < FEDCH_PER_FED; i++) {
100  //if FE unit is not enabled then skip rest of FE unit adding NULL pointers
101  if
103  channels_.insert(channels_.end(), uint16_t(FEDCH_PER_FEUNIT), FEDChannel(payloadPointer_, 0, 0));
104  i += FEDCH_PER_FEUNIT - 1;
106  continue;
107  }
108  //if FE unit is enabled
109  //check that channel length bytes fit into buffer
110  if
111  UNLIKELY(offsetBeginningOfChannel + 1 >= payloadLength_) {
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. "
118  << "Payload length is " << uint16_t(payloadLength_) << ". ";
119  throw cms::Exception("FEDBuffer") << ss.str();
120  }
121 
122  channels_.push_back(FEDChannel(payloadPointer_, offsetBeginningOfChannel));
123  //get length and check that whole channel fits into buffer
124  uint16_t channelLength = channels_.back().length();
125 
126  //check that the channel length is long enough to contain the header
127  if
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)"
133  << " is too short. "
134  << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
135  << "Channel length is " << uint16_t(channelLength) << ". "
136  << "Min length is " << uint16_t(minLength) << ". ";
137  throw cms::Exception("FEDBuffer") << ss.str();
138  }
139  if
140  UNLIKELY(offsetBeginningOfChannel + channelLength > payloadLength_) {
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) << ". "
147  << "Payload length is " << uint16_t(payloadLength_) << ". ";
148  throw cms::Exception("FEDBuffer") << ss.str();
149  }
150 
151  validChannels_++;
152  const uint16_t offsetEndOfChannel = offsetBeginningOfChannel + channelLength;
153  //add padding if necessary and calculate offset for begining of next channel
154  if (!((i + 1) % FEDCH_PER_FEUNIT)) {
155  uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
156  if (numPaddingBytes == 8)
157  numPaddingBytes = 0;
158  offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
159  } else {
160  offsetBeginningOfChannel = offsetEndOfChannel;
161  }
162  }
163  }
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
FEDReadoutMode readoutMode() const
const uint8_t * payloadPointer_
bool fePresent(uint8_t internalFEUnitNum) const
bool feEnabled(const uint8_t internalFEUnitNum) const
std::vector< FEDChannel > channels_
static const uint16_t FEDCH_PER_FEUNIT
static const uint16_t FEDCH_PER_FED
#define UNLIKELY(x)
Definition: Likely.h:21
uint8_t sistrip::FEDBuffer::getCorrectPacketCode ( ) const
inlineprivate

Definition at line 78 of file SiStripFEDBuffer.h.

References calculateFEUnitLength(), legacyUnpacker_, and sistrip::FEDBufferBase::packetCode().

Referenced by checkChannelPacketCodes(), and checkSummary().

78 { return packetCode(legacyUnpacker_); }
uint8_t packetCode(bool legacy=false, const uint8_t internalFEDChannelNum=0) const
uint8_t sistrip::FEDBuffer::nFEUnitsPresent ( ) const
private

Definition at line 409 of file SiStripFEDBuffer.cc.

References fePresent(), sistrip::FEUNITS_PER_FED, and mps_fire::result.

Referenced by print(), and setLegacyMode().

409  {
410  uint8_t result = 0;
411  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
412  if (fePresent(iFE))
413  result++;
414  }
415  return result;
416  }
bool fePresent(uint8_t internalFEUnitNum) const
static const uint16_t FEUNITS_PER_FED
void sistrip::FEDBuffer::print ( std::ostream &  os) const
overridevirtual

Reimplemented from sistrip::FEDBufferBase.

Definition at line 418 of file SiStripFEDBuffer.cc.

References feHeader(), sistrip::HEADER_TYPE_FULL_DEBUG, sistrip::FEDBufferBase::headerType(), nFEUnitsPresent(), and sistrip::FEDBufferBase::print().

418  {
421  os << "FE units with data: " << uint16_t(nFEUnitsPresent()) << std::endl;
422  os << "BE status register flags: ";
423  dynamic_cast<const FEDFullDebugHeader*>(feHeader())->beStatusRegister().printFlags(os);
424  os << std::endl;
425  }
426  }
const FEDFEHeader * feHeader() const
FEDHeaderType headerType() const
uint8_t nFEUnitsPresent() const
virtual void print(std::ostream &os) const
void sistrip::FEDBuffer::setLegacyMode ( bool  legacy)
inline

Member Data Documentation

std::unique_ptr<FEDFEHeader> sistrip::FEDBuffer::feHeader_
private
bool sistrip::FEDBuffer::fePresent_[FEUNITS_PER_FED]
private

Definition at line 84 of file SiStripFEDBuffer.h.

Referenced by FEDBuffer(), and fePresent().

bool sistrip::FEDBuffer::legacyUnpacker_ = false
private

Definition at line 85 of file SiStripFEDBuffer.h.

Referenced by getCorrectPacketCode(), and setLegacyMode().

uint16_t sistrip::FEDBuffer::payloadLength_
private
const uint8_t* sistrip::FEDBuffer::payloadPointer_
private

Definition at line 81 of file SiStripFEDBuffer.h.

Referenced by FEDBuffer(), and findChannels().

uint8_t sistrip::FEDBuffer::validChannels_
private