CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

sistrip::FEDSpyBuffer Class Reference

#include <SiStripFEDSpyBuffer.h>

Inheritance diagram for sistrip::FEDSpyBuffer:
sistrip::FEDBufferBase

List of all members.

Public Member Functions

virtual bool channelGood (const uint8_t internalFEDannelNum) const
bool delayChipGood (const uint8_t delayChip) const
uint32_t delayChipL1ID (const uint8_t delayChip) const
uint32_t delayChipTotalEventCount (const uint8_t delayChip) const
 FEDSpyBuffer (const uint8_t *fedBuffer, const size_t fedBufferSize)
uint32_t globalRunNumber () const
virtual void print (std::ostream &os) const
uint32_t spyHeaderL1ID () const
uint32_t spyHeaderTotalEventCount () const
virtual ~FEDSpyBuffer ()

Private Member Functions

void findChannels ()

Private Attributes

uint16_t payloadLength_
const uint8_t * payloadPointer_
uint8_t versionId_

Static Private Attributes

static const uint8_t channelPositionsInData_ [FEDCH_PER_DELAY_CHIP] = { 0, 3, 2, 1 }

Detailed Description

Definition at line 32 of file SiStripFEDSpyBuffer.h.


Constructor & Destructor Documentation

sistrip::FEDSpyBuffer::FEDSpyBuffer ( const uint8_t *  fedBuffer,
const size_t  fedBufferSize 
)

Definition at line 8 of file SiStripFEDSpyBuffer.cc.

References Exception, findChannels(), payloadPointer_, sistrip::READOUT_MODE_SPY, sistrip::FEDBufferBase::readoutMode(), and versionId_.

    : FEDBufferBase(fedBuffer,fedBufferSize,false),
      payloadPointer_(getPointerToDataAfterTrackerSpecialHeader()+16),
      payloadLength_(getPointerToByteAfterEndOfPayload()-payloadPointer_),
      versionId_(*(getPointerToDataAfterTrackerSpecialHeader()+3))
  {
    //Check it is spy data
    if (!(readoutMode() == READOUT_MODE_SPY))
      throw cms::Exception("FEDSpyBuffer") << "Buffer is not from spy channel";
    //Check the buffer format version ID and take action for any exceptions
    if (versionId_ == 0x00) {
      payloadPointer_ = payloadPointer_-8;
    }
    //find the channel start positions
    findChannels();
  }
sistrip::FEDSpyBuffer::~FEDSpyBuffer ( ) [virtual]

Definition at line 25 of file SiStripFEDSpyBuffer.cc.

  {
  }

Member Function Documentation

bool sistrip::FEDSpyBuffer::channelGood ( const uint8_t  internalFEDannelNum) const [virtual]
bool sistrip::FEDSpyBuffer::delayChipGood ( const uint8_t  delayChip) const

Definition at line 118 of file SiStripFEDSpyBuffer.cc.

References delayChipL1ID(), delayChipTotalEventCount(), sistrip::FEDBufferBase::dump(), spyHeaderL1ID(), spyHeaderTotalEventCount(), and versionId_.

Referenced by channelGood().

  {
    if (versionId_ == 0x00) {
      if (delayChip == 0) return true;
    }
    uint32_t l1CountBefore = 0;
    uint32_t totalEventCountBefore = 0;
    if (delayChip == 0) {
      l1CountBefore = spyHeaderL1ID();
      totalEventCountBefore = spyHeaderTotalEventCount();
    } else {
      l1CountBefore = delayChipL1ID(delayChip-1);
      totalEventCountBefore = delayChipTotalEventCount(delayChip-1);
    }
    const uint32_t l1CountAfter = delayChipL1ID(delayChip);
    const uint32_t totalEventCountAfter = delayChipTotalEventCount(delayChip);
    const bool eventMatches = ( (l1CountBefore == l1CountAfter) && (totalEventCountBefore == totalEventCountAfter) );
    if (!eventMatches) {
      std::ostringstream ss;
      ss << "Delay chip data was overwritten on chip " << uint16_t(delayChip)
         << " L1A before: " << l1CountBefore << " after: " << l1CountAfter
         << " Total event count before: " << totalEventCountBefore << " after: " << totalEventCountAfter << std::endl;
      dump(ss);
      edm::LogInfo("FEDSpyBuffer") << ss.str();
    }
    return eventMatches;
  }
uint32_t sistrip::FEDSpyBuffer::delayChipL1ID ( const uint8_t  delayChip) const

Definition at line 90 of file SiStripFEDSpyBuffer.cc.

References payloadPointer_, query::result, and sistrip::SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES.

Referenced by delayChipGood(), and spyHeaderL1ID().

  {
    const uint8_t* delayChipCounters = payloadPointer_ + ( (SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES) * (delayChip+1) - 8);
    uint32_t result = 0;
    result |= delayChipCounters[4];
    result |= (uint32_t(delayChipCounters[5]) << 8);
    result |= (uint32_t(delayChipCounters[6]) << 16);
    result |= (uint32_t(delayChipCounters[7]) << 24);
    return result;
  }
uint32_t sistrip::FEDSpyBuffer::delayChipTotalEventCount ( const uint8_t  delayChip) const

Definition at line 101 of file SiStripFEDSpyBuffer.cc.

References payloadPointer_, query::result, and sistrip::SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES.

Referenced by delayChipGood(), and spyHeaderTotalEventCount().

  {
    const uint8_t* delayChipCounters = payloadPointer_ + ( (SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES) * (delayChip+1) - 8);
    uint32_t result = 0;
    result |= delayChipCounters[0];
    result |= (uint32_t(delayChipCounters[1]) << 8);
    result |= (uint32_t(delayChipCounters[2]) << 16);
    result |= (uint32_t(delayChipCounters[3]) << 24);
    return result;
  }
void sistrip::FEDSpyBuffer::findChannels ( ) [private]

Definition at line 29 of file SiStripFEDSpyBuffer.cc.

References sistrip::FEDBufferBase::bufferSize(), channelPositionsInData_, sistrip::FEDBufferBase::channels_, sistrip::DELAY_CHIPS_PER_FED, Exception, sistrip::FEDCH_PER_DELAY_CHIP, i, payloadLength_, payloadPointer_, sistrip::SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES, sistrip::SPY_DELAYCHIP_DATA_OFFSET_IN_BITS, and sistrip::SPY_SAMPLES_PER_CHANNEL.

Referenced by FEDSpyBuffer().

  {
    size_t delayChipStartByteIndex = 0;
    //Loop over delay chips checking their data fits into buffer and setting up channel objects with correct offset
    for (uint8_t iDelayChip = 0; iDelayChip < DELAY_CHIPS_PER_FED; ++iDelayChip) {
      if (delayChipStartByteIndex+SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES > payloadLength_) {
        throw cms::Exception("FEDSpyBuffer") << "Delay chip " << uint16_t(iDelayChip) << " does not fit into buffer. "
                                             << "Buffer size is " << bufferSize() << " delay chip data starts at " << delayChipStartByteIndex+8+8+8+8 << ". ";
      }
      for (uint8_t i = 0; i < FEDCH_PER_DELAY_CHIP; i++) {
        const uint8_t chanelIndexInDataOrder = channelPositionsInData_[i];
        const uint8_t fedCh = iDelayChip*FEDCH_PER_DELAY_CHIP + i;
        const size_t channelOffsetInBits = SPY_DELAYCHIP_DATA_OFFSET_IN_BITS + 10*chanelIndexInDataOrder;
        channels_[fedCh] = FEDChannel(payloadPointer_+delayChipStartByteIndex,channelOffsetInBits,SPY_SAMPLES_PER_CHANNEL);
      }
      delayChipStartByteIndex += SPY_DELAY_CHIP_BUFFER_SIZE_IN_BYTES;
    }
  }
uint32_t sistrip::FEDSpyBuffer::globalRunNumber ( ) const

Definition at line 48 of file SiStripFEDSpyBuffer.cc.

References sistrip::FEDBufferBase::getPointerToDataAfterTrackerSpecialHeader(), query::result, and versionId_.

  {
    if (versionId_ < 0x02) {
      return 0;
    }
    const uint8_t * runNumberPointer = getPointerToDataAfterTrackerSpecialHeader()+4;
    uint32_t result = 0;
    result |= runNumberPointer[0];
    result |= (uint32_t(runNumberPointer[1]) << 8);
    result |= (uint32_t(runNumberPointer[2]) << 16);
    result |= (uint32_t(runNumberPointer[3]) << 24);
    return result;
  }
void sistrip::FEDSpyBuffer::print ( std::ostream &  os) const [virtual]

Reimplemented from sistrip::FEDBufferBase.

Definition at line 112 of file SiStripFEDSpyBuffer.cc.

  {
    FEDBufferBase::print(os);
    //TODO
  }
uint32_t sistrip::FEDSpyBuffer::spyHeaderL1ID ( ) const

Definition at line 62 of file SiStripFEDSpyBuffer.cc.

References delayChipL1ID(), payloadPointer_, query::result, and versionId_.

Referenced by delayChipGood().

  {
    if (versionId_ == 0x00) {
      return delayChipL1ID(0);
    }
    uint32_t result = 0;
    const uint8_t* spyCounters = payloadPointer_-8;
    result |= spyCounters[4];
    result |= (uint32_t(spyCounters[5]) << 8);
    result |= (uint32_t(spyCounters[6]) << 16);
    result |= (uint32_t(spyCounters[7]) << 24);
    return result;
  }
uint32_t sistrip::FEDSpyBuffer::spyHeaderTotalEventCount ( ) const

Definition at line 76 of file SiStripFEDSpyBuffer.cc.

References delayChipTotalEventCount(), payloadPointer_, query::result, and versionId_.

Referenced by delayChipGood().

  {
    if (versionId_ == 0x00) {
      return delayChipTotalEventCount(0);
    }
    uint32_t result = 0;
    const uint8_t* spyCounters = payloadPointer_-8;
    result |= spyCounters[0];
    result |= (uint32_t(spyCounters[1]) << 8);
    result |= (uint32_t(spyCounters[2]) << 16);
    result |= (uint32_t(spyCounters[3]) << 24);
    return result;
  }

Member Data Documentation

const uint8_t sistrip::FEDSpyBuffer::channelPositionsInData_ = { 0, 3, 2, 1 } [static, private]

Definition at line 57 of file SiStripFEDSpyBuffer.h.

Referenced by findChannels().

Definition at line 63 of file SiStripFEDSpyBuffer.h.

Referenced by findChannels().

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