CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
sistrip::FEDBuffer Class Reference

#include <SiStripFEDBuffer.h>

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

Public Member Functions

virtual bool channelGood (const uint8_t internalFEDannelNum) 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
 
virtual std::string checkSummary () const
 
virtual bool doChecks () const
 
virtual bool doCorruptBufferChecks () const
 
 FEDBuffer (const uint8_t *fedBuffer, const size_t fedBufferSize, const bool allowBadBuffer=false)
 
bool feGood (const uint8_t internalFEUnitNum) const
 
const FEDFEHeaderfeHeader () const
 
bool fePresent (uint8_t internalFEUnitNum) const
 
virtual void print (std::ostream &os) const
 
virtual ~FEDBuffer ()
 
- 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
 
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
 
FEDDataType dataType () 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
 
bool majorityAddressErrorForFEUnit (const uint8_t internalFEUnitNum) const
 
uint8_t nFEUnitsEnabled () 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::auto_ptr< FEDFEHeaderfeHeader_
 
bool fePresent_ [FEUNITS_PER_FED]
 
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 19 of file SiStripFEDBuffer.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file SiStripFEDBuffer.cc.

References sistrip::FEDBufferBase::channels_, edm::hlt::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(), sistrip::FEDBufferBase::trackerSpecialHeader(), and validChannels_.

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

Definition at line 67 of file SiStripFEDBuffer.cc.

68  {
69  }

Member Function Documentation

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

Definition at line 273 of file SiStripFEDBuffer.cc.

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

Referenced by checkFEUnitLengths(), and checkSummary().

274  {
275  //get length from channels
276  uint16_t lengthFromChannels = 0;
277  for (uint8_t iCh = 0; iCh < FEDCH_PER_FEUNIT; iCh++) {
278  lengthFromChannels += channels_[internalFEDChannelNum(internalFEUnitNumber,iCh)].length();
279  }
280  return lengthFromChannels;
281  }
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
virtual

Reimplemented from sistrip::FEDBufferBase.

Definition at line 142 of file SiStripFEDBuffer.cc.

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

Referenced by checkChannelPacketCodes(), and sistrip::RawToClustersLazyUnpacker::fill().

143  {
144  return ( (internalFEDChannelNum < validChannels_) &&
147  }
bool checkStatusBits(const uint8_t internalFEDChannelNum) const
FEDReadoutMode readoutMode() const
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
static const uint16_t FEDCH_PER_FEUNIT
bool feGood(const uint8_t internalFEUnitNum) const
bool sistrip::FEDBuffer::checkAllChannelStatusBits ( ) const

Definition at line 170 of file SiStripFEDBuffer.cc.

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

Referenced by checkSummary().

171  {
172  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
173  //if FE unit is disabled then skip all channels on it
174  if (!feGood(iCh/FEDCH_PER_FEUNIT)) {
175  iCh += FEDCH_PER_FEUNIT;
176  continue;
177  }
178  //channel is bad then return false
179  if (!checkStatusBits(iCh)) return false;
180  }
181  //if no bad channels have been found then they are all fine
182  return true;
183  }
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 185 of file SiStripFEDBuffer.cc.

References sistrip::FEDCH_PER_FED, and validChannels_.

Referenced by checkChannelLengthsMatchBufferLength().

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

Definition at line 190 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(), and doCorruptBufferChecks().

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

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

Referenced by checkSummary(), and doCorruptBufferChecks().

220  {
221  const uint8_t correctPacketCode = getCorrectPacketCode();
222  //if the readout mode if not one which has a packet code then this is set to zero. in this case return true
223  if (!correctPacketCode) return true;
224  for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
225  //if FE unit is disabled then skip all channels on it
226  if (!feGood(iCh/FEDCH_PER_FEUNIT)) {
227  iCh += FEDCH_PER_FEUNIT;
228  continue;
229  }
230  //only check enabled, working channels
231  if (channelGood(iCh)) {
232  //if a channel is bad then return false
233  if (channels_[iCh].packetCode() != correctPacketCode) return false;
234  }
235  }
236  //if no bad channels were found the they are all ok
237  return true;
238  }
virtual bool channelGood(const uint8_t internalFEDannelNum) 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 283 of file SiStripFEDBuffer.cc.

References fePresent(), and sistrip::FEUNITS_PER_FED.

Referenced by checkSummary().

284  {
285  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
286  if (!fePresent(iFE)) return false;
287  }
288  return true;
289  }
bool fePresent(uint8_t internalFEUnitNum) const
static const uint16_t FEUNITS_PER_FED
bool sistrip::FEDBuffer::checkFEUnitAPVAddresses ( ) const

Definition at line 240 of file SiStripFEDBuffer.cc.

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

Referenced by checkSummary().

241  {
242  //get golden address
243  const uint8_t goldenAddress = apveAddress();
244  //don't check if the address is 00 since APVe is probably not connected
245  if (goldenAddress == 0x00) return true;
246  //check can only be done for full debug headers
247  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
248  if (!fdHeader) return true;
249  //check all enabled FE units
250  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
251  if (!feGood(iFE)) continue;
252  //if address is bad then return false
253  if (fdHeader->feUnitMajorityAddress(iFE) != goldenAddress) return false;
254  }
255  //if no bad addresses were found then return true
256  return true;
257  }
std::auto_ptr< FEDFEHeader > feHeader_
static const uint16_t FEUNITS_PER_FED
bool feGood(const uint8_t internalFEUnitNum) const
bool sistrip::FEDBuffer::checkFEUnitLengths ( ) const

Definition at line 259 of file SiStripFEDBuffer.cc.

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

Referenced by checkSummary(), and doCorruptBufferChecks().

260  {
261  //check can only be done for full debug headers
262  const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
263  if (!fdHeader) return true;
264  //check lengths for enabled FE units
265  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
266  if (!feGood(iFE)) continue;
267  if (calculateFEUnitLength(iFE) != fdHeader->feUnitLength(iFE)) return false;
268  }
269  //if no errors were encountered then return true
270  return true;
271  }
std::auto_ptr< FEDFEHeader > feHeader_
static const uint16_t FEUNITS_PER_FED
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 148 of file SiStripFEDBuffer.h.

References feHeader_.

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

149  {
150  return feHeader_->checkChannelStatusBits(internalFEDChannelNum);
151  }
std::auto_ptr< FEDFEHeader > feHeader_
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
bool sistrip::FEDBuffer::checkStatusBits ( const uint8_t  internalFEUnitNum,
const uint8_t  internalChannelNum 
) const
inline

Definition at line 153 of file SiStripFEDBuffer.h.

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

154  {
155  return checkStatusBits(internalFEDChannelNum(internalFEUnitNum,internalChannelNum));
156  }
bool checkStatusBits(const uint8_t internalFEDChannelNum) const
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
std::string sistrip::FEDBuffer::checkSummary ( ) const
virtual

Reimplemented from sistrip::FEDBufferBase.

Definition at line 291 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(), and summarizeEdmComparisonLogfiles::summary.

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

Reimplemented from sistrip::FEDBufferBase.

Definition at line 149 of file SiStripFEDBuffer.cc.

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

Referenced by sistrip::RawToClustersLazyUnpacker::fill().

150  {
151  //check that all channels were unpacked properly
152  if (validChannels_ != FEDCH_PER_FED) return false;
153  //do checks from base class
154  if (!FEDBufferBase::doChecks()) return false;
155  //check CRC
156  if (!checkCRC()) return false;
157  return true;
158  }
static const uint16_t FEDCH_PER_FED
bool sistrip::FEDBuffer::doCorruptBufferChecks ( ) const
virtual

Definition at line 160 of file SiStripFEDBuffer.cc.

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

161  {
162  return ( checkCRC() &&
165  //checkClusterLengths() &&
166  checkFEUnitLengths() );
167  //checkFEUnitAPVAddresses() );
168  }
bool checkFEUnitLengths() const
bool checkChannelPacketCodes() const
bool checkChannelLengthsMatchBufferLength() const
bool sistrip::FEDBuffer::feGood ( const uint8_t  internalFEUnitNum) const
inline

Definition at line 138 of file SiStripFEDBuffer.h.

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

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

139  {
140  return ( !majorityAddressErrorForFEUnit(internalFEUnitNum) && !feOverflow(internalFEUnitNum) && fePresent(internalFEUnitNum) );
141  }
bool fePresent(uint8_t internalFEUnitNum) const
bool majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const
bool feOverflow(const uint8_t internalFEUnitNum) const
const FEDFEHeader * sistrip::FEDBuffer::feHeader ( ) const
inline

Definition at line 133 of file SiStripFEDBuffer.h.

References feHeader_.

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

134  {
135  return feHeader_.get();
136  }
std::auto_ptr< FEDFEHeader > feHeader_
bool sistrip::FEDBuffer::fePresent ( uint8_t  internalFEUnitNum) const
inline

Definition at line 143 of file SiStripFEDBuffer.h.

References fePresent_.

Referenced by checkChannelLengthsMatchBufferLength(), checkFEPayloadsPresent(), checkSummary(), feGood(), findChannels(), and nFEUnitsPresent().

144  {
145  return fePresent_[internalFEUnitNum];
146  }
bool fePresent_[FEUNITS_PER_FED]
void sistrip::FEDBuffer::findChannels ( )
private

Definition at line 71 of file SiStripFEDBuffer.cc.

References sistrip::FEDBufferBase::channels_, edm::hlt::Exception, SiStripFedKey::feChan(), sistrip::FEDCH_PER_FED, sistrip::FEDCH_PER_FEUNIT, sistrip::FEDBufferBase::feEnabled(), fePresent(), SiStripFedKey::feUnit(), i, combine::key, payloadLength_, payloadPointer_, sistrip::READOUT_MODE_ZERO_SUPPRESSED, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE, sistrip::FEDBufferBase::readoutMode(), and validChannels_.

Referenced by FEDBuffer().

72  {
73  //set min length to 2 for ZSLite, 7 for ZS and 3 for raw
74  uint16_t minLength;
75  switch (readoutMode()) {
77  minLength = 7;
78  break;
80  minLength = 2;
81  break;
82  default:
83  minLength = 3;
84  break;
85  }
86  size_t offsetBeginningOfChannel = 0;
87  for (size_t i = 0; i < FEDCH_PER_FED; i++) {
88  //if FE unit is not enabled then skip rest of FE unit adding NULL pointers
90  channels_.insert(channels_.end(),size_t(FEDCH_PER_FEUNIT),FEDChannel(payloadPointer_,0,0));
91  i += FEDCH_PER_FEUNIT-1;
93  continue;
94  }
95  //if FE unit is enabled
96  //check that channel length bytes fit into buffer
97  if (offsetBeginningOfChannel+1 >= payloadLength_) {
98  std::ostringstream ss;
100  ss << "Channel " << uint16_t(i) << " (FE unit " << key.feUnit() << " channel " << key.feChan() << " according to external numbering scheme)"
101  << " does not fit into buffer. "
102  << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
103  << "Payload length is " << uint16_t(payloadLength_) << ". ";
104  throw cms::Exception("FEDBuffer") << ss.str();
105  }
106  channels_.push_back(FEDChannel(payloadPointer_,offsetBeginningOfChannel));
107  //get length and check that whole channel fits into buffer
108  uint16_t channelLength = channels_.back().length();
109  //check that the channel length is long enough to contain the header
110  if (channelLength < minLength) {
112  std::ostringstream ss;
113  ss << "Channel " << uint16_t(i) << " (FE unit " << key.feUnit() << " channel " << key.feChan() << " according to external numbering scheme)"
114  << " is too short. "
115  << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
116  << "Channel length is " << uint16_t(channelLength) << ". "
117  << "Min length is " << uint16_t(minLength) << ". ";
118  throw cms::Exception("FEDBuffer") << ss.str();
119  }
120  if (offsetBeginningOfChannel+channelLength > payloadLength_) {
122  std::ostringstream ss;
123  ss << "Channel " << uint16_t(i) << " (FE unit " << key.feUnit() << " channel " << key.feChan() << " according to external numbering scheme)"
124  << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
125  << "Channel length is " << uint16_t(channelLength) << ". "
126  << "Payload length is " << uint16_t(payloadLength_) << ". ";
127  throw cms::Exception("FEDBuffer") << ss.str();
128  }
129  validChannels_++;
130  const size_t offsetEndOfChannel = offsetBeginningOfChannel+channelLength;
131  //add padding if necessary and calculate offset for begining of next channel
132  if (!( (i+1) % FEDCH_PER_FEUNIT )) {
133  uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
134  if (numPaddingBytes == 8) numPaddingBytes = 0;
135  offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
136  } else {
137  offsetBeginningOfChannel = offsetEndOfChannel;
138  }
139  }
140  }
int i
Definition: DBlmapReader.cc:9
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:57
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
list key
Definition: combine.py:13
static const uint16_t FEDCH_PER_FED
uint8_t sistrip::FEDBuffer::getCorrectPacketCode ( ) const
private

Definition at line 376 of file SiStripFEDBuffer.cc.

References sistrip::PACKET_CODE_PROC_RAW, sistrip::PACKET_CODE_SCOPE, sistrip::PACKET_CODE_VIRGIN_RAW, sistrip::PACKET_CODE_ZERO_SUPPRESSED, sistrip::READOUT_MODE_INVALID, sistrip::READOUT_MODE_PROC_RAW, sistrip::READOUT_MODE_SCOPE, sistrip::READOUT_MODE_SPY, sistrip::READOUT_MODE_VIRGIN_RAW, sistrip::READOUT_MODE_ZERO_SUPPRESSED, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE, and sistrip::FEDBufferBase::readoutMode().

Referenced by checkChannelPacketCodes(), and checkSummary().

377  {
378  switch(readoutMode()) {
379  case READOUT_MODE_SCOPE:
380  return PACKET_CODE_SCOPE;
381  break;
383  return PACKET_CODE_VIRGIN_RAW;
384  break;
386  return PACKET_CODE_PROC_RAW;
387  break;
390  break;
392  case READOUT_MODE_SPY:
394  default:
395  return 0;
396  }
397  }
static const uint8_t PACKET_CODE_SCOPE
FEDReadoutMode readoutMode() const
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED
static const uint8_t PACKET_CODE_PROC_RAW
static const uint8_t PACKET_CODE_VIRGIN_RAW
uint8_t sistrip::FEDBuffer::nFEUnitsPresent ( ) const
private

Definition at line 399 of file SiStripFEDBuffer.cc.

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

Referenced by print().

400  {
401  uint8_t result = 0;
402  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
403  if (fePresent(iFE)) result++;
404  }
405  return result;
406  }
bool fePresent(uint8_t internalFEUnitNum) const
static const uint16_t FEUNITS_PER_FED
tuple result
Definition: query.py:137
void sistrip::FEDBuffer::print ( std::ostream &  os) const
virtual

Reimplemented from sistrip::FEDBufferBase.

Definition at line 408 of file SiStripFEDBuffer.cc.

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

409  {
412  os << "FE units with data: " << uint16_t(nFEUnitsPresent()) << std::endl;
413  os << "BE status register flags: ";
414  dynamic_cast<const FEDFullDebugHeader*>(feHeader())->beStatusRegister().printFlags(os);
415  os << std::endl;
416  }
417  }
const FEDFEHeader * feHeader() const
FEDHeaderType headerType() const
uint8_t nFEUnitsPresent() const
virtual void print(std::ostream &os) const

Member Data Documentation

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

Definition at line 76 of file SiStripFEDBuffer.h.

Referenced by FEDBuffer(), and fePresent().

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

Definition at line 73 of file SiStripFEDBuffer.h.

Referenced by FEDBuffer(), and findChannels().

uint8_t sistrip::FEDBuffer::validChannels_
private