CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

sistrip::TrackerSpecialHeader Class Reference

#include <SiStripFEDBufferComponents.h>

List of all members.

Public Member Functions

uint8_t apvAddressErrorRegister () const
uint8_t apveAddress () const
FEDBufferFormat bufferFormat () const
uint8_t bufferFormatByte () const
const uint8_t * data () const
FEDDataType dataType () const
FEDStatusRegister fedStatusRegister () const
uint16_t fedStatusRegisterWord () const
bool feEnabled (const uint8_t internalFEUnitNum) const
uint8_t feEnableRegister () const
bool feOverflow (const uint8_t internalFEUnitNum) const
uint8_t feOverflowRegister () const
FEDHeaderType headerType () const
uint8_t headerTypeNibble () const
bool majorityAddressErrorForFEUnit (const uint8_t internalFEUnitNum) const
void print (std::ostream &os) const
FEDReadoutMode readoutMode () const
TrackerSpecialHeadersetAPVAddressErrorForFEUnit (const uint8_t internalFEUnitNum, const bool error)
TrackerSpecialHeadersetAPVEAddress (const uint8_t address)
TrackerSpecialHeadersetAPVEAddressErrorRegister (const uint8_t addressErrorRegister)
TrackerSpecialHeadersetBufferFormat (const FEDBufferFormat newBufferFormat)
TrackerSpecialHeadersetDataType (const FEDDataType dataType)
TrackerSpecialHeadersetFEDStatusRegister (const FEDStatusRegister fedStatusRegister)
TrackerSpecialHeadersetFEEnableForFEUnit (const uint8_t internalFEUnitNum, const bool enabled)
TrackerSpecialHeadersetFEEnableRegister (const uint8_t feEnableRegister)
TrackerSpecialHeadersetFEOverflowForFEUnit (const uint8_t internalFEUnitNum, const bool overflow)
TrackerSpecialHeadersetFEOverflowRegister (const uint8_t feOverflowRegister)
TrackerSpecialHeadersetHeaderType (const FEDHeaderType headerType)
TrackerSpecialHeadersetReadoutMode (const FEDReadoutMode readoutMode)
uint8_t trackerEventTypeNibble () const
 TrackerSpecialHeader ()
 TrackerSpecialHeader (const FEDBufferFormat bufferFormat, const FEDReadoutMode readoutMode, const FEDHeaderType headerType, const FEDDataType dataType, const uint8_t address=0x00, const uint8_t addressErrorRegister=0x00, const uint8_t feEnableRegister=0xFF, const uint8_t feOverflowRegister=0x00, const FEDStatusRegister fedStatusRegister=FEDStatusRegister())
 TrackerSpecialHeader (const uint8_t *headerPointer)
bool wasSwapped () const

Private Types

enum  byteIndicies {
  FEDSTATUS = 0, FEOVERFLOW = 2, FEENABLE = 3, ADDRESSERROR = 4,
  APVEADDRESS = 5, BUFFERTYPE = 6, BUFFERFORMAT = 7
}

Private Member Functions

void setBufferFormatByte (const FEDBufferFormat newBufferFormat)
void setDataTypeBit (const bool value)
void setHeaderTypeNibble (const uint8_t value)
void setReadoutModeBits (const uint8_t value)

Private Attributes

uint8_t specialHeader_ [8]
bool wordSwapped_

Detailed Description

Definition at line 257 of file SiStripFEDBufferComponents.h.


Member Enumeration Documentation

Enumerator:
FEDSTATUS 
FEOVERFLOW 
FEENABLE 
ADDRESSERROR 
APVEADDRESS 
BUFFERTYPE 
BUFFERFORMAT 

Definition at line 306 of file SiStripFEDBufferComponents.h.


Constructor & Destructor Documentation

sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( ) [inline]

Definition at line 671 of file SiStripFEDBufferComponents.h.

    : wordSwapped_(false)
    {
    }
sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( const uint8_t *  headerPointer) [explicit]

Definition at line 611 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_CODE_NEW, sistrip::BUFFER_FORMAT_CODE_OLD, BUFFERFORMAT, specialHeader_, and wordSwapped_.

  {
    //the buffer format byte is one of the valid values if we assume the buffer is not swapped
    const bool validFormatByteWhenNotWordSwapped = ( (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_NEW) ||
                                                     (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_OLD) );
    //the buffer format byte is the old value if we assume the buffer is swapped
    const bool validFormatByteWhenWordSwapped = (headerPointer[BUFFERFORMAT^4] == BUFFER_FORMAT_CODE_OLD);
    //if the buffer format byte is valid if the buffer is not swapped or it is never valid
    if (validFormatByteWhenNotWordSwapped || (!validFormatByteWhenNotWordSwapped && !validFormatByteWhenWordSwapped) ) {
      memcpy(specialHeader_,headerPointer,8);
      wordSwapped_ = false;
    } else {
      memcpy(specialHeader_,headerPointer+4,4);
      memcpy(specialHeader_+4,headerPointer,4);
      wordSwapped_ = true;
    }
  }
sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( const FEDBufferFormat  bufferFormat,
const FEDReadoutMode  readoutMode,
const FEDHeaderType  headerType,
const FEDDataType  dataType,
const uint8_t  address = 0x00,
const uint8_t  addressErrorRegister = 0x00,
const uint8_t  feEnableRegister = 0xFF,
const uint8_t  feOverflowRegister = 0x00,
const FEDStatusRegister  fedStatusRegister = FEDStatusRegister() 
)

Member Function Documentation

uint8_t sistrip::TrackerSpecialHeader::apvAddressErrorRegister ( ) const [inline]
uint8_t sistrip::TrackerSpecialHeader::apveAddress ( ) const [inline]
FEDBufferFormat sistrip::TrackerSpecialHeader::bufferFormat ( ) const
uint8_t sistrip::TrackerSpecialHeader::bufferFormatByte ( ) const [inline]

Definition at line 676 of file SiStripFEDBufferComponents.h.

References BUFFERFORMAT, and specialHeader_.

Referenced by bufferFormat().

const uint8_t * sistrip::TrackerSpecialHeader::data ( ) const [inline]

Definition at line 725 of file SiStripFEDBufferComponents.h.

References specialHeader_.

Referenced by sistrip::FEDBufferGenerator::fillBuffer().

    {
      return specialHeader_;
    }
FEDDataType sistrip::TrackerSpecialHeader::dataType ( ) const

Definition at line 669 of file SiStripFEDBufferComponents.cc.

References sistrip::DATA_TYPE_REAL, sistrip::READOUT_MODE_SCOPE, and trackerEventTypeNibble().

Referenced by sistrip::FEDBufferBase::dataType(), and sistrip::FEDBufferGenerator::getFEDDataType().

  {
    const uint8_t eventTypeNibble = trackerEventTypeNibble();
    //if it is scope mode then it is always real
    if (eventTypeNibble == READOUT_MODE_SCOPE) return DATA_TYPE_REAL;
    //in other modes it is the lowest order bit of event type nibble
    else return FEDDataType(eventTypeNibble & 0x1);
  }
FEDStatusRegister sistrip::TrackerSpecialHeader::fedStatusRegister ( ) const [inline]

Definition at line 719 of file SiStripFEDBufferComponents.h.

References fedStatusRegisterWord().

Referenced by sistrip::FEDBufferBase::fedStatusRegister(), and setFEDStatusRegister().

    { return FEDStatusRegister(fedStatusRegisterWord()); }
uint16_t sistrip::TrackerSpecialHeader::fedStatusRegisterWord ( ) const [inline]

Definition at line 712 of file SiStripFEDBufferComponents.h.

References FEDSTATUS, and specialHeader_.

Referenced by fedStatusRegister().

    {
      //get 16 bits
      uint16_t statusRegister = ( (specialHeader_[(FEDSTATUS+1)]<<8) | specialHeader_[FEDSTATUS]);
      return statusRegister;
    }
bool sistrip::TrackerSpecialHeader::feEnabled ( const uint8_t  internalFEUnitNum) const [inline]

Definition at line 699 of file SiStripFEDBufferComponents.h.

References feEnableRegister().

Referenced by sistrip::FEDBufferBase::feEnabled().

    {
      return ( (0x1<<internalFEUnitNum) & feEnableRegister() );
    }
uint8_t sistrip::TrackerSpecialHeader::feEnableRegister ( ) const [inline]

Definition at line 696 of file SiStripFEDBufferComponents.h.

References FEENABLE, and specialHeader_.

Referenced by feEnabled(), setFEEnableForFEUnit(), and setFEEnableRegister().

    { return specialHeader_[FEENABLE]; }
bool sistrip::TrackerSpecialHeader::feOverflow ( const uint8_t  internalFEUnitNum) const [inline]

Definition at line 707 of file SiStripFEDBufferComponents.h.

References feOverflowRegister().

Referenced by sistrip::FEDBufferBase::feOverflow().

    {
      return ( (0x1<<internalFEUnitNum) & feOverflowRegister() );
    }
uint8_t sistrip::TrackerSpecialHeader::feOverflowRegister ( ) const [inline]
FEDHeaderType sistrip::TrackerSpecialHeader::headerType ( ) const
uint8_t sistrip::TrackerSpecialHeader::headerTypeNibble ( ) const [inline]

Definition at line 679 of file SiStripFEDBufferComponents.h.

References BUFFERTYPE, and specialHeader_.

Referenced by sistrip::FEDBuffer::FEDBuffer(), and headerType().

    { return ( (specialHeader_[BUFFERTYPE] & 0xF0) >> 4 ); }
bool sistrip::TrackerSpecialHeader::majorityAddressErrorForFEUnit ( const uint8_t  internalFEUnitNum) const [inline]
void sistrip::TrackerSpecialHeader::print ( std::ostream &  os) const [inline]

Definition at line 722 of file SiStripFEDBufferComponents.h.

References sistrip::printHex(), and specialHeader_.

Referenced by sistrip::operator<<().

FEDReadoutMode sistrip::TrackerSpecialHeader::readoutMode ( ) const

Definition at line 648 of file SiStripFEDBufferComponents.cc.

References mode, 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 trackerEventTypeNibble().

Referenced by sistrip::FEDBufferGenerator::getReadoutMode(), majorityAddressErrorForFEUnit(), sistrip::FEDBufferBase::readoutMode(), and setDataType().

  {
    const uint8_t eventTypeNibble = trackerEventTypeNibble();
    //if it is scope mode then return as is (it cannot be fake data)
    if (eventTypeNibble == READOUT_MODE_SCOPE) return FEDReadoutMode(eventTypeNibble);
    //if not then ignore the last bit which indicates if it is real or fake
    else {
      const uint8_t mode = (eventTypeNibble & 0xE);
      switch(mode) {
      case READOUT_MODE_VIRGIN_RAW:
      case READOUT_MODE_PROC_RAW:
      case READOUT_MODE_ZERO_SUPPRESSED:
      case READOUT_MODE_ZERO_SUPPRESSED_LITE:
      case READOUT_MODE_SPY:
        return FEDReadoutMode(mode);
      default:
        return READOUT_MODE_INVALID;
      }
    }   
  }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVAddressErrorForFEUnit ( const uint8_t  internalFEUnitNum,
const bool  error 
)

Definition at line 764 of file SiStripFEDBufferComponents.cc.

References apvAddressErrorRegister(), query::result, and setAPVEAddressErrorRegister().

  {
    const uint8_t mask = 0x1 << internalFEUnitNum;
    const uint8_t result = ( (apvAddressErrorRegister() & (~mask)) | (error?mask:0x00) );
    setAPVEAddressErrorRegister(result);
    return *this;
  }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVEAddress ( const uint8_t  address) [inline]

Definition at line 750 of file SiStripFEDBufferComponents.h.

References APVEADDRESS, and specialHeader_.

Referenced by TrackerSpecialHeader().

    {
      specialHeader_[APVEADDRESS] = address;
      return *this;
    }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVEAddressErrorRegister ( const uint8_t  addressErrorRegister) [inline]

Definition at line 756 of file SiStripFEDBufferComponents.h.

References ADDRESSERROR, and specialHeader_.

Referenced by setAPVAddressErrorForFEUnit(), and TrackerSpecialHeader().

    {
      specialHeader_[ADDRESSERROR] = addressErrorRegister;
      return *this;
    }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setBufferFormat ( const FEDBufferFormat  newBufferFormat)

Definition at line 678 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_OLD_VME, bufferFormat(), setBufferFormatByte(), and wordSwapped_.

Referenced by sistrip::FEDBufferGenerator::setBufferFormat().

  {
    //check if order in buffer is different
    if ( ( (bufferFormat()==BUFFER_FORMAT_OLD_VME) && (newBufferFormat!=BUFFER_FORMAT_OLD_VME) ) ||
         ( (bufferFormat()!=BUFFER_FORMAT_OLD_VME) && (newBufferFormat==BUFFER_FORMAT_OLD_VME) ) ) {
      wordSwapped_ = !wordSwapped_;
    }
    //set appropriate code
    setBufferFormatByte(newBufferFormat);
    return *this;
  }
void sistrip::TrackerSpecialHeader::setBufferFormatByte ( const FEDBufferFormat  newBufferFormat) [private]
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setDataType ( const FEDDataType  dataType)

Definition at line 747 of file SiStripFEDBufferComponents.cc.

References sistrip::DATA_TYPE_FAKE, sistrip::DATA_TYPE_REAL, Exception, sistrip::printHex(), sistrip::READOUT_MODE_SCOPE, readoutMode(), and setDataTypeBit().

Referenced by sistrip::FEDBufferGenerator::setFEDDataType(), and TrackerSpecialHeader().

  {
    //if mode is scope then this bit can't be changed
    if (readoutMode() == READOUT_MODE_SCOPE) return *this;
    switch (dataType) {
    case DATA_TYPE_REAL:
    case DATA_TYPE_FAKE:
      setDataTypeBit(dataType);
      return *this;
    default:
      std::ostringstream ss;
      ss << "Invalid data type: ";
      printHex(&dataType,1,ss);
      throw cms::Exception("FEDBuffer") << ss.str();
    }
  }
void sistrip::TrackerSpecialHeader::setDataTypeBit ( const bool  value) [inline, private]

Definition at line 745 of file SiStripFEDBufferComponents.h.

References BUFFERTYPE, and specialHeader_.

Referenced by setDataType(), and setReadoutMode().

    {
      specialHeader_[BUFFERTYPE] = ( (specialHeader_[BUFFERTYPE] & (~0x01)) | (value ? 0x01 : 0x00) );
    }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEDStatusRegister ( const FEDStatusRegister  fedStatusRegister) [inline]

Definition at line 774 of file SiStripFEDBufferComponents.h.

References FEDSTATUS, fedStatusRegister(), and specialHeader_.

Referenced by TrackerSpecialHeader().

    {
      specialHeader_[FEDSTATUS] = (static_cast<uint16_t>(fedStatusRegister) & 0x00FF);
      specialHeader_[FEDSTATUS+1] = ( (static_cast<uint16_t>(fedStatusRegister) & 0xFF00) >> 8);
      return *this;
    }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEEnableForFEUnit ( const uint8_t  internalFEUnitNum,
const bool  enabled 
)

Definition at line 772 of file SiStripFEDBufferComponents.cc.

References feEnableRegister(), query::result, and setFEEnableRegister().

Referenced by sistrip::FEDBufferGenerator::generateBuffer().

  {
    const uint8_t mask = 0x1 << internalFEUnitNum;
    const uint8_t result = ( (feEnableRegister() & (~mask)) | (enabled?mask:0x00) );
    setFEEnableRegister(result);
    return *this;
  }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEEnableRegister ( const uint8_t  feEnableRegister) [inline]
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEOverflowForFEUnit ( const uint8_t  internalFEUnitNum,
const bool  overflow 
)

Definition at line 780 of file SiStripFEDBufferComponents.cc.

References feOverflowRegister(), query::result, and setFEEnableRegister().

  {
    const uint8_t mask = 0x1 << internalFEUnitNum;
    const uint8_t result = ( (feOverflowRegister() & (~mask)) | (overflow?mask:0x00) );
    setFEEnableRegister(result);
    return *this;
  }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEOverflowRegister ( const uint8_t  feOverflowRegister) [inline]

Definition at line 768 of file SiStripFEDBufferComponents.h.

References FEOVERFLOW, feOverflowRegister(), and specialHeader_.

Referenced by TrackerSpecialHeader().

TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setHeaderType ( const FEDHeaderType  headerType)

Definition at line 708 of file SiStripFEDBufferComponents.cc.

References Exception, sistrip::HEADER_TYPE_APV_ERROR, sistrip::HEADER_TYPE_FULL_DEBUG, sistrip::HEADER_TYPE_NONE, sistrip::printHex(), and setHeaderTypeNibble().

Referenced by sistrip::FEDBufferGenerator::setHeaderType(), and TrackerSpecialHeader().

  {
    switch(headerType) {
    case HEADER_TYPE_FULL_DEBUG:
    case HEADER_TYPE_APV_ERROR:
    case HEADER_TYPE_NONE:
      setHeaderTypeNibble(headerType);
      return *this;
    default:
      std::ostringstream ss;
      ss << "Invalid header type: ";
      printHex(&headerType,1,ss);
      throw cms::Exception("FEDBuffer") << ss.str();
    }
  }
void sistrip::TrackerSpecialHeader::setHeaderTypeNibble ( const uint8_t  value) [inline, private]

Definition at line 735 of file SiStripFEDBufferComponents.h.

References BUFFERTYPE, and specialHeader_.

Referenced by setHeaderType().

    {
      specialHeader_[BUFFERTYPE] = ( (specialHeader_[BUFFERTYPE] & 0x0F) | ((value<<4) & 0xF0) );
    }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setReadoutMode ( const FEDReadoutMode  readoutMode)
void sistrip::TrackerSpecialHeader::setReadoutModeBits ( const uint8_t  value) [inline, private]

Definition at line 740 of file SiStripFEDBufferComponents.h.

References BUFFERTYPE, and specialHeader_.

Referenced by setReadoutMode().

    {
      specialHeader_[BUFFERTYPE] = ( (specialHeader_[BUFFERTYPE] & (~0x0E)) | (value & 0x0E) );
    }
uint8_t sistrip::TrackerSpecialHeader::trackerEventTypeNibble ( ) const [inline]

Definition at line 682 of file SiStripFEDBufferComponents.h.

References BUFFERTYPE, and specialHeader_.

Referenced by dataType(), and readoutMode().

    { return (specialHeader_[BUFFERTYPE] & 0x0F); }
bool sistrip::TrackerSpecialHeader::wasSwapped ( ) const [inline]

Definition at line 730 of file SiStripFEDBufferComponents.h.

References wordSwapped_.

Referenced by sistrip::FEDBufferGenerator::fillBuffer().

    {
      return wordSwapped_;
    }

Member Data Documentation