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

Member Enumeration Documentation

Constructor & Destructor Documentation

sistrip::TrackerSpecialHeader::TrackerSpecialHeader ( )
inline

Definition at line 671 of file SiStripFEDBufferComponents.h.

672  : wordSwapped_(false)
673  {
674  }
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_.

612  {
613  //the buffer format byte is one of the valid values if we assume the buffer is not swapped
614  const bool validFormatByteWhenNotWordSwapped = ( (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_NEW) ||
615  (headerPointer[BUFFERFORMAT] == BUFFER_FORMAT_CODE_OLD) );
616  //the buffer format byte is the old value if we assume the buffer is swapped
617  const bool validFormatByteWhenWordSwapped = (headerPointer[BUFFERFORMAT^4] == BUFFER_FORMAT_CODE_OLD);
618  //if the buffer format byte is valid if the buffer is not swapped or it is never valid
619  if (validFormatByteWhenNotWordSwapped || (!validFormatByteWhenNotWordSwapped && !validFormatByteWhenWordSwapped) ) {
620  memcpy(specialHeader_,headerPointer,8);
621  wordSwapped_ = false;
622  } else {
623  memcpy(specialHeader_,headerPointer+4,4);
624  memcpy(specialHeader_+4,headerPointer,4);
625  wordSwapped_ = true;
626  }
627  }
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 788 of file SiStripFEDBufferComponents.cc.

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

793  {
794  memset(specialHeader_,0x00,8);
795  //determine if order is swapped in real buffer
797  //set fields
802  setAPVEAddress(address);
803  setAPVEAddressErrorRegister(addressErrorRegister);
807  }
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 629 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 725 of file SiStripFEDBufferComponents.h.

References specialHeader_.

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

726  {
727  return specialHeader_;
728  }
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().

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

Definition at line 719 of file SiStripFEDBufferComponents.h.

References fedStatusRegisterWord().

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

720  { 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().

713  {
714  //get 16 bits
715  uint16_t statusRegister = ( (specialHeader_[(FEDSTATUS+1)]<<8) | specialHeader_[FEDSTATUS]);
716  return statusRegister;
717  }
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().

700  {
701  return ( (0x1<<internalFEUnitNum) & feEnableRegister() );
702  }
uint8_t sistrip::TrackerSpecialHeader::feEnableRegister ( ) const
inline
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().

708  {
709  return ( (0x1<<internalFEUnitNum) & feOverflowRegister() );
710  }
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 722 of file SiStripFEDBufferComponents.h.

References sistrip::printHex(), and specialHeader_.

Referenced by sistrip::operator<<().

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

Definition at line 648 of file SiStripFEDBufferComponents.cc.

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

649  {
650  const uint8_t eventTypeNibble = trackerEventTypeNibble();
651  //if it is scope mode then return as is (it cannot be fake data)
652  if (eventTypeNibble == READOUT_MODE_SCOPE) return FEDReadoutMode(eventTypeNibble);
653  //if not then ignore the last bit which indicates if it is real or fake
654  else {
655  const uint8_t mode = (eventTypeNibble & 0xE);
656  switch(mode) {
661  case READOUT_MODE_SPY:
662  return FEDReadoutMode(mode);
663  default:
664  return READOUT_MODE_INVALID;
665  }
666  }
667  }
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().

765  {
766  const uint8_t mask = 0x1 << internalFEUnitNum;
767  const uint8_t result = ( (apvAddressErrorRegister() & (~mask)) | (error?mask:0x00) );
769  return *this;
770  }
TrackerSpecialHeader & setAPVEAddressErrorRegister(const uint8_t addressErrorRegister)
tuple result
Definition: query.py:137
TrackerSpecialHeader & sistrip::TrackerSpecialHeader::setAPVEAddress ( const uint8_t  address)
inline

Definition at line 750 of file SiStripFEDBufferComponents.h.

References APVEADDRESS, and specialHeader_.

Referenced by TrackerSpecialHeader().

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().

757  {
758  specialHeader_[ADDRESSERROR] = addressErrorRegister;
759  return *this;
760  }
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().

679  {
680  //check if order in buffer is different
681  if ( ( (bufferFormat()==BUFFER_FORMAT_OLD_VME) && (newBufferFormat!=BUFFER_FORMAT_OLD_VME) ) ||
682  ( (bufferFormat()!=BUFFER_FORMAT_OLD_VME) && (newBufferFormat==BUFFER_FORMAT_OLD_VME) ) ) {
684  }
685  //set appropriate code
686  setBufferFormatByte(newBufferFormat);
687  return *this;
688  }
void setBufferFormatByte(const FEDBufferFormat newBufferFormat)
void sistrip::TrackerSpecialHeader::setBufferFormatByte ( const FEDBufferFormat  newBufferFormat)
private

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

691  {
692  switch (newBufferFormat) {
696  break;
697  case BUFFER_FORMAT_NEW:
699  break;
700  default:
701  std::ostringstream ss;
702  ss << "Invalid buffer format: ";
703  printHex(&newBufferFormat,1,ss);
704  throw cms::Exception("FEDBuffer") << ss.str();
705  }
706  }
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 747 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().

748  {
749  //if mode is scope then this bit can't be changed
750  if (readoutMode() == READOUT_MODE_SCOPE) return *this;
751  switch (dataType) {
752  case DATA_TYPE_REAL:
753  case DATA_TYPE_FAKE:
755  return *this;
756  default:
757  std::ostringstream ss;
758  ss << "Invalid data type: ";
759  printHex(&dataType,1,ss);
760  throw cms::Exception("FEDBuffer") << ss.str();
761  }
762  }
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 774 of file SiStripFEDBufferComponents.h.

References FEDSTATUS, fedStatusRegister(), and specialHeader_.

Referenced by TrackerSpecialHeader().

775  {
776  specialHeader_[FEDSTATUS] = (static_cast<uint16_t>(fedStatusRegister) & 0x00FF);
777  specialHeader_[FEDSTATUS+1] = ( (static_cast<uint16_t>(fedStatusRegister) & 0xFF00) >> 8);
778  return *this;
779  }
FEDStatusRegister fedStatusRegister() const
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().

773  {
774  const uint8_t mask = 0x1 << internalFEUnitNum;
775  const uint8_t result = ( (feEnableRegister() & (~mask)) | (enabled?mask:0x00) );
776  setFEEnableRegister(result);
777  return *this;
778  }
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 780 of file SiStripFEDBufferComponents.cc.

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

781  {
782  const uint8_t mask = 0x1 << internalFEUnitNum;
783  const uint8_t result = ( (feOverflowRegister() & (~mask)) | (overflow?mask:0x00) );
784  setFEEnableRegister(result);
785  return *this;
786  }
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 708 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().

709  {
710  switch(headerType) {
713  case HEADER_TYPE_NONE:
715  return *this;
716  default:
717  std::ostringstream ss;
718  ss << "Invalid header type: ";
719  printHex(&headerType,1,ss);
720  throw cms::Exception("FEDBuffer") << ss.str();
721  }
722  }
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 724 of file SiStripFEDBufferComponents.cc.

References edm::hlt::Exception, sistrip::printHex(), 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().

725  {
726  switch(readoutMode) {
727  case READOUT_MODE_SCOPE:
728  //scope mode is always real
730  setDataTypeBit(true);
735  case READOUT_MODE_SPY:
737  break;
738  default:
739  std::ostringstream ss;
740  ss << "Invalid readout mode: ";
741  printHex(&readoutMode,1,ss);
742  throw cms::Exception("FEDBuffer") << ss.str();
743  }
744  return *this;
745  }
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 730 of file SiStripFEDBufferComponents.h.

References wordSwapped_.

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

731  {
732  return wordSwapped_;
733  }

Member Data Documentation

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