CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
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 uint8_t *headerPointer)
 
 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())
 
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 258 of file SiStripFEDBufferComponents.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( )
inline

Definition at line 672 of file SiStripFEDBufferComponents.h.

673  : wordSwapped_(false)
674  {
675  }
sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( const uint8_t *  headerPointer)
explicit

Definition at line 619 of file SiStripFEDBufferComponents.cc.

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

620  {
621  //the buffer format byte is one of the valid values if we assume the buffer is not swapped
622  const bool validFormatByteWhenNotWordSwapped = ( (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_NEW) ||
623  (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_OLD) );
624  //the buffer format byte is the old value if we assume the buffer is swapped
625  const bool validFormatByteWhenWordSwapped = (headerPointer[BUFFERFORMAT^4] == BUFFER_FORMAT_CODE_OLD);
626  //if the buffer format byte is valid if the buffer is not swapped or it is never valid
627  if (validFormatByteWhenNotWordSwapped || (!validFormatByteWhenNotWordSwapped && !validFormatByteWhenWordSwapped) ) {
628  memcpy(specialHeader_,headerPointer,8);
629  wordSwapped_ = false;
630  } else {
631  memcpy(specialHeader_,headerPointer+4,4);
632  memcpy(specialHeader_+4,headerPointer,4);
633  wordSwapped_ = true;
634  }
635  }
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 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() 
)

Definition at line 803 of file SiStripFEDBufferComponents.cc.

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

808  {
809  memset(specialHeader_,0x00,8);
810  //determine if order is swapped in real buffer
812  //set fields
817  setAPVEAddress(address);
818  setAPVEAddressErrorRegister(addressErrorRegister);
822  }
TrackerSpecialHeader & setDataType(const FEDDataType dataType)
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 637 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::FEDBufferGenerator::getBufferFormat(), sistrip::FEDBufferBase::init(), and setBufferFormat().

uint8_t sistrip::TrackerSpecialHeader::bufferFormatByte ( ) const
inline
const uint8_t * sistrip::TrackerSpecialHeader::data ( ) const
inline

Definition at line 726 of file SiStripFEDBufferComponents.h.

References specialHeader_.

Referenced by cuy.FindIssue::__init__(), and sistrip::FEDBufferGenerator::fillBuffer().

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

Definition at line 679 of file SiStripFEDBufferComponents.cc.

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

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

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

Definition at line 720 of file SiStripFEDBufferComponents.h.

References fedStatusRegisterWord().

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

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

Definition at line 713 of file SiStripFEDBufferComponents.h.

References FEDSTATUS, and specialHeader_.

Referenced by fedStatusRegister().

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

Definition at line 700 of file SiStripFEDBufferComponents.h.

References feEnableRegister().

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

701  {
702  return ( (0x1<<internalFEUnitNum) & feEnableRegister() );
703  }
uint8_t sistrip::TrackerSpecialHeader::feEnableRegister ( ) const
inline
bool sistrip::TrackerSpecialHeader::feOverflow ( const uint8_t  internalFEUnitNum) const
inline

Definition at line 708 of file SiStripFEDBufferComponents.h.

References feOverflowRegister().

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

709  {
710  return ( (0x1<<internalFEUnitNum) & feOverflowRegister() );
711  }
uint8_t sistrip::TrackerSpecialHeader::feOverflowRegister ( ) const
inline
FEDHeaderType sistrip::TrackerSpecialHeader::headerType ( ) const
uint8_t sistrip::TrackerSpecialHeader::headerTypeNibble ( ) const
inline
bool sistrip::TrackerSpecialHeader::majorityAddressErrorForFEUnit ( const uint8_t  internalFEUnitNum) const
inline
void sistrip::TrackerSpecialHeader::print ( std::ostream &  os) const
inline

Definition at line 723 of file SiStripFEDBufferComponents.h.

References sistrip::printHex(), and specialHeader_.

Referenced by sistrip::operator<<().

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

Definition at line 656 of file SiStripFEDBufferComponents.cc.

References alignBH_cfg::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_LITE, and trackerEventTypeNibble().

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

657  {
658  const uint8_t eventTypeNibble = trackerEventTypeNibble();
659  //if it is scope mode then return as is (it cannot be fake data)
660  if (eventTypeNibble == READOUT_MODE_SCOPE) return FEDReadoutMode(eventTypeNibble);
661  //if it is premix then return as is: stripping last bit would make it spy data !
662  if (eventTypeNibble == READOUT_MODE_PREMIX_RAW) return FEDReadoutMode(eventTypeNibble);
663  //if not then ignore the last bit which indicates if it is real or fake
664  else {
665  const uint8_t mode = (eventTypeNibble & 0xE);
666  switch(mode) {
671  case READOUT_MODE_SPY:
672  return FEDReadoutMode(mode);
673  default:
674  return READOUT_MODE_INVALID;
675  }
676  }
677  }
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVAddressErrorForFEUnit ( const uint8_t  internalFEUnitNum,
const bool  error 
)

Definition at line 779 of file SiStripFEDBufferComponents.cc.

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

780  {
781  const uint8_t mask = 0x1 << internalFEUnitNum;
782  const uint8_t result = ( (apvAddressErrorRegister() & (~mask)) | (error?mask:0x00) );
784  return *this;
785  }
TrackerSpecialHeader & setAPVEAddressErrorRegister(const uint8_t addressErrorRegister)
tuple result
Definition: query.py:137
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVEAddress ( const uint8_t  address)
inline

Definition at line 751 of file SiStripFEDBufferComponents.h.

References APVEADDRESS, and specialHeader_.

Referenced by TrackerSpecialHeader().

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

Definition at line 757 of file SiStripFEDBufferComponents.h.

References ADDRESSERROR, and specialHeader_.

Referenced by setAPVAddressErrorForFEUnit(), and TrackerSpecialHeader().

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

Definition at line 688 of file SiStripFEDBufferComponents.cc.

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

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

689  {
690  //check if order in buffer is different
691  if ( ( (bufferFormat()==BUFFER_FORMAT_OLD_VME) && (newBufferFormat!=BUFFER_FORMAT_OLD_VME) ) ||
692  ( (bufferFormat()!=BUFFER_FORMAT_OLD_VME) && (newBufferFormat==BUFFER_FORMAT_OLD_VME) ) ) {
694  }
695  //set appropriate code
696  setBufferFormatByte(newBufferFormat);
697  return *this;
698  }
void setBufferFormatByte(const FEDBufferFormat newBufferFormat)
void sistrip::TrackerSpecialHeader::setBufferFormatByte ( const FEDBufferFormat  newBufferFormat)
private

Definition at line 700 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, edm::hlt::Exception, sistrip::printHex(), specialHeader_, and contentValuesCheck::ss.

Referenced by setBufferFormat(), and TrackerSpecialHeader().

701  {
702  switch (newBufferFormat) {
706  break;
707  case BUFFER_FORMAT_NEW:
709  break;
710  default:
711  std::ostringstream ss;
712  ss << "Invalid buffer format: ";
713  printHex(&newBufferFormat,1,ss);
714  throw cms::Exception("FEDBuffer") << ss.str();
715  }
716  }
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::setDataType ( const FEDDataType  dataType)

Definition at line 762 of file SiStripFEDBufferComponents.cc.

References sistrip::DATA_TYPE_FAKE, sistrip::DATA_TYPE_REAL, edm::hlt::Exception, sistrip::printHex(), sistrip::READOUT_MODE_SCOPE, readoutMode(), setDataTypeBit(), and contentValuesCheck::ss.

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

763  {
764  //if mode is scope then this bit can't be changed
765  if (readoutMode() == READOUT_MODE_SCOPE) return *this;
766  switch (dataType) {
767  case DATA_TYPE_REAL:
768  case DATA_TYPE_FAKE:
770  return *this;
771  default:
772  std::ostringstream ss;
773  ss << "Invalid data type: ";
774  printHex(&dataType,1,ss);
775  throw cms::Exception("FEDBuffer") << ss.str();
776  }
777  }
void printHex(const void *pointer, const size_t length, std::ostream &os)
void sistrip::TrackerSpecialHeader::setDataTypeBit ( const bool  value)
inlineprivate
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setFEDStatusRegister ( const FEDStatusRegister  fedStatusRegister)
inline

Definition at line 775 of file SiStripFEDBufferComponents.h.

References FEDSTATUS, fedStatusRegister(), and specialHeader_.

Referenced by TrackerSpecialHeader().

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

Definition at line 787 of file SiStripFEDBufferComponents.cc.

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

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

788  {
789  const uint8_t mask = 0x1 << internalFEUnitNum;
790  const uint8_t result = ( (feEnableRegister() & (~mask)) | (enabled?mask:0x00) );
791  setFEEnableRegister(result);
792  return *this;
793  }
tuple result
Definition: query.py:137
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 795 of file SiStripFEDBufferComponents.cc.

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

796  {
797  const uint8_t mask = 0x1 << internalFEUnitNum;
798  const uint8_t result = ( (feOverflowRegister() & (~mask)) | (overflow?mask:0x00) );
799  setFEEnableRegister(result);
800  return *this;
801  }
tuple result
Definition: query.py:137
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 718 of file SiStripFEDBufferComponents.cc.

References edm::hlt::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().

719  {
720  switch(headerType) {
723  case HEADER_TYPE_NONE:
725  return *this;
726  default:
727  std::ostringstream ss;
728  ss << "Invalid header type: ";
729  printHex(&headerType,1,ss);
730  throw cms::Exception("FEDBuffer") << ss.str();
731  }
732  }
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 734 of file SiStripFEDBufferComponents.cc.

References edm::hlt::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_LITE, setDataTypeBit(), setReadoutModeBits(), and contentValuesCheck::ss.

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

735  {
736  switch(readoutMode) {
737  case READOUT_MODE_SCOPE:
738  //scope mode is always real
740  setDataTypeBit(true);
745  case READOUT_MODE_SPY:
747  break;
749  //special mode for simulation
751  setDataTypeBit(true);
752  break;
753  default:
754  std::ostringstream ss;
755  ss << "Invalid readout mode: ";
756  printHex(&readoutMode,1,ss);
757  throw cms::Exception("FEDBuffer") << ss.str();
758  }
759  return *this;
760  }
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 731 of file SiStripFEDBufferComponents.h.

References wordSwapped_.

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

732  {
733  return wordSwapped_;
734  }

Member Data Documentation

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