CMS 3D CMS Logo

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

#include <SiStripFEDBufferComponents.h>

Public Member Functions

uint8_t apvAddressErrorRegister () const
 
uint8_t apveAddress () const
 
FEDBufferFormat bufferFormat () const
 
uint8_t bufferFormatByte () const
 
const uint8_t * data () 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
 
FEDLegacyReadoutMode legacyReadoutMode () 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)
 
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 uint8_t *headerPointer)
 
 TrackerSpecialHeader (const FEDBufferFormat bufferFormat, const FEDReadoutMode readoutMode, const FEDHeaderType headerType, const uint8_t address=0x00, const uint8_t addressErrorRegister=0x00, const uint8_t feEnableRegister=0xFF, const uint8_t feOverflowRegister=0x00, const FEDStatusRegister fedStatusRegister=FEDStatusRegister())
 
bool wasSwapped () const
 

Static Public Member Functions

static FEDBufferFormat bufferFormat (const uint8_t *headerPointer)
 

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 setHeaderTypeNibble (const uint8_t value)
 
void setReadoutModeBits (const uint8_t value)
 

Private Attributes

uint8_t specialHeader_ [8]
 
bool wordSwapped_
 

Detailed Description

Definition at line 315 of file SiStripFEDBufferComponents.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( )
inline

Definition at line 834 of file SiStripFEDBufferComponents.h.

sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( const uint8_t *  headerPointer)
explicit

Definition at line 746 of file SiStripFEDBufferComponents.cc.

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

746  {
747  //the buffer format byte is one of the valid values if we assume the buffer is not swapped
748  const bool validFormatByteWhenNotWordSwapped = ((headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_NEW) ||
749  (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_OLD));
750  //the buffer format byte is the old value if we assume the buffer is swapped
751  const bool validFormatByteWhenWordSwapped = (headerPointer[BUFFERFORMAT ^ 4] == BUFFER_FORMAT_CODE_OLD);
752  //if the buffer format byte is valid if the buffer is not swapped or it is never valid
753  if (validFormatByteWhenNotWordSwapped || (!validFormatByteWhenNotWordSwapped && !validFormatByteWhenWordSwapped)) {
754  memcpy(specialHeader_, headerPointer, 8);
755  wordSwapped_ = false;
756  } else {
757  memcpy(specialHeader_, headerPointer + 4, 4);
758  memcpy(specialHeader_ + 4, headerPointer, 4);
759  wordSwapped_ = true;
760  }
761  }
static const uint8_t BUFFER_FORMAT_CODE_NEW
static const uint8_t BUFFER_FORMAT_CODE_OLD
sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( const FEDBufferFormat  bufferFormat,
const FEDReadoutMode  readoutMode,
const FEDHeaderType  headerType,
const uint8_t  address = 0x00,
const uint8_t  addressErrorRegister = 0x00,
const uint8_t  feEnableRegister = 0xFF,
const uint8_t  feOverflowRegister = 0x00,
const FEDStatusRegister  fedStatusRegister = FEDStatusRegister() 
)

Definition at line 888 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_OLD_VME, setAPVEAddress(), setAPVEAddressErrorRegister(), setBufferFormatByte(), setFEDStatusRegister(), setFEEnableRegister(), setFEOverflowRegister(), setHeaderType(), setReadoutMode(), specialHeader_, and wordSwapped_.

895  {
896  memset(specialHeader_, 0x00, 8);
897  //determine if order is swapped in real buffer
899  //set fields
903  setAPVEAddress(address);
904  setAPVEAddressErrorRegister(addressErrorRegister);
908  }
TrackerSpecialHeader & setFEOverflowRegister(const uint8_t feOverflowRegister)
FEDStatusRegister fedStatusRegister() const
TrackerSpecialHeader & setAPVEAddress(const uint8_t address)
TrackerSpecialHeader & setHeaderType(const FEDHeaderType headerType)
TrackerSpecialHeader & setAPVEAddressErrorRegister(const uint8_t addressErrorRegister)
TrackerSpecialHeader & setFEDStatusRegister(const FEDStatusRegister fedStatusRegister)
void setBufferFormatByte(const FEDBufferFormat newBufferFormat)
TrackerSpecialHeader & setReadoutMode(const FEDReadoutMode readoutMode)
TrackerSpecialHeader & setFEEnableRegister(const uint8_t feEnableRegister)

Member Function Documentation

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

Definition at line 763 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_CODE_NEW, sistrip::BUFFER_FORMAT_CODE_OLD, sistrip::BUFFER_FORMAT_INVALID, sistrip::BUFFER_FORMAT_NEW, sistrip::BUFFER_FORMAT_OLD_SLINK, sistrip::BUFFER_FORMAT_OLD_VME, bufferFormatByte(), and wordSwapped_.

Referenced by sistrip::FEDBufferBase::bufferFormat(), sistrip::DigiToRaw::createFedBuffers_(), sistrip::FEDBufferGenerator::getBufferFormat(), sistrip::FEDBufferBase::init(), sistrip::preconstructCheckFEDBufferBase(), and setBufferFormat().

static FEDBufferFormat sistrip::TrackerSpecialHeader::bufferFormat ( const uint8_t *  headerPointer)
inlinestatic
uint8_t sistrip::TrackerSpecialHeader::bufferFormatByte ( ) const
inline
const uint8_t * sistrip::TrackerSpecialHeader::data ( ) const
inline
FEDStatusRegister sistrip::TrackerSpecialHeader::fedStatusRegister ( ) const
inline
uint16_t sistrip::TrackerSpecialHeader::fedStatusRegisterWord ( ) const
inline

Definition at line 905 of file SiStripFEDBufferComponents.h.

References FEDSTATUS, and specialHeader_.

Referenced by fedStatusRegister().

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

Definition at line 895 of file SiStripFEDBufferComponents.h.

References feEnableRegister().

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

895  {
896  return ((0x1 << internalFEUnitNum) & feEnableRegister());
897  }
uint8_t sistrip::TrackerSpecialHeader::feEnableRegister ( ) const
inline
bool sistrip::TrackerSpecialHeader::feOverflow ( const uint8_t  internalFEUnitNum) const
inline

Definition at line 901 of file SiStripFEDBufferComponents.h.

References feOverflowRegister().

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

901  {
902  return ((0x1 << internalFEUnitNum) & feOverflowRegister());
903  }
uint8_t sistrip::TrackerSpecialHeader::feOverflowRegister ( ) const
inline
FEDHeaderType sistrip::TrackerSpecialHeader::headerType ( ) const
inline
uint8_t sistrip::TrackerSpecialHeader::headerTypeNibble ( ) const
inline
FEDLegacyReadoutMode sistrip::TrackerSpecialHeader::legacyReadoutMode ( ) const

Definition at line 775 of file SiStripFEDBufferComponents.cc.

References universalConfigTemplate::mode, sistrip::READOUT_MODE_LEGACY_INVALID, sistrip::READOUT_MODE_LEGACY_PROC_RAW_FAKE, sistrip::READOUT_MODE_LEGACY_PROC_RAW_REAL, sistrip::READOUT_MODE_LEGACY_VIRGIN_RAW_FAKE, sistrip::READOUT_MODE_LEGACY_VIRGIN_RAW_REAL, sistrip::READOUT_MODE_LEGACY_ZERO_SUPPRESSED_FAKE, sistrip::READOUT_MODE_LEGACY_ZERO_SUPPRESSED_LITE_FAKE, sistrip::READOUT_MODE_LEGACY_ZERO_SUPPRESSED_LITE_REAL, sistrip::READOUT_MODE_LEGACY_ZERO_SUPPRESSED_REAL, and trackerEventTypeNibble().

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

775  {
776  const uint8_t eventTypeNibble = trackerEventTypeNibble();
777  const uint8_t mode = (eventTypeNibble & 0xF);
778  switch (mode) {
787  return FEDLegacyReadoutMode(mode);
788  default:
790  }
791  }
bool sistrip::TrackerSpecialHeader::majorityAddressErrorForFEUnit ( const uint8_t  internalFEUnitNum) const
inline
void sistrip::TrackerSpecialHeader::print ( std::ostream &  os) const
inline

Definition at line 915 of file SiStripFEDBufferComponents.h.

References sistrip::printHex(), and specialHeader_.

Referenced by sistrip::DigiToRaw::createFedBuffers_(), and sistrip::operator<<().

915 { printHex(specialHeader_, 8, os); }
void printHex(const void *pointer, const size_t length, std::ostream &os)
FEDReadoutMode sistrip::TrackerSpecialHeader::readoutMode ( ) const
inline

Definition at line 854 of file SiStripFEDBufferComponents.h.

References universalConfigTemplate::mode, sistrip::READOUT_MODE_INVALID, sistrip::READOUT_MODE_PREMIX_RAW, 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_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, and trackerEventTypeNibble().

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

854  {
855  const auto nibble = trackerEventTypeNibble();
856  //if it is scope mode then return as is (it cannot be fake data)
857  //if it is premix then return as is: stripping last bit would make it spy data !
858  if ((nibble == READOUT_MODE_SCOPE) || (nibble == READOUT_MODE_PREMIX_RAW)) // 0x or 0xf
859  return FEDReadoutMode(nibble);
860  //if not then ignore the last bit which indicates if it is real or fake
861  else {
862  const uint8_t mode = (nibble & 0xF);
863  switch (mode) {
869  //case READOUT_MODE_ZERO_SUPPRESSED_CMOVERRIDE:
877  case READOUT_MODE_SPY:
878  return FEDReadoutMode(mode);
879  default:
880  return READOUT_MODE_INVALID;
881  }
882  }
883  }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVAddressErrorForFEUnit ( const uint8_t  internalFEUnitNum,
const bool  error 
)

Definition at line 864 of file SiStripFEDBufferComponents.cc.

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

865  {
866  const uint8_t mask = 0x1 << internalFEUnitNum;
867  const uint8_t result = ((apvAddressErrorRegister() & (~mask)) | (error ? mask : 0x00));
869  return *this;
870  }
tuple result
Definition: mps_fire.py:311
TrackerSpecialHeader & setAPVEAddressErrorRegister(const uint8_t addressErrorRegister)
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVEAddress ( const uint8_t  address)
inline

Definition at line 929 of file SiStripFEDBufferComponents.h.

References APVEADDRESS, and specialHeader_.

Referenced by TrackerSpecialHeader().

TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVEAddressErrorRegister ( const uint8_t  addressErrorRegister)
inline

Definition at line 934 of file SiStripFEDBufferComponents.h.

References ADDRESSERROR, and specialHeader_.

Referenced by setAPVAddressErrorForFEUnit(), and TrackerSpecialHeader().

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

Definition at line 793 of file SiStripFEDBufferComponents.cc.

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

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

793  {
794  //check if order in buffer is different
795  if (((bufferFormat() == BUFFER_FORMAT_OLD_VME) && (newBufferFormat != BUFFER_FORMAT_OLD_VME)) ||
796  ((bufferFormat() != BUFFER_FORMAT_OLD_VME) && (newBufferFormat == BUFFER_FORMAT_OLD_VME))) {
798  }
799  //set appropriate code
800  setBufferFormatByte(newBufferFormat);
801  return *this;
802  }
void setBufferFormatByte(const FEDBufferFormat newBufferFormat)
void sistrip::TrackerSpecialHeader::setBufferFormatByte ( const FEDBufferFormat  newBufferFormat)
private

Definition at line 804 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_CODE_NEW, sistrip::BUFFER_FORMAT_CODE_OLD, sistrip::BUFFER_FORMAT_NEW, sistrip::BUFFER_FORMAT_OLD_SLINK, sistrip::BUFFER_FORMAT_OLD_VME, BUFFERFORMAT, Exception, sistrip::printHex(), specialHeader_, and contentValuesCheck::ss.

Referenced by setBufferFormat(), and TrackerSpecialHeader().

804  {
805  switch (newBufferFormat) {
809  break;
810  case BUFFER_FORMAT_NEW:
812  break;
813  default:
814  std::ostringstream ss;
815  ss << "Invalid buffer format: ";
816  printHex(&newBufferFormat, 1, ss);
817  throw cms::Exception("FEDBuffer") << ss.str();
818  }
819  }
static const uint8_t BUFFER_FORMAT_CODE_NEW
void printHex(const void *pointer, const size_t length, std::ostream &os)
static const uint8_t BUFFER_FORMAT_CODE_OLD
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEDStatusRegister ( const FEDStatusRegister  fedStatusRegister)
inline

Definition at line 949 of file SiStripFEDBufferComponents.h.

References FEDSTATUS, fedStatusRegister(), and specialHeader_.

Referenced by TrackerSpecialHeader().

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

Definition at line 872 of file SiStripFEDBufferComponents.cc.

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

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

873  {
874  const uint8_t mask = 0x1 << internalFEUnitNum;
875  const uint8_t result = ((feEnableRegister() & (~mask)) | (enabled ? mask : 0x00));
876  setFEEnableRegister(result);
877  return *this;
878  }
tuple result
Definition: mps_fire.py:311
TrackerSpecialHeader & setFEEnableRegister(const uint8_t feEnableRegister)
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEEnableRegister ( const uint8_t  feEnableRegister)
inline
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEOverflowForFEUnit ( const uint8_t  internalFEUnitNum,
const bool  overflow 
)

Definition at line 880 of file SiStripFEDBufferComponents.cc.

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

881  {
882  const uint8_t mask = 0x1 << internalFEUnitNum;
883  const uint8_t result = ((feOverflowRegister() & (~mask)) | (overflow ? mask : 0x00));
884  setFEEnableRegister(result);
885  return *this;
886  }
tuple result
Definition: mps_fire.py:311
TrackerSpecialHeader & setFEEnableRegister(const uint8_t feEnableRegister)
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEOverflowRegister ( const uint8_t  feOverflowRegister)
inline
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setHeaderType ( const FEDHeaderType  headerType)

Definition at line 821 of file SiStripFEDBufferComponents.cc.

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

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

821  {
822  switch (headerType) {
825  case HEADER_TYPE_NONE:
827  return *this;
828  default:
829  std::ostringstream ss;
830  ss << "Invalid header type: ";
831  printHex(&headerType, 1, ss);
832  throw cms::Exception("FEDBuffer") << ss.str();
833  }
834  }
void setHeaderTypeNibble(const uint8_t value)
void printHex(const void *pointer, const size_t length, std::ostream &os)
void sistrip::TrackerSpecialHeader::setHeaderTypeNibble ( const uint8_t  value)
inlineprivate
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setReadoutMode ( const FEDReadoutMode  readoutMode)

Definition at line 836 of file SiStripFEDBufferComponents.cc.

References Exception, sistrip::printHex(), sistrip::READOUT_MODE_PREMIX_RAW, 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_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, setReadoutModeBits(), and contentValuesCheck::ss.

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

836  {
837  switch (readoutMode) {
838  case READOUT_MODE_SCOPE:
841  case READOUT_MODE_SPY:
854  break;
855  default:
856  std::ostringstream ss;
857  ss << "Invalid readout mode: ";
858  printHex(&readoutMode, 1, ss);
859  throw cms::Exception("FEDBuffer") << ss.str();
860  }
861  return *this;
862  }
void printHex(const void *pointer, const size_t length, std::ostream &os)
void setReadoutModeBits(const uint8_t value)
void sistrip::TrackerSpecialHeader::setReadoutModeBits ( const uint8_t  value)
inlineprivate
uint8_t sistrip::TrackerSpecialHeader::trackerEventTypeNibble ( ) const
inline
bool sistrip::TrackerSpecialHeader::wasSwapped ( ) const
inline

Member Data Documentation

uint8_t sistrip::TrackerSpecialHeader::specialHeader_[8]
private
bool sistrip::TrackerSpecialHeader::wordSwapped_
private