CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Phase2Tracker::Phase2TrackerFEDHeader Class Reference

#include <Phase2TrackerFEDHeader.h>

Public Member Functions

std::vector< uint8_t > CBCStatus () const
 
std::vector< bool > frontendStatus () const
 
uint8_t getConditionData () const
 
uint8_t getDataFormatVersion () const
 
uint8_t getDataType () const
 
READ_MODE getDebugMode () const
 
uint8_t getEventType () const
 
uint64_t getGlibStatusCode () const
 
uint16_t getNumberOfCBC () const
 
const uint8_t * getPointerToData () const
 
FEDReadoutMode getReadoutMode () const
 
uint8_t getTrackerHeaderSize () const
 
 Phase2TrackerFEDHeader ()
 
 Phase2TrackerFEDHeader (const uint8_t *headerPointer)
 

Private Member Functions

uint8_t conditionData () const
 
uint8_t dataFormatVersion () const
 
uint8_t dataType () const
 
READ_MODE debugMode () const
 
uint8_t eventType () const
 
uint64_t glibStatusCode () const
 
void init ()
 
uint16_t numberOfCBC () const
 
const uint8_t * pointerToData ()
 
FEDReadoutMode readoutMode () const
 

Private Attributes

uint8_t conditionData_
 
uint8_t dataFormatVersion_
 
uint8_t dataType_
 
READ_MODE debugMode_
 
uint8_t eventType_
 
uint64_t glibStatusCode_
 
uint64_t header_first_word_
 
uint64_t header_second_word_
 
uint16_t numberOfCBC_
 
const uint8_t * pointerToData_
 
FEDReadoutMode readoutMode_
 
const uint8_t * trackerHeader_
 
uint8_t trackerHeaderSize_
 

Detailed Description

Definition at line 12 of file Phase2TrackerFEDHeader.h.

Constructor & Destructor Documentation

◆ Phase2TrackerFEDHeader() [1/2]

Phase2Tracker::Phase2TrackerFEDHeader::Phase2TrackerFEDHeader ( )
inline

Definition at line 14 of file Phase2TrackerFEDHeader.h.

14 {}

◆ Phase2TrackerFEDHeader() [2/2]

Phase2Tracker::Phase2TrackerFEDHeader::Phase2TrackerFEDHeader ( const uint8_t *  headerPointer)
explicit

Definition at line 8 of file Phase2TrackerFEDHeader.cc.

References header_first_word_, header_second_word_, init(), Phase2Tracker::read64(), and trackerHeader_.

8  : trackerHeader_(headerPointer) {
11  // decode the Tracker Header and store info
12  init();
13  }
uint64_t read64(int offset, const uint8_t *buffer)
Definition: utils.h:186

Member Function Documentation

◆ CBCStatus()

std::vector< uint8_t > Phase2Tracker::Phase2TrackerFEDHeader::CBCStatus ( ) const

Definition at line 127 of file Phase2TrackerFEDHeader.cc.

References Phase2Tracker::CBC_ERROR, debugMode_, Phase2Tracker::FULL_DEBUG, header_second_word_, numberOfCBC(), hltrates_dqm_sourceclient-live_cfg::offset, Phase2Tracker::read64(), and trackerHeader_.

Referenced by Phase2Tracker::Phase2TrackerDigiProducer::produce().

127  {
128  // set offset and data to begining of second header 64 bit word
129  int offset = 8;
130  uint64_t data64 = header_second_word_;
131  // number of CBC:
132  uint16_t cbc_num = numberOfCBC();
133  // size of data per CBC (in bits)
134  int status_size = 0;
135  if (debugMode_ == FULL_DEBUG) {
136  status_size = 8;
137  } else if (debugMode_ == CBC_ERROR) {
138  status_size = 1;
139  }
140  // starting byte for CBC status bits
141  std::vector<uint8_t> cbc_status;
142  if (status_size == 8) {
143  int num_bytes = cbc_num;
144  int current_byte = 5;
145  while (num_bytes > 0) {
146  cbc_status.push_back(static_cast<uint8_t>((data64 >> current_byte * 8) & 0xFF));
147  if (current_byte == 0) {
148  current_byte = 8;
149  offset += 8;
150  data64 = read64(offset, trackerHeader_);
151  }
152  current_byte--;
153  num_bytes--;
154  }
155  } else if (status_size == 1) {
156  int current_bit = 47;
157  int num_bits = cbc_num;
158  while (num_bits > 0) {
159  cbc_status.push_back(static_cast<uint8_t>((data64 >> current_bit) & 0x1));
160  if (current_bit == 0) {
161  current_bit = 64;
162  offset += 8;
163  data64 = read64(offset, trackerHeader_);
164  }
165  current_bit--;
166  num_bits--;
167  }
168  }
169 
170  return cbc_status;
171  }
unsigned long long uint64_t
Definition: Time.h:13
uint64_t read64(int offset, const uint8_t *buffer)
Definition: utils.h:186

◆ conditionData()

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::conditionData ( ) const
private

Definition at line 101 of file Phase2TrackerFEDHeader.cc.

References eventType_.

Referenced by init().

101 { return static_cast<uint8_t>(eventType_ >> 1) & 0x1; }

◆ dataFormatVersion()

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::dataFormatVersion ( ) const
private

Definition at line 44 of file Phase2TrackerFEDHeader.cc.

References Exception, Phase2Tracker::extract64(), header_first_word_, Phase2Tracker::printHex(), contentValuesCheck::ss, Phase2Tracker::VERSION_M, and Phase2Tracker::VERSION_S.

Referenced by init().

44  {
45  uint8_t Version = static_cast<uint8_t>(extract64(VERSION_M, VERSION_S, header_first_word_));
46  if (Version != 1) {
47  std::ostringstream ss;
48  ss << "[Phase2Tracker::Phase2TrackerFEDHeader::" << __func__ << "] ";
49  ss << "Invalid Data Format Version in Traker Header : ";
51  throw cms::Exception("Phase2TrackerFEDBuffer") << ss.str();
52  }
53  return Version;
54  }
void printHex(const void *pointer, const size_t lengthInBytes, std::ostream &os)
Definition: utils.h:58
uint64_t extract64(trackerHeader_m mask, trackerHeader_s shift, uint64_t data)
Definition: utils.h:191

◆ dataType()

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::dataType ( ) const
private

Definition at line 103 of file Phase2TrackerFEDHeader.cc.

References eventType_.

Referenced by init().

103 { return static_cast<uint8_t>(eventType_) & 0x1; }

◆ debugMode()

READ_MODE Phase2Tracker::Phase2TrackerFEDHeader::debugMode ( ) const
private

Definition at line 56 of file Phase2TrackerFEDHeader.cc.

References Phase2Tracker::CBC_ERROR, Exception, Phase2Tracker::extract64(), Phase2Tracker::FULL_DEBUG, header_first_word_, Phase2Tracker::HEADER_FORMAT_M, Phase2Tracker::HEADER_FORMAT_S, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, Phase2Tracker::printHex(), Phase2Tracker::READ_MODE_INVALID, contentValuesCheck::ss, and Phase2Tracker::SUMMARY.

Referenced by init().

56  {
57  // Read debugMode in Tracker Header
58  uint8_t mode = static_cast<uint8_t>(extract64(HEADER_FORMAT_M, HEADER_FORMAT_S, header_first_word_));
59 
60  switch (mode) { // check if it is one of correct modes
61  case SUMMARY:
62  return READ_MODE(SUMMARY);
63  case FULL_DEBUG:
64  return READ_MODE(FULL_DEBUG);
65  case CBC_ERROR:
66  return READ_MODE(CBC_ERROR);
67  default: // else create Exception
68  std::ostringstream ss;
69  ss << "[Phase2Tracker::Phase2TrackerFEDHeader::" << __func__ << "] ";
70  ss << "Invalid Header Format in Traker Header : ";
72  throw cms::Exception("Phase2TrackerFEDBuffer") << ss.str();
73  }
74 
76  }
void printHex(const void *pointer, const size_t lengthInBytes, std::ostream &os)
Definition: utils.h:58
uint64_t extract64(trackerHeader_m mask, trackerHeader_s shift, uint64_t data)
Definition: utils.h:191

◆ eventType()

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::eventType ( ) const
private

Definition at line 78 of file Phase2TrackerFEDHeader.cc.

References Phase2Tracker::EVENT_TYPE_M, Phase2Tracker::EVENT_TYPE_S, Phase2Tracker::extract64(), and header_first_word_.

Referenced by init().

78  {
79  return static_cast<uint8_t>(extract64(EVENT_TYPE_M, EVENT_TYPE_S, header_first_word_));
80  }
uint64_t extract64(trackerHeader_m mask, trackerHeader_s shift, uint64_t data)
Definition: utils.h:191

◆ frontendStatus()

std::vector< bool > Phase2Tracker::Phase2TrackerFEDHeader::frontendStatus ( ) const

Definition at line 109 of file Phase2TrackerFEDHeader.cc.

References Phase2Tracker::extract64(), Phase2Tracker::FRONTEND_STAT_M, Phase2Tracker::FRONTEND_STAT_S, header_first_word_, mps_fire::i, and mps_update::status.

Referenced by Phase2Tracker::Phase2TrackerFEDBuffer::findChannels(), and Phase2Tracker::Phase2TrackerDigiProducer::produce().

109  {
110  uint16_t FE_status = static_cast<uint16_t>(extract64(FRONTEND_STAT_M, FRONTEND_STAT_S, header_first_word_));
111  std::vector<bool> status(16, false);
112  for (int i = 0; i < 16; i++) {
113  status[i] = (FE_status >> i) & 0x1;
114  }
115  return status;
116  }
uint64_t extract64(trackerHeader_m mask, trackerHeader_s shift, uint64_t data)
Definition: utils.h:191

◆ getConditionData()

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::getConditionData ( ) const
inline

◆ getDataFormatVersion()

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::getDataFormatVersion ( ) const
inline

◆ getDataType()

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::getDataType ( ) const
inline

◆ getDebugMode()

READ_MODE Phase2Tracker::Phase2TrackerFEDHeader::getDebugMode ( ) const
inline

◆ getEventType()

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::getEventType ( ) const
inline

◆ getGlibStatusCode()

uint64_t Phase2Tracker::Phase2TrackerFEDHeader::getGlibStatusCode ( ) const
inline

◆ getNumberOfCBC()

uint16_t Phase2Tracker::Phase2TrackerFEDHeader::getNumberOfCBC ( ) const
inline

◆ getPointerToData()

const uint8_t* Phase2Tracker::Phase2TrackerFEDHeader::getPointerToData ( ) const
inline

◆ getReadoutMode()

FEDReadoutMode Phase2Tracker::Phase2TrackerFEDHeader::getReadoutMode ( ) const
inline

◆ getTrackerHeaderSize()

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::getTrackerHeaderSize ( ) const
inline

◆ glibStatusCode()

uint64_t Phase2Tracker::Phase2TrackerFEDHeader::glibStatusCode ( ) const
private

Definition at line 105 of file Phase2TrackerFEDHeader.cc.

References Phase2Tracker::extract64(), Phase2Tracker::GLIB_STATUS_M, Phase2Tracker::GLIB_STATUS_S, and header_first_word_.

Referenced by init().

105  {
107  }
uint64_t extract64(trackerHeader_m mask, trackerHeader_s shift, uint64_t data)
Definition: utils.h:191

◆ init()

void Phase2Tracker::Phase2TrackerFEDHeader::init ( void  )
private

Definition at line 15 of file Phase2TrackerFEDHeader.cc.

References conditionData(), conditionData_, dataFormatVersion(), dataFormatVersion_, dataType(), dataType_, debugMode(), debugMode_, TauDecayModes::dec, eventType(), eventType_, glibStatusCode(), glibStatusCode_, LogTrace, numberOfCBC(), numberOfCBC_, pointerToData(), pointerToData_, readoutMode(), and readoutMode_.

Referenced by Phase2TrackerFEDHeader().

15  {
18  // WARNING: eventType must be called before
19  // readoutMode, conditionData and dataType
20  // as this info is stored in eventType
24  dataType_ = dataType();
25 
27  // numberOfCBC must be called before pointerToData
30 
31  LogTrace("Phase2TrackerFEDBuffer") << "[Phase2Tracker::Phase2TrackerFEDHeader::" << __func__ << "]: \n"
32  << " Tracker Header contents:\n"
33  << " -- Data Format Version : " << uint32_t(dataFormatVersion_) << "\n"
34  << " -- Debug Level : " << debugMode_ << "\n"
35  << " -- Operating Mode : " << readoutMode_ << "\n"
36  << " -- Condition Data : " << (conditionData_ ? "Present" : "Absent")
37  << "\n"
38  << " -- Data Type : " << (dataType_ ? "Real" : "Fake") << "\n"
39  << " -- Glib Stat registers : " << std::hex << std::setw(16) << glibStatusCode_
40  << "\n"
41  << " -- connected CBC : " << std::dec << numberOfCBC_ << "\n";
42  }
#define LogTrace(id)

◆ numberOfCBC()

uint16_t Phase2Tracker::Phase2TrackerFEDHeader::numberOfCBC ( ) const
private

Definition at line 118 of file Phase2TrackerFEDHeader.cc.

References Phase2Tracker::CBC_NUMBER_M, Phase2Tracker::CBC_NUMBER_S, debugMode_, Phase2Tracker::extract64(), header_second_word_, and Phase2Tracker::SUMMARY.

Referenced by CBCStatus(), init(), and pointerToData().

118  {
119  if (debugMode_ != SUMMARY) {
120  return static_cast<uint16_t>(extract64(CBC_NUMBER_M, CBC_NUMBER_S, header_second_word_));
121  } else {
122  return 0;
123  }
124  }
uint64_t extract64(trackerHeader_m mask, trackerHeader_s shift, uint64_t data)
Definition: utils.h:191

◆ pointerToData()

const uint8_t * Phase2Tracker::Phase2TrackerFEDHeader::pointerToData ( )
private

Definition at line 173 of file Phase2TrackerFEDHeader.cc.

References Phase2Tracker::CBC_ERROR, debugMode_, Phase2Tracker::FULL_DEBUG, numberOfCBC(), trackerHeader_, and trackerHeaderSize_.

Referenced by init().

173  {
174  int status_size = 0;
175  int cbc_num = numberOfCBC();
176  // CAUTION: we express all sizes in bits here
177  if (debugMode_ == FULL_DEBUG) {
178  status_size = 8;
179  } else if (debugMode_ == CBC_ERROR) {
180  status_size = 1;
181  }
182  // compute number of additional 64 bit words before payload
183  int num_add_words64 = (cbc_num * status_size - 48 + 64 - 1) / 64;
184  // back to bytes
185  trackerHeaderSize_ = (2 + num_add_words64) * 8;
187  }

◆ readoutMode()

FEDReadoutMode Phase2Tracker::Phase2TrackerFEDHeader::readoutMode ( ) const
private

Definition at line 83 of file Phase2TrackerFEDHeader.cc.

References eventType_, Exception, header_first_word_, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, Phase2Tracker::printHex(), Phase2Tracker::READOUT_MODE_PROC_RAW, Phase2Tracker::READOUT_MODE_ZERO_SUPPRESSED, and contentValuesCheck::ss.

Referenced by init().

83  {
84  // readout mode is first bit of event type
85  uint8_t mode = static_cast<uint8_t>(eventType_ >> 2) & 0x3;
86 
87  switch (mode) { // check if it is one of correct modes
88  case 2:
90  case 1:
92  default: // else create Exception
93  std::ostringstream ss;
94  ss << "[Phase2Tracker::Phase2TrackerFEDHeader::" << __func__ << "] ";
95  ss << "Invalid Readout Mode in Traker Header : ";
97  throw cms::Exception("Phase2TrackerFEDBuffer") << ss.str();
98  }
99  }
FEDReadoutMode
Definition: utils.h:95
void printHex(const void *pointer, const size_t lengthInBytes, std::ostream &os)
Definition: utils.h:58

Member Data Documentation

◆ conditionData_

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::conditionData_
private

Definition at line 74 of file Phase2TrackerFEDHeader.h.

Referenced by getConditionData(), and init().

◆ dataFormatVersion_

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::dataFormatVersion_
private

Definition at line 70 of file Phase2TrackerFEDHeader.h.

Referenced by getDataFormatVersion(), and init().

◆ dataType_

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::dataType_
private

Definition at line 75 of file Phase2TrackerFEDHeader.h.

Referenced by getDataType(), and init().

◆ debugMode_

READ_MODE Phase2Tracker::Phase2TrackerFEDHeader::debugMode_
private

Definition at line 71 of file Phase2TrackerFEDHeader.h.

Referenced by CBCStatus(), getDebugMode(), init(), numberOfCBC(), and pointerToData().

◆ eventType_

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::eventType_
private

Definition at line 72 of file Phase2TrackerFEDHeader.h.

Referenced by conditionData(), dataType(), getEventType(), init(), and readoutMode().

◆ glibStatusCode_

uint64_t Phase2Tracker::Phase2TrackerFEDHeader::glibStatusCode_
private

Definition at line 76 of file Phase2TrackerFEDHeader.h.

Referenced by getGlibStatusCode(), and init().

◆ header_first_word_

uint64_t Phase2Tracker::Phase2TrackerFEDHeader::header_first_word_
private

◆ header_second_word_

uint64_t Phase2Tracker::Phase2TrackerFEDHeader::header_second_word_
private

Definition at line 69 of file Phase2TrackerFEDHeader.h.

Referenced by CBCStatus(), numberOfCBC(), and Phase2TrackerFEDHeader().

◆ numberOfCBC_

uint16_t Phase2Tracker::Phase2TrackerFEDHeader::numberOfCBC_
private

Definition at line 77 of file Phase2TrackerFEDHeader.h.

Referenced by getNumberOfCBC(), and init().

◆ pointerToData_

const uint8_t* Phase2Tracker::Phase2TrackerFEDHeader::pointerToData_
private

Definition at line 66 of file Phase2TrackerFEDHeader.h.

Referenced by getPointerToData(), and init().

◆ readoutMode_

FEDReadoutMode Phase2Tracker::Phase2TrackerFEDHeader::readoutMode_
private

Definition at line 73 of file Phase2TrackerFEDHeader.h.

Referenced by getReadoutMode(), and init().

◆ trackerHeader_

const uint8_t* Phase2Tracker::Phase2TrackerFEDHeader::trackerHeader_
private

Definition at line 65 of file Phase2TrackerFEDHeader.h.

Referenced by CBCStatus(), Phase2TrackerFEDHeader(), and pointerToData().

◆ trackerHeaderSize_

uint8_t Phase2Tracker::Phase2TrackerFEDHeader::trackerHeaderSize_
private

Definition at line 67 of file Phase2TrackerFEDHeader.h.

Referenced by getTrackerHeaderSize(), and pointerToData().