CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

sistrip::FEDBuffer Class Reference

#include <SiStripFEDBuffer.h>

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

List of all members.

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 internalFEUnitNum, const uint8_t internalChannelNum) const
bool checkStatusBits (const uint8_t internalFEDChannelNum) 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 ()

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_

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_, ExpressReco_HICollisions_FallBack::e, Exception, sistrip::FEDStatusRegister::feDataMissingFlag(), sistrip::FEDCH_PER_FED, sistrip::FEDBufferBase::fedStatusRegister(), feHeader_, sistrip::FEDFullDebugHeader::fePresent(), fePresent_, sistrip::FEUNITS_PER_FED, findChannels(), sistrip::FEDBufferBase::getPointerToByteAfterEndOfPayload(), sistrip::FEDBufferBase::getPointerToDataAfterTrackerSpecialHeader(), sistrip::HEADER_TYPE_INVALID, sistrip::HEADER_TYPE_NONE, sistrip::FEDBufferBase::headerType(), sistrip::TrackerSpecialHeader::headerTypeNibble(), sistrip::FEDFEHeader::newFEHeader(), payloadLength_, payloadPointer_, sistrip::printHex(), sistrip::READOUT_MODE_SPY, sistrip::FEDBufferBase::readoutMode(), sistrip::FEDBufferBase::trackerSpecialHeader(), and validChannels_.

    : FEDBufferBase(fedBuffer,fedBufferSize,allowBadBuffer,false)
  {
    channels_.reserve(FEDCH_PER_FED);
    //build the correct type of FE header object
    if ( (headerType() != HEADER_TYPE_INVALID) && (headerType() != HEADER_TYPE_NONE) ) {
      feHeader_ = FEDFEHeader::newFEHeader(headerType(),getPointerToDataAfterTrackerSpecialHeader());
      payloadPointer_ = getPointerToDataAfterTrackerSpecialHeader()+feHeader_->lengthInBytes();
    } else {
      feHeader_ = std::auto_ptr<FEDFEHeader>();
      payloadPointer_ = getPointerToDataAfterTrackerSpecialHeader();
      if (!allowBadBuffer) {
        std::ostringstream ss;
        ss << "Header type is invalid. "
           << "Header type nibble is ";
        uint8_t headerNibble = trackerSpecialHeader().headerTypeNibble();
        printHex(&headerNibble,1,ss);
        ss << ". ";
        throw cms::Exception("FEDBuffer") << ss.str();
      }
    }
    if (readoutMode() == READOUT_MODE_SPY) {
      throw cms::Exception("FEDBuffer") << "Unpacking of spy channel data with FEDBuffer is not supported" << std::endl;
    }
    payloadLength_ = getPointerToByteAfterEndOfPayload()-payloadPointer_;
    //check if FE units are present in data
    //in Full Debug mode, use the lengths from the header
    const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
    if (fdHeader) {
      for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
        if (fdHeader->fePresent(iFE)) fePresent_[iFE] = true;
        else fePresent_[iFE] = false;
      }
    }
    //in APV error mode, use the FE present byte in the FED status register
    // a value of '1' means a FE unit's data is missing (in old firmware versions it is always 0)
    else {
      for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
      if (fedStatusRegister().feDataMissingFlag(iFE)) fePresent_[iFE] = false;
      else fePresent_[iFE] = true;
      }
    }
    //try to find channels
    validChannels_ = 0;
    try {
      findChannels();
    } catch (const cms::Exception& e) {
      //if there was a problem either rethrow the exception or just mark channel pointers NULL
      if (!allowBadBuffer) throw;
      else {
        channels_.insert(channels_.end(),size_t(FEDCH_PER_FED-validChannels_),FEDChannel(payloadPointer_,0,0));
      }
    }
  }
sistrip::FEDBuffer::~FEDBuffer ( ) [virtual]

Definition at line 67 of file SiStripFEDBuffer.cc.

  {
  }

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().

  {
    //get length from channels
    uint16_t lengthFromChannels = 0;
    for (uint8_t iCh = 0; iCh < FEDCH_PER_FEUNIT; iCh++) {
      lengthFromChannels += channels_[internalFEDChannelNum(internalFEUnitNumber,iCh)].length();
    }
    return lengthFromChannels;
  }
bool sistrip::FEDBuffer::channelGood ( const uint8_t  internalFEDannelNum) const [virtual]
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().

  {
    for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
      //if FE unit is disabled then skip all channels on it
      if (!feGood(iCh/FEDCH_PER_FEUNIT)) {
        iCh += FEDCH_PER_FEUNIT;
        continue;
      }
      //channel is bad then return false
      if (!checkStatusBits(iCh)) return false;
    }
    //if no bad channels have been found then they are all fine
    return true;
  }
bool sistrip::FEDBuffer::checkChannelLengths ( ) const

Definition at line 185 of file SiStripFEDBuffer.cc.

References sistrip::FEDCH_PER_FED, and validChannels_.

Referenced by checkChannelLengthsMatchBufferLength().

  {
    return (validChannels_ == 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().

  {
    //check they fit into buffer
    if (!checkChannelLengths()) return false;
  
    //payload length from length of data buffer
    const size_t payloadLengthInWords = payloadLength_/8;
  
    //find channel length
    //find last enabled FE unit
    uint8_t lastEnabledFeUnit = 7;
    while ( !(fePresent(lastEnabledFeUnit) && feEnabled(lastEnabledFeUnit)) && lastEnabledFeUnit!=0 ) lastEnabledFeUnit--;
    //last channel is last channel on last enabled FE unit
    const FEDChannel& lastChannel = channels_[internalFEDChannelNum(lastEnabledFeUnit,FEDCH_PER_FEUNIT-1)];
    const size_t offsetLastChannel = lastChannel.offset();
    const size_t offsetEndOfChannelData = offsetLastChannel+lastChannel.length();
    const size_t channelDataLength = offsetEndOfChannelData;
    //channel length in words is length in bytes rounded up to nearest word
    size_t channelDataLengthInWords = channelDataLength/8;
    if (channelDataLength % 8) channelDataLengthInWords++;
  
    //check lengths match
    if (channelDataLengthInWords == payloadLengthInWords) {
      return true;
    } else {
      return false;
    }
  }
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().

  {
    const uint8_t correctPacketCode = getCorrectPacketCode();
    //if the readout mode if not one which has a packet code then this is set to zero. in this case return true
    if (!correctPacketCode) return true;
    for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
      //if FE unit is disabled then skip all channels on it
      if (!feGood(iCh/FEDCH_PER_FEUNIT)) {
        iCh += FEDCH_PER_FEUNIT;
        continue;
      }
      //only check enabled, working channels
      if (channelGood(iCh)) {
        //if a channel is bad then return false
        if (channels_[iCh].packetCode() != correctPacketCode) return false;
      }
    }
    //if no bad channels were found the they are all ok
    return true;
  }
bool sistrip::FEDBuffer::checkFEPayloadsPresent ( ) const

Definition at line 283 of file SiStripFEDBuffer.cc.

References fePresent(), and sistrip::FEUNITS_PER_FED.

Referenced by checkSummary().

  {
    for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
      if (!fePresent(iFE)) return false;
    }
    return true;
  }
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().

  {
    //get golden address
    const uint8_t goldenAddress = apveAddress();
    //don't check if the address is 00 since APVe is probably not connected
    if (goldenAddress == 0x00) return true;
    //check can only be done for full debug headers
    const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
    if (!fdHeader) return true;
    //check all enabled FE units
    for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
      if (!feGood(iFE)) continue;
      //if address is bad then return false
      if (fdHeader->feUnitMajorityAddress(iFE) != goldenAddress) return false;
    }
    //if no bad addresses were found then return true
    return true;
  }
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().

  {
    //check can only be done for full debug headers
    const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
    if (!fdHeader) return true;
    //check lengths for enabled FE units
    for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
      if (!feGood(iFE)) continue;
      if (calculateFEUnitLength(iFE) != fdHeader->feUnitLength(iFE)) return false;
    }
    //if no errors were encountered then return true
    return true;
  }
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().

    {
      return feHeader_->checkChannelStatusBits(internalFEDChannelNum);
    }
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().

    {
      return checkStatusBits(internalFEDChannelNum(internalFEUnitNum,internalChannelNum));
    }
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::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 edmLumisInFiles::summary.

  {
    std::ostringstream summary;
    summary << FEDBufferBase::checkSummary();
    summary << "Check FE unit payloads are all present: " << (checkFEPayloadsPresent() ? "passed" : "FAILED" ) << std::endl;
    if (!checkFEPayloadsPresent()) {
      summary << "FE units missing payloads: ";
      for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
        if (!fePresent(iFE)) summary << uint16_t(iFE) << " ";
      }
      summary << std::endl;
    }
    summary << "Check channel status bits: " << ( checkAllChannelStatusBits() ? "passed" : "FAILED" ) << std::endl;
    if (!checkAllChannelStatusBits()) {
      unsigned int badChannels = 0;
      if (headerType() == HEADER_TYPE_FULL_DEBUG) {
        const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
        if (fdHeader) {
          for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
            if (!feGood(iCh/FEDCH_PER_FEUNIT)) continue;
            if (!checkStatusBits(iCh)) {
              summary << uint16_t(iCh) << ": " << fdHeader->getChannelStatus(iCh) << std::endl;
              badChannels++;
            }
          }
        }
      } else {
        summary << "Channels with errors: ";
        for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
          if (!feGood(iCh/FEDCH_PER_FEUNIT)) continue;
          if (!checkStatusBits(iCh)) {
            summary << uint16_t(iCh) << " ";
            badChannels++;
          }
        }
        summary << std::endl;
      } 
      summary << "Number of channels with bad status bits: " << badChannels << std::endl;
    }
    summary << "Check channel lengths match buffer length: " << ( checkChannelLengthsMatchBufferLength() ? "passed" : "FAILED" ) << std::endl;
    summary << "Check channel packet codes: " << ( checkChannelPacketCodes() ? "passed" : "FAILED" ) << std::endl;
    if (!checkChannelPacketCodes()) {
      summary << "Channels with bad packet codes: ";
      for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
        if (!feGood(iCh/FEDCH_PER_FEUNIT)) continue;
        if (channels_[iCh].packetCode() != getCorrectPacketCode())
          summary << uint16_t(iCh) << " ";
      }
    }
    summary << "Check FE unit lengths: " << ( checkFEUnitLengths() ? "passed" : "FAILED" ) << std::endl;
    if (!checkFEUnitLengths()) {
      const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
      if (fdHeader) {
        summary << "Bad FE units:" << std::endl;
        for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
          if (!feGood(iFE)) continue;
          uint16_t lengthFromChannels = calculateFEUnitLength(iFE);
          uint16_t lengthFromHeader = fdHeader->feUnitLength(iFE);
          if (lengthFromHeader != lengthFromChannels) {
            summary << "FE unit: " << uint16_t(iFE) 
                    << " length in header: " << lengthFromHeader 
                    << " length from channel lengths: " << lengthFromChannels << std::endl;
          }
        }
      }
    }
    summary << "Check FE unit APV addresses match APVe: " << ( checkFEUnitAPVAddresses() ? "passed" : "FAILED" ) << std::endl;
    if (!checkFEUnitAPVAddresses()) {
      const FEDFullDebugHeader* fdHeader = dynamic_cast<FEDFullDebugHeader*>(feHeader_.get());
      if (fdHeader) {
        const uint8_t goldenAddress = apveAddress();
        summary << "Address from APVe:" << uint16_t(goldenAddress) << std::endl;
        summary << "Bad FE units:" << std::endl;
        for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
          if (!feGood(iFE)) continue;
          if (fdHeader->feUnitMajorityAddress(iFE) != goldenAddress) {
            summary << "FE unit: " << uint16_t(iFE)
                    << " majority address: " << uint16_t(fdHeader->feUnitMajorityAddress(iFE)) << std::endl;
          }
        }
      }
    }
    return summary.str();
  }
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().

  {
    //check that all channels were unpacked properly
    if (validChannels_ != FEDCH_PER_FED) return false;
    //do checks from base class
    if (!FEDBufferBase::doChecks()) return false;
    //check CRC
    if (!checkCRC()) return false;
    return true;
  }
bool sistrip::FEDBuffer::doCorruptBufferChecks ( ) const [virtual]
bool sistrip::FEDBuffer::feGood ( const uint8_t  internalFEUnitNum) const [inline]
const FEDFEHeader * sistrip::FEDBuffer::feHeader ( ) const [inline]

Definition at line 133 of file SiStripFEDBuffer.h.

References feHeader_.

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

    {
      return feHeader_.get();
    }
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().

    {
      return fePresent_[internalFEUnitNum];
    }
void sistrip::FEDBuffer::findChannels ( ) [private]

Definition at line 71 of file SiStripFEDBuffer.cc.

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

Referenced by FEDBuffer().

  {
    //set min length to 2 for ZSLite, 7 for ZS and 3 for raw
    uint16_t minLength;
    switch (readoutMode()) {
      case READOUT_MODE_ZERO_SUPPRESSED:
        minLength = 7;
        break;
      case READOUT_MODE_ZERO_SUPPRESSED_LITE:
        minLength = 2;
        break;
      default:
        minLength = 3;
        break;
    }
    size_t offsetBeginningOfChannel = 0;
    for (size_t i = 0; i < FEDCH_PER_FED; i++) {
      //if FE unit is not enabled then skip rest of FE unit adding NULL pointers
      if ( !(fePresent(i/FEDCH_PER_FEUNIT) && feEnabled(i/FEDCH_PER_FEUNIT)) ) {
        channels_.insert(channels_.end(),size_t(FEDCH_PER_FEUNIT),FEDChannel(payloadPointer_,0,0));
        i += FEDCH_PER_FEUNIT-1;
        validChannels_ += FEDCH_PER_FEUNIT;
        continue;
      }
      //if FE unit is enabled
      //check that channel length bytes fit into buffer
      if (offsetBeginningOfChannel+1 >= payloadLength_) {
        std::ostringstream ss;
        SiStripFedKey key(0,i/FEDCH_PER_FEUNIT,i%FEDCH_PER_FEUNIT);
        ss << "Channel " << uint16_t(i) << " (FE unit " << key.feUnit() << " channel " << key.feChan() << " according to external numbering scheme)" 
           << " does not fit into buffer. "
           << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
           << "Payload length is " << uint16_t(payloadLength_) << ". ";
        throw cms::Exception("FEDBuffer") << ss.str();
      }
      channels_.push_back(FEDChannel(payloadPointer_,offsetBeginningOfChannel));
      //get length and check that whole channel fits into buffer
      uint16_t channelLength = channels_.back().length();
      //check that the channel length is long enough to contain the header
      if (channelLength < minLength) {
        SiStripFedKey key(0,i/FEDCH_PER_FEUNIT,i%FEDCH_PER_FEUNIT);
        std::ostringstream ss;
        ss << "Channel " << uint16_t(i) << " (FE unit " << key.feUnit() << " channel " << key.feChan() << " according to external numbering scheme)"
           << " is too short. "
           << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
           << "Channel length is " << uint16_t(channelLength) << ". "
           << "Min length is " << uint16_t(minLength) << ". ";
        throw cms::Exception("FEDBuffer") << ss.str();
      }
      if (offsetBeginningOfChannel+channelLength > payloadLength_) {
        SiStripFedKey key(0,i/FEDCH_PER_FEUNIT,i%FEDCH_PER_FEUNIT);
        std::ostringstream ss;
        ss << "Channel " << uint16_t(i) << " (FE unit " << key.feUnit() << " channel " << key.feChan() << " according to external numbering scheme)" 
           << "Channel starts at " << uint16_t(offsetBeginningOfChannel) << " in payload. "
           << "Channel length is " << uint16_t(channelLength) << ". "
           << "Payload length is " << uint16_t(payloadLength_) << ". ";
        throw cms::Exception("FEDBuffer") << ss.str();
      }
      validChannels_++;
      const size_t offsetEndOfChannel = offsetBeginningOfChannel+channelLength;
      //add padding if necessary and calculate offset for begining of next channel
      if (!( (i+1) % FEDCH_PER_FEUNIT )) {
        uint8_t numPaddingBytes = 8 - (offsetEndOfChannel % 8);
        if (numPaddingBytes == 8) numPaddingBytes = 0;
        offsetBeginningOfChannel = offsetEndOfChannel + numPaddingBytes;
      } else {
        offsetBeginningOfChannel = offsetEndOfChannel;
      }
    }
  }
uint8_t sistrip::FEDBuffer::getCorrectPacketCode ( ) const [private]
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().

  {
    uint8_t result = 0;
    for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
      if (fePresent(iFE)) result++;
    }
    return result;
  }
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(), and nFEUnitsPresent().

  {
    FEDBufferBase::print(os);
    if (headerType() == HEADER_TYPE_FULL_DEBUG) {
      os << "FE units with data: " << uint16_t(nFEUnitsPresent()) << std::endl;
      os << "BE status register flags: ";
      dynamic_cast<const FEDFullDebugHeader*>(feHeader())->beStatusRegister().printFlags(os);
      os << std::endl;
    }
  }

Member Data Documentation

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

Definition at line 76 of file SiStripFEDBuffer.h.

Referenced by FEDBuffer(), and fePresent().

const uint8_t* sistrip::FEDBuffer::payloadPointer_ [private]

Definition at line 73 of file SiStripFEDBuffer.h.

Referenced by FEDBuffer(), and findChannels().