CMS 3D CMS Logo

List of all members | 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
 

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 284 of file SiStripFEDBufferComponents.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( )
inline

Definition at line 703 of file SiStripFEDBufferComponents.h.

704  : wordSwapped_(false)
705  {
706  }
sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( const uint8_t *  headerPointer)
explicit

Definition at line 702 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_CODE_NEW, and sistrip::BUFFER_FORMAT_CODE_OLD.

703  {
704  //the buffer format byte is one of the valid values if we assume the buffer is not swapped
705  const bool validFormatByteWhenNotWordSwapped = ( (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_NEW) ||
706  (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_OLD) );
707  //the buffer format byte is the old value if we assume the buffer is swapped
708  const bool validFormatByteWhenWordSwapped = (headerPointer[BUFFERFORMAT^4] == BUFFER_FORMAT_CODE_OLD);
709  //if the buffer format byte is valid if the buffer is not swapped or it is never valid
710  if (validFormatByteWhenNotWordSwapped || (!validFormatByteWhenNotWordSwapped && !validFormatByteWhenWordSwapped) ) {
711  memcpy(specialHeader_,headerPointer,8);
712  wordSwapped_ = false;
713  } else {
714  memcpy(specialHeader_,headerPointer+4,4);
715  memcpy(specialHeader_+4,headerPointer,4);
716  wordSwapped_ = true;
717  }
718  }
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 894 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_OLD_VME.

899  {
900  memset(specialHeader_,0x00,8);
901  //determine if order is swapped in real buffer
903  //set fields
907  setAPVEAddress(address);
908  setAPVEAddressErrorRegister(addressErrorRegister);
912  }
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
uint8_t sistrip::TrackerSpecialHeader::bufferFormatByte ( ) const
inline
const uint8_t * sistrip::TrackerSpecialHeader::data ( ) const
inline

Definition at line 757 of file SiStripFEDBufferComponents.h.

References specialHeader_.

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

758  {
759  return specialHeader_;
760  }
FEDStatusRegister sistrip::TrackerSpecialHeader::fedStatusRegister ( ) const
inline

Definition at line 751 of file SiStripFEDBufferComponents.h.

References fedStatusRegisterWord().

Referenced by sistrip::DigiToRaw::createFedBuffers_(), and setFEDStatusRegister().

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

Definition at line 744 of file SiStripFEDBufferComponents.h.

References FEDSTATUS, and specialHeader_.

Referenced by fedStatusRegister().

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

Definition at line 731 of file SiStripFEDBufferComponents.h.

References feEnableRegister(), and globals_cff::x1.

732  {
733  return ( (0x1<<internalFEUnitNum) & feEnableRegister() );
734  }
uint8_t sistrip::TrackerSpecialHeader::feEnableRegister ( ) const
inline
bool sistrip::TrackerSpecialHeader::feOverflow ( const uint8_t  internalFEUnitNum) const
inline

Definition at line 739 of file SiStripFEDBufferComponents.h.

References feOverflowRegister(), and globals_cff::x1.

740  {
741  return ( (0x1<<internalFEUnitNum) & feOverflowRegister() );
742  }
uint8_t sistrip::TrackerSpecialHeader::feOverflowRegister ( ) const
inline
FEDHeaderType sistrip::TrackerSpecialHeader::headerType ( ) const
uint8_t sistrip::TrackerSpecialHeader::headerTypeNibble ( ) const
inline
FEDLegacyReadoutMode sistrip::TrackerSpecialHeader::legacyReadoutMode ( ) const

Definition at line 739 of file SiStripFEDBufferComponents.cc.

References ALCARECOPromptCalibProdSiPixelAli0T_cff::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, and sistrip::READOUT_MODE_LEGACY_ZERO_SUPPRESSED_REAL.

740  {
741  const uint8_t eventTypeNibble = trackerEventTypeNibble();
742  const uint8_t mode = (eventTypeNibble & 0xF);
743  switch(mode) {
752  return FEDLegacyReadoutMode(mode);
753  default:
755  }
756  }
bool sistrip::TrackerSpecialHeader::majorityAddressErrorForFEUnit ( const uint8_t  internalFEUnitNum) const
inline
void sistrip::TrackerSpecialHeader::print ( std::ostream &  os) const
inline

Definition at line 754 of file SiStripFEDBufferComponents.h.

References sistrip::printHex(), and specialHeader_.

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

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

Definition at line 758 of file SiStripFEDBufferComponents.cc.

References ALCARECOPromptCalibProdSiPixelAli0T_cff::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, and sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT_CMOVERRIDE.

Referenced by sistrip::DigiToRaw::createFedBuffers_(), and majorityAddressErrorForFEUnit().

759  {
760  const uint8_t eventTypeNibble = trackerEventTypeNibble();
761  //if it is scope mode then return as is (it cannot be fake data)
762  if (eventTypeNibble == READOUT_MODE_SCOPE) return FEDReadoutMode(eventTypeNibble);
763  //if it is premix then return as is: stripping last bit would make it spy data !
764  if (eventTypeNibble == READOUT_MODE_PREMIX_RAW) return FEDReadoutMode(eventTypeNibble);
765  //if not then ignore the last bit which indicates if it is real or fake
766  else {
767  const uint8_t mode = (eventTypeNibble & 0xF);
768  switch(mode) {
774  //case READOUT_MODE_ZERO_SUPPRESSED_CMOVERRIDE:
782  case READOUT_MODE_SPY:
783  return FEDReadoutMode(mode);
784  default:
785  return READOUT_MODE_INVALID;
786  }
787  }
788  }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVAddressErrorForFEUnit ( const uint8_t  internalFEUnitNum,
const bool  error 
)

Definition at line 870 of file SiStripFEDBufferComponents.cc.

References RecoTauDiscriminantConfiguration::mask, and mps_fire::result.

871  {
872  const uint8_t mask = 0x1 << internalFEUnitNum;
873  const uint8_t result = ( (apvAddressErrorRegister() & (~mask)) | (error?mask:0x00) );
875  return *this;
876  }
TrackerSpecialHeader & setAPVEAddressErrorRegister(const uint8_t addressErrorRegister)
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVEAddress ( const uint8_t  address)
inline

Definition at line 777 of file SiStripFEDBufferComponents.h.

References APVEADDRESS, and specialHeader_.

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

Definition at line 783 of file SiStripFEDBufferComponents.h.

References ADDRESSERROR, and specialHeader_.

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

Definition at line 790 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_OLD_VME.

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

Definition at line 802 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, Exception, and sistrip::printHex().

803  {
804  switch (newBufferFormat) {
808  break;
809  case BUFFER_FORMAT_NEW:
811  break;
812  default:
813  std::ostringstream ss;
814  ss << "Invalid buffer format: ";
815  printHex(&newBufferFormat,1,ss);
816  throw cms::Exception("FEDBuffer") << ss.str();
817  }
818  }
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 801 of file SiStripFEDBufferComponents.h.

References FEDSTATUS, fedStatusRegister(), and specialHeader_.

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

Definition at line 878 of file SiStripFEDBufferComponents.cc.

References RecoTauDiscriminantConfiguration::mask, and mps_fire::result.

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

879  {
880  const uint8_t mask = 0x1 << internalFEUnitNum;
881  const uint8_t result = ( (feEnableRegister() & (~mask)) | (enabled?mask:0x00) );
882  setFEEnableRegister(result);
883  return *this;
884  }
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 886 of file SiStripFEDBufferComponents.cc.

References RecoTauDiscriminantConfiguration::mask, and mps_fire::result.

887  {
888  const uint8_t mask = 0x1 << internalFEUnitNum;
889  const uint8_t result = ( (feOverflowRegister() & (~mask)) | (overflow?mask:0x00) );
890  setFEEnableRegister(result);
891  return *this;
892  }
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 820 of file SiStripFEDBufferComponents.cc.

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

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, and sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT_CMOVERRIDE.

837  {
838  switch(readoutMode) {
839  case READOUT_MODE_SCOPE:
840  //scope mode is always real
844  case READOUT_MODE_SPY:
856  break;
858  //special mode for simulation
860  break;
861  default:
862  std::ostringstream ss;
863  ss << "Invalid readout mode: ";
864  printHex(&readoutMode,1,ss);
865  throw cms::Exception("FEDBuffer") << ss.str();
866  }
867  return *this;
868  }
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

Definition at line 762 of file SiStripFEDBufferComponents.h.

References wordSwapped_.

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

763  {
764  return wordSwapped_;
765  }

Member Data Documentation

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

Definition at line 334 of file SiStripFEDBufferComponents.h.

Referenced by wasSwapped().