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

bool channelGood (const uint8_t internalFEDannelNum, const bool doAPVeCheck) 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
 
bool doChecks (bool doCRC) 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
 
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 ( )
inlineoverride

Definition at line 42 of file SiStripFEDBuffer.h.

42 {}

Member Function Documentation

◆ calculateFEUnitLength()

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

Definition at line 257 of file SiStripFEDBuffer.cc.

257  {
258  //get length from channels
259  uint16_t lengthFromChannels = 0;
260  for (uint8_t iCh = 0; iCh < FEDCH_PER_FEUNIT; iCh++) {
261  lengthFromChannels += channels_[internalFEDChannelNum(internalFEUnitNumber, iCh)].length();
262  }
263  return lengthFromChannels;
264  }

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 
) const
inline

◆ checkAllChannelStatusBits()

bool sistrip::FEDBuffer::checkAllChannelStatusBits ( ) const

Definition at line 149 of file SiStripFEDBuffer.cc.

149  {
150  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
151  //if FE unit is disabled then skip all channels on it
152  if (!feGood(iCh / FEDCH_PER_FEUNIT)) {
153  iCh += FEDCH_PER_FEUNIT;
154  continue;
155  }
156  //channel is bad then return false
157  if (!checkStatusBits(iCh))
158  return false;
159  }
160  //if no bad channels have been found then they are all fine
161  return true;
162  }

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

Referenced by checkSummary().

◆ checkChannelLengths()

bool sistrip::FEDBuffer::checkChannelLengths ( ) const

Definition at line 164 of file SiStripFEDBuffer.cc.

164 { return (validChannels_ == FEDCH_PER_FED); }

References sistrip::FEDCH_PER_FED, and validChannels_.

Referenced by checkChannelLengthsMatchBufferLength().

◆ checkChannelLengthsMatchBufferLength()

bool sistrip::FEDBuffer::checkChannelLengthsMatchBufferLength ( ) const

Definition at line 166 of file SiStripFEDBuffer.cc.

166  {
167  //check they fit into buffer
168  if (!checkChannelLengths())
169  return false;
170 
171  //payload length from length of data buffer
172  const uint16_t payloadLengthInWords = payloadLength_ / 8;
173 
174  //find channel length
175  //find last enabled FE unit
176  uint8_t lastEnabledFeUnit = 7;
177  while (!(fePresent(lastEnabledFeUnit) && feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit != 0)
178  lastEnabledFeUnit--;
179  //last channel is last channel on last enabled FE unit
180  const FEDChannel& lastChannel = channels_[internalFEDChannelNum(lastEnabledFeUnit, FEDCH_PER_FEUNIT - 1)];
181  const uint16_t offsetLastChannel = lastChannel.offset();
182  const uint16_t offsetEndOfChannelData = offsetLastChannel + lastChannel.length();
183  const uint16_t channelDataLength = offsetEndOfChannelData;
184  //channel length in words is length in bytes rounded up to nearest word
185  uint16_t channelDataLengthInWords = channelDataLength / 8;
186  if (channelDataLength % 8)
187  channelDataLengthInWords++;
188 
189  //check lengths match
190  if (channelDataLengthInWords == payloadLengthInWords) {
191  return true;
192  } else {
193  return false;
194  }
195  }

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 197 of file SiStripFEDBuffer.cc.

197  {
198  const uint8_t correctPacketCode = getCorrectPacketCode();
199  //if the readout mode if not one which has a packet code then this is set to zero. in this case return true
200  if (!correctPacketCode)
201  return true;
202  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
203  //if FE unit is disabled then skip all channels on it
204  if (!feGood(iCh / FEDCH_PER_FEUNIT)) {
205  iCh += FEDCH_PER_FEUNIT;
206  continue;
207  }
208  //only check enabled, working channels
209  if (FEDBuffer::channelGood(iCh, true)) {
210  //if a channel is bad then return false
211  if (channels_[iCh].packetCode() != correctPacketCode)
212  return false;
213  }
214  }
215  //if no bad channels were found the they are all ok
216  return true;
217  }

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 266 of file SiStripFEDBuffer.cc.

266  {
267  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
268  if (!fePresent(iFE))
269  return false;
270  }
271  return true;
272  }

References fePresent(), and sistrip::FEUNITS_PER_FED.

Referenced by checkSummary().

◆ checkFEUnitAPVAddresses()

bool sistrip::FEDBuffer::checkFEUnitAPVAddresses ( ) const

Definition at line 219 of file SiStripFEDBuffer.cc.

219  {
220  //get golden address
221  const uint8_t goldenAddress = apveAddress();
222  //don't check if the address is 00 since APVe is probably not connected
223  if (goldenAddress == 0x00)
224  return true;
225  //check can only be done for full debug headers
226  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
227  if (!fdHeader)
228  return true;
229  //check all enabled FE units
230  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
231  if (!feGood(iFE))
232  continue;
233  //if address is bad then return false
234  if (fdHeader->feUnitMajorityAddress(iFE) != goldenAddress)
235  return false;
236  }
237  //if no bad addresses were found then return true
238  return true;
239  }

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 241 of file SiStripFEDBuffer.cc.

241  {
242  //check can only be done for full debug headers
243  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
244  if (!fdHeader)
245  return true;
246  //check lengths for enabled FE units
247  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
248  if (!feGood(iFE))
249  continue;
250  if (calculateFEUnitLength(iFE) != fdHeader->feUnitLength(iFE))
251  return false;
252  }
253  //if no errors were encountered then return true
254  return true;
255  }

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 174 of file SiStripFEDBuffer.h.

174  {
175  return feHeader_->checkChannelStatusBits(internalFEDChannelNum);
176  }

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 178 of file SiStripFEDBuffer.h.

178  {
179  return checkStatusBits(internalFEDChannelNum(internalFEUnitNum, internalChannelNum));
180  }

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

◆ checkSummary()

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

Reimplemented from sistrip::FEDBufferBase.

Definition at line 274 of file SiStripFEDBuffer.cc.

274  {
275  std::ostringstream summary;
277  summary << "Check FE unit payloads are all present: " << (checkFEPayloadsPresent() ? "passed" : "FAILED")
278  << std::endl;
279  if (!checkFEPayloadsPresent()) {
280  summary << "FE units missing payloads: ";
281  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
282  if (!fePresent(iFE))
283  summary << uint16_t(iFE) << " ";
284  }
285  summary << std::endl;
286  }
287  summary << "Check channel status bits: " << (checkAllChannelStatusBits() ? "passed" : "FAILED") << std::endl;
288  if (!checkAllChannelStatusBits()) {
289  unsigned int badChannels = 0;
291  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
292  if (fdHeader) {
293  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
294  if (!feGood(iCh / FEDCH_PER_FEUNIT))
295  continue;
296  if (!checkStatusBits(iCh)) {
297  summary << uint16_t(iCh) << ": " << fdHeader->getChannelStatus(iCh) << std::endl;
298  badChannels++;
299  }
300  }
301  }
302  } else {
303  summary << "Channels with errors: ";
304  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
305  if (!feGood(iCh / FEDCH_PER_FEUNIT))
306  continue;
307  if (!checkStatusBits(iCh)) {
308  summary << uint16_t(iCh) << " ";
309  badChannels++;
310  }
311  }
312  summary << std::endl;
313  }
314  summary << "Number of channels with bad status bits: " << badChannels << std::endl;
315  }
316  summary << "Check channel lengths match buffer length: "
317  << (checkChannelLengthsMatchBufferLength() ? "passed" : "FAILED") << std::endl;
318  summary << "Check channel packet codes: " << (checkChannelPacketCodes() ? "passed" : "FAILED") << std::endl;
319  if (!checkChannelPacketCodes()) {
320  summary << "Channels with bad packet codes: ";
321  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
322  if (!feGood(iCh / FEDCH_PER_FEUNIT))
323  continue;
324  if (channels_[iCh].packetCode() != getCorrectPacketCode())
325  summary << uint16_t(iCh) << " ";
326  }
327  }
328  summary << "Check FE unit lengths: " << (checkFEUnitLengths() ? "passed" : "FAILED") << std::endl;
329  if (!checkFEUnitLengths()) {
330  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
331  if (fdHeader) {
332  summary << "Bad FE units:" << std::endl;
333  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
334  if (!feGood(iFE))
335  continue;
336  uint16_t lengthFromChannels = calculateFEUnitLength(iFE);
337  uint16_t lengthFromHeader = fdHeader->feUnitLength(iFE);
338  if (lengthFromHeader != lengthFromChannels) {
339  summary << "FE unit: " << uint16_t(iFE) << " length in header: " << lengthFromHeader
340  << " length from channel lengths: " << lengthFromChannels << std::endl;
341  }
342  }
343  }
344  }
345  summary << "Check FE unit APV addresses match APVe: " << (checkFEUnitAPVAddresses() ? "passed" : "FAILED")
346  << std::endl;
347  if (!checkFEUnitAPVAddresses()) {
348  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
349  if (fdHeader) {
350  const uint8_t goldenAddress = apveAddress();
351  summary << "Address from APVe:" << uint16_t(goldenAddress) << std::endl;
352  summary << "Bad FE units:" << std::endl;
353  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
354  if (!feGood(iFE))
355  continue;
356  if (fdHeader->feUnitMajorityAddress(iFE) != goldenAddress) {
357  summary << "FE unit: " << uint16_t(iFE)
358  << " majority address: " << uint16_t(fdHeader->feUnitMajorityAddress(iFE)) << std::endl;
359  }
360  }
361  }
362  }
363  return summary.str();
364  }

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) const
inline

Definition at line 182 of file SiStripFEDBuffer.h.

182  {
183  //check that all channels were unpacked properly
184  return (validChannels_ == FEDCH_PER_FED) &
185  //do checks from base class
187  // check crc if required
188  (!doCRC || checkCRC());
189  }

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

◆ doCorruptBufferChecks()

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

Definition at line 142 of file SiStripFEDBuffer.cc.

142  {
144  //checkClusterLengths() &&
146  //checkFEUnitAPVAddresses() );
147  }

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 168 of file SiStripFEDBuffer.h.

168  {
169  return (!feOverflow(internalFEUnitNum) && fePresent(internalFEUnitNum));
170  }

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 48 of file SiStripFEDBuffer.cc.

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

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 366 of file SiStripFEDBuffer.cc.

366  {
367  uint8_t result = 0;
368  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
369  if (fePresent(iFE))
370  result++;
371  }
372  return result;
373  }

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 375 of file SiStripFEDBuffer.cc.

375  {
378  os << "FE units with data: " << uint16_t(nFEUnitsPresent()) << std::endl;
379  os << "BE status register flags: ";
380  dynamic_cast<const FEDFullDebugHeader*>(feHeader())->beStatusRegister().printFlags(os);
381  os << std::endl;
382  }
383  }

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:428
sistrip::FEDBuffer::feGood
bool feGood(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBuffer.h:163
sistrip::READOUT_MODE_PREMIX_RAW
Definition: SiStripFEDBufferComponents.h:61
sistrip::FEDBufferBase::fedStatusRegister
FEDStatusRegister fedStatusRegister() const
Definition: SiStripFEDBufferComponents.h:1500
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:1552
sistrip::FEDBufferBase::doChecks
bool doChecks() const
Definition: SiStripFEDBufferComponents.h:1433
sistrip::FEDBufferBase::FEDBufferBase
FEDBufferBase(const FEDRawData &fedBuffer)
Definition: SiStripFEDBufferComponents.cc:1248
sistrip::FEDBufferBase::getPointerToDataAfterTrackerSpecialHeader
const uint8_t * getPointerToDataAfterTrackerSpecialHeader() const
Definition: SiStripFEDBufferComponents.h:1550
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:174
sistrip::FEDBuffer::checkChannelLengths
bool checkChannelLengths() const
Definition: SiStripFEDBuffer.cc:164
sistrip::FEDBufferBase::checkSummary
virtual std::string checkSummary() const
Definition: SiStripFEDBufferComponents.cc:1356
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:1492
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:166
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:233
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:1526
sistrip::FEDBuffer::checkChannelPacketCodes
bool checkChannelPacketCodes() const
Definition: SiStripFEDBuffer.cc:197
sistrip::FEDBufferBase::majorityAddressErrorForFEUnit
bool majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBufferComponents.h:1488
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:172
sistrip::FEDBuffer::checkFEUnitAPVAddresses
bool checkFEUnitAPVAddresses() const
Definition: SiStripFEDBuffer.cc:219
sistrip::FEDBuffer::fePresent_
bool fePresent_[FEUNITS_PER_FED]
Definition: SiStripFEDBuffer.h:110
sistrip::FEDBuffer::checkAllChannelStatusBits
bool checkAllChannelStatusBits() const
Definition: SiStripFEDBuffer.cc:149
sistrip::FEDBufferBase::feOverflow
bool feOverflow(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBufferComponents.h:1496
sistrip::FEDBuffer::feGoodWithoutAPVEmulatorCheck
bool feGoodWithoutAPVEmulatorCheck(const uint8_t internalFEUnitNum) const
Definition: SiStripFEDBuffer.h:168
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
sistrip::FEDBuffer::channelGood
bool channelGood(const uint8_t internalFEDannelNum, const bool doAPVeCheck) const
Definition: SiStripFEDBuffer.h:156
mps_fire.result
result
Definition: mps_fire.py:311
sistrip::FEDBuffer::payloadPointer_
const uint8_t * payloadPointer_
Definition: SiStripFEDBuffer.h:107
sistrip::FEDBufferBase::apveAddress
uint8_t apveAddress() const
Definition: SiStripFEDBufferComponents.h:1486
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:1435
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_CMOVERRIDE
Definition: SiStripFEDBufferComponents.h:54
sistrip::FEDBuffer::nFEUnitsPresent
uint8_t nFEUnitsPresent() const
Definition: SiStripFEDBuffer.cc:366
sistrip::READOUT_MODE_ZERO_SUPPRESSED_FAKE
Definition: SiStripFEDBufferComponents.h:57
sistrip::FEDBuffer::checkFEPayloadsPresent
bool checkFEPayloadsPresent() const
Definition: SiStripFEDBuffer.cc:266
sistrip::FEDBuffer::checkFEUnitLengths
bool checkFEUnitLengths() const
Definition: SiStripFEDBuffer.cc:241
sistrip::READOUT_MODE_ZERO_SUPPRESSED
Definition: SiStripFEDBufferComponents.h:56
sistrip::FEDBuffer::calculateFEUnitLength
uint16_t calculateFEUnitLength(const uint8_t internalFEUnitNumber) const
Definition: SiStripFEDBuffer.cc:257