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 FEDRawData &fedBuffer, 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
 
FEDBufferStatusCode findChannels ()
 
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 FEDRawData &fedBuffer)
 
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
 
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 FEDRawData &fedBuffer, 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 24 of file SiStripFEDBuffer.h.

Constructor & Destructor Documentation

◆ FEDBuffer()

sistrip::FEDBuffer::FEDBuffer ( const FEDRawData fedBuffer,
const bool  allowBadBuffer = false 
)
explicit

constructor from a FEDRawData buffer

The sistrip::preconstructCheckFEDBuffer() method should be used (with the same value of allowBadBuffer) to check the validity of fedBuffer before constructing a sistrip::FEDBuffer. If allowBadBuffer is set to true, the initialization proceeds even if the event format is not recognized. To initialize also the channel information, the FEDBuffer::findChannels() method should be called as well, and its return status checked (unless bad buffers, with an unrecognized event format or channel lengths that do not make sense, should also be included).

See also
sistrip::preconstructCheckFEDBuffer() sistrip::FEDBuffer::findChannels()

Definition at line 13 of file SiStripFEDBuffer.cc.

13  : FEDBufferBase(fedBuffer, false) {
14  validChannels_ = 0;
15  channels_.reserve(FEDCH_PER_FED);
16  //build the correct type of FE header object
20  } else {
21  feHeader_ = std::unique_ptr<FEDFEHeader>();
23  }
25  //check if FE units are present in data
26  //in Full Debug mode, use the lengths from the header
27  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
28  if (fdHeader) {
29  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
30  if (fdHeader->fePresent(iFE))
31  fePresent_[iFE] = true;
32  else
33  fePresent_[iFE] = false;
34  }
35  }
36  //in APV error mode, use the FE present byte in the FED status register
37  // a value of '1' means a FE unit's data is missing (in old firmware versions it is always 0)
38  else {
39  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
41  fePresent_[iFE] = false;
42  else
43  fePresent_[iFE] = true;
44  }
45  }
46  }

References sistrip::FEDBufferBase::channels_, sistrip::FEDStatusRegister::feDataMissingFlag(), sistrip::FEDCH_PER_FED, sistrip::FEDBufferBase::fedStatusRegister(), feHeader_, sistrip::FEDFullDebugHeader::fePresent(), fePresent_, sistrip::FEUNITS_PER_FED, sistrip::FEDBufferBase::getPointerToByteAfterEndOfPayload(), sistrip::FEDBufferBase::getPointerToDataAfterTrackerSpecialHeader(), sistrip::HEADER_TYPE_INVALID, sistrip::HEADER_TYPE_NONE, sistrip::FEDBufferBase::headerType(), sistrip::FEDFEHeader::newFEHeader(), payloadLength_, payloadPointer_, and validChannels_.

◆ ~FEDBuffer()

sistrip::FEDBuffer::~FEDBuffer ( )
override

Definition at line 48 of file SiStripFEDBuffer.cc.

48 {}

Member Function Documentation

◆ calculateFEUnitLength()

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

Definition at line 284 of file SiStripFEDBuffer.cc.

284  {
285  //get length from channels
286  uint16_t lengthFromChannels = 0;
287  for (uint8_t iCh = 0; iCh < FEDCH_PER_FEUNIT; iCh++) {
288  lengthFromChannels += channels_[internalFEDChannelNum(internalFEUnitNumber, iCh)].length();
289  }
290  return lengthFromChannels;
291  }

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

Referenced by checkFEUnitLengths(), and checkSummary().

◆ channelGood()

bool sistrip::FEDBuffer::channelGood ( const uint8_t  internalFEDannelNum,
const bool  doAPVeCheck = true 
) const
virtual

◆ checkAllChannelStatusBits()

bool sistrip::FEDBuffer::checkAllChannelStatusBits ( ) const

Definition at line 176 of file SiStripFEDBuffer.cc.

176  {
177  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
178  //if FE unit is disabled then skip all channels on it
179  if (!feGood(iCh / FEDCH_PER_FEUNIT)) {
180  iCh += FEDCH_PER_FEUNIT;
181  continue;
182  }
183  //channel is bad then return false
184  if (!checkStatusBits(iCh))
185  return false;
186  }
187  //if no bad channels have been found then they are all fine
188  return true;
189  }

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

Referenced by checkSummary().

◆ checkChannelLengths()

bool sistrip::FEDBuffer::checkChannelLengths ( ) const

Definition at line 191 of file SiStripFEDBuffer.cc.

191 { return (validChannels_ == FEDCH_PER_FED); }

References sistrip::FEDCH_PER_FED, and validChannels_.

Referenced by checkChannelLengthsMatchBufferLength().

◆ checkChannelLengthsMatchBufferLength()

bool sistrip::FEDBuffer::checkChannelLengthsMatchBufferLength ( ) const

Definition at line 193 of file SiStripFEDBuffer.cc.

193  {
194  //check they fit into buffer
195  if (!checkChannelLengths())
196  return false;
197 
198  //payload length from length of data buffer
199  const uint16_t payloadLengthInWords = payloadLength_ / 8;
200 
201  //find channel length
202  //find last enabled FE unit
203  uint8_t lastEnabledFeUnit = 7;
204  while (!(fePresent(lastEnabledFeUnit) && feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit != 0)
205  lastEnabledFeUnit--;
206  //last channel is last channel on last enabled FE unit
207  const FEDChannel& lastChannel = channels_[internalFEDChannelNum(lastEnabledFeUnit, FEDCH_PER_FEUNIT - 1)];
208  const uint16_t offsetLastChannel = lastChannel.offset();
209  const uint16_t offsetEndOfChannelData = offsetLastChannel + lastChannel.length();
210  const uint16_t channelDataLength = offsetEndOfChannelData;
211  //channel length in words is length in bytes rounded up to nearest word
212  uint16_t channelDataLengthInWords = channelDataLength / 8;
213  if (channelDataLength % 8)
214  channelDataLengthInWords++;
215 
216  //check lengths match
217  if (channelDataLengthInWords == payloadLengthInWords) {
218  return true;
219  } else {
220  return false;
221  }
222  }

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(), and doCorruptBufferChecks().

◆ checkChannelPacketCodes()

bool sistrip::FEDBuffer::checkChannelPacketCodes ( ) const

Definition at line 224 of file SiStripFEDBuffer.cc.

224  {
225  const uint8_t correctPacketCode = getCorrectPacketCode();
226  //if the readout mode if not one which has a packet code then this is set to zero. in this case return true
227  if (!correctPacketCode)
228  return true;
229  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
230  //if FE unit is disabled then skip all channels on it
231  if (!feGood(iCh / FEDCH_PER_FEUNIT)) {
232  iCh += FEDCH_PER_FEUNIT;
233  continue;
234  }
235  //only check enabled, working channels
236  if (FEDBuffer::channelGood(iCh, true)) {
237  //if a channel is bad then return false
238  if (channels_[iCh].packetCode() != correctPacketCode)
239  return false;
240  }
241  }
242  //if no bad channels were found the they are all ok
243  return true;
244  }

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

Referenced by checkSummary(), and doCorruptBufferChecks().

◆ checkFEPayloadsPresent()

bool sistrip::FEDBuffer::checkFEPayloadsPresent ( ) const

Definition at line 293 of file SiStripFEDBuffer.cc.

293  {
294  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
295  if (!fePresent(iFE))
296  return false;
297  }
298  return true;
299  }

References fePresent(), and sistrip::FEUNITS_PER_FED.

Referenced by checkSummary().

◆ checkFEUnitAPVAddresses()

bool sistrip::FEDBuffer::checkFEUnitAPVAddresses ( ) const

Definition at line 246 of file SiStripFEDBuffer.cc.

246  {
247  //get golden address
248  const uint8_t goldenAddress = apveAddress();
249  //don't check if the address is 00 since APVe is probably not connected
250  if (goldenAddress == 0x00)
251  return true;
252  //check can only be done for full debug headers
253  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
254  if (!fdHeader)
255  return true;
256  //check all enabled FE units
257  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
258  if (!feGood(iFE))
259  continue;
260  //if address is bad then return false
261  if (fdHeader->feUnitMajorityAddress(iFE) != goldenAddress)
262  return false;
263  }
264  //if no bad addresses were found then return true
265  return true;
266  }

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

Referenced by checkSummary().

◆ checkFEUnitLengths()

bool sistrip::FEDBuffer::checkFEUnitLengths ( ) const

Definition at line 268 of file SiStripFEDBuffer.cc.

268  {
269  //check can only be done for full debug headers
270  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
271  if (!fdHeader)
272  return true;
273  //check lengths for enabled FE units
274  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
275  if (!feGood(iFE))
276  continue;
277  if (calculateFEUnitLength(iFE) != fdHeader->feUnitLength(iFE))
278  return false;
279  }
280  //if no errors were encountered then return true
281  return true;
282  }

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

Referenced by checkSummary(), and doCorruptBufferChecks().

◆ checkStatusBits() [1/2]

bool sistrip::FEDBuffer::checkStatusBits ( const uint8_t  internalFEDChannelNum) const
inline

Definition at line 167 of file SiStripFEDBuffer.h.

167  {
168  return feHeader_->checkChannelStatusBits(internalFEDChannelNum);
169  }

References feHeader_, and sistrip::internalFEDChannelNum().

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

◆ checkStatusBits() [2/2]

bool sistrip::FEDBuffer::checkStatusBits ( const uint8_t  internalFEUnitNum,
const uint8_t  internalChannelNum 
) const
inline

Definition at line 171 of file SiStripFEDBuffer.h.

171  {
172  return checkStatusBits(internalFEDChannelNum(internalFEUnitNum, internalChannelNum));
173  }

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

◆ checkSummary()

std::string sistrip::FEDBuffer::checkSummary ( ) const
overridevirtual

Reimplemented from sistrip::FEDBufferBase.

Definition at line 301 of file SiStripFEDBuffer.cc.

301  {
302  std::ostringstream summary;
304  summary << "Check FE unit payloads are all present: " << (checkFEPayloadsPresent() ? "passed" : "FAILED")
305  << std::endl;
306  if (!checkFEPayloadsPresent()) {
307  summary << "FE units missing payloads: ";
308  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
309  if (!fePresent(iFE))
310  summary << uint16_t(iFE) << " ";
311  }
312  summary << std::endl;
313  }
314  summary << "Check channel status bits: " << (checkAllChannelStatusBits() ? "passed" : "FAILED") << std::endl;
315  if (!checkAllChannelStatusBits()) {
316  unsigned int badChannels = 0;
318  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
319  if (fdHeader) {
320  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
321  if (!feGood(iCh / FEDCH_PER_FEUNIT))
322  continue;
323  if (!checkStatusBits(iCh)) {
324  summary << uint16_t(iCh) << ": " << fdHeader->getChannelStatus(iCh) << std::endl;
325  badChannels++;
326  }
327  }
328  }
329  } else {
330  summary << "Channels with errors: ";
331  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
332  if (!feGood(iCh / FEDCH_PER_FEUNIT))
333  continue;
334  if (!checkStatusBits(iCh)) {
335  summary << uint16_t(iCh) << " ";
336  badChannels++;
337  }
338  }
339  summary << std::endl;
340  }
341  summary << "Number of channels with bad status bits: " << badChannels << std::endl;
342  }
343  summary << "Check channel lengths match buffer length: "
344  << (checkChannelLengthsMatchBufferLength() ? "passed" : "FAILED") << std::endl;
345  summary << "Check channel packet codes: " << (checkChannelPacketCodes() ? "passed" : "FAILED") << std::endl;
346  if (!checkChannelPacketCodes()) {
347  summary << "Channels with bad packet codes: ";
348  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
349  if (!feGood(iCh / FEDCH_PER_FEUNIT))
350  continue;
351  if (channels_[iCh].packetCode() != getCorrectPacketCode())
352  summary << uint16_t(iCh) << " ";
353  }
354  }
355  summary << "Check FE unit lengths: " << (checkFEUnitLengths() ? "passed" : "FAILED") << std::endl;
356  if (!checkFEUnitLengths()) {
357  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
358  if (fdHeader) {
359  summary << "Bad FE units:" << std::endl;
360  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
361  if (!feGood(iFE))
362  continue;
363  uint16_t lengthFromChannels = calculateFEUnitLength(iFE);
364  uint16_t lengthFromHeader = fdHeader->feUnitLength(iFE);
365  if (lengthFromHeader != lengthFromChannels) {
366  summary << "FE unit: " << uint16_t(iFE) << " length in header: " << lengthFromHeader
367  << " length from channel lengths: " << lengthFromChannels << std::endl;
368  }
369  }
370  }
371  }
372  summary << "Check FE unit APV addresses match APVe: " << (checkFEUnitAPVAddresses() ? "passed" : "FAILED")
373  << std::endl;
374  if (!checkFEUnitAPVAddresses()) {
375  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
376  if (fdHeader) {
377  const uint8_t goldenAddress = apveAddress();
378  summary << "Address from APVe:" << uint16_t(goldenAddress) << std::endl;
379  summary << "Bad FE units:" << std::endl;
380  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
381  if (!feGood(iFE))
382  continue;
383  if (fdHeader->feUnitMajorityAddress(iFE) != goldenAddress) {
384  summary << "FE unit: " << uint16_t(iFE)
385  << " majority address: " << uint16_t(fdHeader->feUnitMajorityAddress(iFE)) << std::endl;
386  }
387  }
388  }
389  }
390  return summary.str();
391  }

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.

◆ doChecks()

bool sistrip::FEDBuffer::doChecks ( bool  doCRC = true) const
virtual

Definition at line 156 of file SiStripFEDBuffer.cc.

156  {
157  //check that all channels were unpacked properly
159  return false;
160  //do checks from base class
162  return false;
163  //check CRC
164  if (doCRC && !checkCRC())
165  return false;
166  return true;
167  }

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

◆ doCorruptBufferChecks()

bool sistrip::FEDBuffer::doCorruptBufferChecks ( ) const
virtual

Definition at line 169 of file SiStripFEDBuffer.cc.

169  {
171  //checkClusterLengths() &&
173  //checkFEUnitAPVAddresses() );
174  }

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

◆ feGood()

bool sistrip::FEDBuffer::feGood ( const uint8_t  internalFEUnitNum) const
inline

◆ feGoodWithoutAPVEmulatorCheck()

bool sistrip::FEDBuffer::feGoodWithoutAPVEmulatorCheck ( const uint8_t  internalFEUnitNum) const
inline

Definition at line 161 of file SiStripFEDBuffer.h.

161  {
162  return (!feOverflow(internalFEUnitNum) && fePresent(internalFEUnitNum));
163  }

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

Referenced by channelGood().

◆ feHeader()

const FEDFEHeader * sistrip::FEDBuffer::feHeader ( ) const
inline

Definition at line 154 of file SiStripFEDBuffer.h.

154 { return feHeader_.get(); }

References feHeader_.

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

◆ fePresent()

bool sistrip::FEDBuffer::fePresent ( uint8_t  internalFEUnitNum) const
inline

◆ findChannels()

FEDBufferStatusCode sistrip::FEDBuffer::findChannels ( )

Read the channel lengths from the payload

This method should be called to after the constructor (and should not be called more than once for the same sistrip::FEDBuffer). In case any check fails, a value different from sistrip::FEDBufferStatusCode::SUCCESS is returned, and detailed information printed to LogDebug("FEDBuffer"), if relevant.

See also
sistrip::FEDBuffer::FEDBuffer()

Definition at line 50 of file SiStripFEDBuffer.cc.

50  {
52  //set min length to 2 for ZSLite, 7 for ZS and 3 for raw
53  uint16_t minLength;
54  switch (readoutMode()) {
57  minLength = 7;
58  break;
60  minLength = 2;
61  break;
70  minLength = 2;
71  break;
72  default:
73  minLength = 3;
74  break;
75  }
76  uint16_t offsetBeginningOfChannel = 0;
77  for (uint16_t i = 0; i < FEDCH_PER_FED; i++) {
78  //if FE unit is not enabled then skip rest of FE unit adding NULL pointers
79  if
81  channels_.insert(channels_.end(), uint16_t(FEDCH_PER_FEUNIT), FEDChannel(payloadPointer_, 0, 0));
82  i += FEDCH_PER_FEUNIT - 1;
84  continue;
85  }
86  //if FE unit is enabled
87  //check that channel length bytes fit into buffer
88  if
89  UNLIKELY(offsetBeginningOfChannel + 1 >= payloadLength_) {
91  LogDebug("FEDBuffer") << "Channel " << uint16_t(i) << " (FE unit " << key.feUnit() << " channel "
92  << key.feChan() << " according to external numbering scheme) "
93  << "does not fit into buffer. "
94  << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
95  << "Payload length is " << uint16_t(payloadLength_) << ". ";
97  break;
98  }
99 
100  channels_.push_back(FEDChannel(payloadPointer_, offsetBeginningOfChannel));
101  //get length and check that whole channel fits into buffer
102  uint16_t channelLength = channels_.back().length();
103 
104  //check that the channel length is long enough to contain the header
105  if
106  UNLIKELY(channelLength < minLength) {
108  LogDebug("FEDBuffer") << "Channel " << uint16_t(i) << " (FE unit " << key.feUnit() << " channel "
109  << key.feChan() << " according to external numbering scheme)"
110  << " is too short. "
111  << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
112  << "Channel length is " << uint16_t(channelLength) << ". "
113  << "Min length is " << uint16_t(minLength) << ". ";
115  break;
116  }
117  if
118  UNLIKELY(offsetBeginningOfChannel + channelLength > payloadLength_) {
120  LogDebug("FEDBuffer") << "Channel " << uint16_t(i) << " (FE unit " << key.feUnit() << " channel "
121  << key.feChan() << " according to external numbering scheme)"
122  << "does not fit into buffer. "
123  << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
124  << "Channel length is " << uint16_t(channelLength) << ". "
125  << "Payload length is " << uint16_t(payloadLength_) << ". ";
127  break;
128  }
129 
130  validChannels_++;
131  const uint16_t offsetEndOfChannel = offsetBeginningOfChannel + channelLength;
132  //add padding if necessary and calculate offset for begining of next channel
133  if (!((i + 1) % FEDCH_PER_FEUNIT)) {
134  uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
135  if (numPaddingBytes == 8)
136  numPaddingBytes = 0;
137  offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
138  } else {
139  offsetBeginningOfChannel = offsetEndOfChannel;
140  }
141  }
142  if
143  UNLIKELY(FEDBufferStatusCode::SUCCESS != st) { // for the allowBadBuffer case
144  channels_.insert(channels_.end(), uint16_t(FEDCH_PER_FED - validChannels_), FEDChannel(payloadPointer_, 0, 0));
145  }
146  return st;
147  }

References sistrip::CHANNEL_BEGIN_BEYOND_PAYLOAD, sistrip::CHANNEL_END_BEYOND_PAYLOAD, sistrip::CHANNEL_TOO_SHORT, sistrip::FEDBufferBase::channels_, sistrip::FEDCH_PER_FED, sistrip::FEDCH_PER_FEUNIT, sistrip::FEDBufferBase::feEnabled(), fePresent(), mps_fire::i, crabWrapper::key, LogDebug, 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(), sistrip::SUCCESS, UNLIKELY, and validChannels_.

◆ getCorrectPacketCode()

uint8_t sistrip::FEDBuffer::getCorrectPacketCode ( ) const
inlineprivate

Definition at line 104 of file SiStripFEDBuffer.h.

104 { return packetCode(legacyUnpacker_); }

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

Referenced by checkChannelPacketCodes(), and checkSummary().

◆ nFEUnitsPresent()

uint8_t sistrip::FEDBuffer::nFEUnitsPresent ( ) const
private

Definition at line 393 of file SiStripFEDBuffer.cc.

393  {
394  uint8_t result = 0;
395  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
396  if (fePresent(iFE))
397  result++;
398  }
399  return result;
400  }

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

Referenced by print().

◆ print()

void sistrip::FEDBuffer::print ( std::ostream &  os) const
overridevirtual

Reimplemented from sistrip::FEDBufferBase.

Definition at line 402 of file SiStripFEDBuffer.cc.

402  {
405  os << "FE units with data: " << uint16_t(nFEUnitsPresent()) << std::endl;
406  os << "BE status register flags: ";
407  dynamic_cast<const FEDFullDebugHeader*>(feHeader())->beStatusRegister().printFlags(os);
408  os << std::endl;
409  }
410  }

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

◆ setLegacyMode()

void sistrip::FEDBuffer::setLegacyMode ( bool  legacy)
inline

Definition at line 68 of file SiStripFEDBuffer.h.

68 { legacyUnpacker_ = legacy; }

References legacyUnpacker_.

Member Data Documentation

◆ feHeader_

std::unique_ptr<FEDFEHeader> sistrip::FEDBuffer::feHeader_
private

◆ fePresent_

bool sistrip::FEDBuffer::fePresent_[FEUNITS_PER_FED]
private

Definition at line 110 of file SiStripFEDBuffer.h.

Referenced by FEDBuffer(), and fePresent().

◆ legacyUnpacker_

bool sistrip::FEDBuffer::legacyUnpacker_ = false
private

Definition at line 111 of file SiStripFEDBuffer.h.

Referenced by getCorrectPacketCode(), and setLegacyMode().

◆ payloadLength_

uint16_t sistrip::FEDBuffer::payloadLength_
private

◆ payloadPointer_

const uint8_t* sistrip::FEDBuffer::payloadPointer_
private

Definition at line 107 of file SiStripFEDBuffer.h.

Referenced by FEDBuffer(), and findChannels().

◆ validChannels_

uint8_t sistrip::FEDBuffer::validChannels_
private
sistrip::FEDBuffer::payloadLength_
uint16_t payloadLength_
Definition: SiStripFEDBuffer.h:108
sistrip::FEDBuffer::getCorrectPacketCode
uint8_t getCorrectPacketCode() const
Definition: SiStripFEDBuffer.h:104
sistrip::FEDBuffer::legacyUnpacker_
bool legacyUnpacker_
Definition: SiStripFEDBuffer.h:111
mps_fire.i
i
Definition: mps_fire.py:355
sistrip::FEDBuffer::feGood
bool feGood(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBuffer.h:156
sistrip::READOUT_MODE_PREMIX_RAW
Definition: SiStripFEDBufferComponents.h:61
sistrip::FEDBufferBase::fedStatusRegister
FEDStatusRegister fedStatusRegister() const
Definition: SiStripFEDBufferComponents.h:1498
sistrip::READOUT_MODE_SCOPE
Definition: SiStripFEDBufferComponents.h:47
sistrip::FEDBufferStatusCode::CHANNEL_END_BEYOND_PAYLOAD
sistrip::FEDStatusRegister::feDataMissingFlag
bool feDataMissingFlag(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBufferComponents.h:979
sistrip::FEDBufferBase::getPointerToByteAfterEndOfPayload
const uint8_t * getPointerToByteAfterEndOfPayload() const
Definition: SiStripFEDBufferComponents.h:1550
sistrip::FEDBufferBase::doChecks
virtual bool doChecks() const
Definition: SiStripFEDBufferComponents.cc:1356
sistrip::FEDBufferBase::FEDBufferBase
FEDBufferBase(const FEDRawData &fedBuffer)
Definition: SiStripFEDBufferComponents.cc:1248
sistrip::FEDBufferBase::getPointerToDataAfterTrackerSpecialHeader
const uint8_t * getPointerToDataAfterTrackerSpecialHeader() const
Definition: SiStripFEDBufferComponents.h:1548
SiStripFedKey
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT
Definition: SiStripFEDBufferComponents.h:51
sistrip::FEDBuffer::checkStatusBits
bool checkStatusBits(const uint8_t internalFEDChannelNum) const
Definition: SiStripFEDBuffer.h:167
sistrip::FEDBuffer::checkChannelLengths
bool checkChannelLengths() const
Definition: SiStripFEDBuffer.cc:191
sistrip::FEDBufferBase::checkSummary
virtual std::string checkSummary() const
Definition: SiStripFEDBufferComponents.cc:1358
sistrip::FEDBuffer::feHeader_
std::unique_ptr< FEDFEHeader > feHeader_
Definition: SiStripFEDBuffer.h:106
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10_CMOVERRIDE
Definition: SiStripFEDBufferComponents.h:50
sistrip::HEADER_TYPE_INVALID
Definition: SiStripFEDBufferComponents.h:38
sistrip::FEDBufferBase::feEnabled
bool feEnabled(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBufferComponents.h:1490
sistrip::internalFEDChannelNum
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
Definition: SiStripFEDBufferComponents.h:785
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
sistrip::FEDBufferBase::readoutMode
FEDReadoutMode readoutMode() const
Definition: SiStripFEDBufferComponents.h:1431
sistrip::HEADER_TYPE_NONE
Definition: SiStripFEDBufferComponents.h:41
sistrip::FEDBufferStatusCode::CHANNEL_BEGIN_BEYOND_PAYLOAD
sistrip::FEDBuffer::checkChannelLengthsMatchBufferLength
bool checkChannelLengthsMatchBufferLength() const
Definition: SiStripFEDBuffer.cc:193
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8
Definition: SiStripFEDBufferComponents.h:58
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT_CMOVERRIDE
Definition: SiStripFEDBufferComponents.h:59
sistrip::FEDFEHeader::newFEHeader
static std::unique_ptr< FEDFEHeader > newFEHeader(const FEDHeaderType headerType, const uint8_t *headerBuffer)
Definition: SiStripFEDBufferComponents.h:1136
sistrip::FEUNITS_PER_FED
static const uint16_t FEUNITS_PER_FED
Definition: ConstantsForHardwareSystems.h:29
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10
Definition: SiStripFEDBufferComponents.h:49
sistrip::FEDBufferBase::headerType
FEDHeaderType headerType() const
Definition: SiStripFEDBufferComponents.h:1427
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT_CMOVERRIDE
Definition: SiStripFEDBufferComponents.h:53
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT
Definition: SiStripFEDBufferComponents.h:55
sistrip::FEDBufferStatusCode::CHANNEL_TOO_SHORT
sistrip::HEADER_TYPE_FULL_DEBUG
Definition: SiStripFEDBufferComponents.h:39
sistrip::FEDBufferBase::checkCRC
bool checkCRC() const
Definition: SiStripFEDBufferComponents.h:1524
sistrip::FEDBuffer::checkChannelPacketCodes
bool checkChannelPacketCodes() const
Definition: SiStripFEDBuffer.cc:224
sistrip::FEDBufferBase::majorityAddressErrorForFEUnit
bool majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBufferComponents.h:1486
sistrip::FEDBuffer::validChannels_
uint8_t validChannels_
Definition: SiStripFEDBuffer.h:109
sistrip::FEDBufferBase::channels_
std::vector< FEDChannel > channels_
Definition: SiStripFEDBufferComponents.h:730
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
sistrip::FEDBufferStatusCode::SUCCESS
sistrip::FEDBufferBase::print
virtual void print(std::ostream &os) const
Definition: SiStripFEDBufferComponents.cc:1310
sistrip::FEDBuffer::fePresent
bool fePresent(uint8_t internalFEUnitNum) const
Definition: SiStripFEDBuffer.h:165
sistrip::FEDBuffer::checkFEUnitAPVAddresses
bool checkFEUnitAPVAddresses() const
Definition: SiStripFEDBuffer.cc:246
sistrip::FEDBuffer::fePresent_
bool fePresent_[FEUNITS_PER_FED]
Definition: SiStripFEDBuffer.h:110
sistrip::FEDBuffer::checkAllChannelStatusBits
bool checkAllChannelStatusBits() const
Definition: SiStripFEDBuffer.cc:176
sistrip::FEDBufferBase::feOverflow
bool feOverflow(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBufferComponents.h:1494
sistrip::FEDBuffer::feGoodWithoutAPVEmulatorCheck
bool feGoodWithoutAPVEmulatorCheck(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBuffer.h:161
sistrip::FEDCH_PER_FED
static const uint16_t FEDCH_PER_FED
Definition: ConstantsForHardwareSystems.h:30
sistrip::FEDCH_PER_FEUNIT
static const uint16_t FEDCH_PER_FEUNIT
Definition: ConstantsForHardwareSystems.h:28
sistrip::FEDBuffer::feHeader
const FEDFEHeader * feHeader() const
Definition: SiStripFEDBuffer.h:154
mps_fire.result
result
Definition: mps_fire.py:303
sistrip::FEDBuffer::channelGood
virtual bool channelGood(const uint8_t internalFEDannelNum, const bool doAPVeCheck=true) const
Definition: SiStripFEDBuffer.cc:149
sistrip::FEDBuffer::payloadPointer_
const uint8_t * payloadPointer_
Definition: SiStripFEDBuffer.h:107
sistrip::FEDBufferBase::apveAddress
uint8_t apveAddress() const
Definition: SiStripFEDBufferComponents.h:1484
crabWrapper.key
key
Definition: crabWrapper.py:19
sistrip::FEDBufferBase::packetCode
uint8_t packetCode(bool legacy=false, const uint8_t internalFEDChannelNum=0) const
Definition: SiStripFEDBufferComponents.h:1433
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_CMOVERRIDE
Definition: SiStripFEDBufferComponents.h:54
sistrip::FEDBuffer::nFEUnitsPresent
uint8_t nFEUnitsPresent() const
Definition: SiStripFEDBuffer.cc:393
sistrip::READOUT_MODE_ZERO_SUPPRESSED_FAKE
Definition: SiStripFEDBufferComponents.h:57
sistrip::FEDBuffer::checkFEPayloadsPresent
bool checkFEPayloadsPresent() const
Definition: SiStripFEDBuffer.cc:293
sistrip::FEDBuffer::checkFEUnitLengths
bool checkFEUnitLengths() const
Definition: SiStripFEDBuffer.cc:268
sistrip::READOUT_MODE_ZERO_SUPPRESSED
Definition: SiStripFEDBufferComponents.h:56
sistrip::FEDBuffer::calculateFEUnitLength
uint16_t calculateFEUnitLength(const uint8_t internalFEUnitNumber) const
Definition: SiStripFEDBuffer.cc:284