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 651 of file SiStripFEDBufferComponents.cc.

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

652  {
653  //the buffer format byte is one of the valid values if we assume the buffer is not swapped
654  const bool validFormatByteWhenNotWordSwapped = ( (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_NEW) ||
655  (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_OLD) );
656  //the buffer format byte is the old value if we assume the buffer is swapped
657  const bool validFormatByteWhenWordSwapped = (headerPointer[BUFFERFORMAT^4] == BUFFER_FORMAT_CODE_OLD);
658  //if the buffer format byte is valid if the buffer is not swapped or it is never valid
659  if (validFormatByteWhenNotWordSwapped || (!validFormatByteWhenNotWordSwapped && !validFormatByteWhenWordSwapped) ) {
660  memcpy(specialHeader_,headerPointer,8);
661  wordSwapped_ = false;
662  } else {
663  memcpy(specialHeader_,headerPointer+4,4);
664  memcpy(specialHeader_+4,headerPointer,4);
665  wordSwapped_ = true;
666  }
667  }
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 843 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_OLD_VME.

848  {
849  memset(specialHeader_,0x00,8);
850  //determine if order is swapped in real buffer
852  //set fields
856  setAPVEAddress(address);
857  setAPVEAddressErrorRegister(addressErrorRegister);
861  }
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 688 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.

689  {
690  const uint8_t eventTypeNibble = trackerEventTypeNibble();
691  const uint8_t mode = (eventTypeNibble & 0xF);
692  switch(mode) {
701  return FEDLegacyReadoutMode(mode);
702  default:
704  }
705  }
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 707 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().

708  {
709  const uint8_t eventTypeNibble = trackerEventTypeNibble();
710  //if it is scope mode then return as is (it cannot be fake data)
711  if (eventTypeNibble == READOUT_MODE_SCOPE) return FEDReadoutMode(eventTypeNibble);
712  //if it is premix then return as is: stripping last bit would make it spy data !
713  if (eventTypeNibble == READOUT_MODE_PREMIX_RAW) return FEDReadoutMode(eventTypeNibble);
714  //if not then ignore the last bit which indicates if it is real or fake
715  else {
716  const uint8_t mode = (eventTypeNibble & 0xF);
717  switch(mode) {
723  //case READOUT_MODE_ZERO_SUPPRESSED_CMOVERRIDE:
731  case READOUT_MODE_SPY:
732  return FEDReadoutMode(mode);
733  default:
734  return READOUT_MODE_INVALID;
735  }
736  }
737  }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVAddressErrorForFEUnit ( const uint8_t  internalFEUnitNum,
const bool  error 
)

Definition at line 819 of file SiStripFEDBufferComponents.cc.

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

820  {
821  const uint8_t mask = 0x1 << internalFEUnitNum;
822  const uint8_t result = ( (apvAddressErrorRegister() & (~mask)) | (error?mask:0x00) );
824  return *this;
825  }
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 739 of file SiStripFEDBufferComponents.cc.

References sistrip::BUFFER_FORMAT_OLD_VME.

740  {
741  //check if order in buffer is different
742  if ( ( (bufferFormat()==BUFFER_FORMAT_OLD_VME) && (newBufferFormat!=BUFFER_FORMAT_OLD_VME) ) ||
743  ( (bufferFormat()!=BUFFER_FORMAT_OLD_VME) && (newBufferFormat==BUFFER_FORMAT_OLD_VME) ) ) {
745  }
746  //set appropriate code
747  setBufferFormatByte(newBufferFormat);
748  return *this;
749  }
void setBufferFormatByte(const FEDBufferFormat newBufferFormat)
void sistrip::TrackerSpecialHeader::setBufferFormatByte ( const FEDBufferFormat  newBufferFormat)
private

Definition at line 751 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().

752  {
753  switch (newBufferFormat) {
757  break;
758  case BUFFER_FORMAT_NEW:
760  break;
761  default:
762  std::ostringstream ss;
763  ss << "Invalid buffer format: ";
764  printHex(&newBufferFormat,1,ss);
765  throw cms::Exception("FEDBuffer") << ss.str();
766  }
767  }
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 827 of file SiStripFEDBufferComponents.cc.

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

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

828  {
829  const uint8_t mask = 0x1 << internalFEUnitNum;
830  const uint8_t result = ( (feEnableRegister() & (~mask)) | (enabled?mask:0x00) );
831  setFEEnableRegister(result);
832  return *this;
833  }
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 835 of file SiStripFEDBufferComponents.cc.

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

836  {
837  const uint8_t mask = 0x1 << internalFEUnitNum;
838  const uint8_t result = ( (feOverflowRegister() & (~mask)) | (overflow?mask:0x00) );
839  setFEEnableRegister(result);
840  return *this;
841  }
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 769 of file SiStripFEDBufferComponents.cc.

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

770  {
771  switch(headerType) {
774  case HEADER_TYPE_NONE:
776  return *this;
777  default:
778  std::ostringstream ss;
779  ss << "Invalid header type: ";
780  printHex(&headerType,1,ss);
781  throw cms::Exception("FEDBuffer") << ss.str();
782  }
783  }
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 785 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.

786  {
787  switch(readoutMode) {
788  case READOUT_MODE_SCOPE:
789  //scope mode is always real
793  case READOUT_MODE_SPY:
805  break;
807  //special mode for simulation
809  break;
810  default:
811  std::ostringstream ss;
812  ss << "Invalid readout mode: ";
813  printHex(&readoutMode,1,ss);
814  throw cms::Exception("FEDBuffer") << ss.str();
815  }
816  return *this;
817  }
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().