CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Attributes | Private Attributes
RPixErrorChecker Class Reference

#include <RPixErrorChecker.h>

Public Types

typedef std::vector
< CTPPSPixelDataError
DetErrors
 
typedef std::map< uint32_t,
DetErrors
Errors
 
typedef uint32_t Word32
 
typedef uint64_t Word64
 

Public Member Functions

bool checkCRC (bool &errorsInEvent, int fedId, const Word64 *trailer, Errors &errors) const
 
bool checkHeader (bool &errorsInEvent, int fedId, const Word64 *header, Errors &errors) const
 
bool checkROC (bool &errorsInEvent, int fedId, uint32_t iD, const Word32 &errorWord, Errors &errors) const
 
bool checkTrailer (bool &errorsInEvent, int fedId, unsigned int nWords, const Word64 *trailer, Errors &errors) const
 
void conversionError (int fedId, uint32_t iD, const State &state, const Word32 &errorWord, Errors &errors) const
 
 RPixErrorChecker ()
 
void setErrorStatus (bool errorStatus)
 

Static Public Attributes

static constexpr int ADC_bits = 8
 
static constexpr int ADC_shift = 0
 
static constexpr int CRC_bits = 1
 
static constexpr Word64 CRC_mask = ~(~RPixErrorChecker::Word64(0) << CRC_bits)
 
static constexpr int CRC_shift = 2
 
static constexpr int DCOL_bits = 5
 
static constexpr int DCOL_shift = PXID_shift + PXID_bits
 
static constexpr Word32 dummyDetId = 0xffffffff
 
static constexpr Word32 ERROR_mask = ~(~RPixErrorChecker::Word32(0) << ROC_bits)
 
static constexpr int OMIT_ERR_bits = 1
 
static constexpr Word32 OMIT_ERR_mask = ~(~RPixErrorChecker::Word32(0) << OMIT_ERR_bits)
 
static constexpr int OMIT_ERR_shift = 20
 
static constexpr int PXID_bits = 8
 
static constexpr int PXID_shift = ADC_shift + ADC_bits
 
static constexpr int ROC_bits = 5
 
static constexpr int ROC_shift = DCOL_shift + DCOL_bits
 

Private Attributes

bool includeErrors_
 

Detailed Description

RPix == CTPPS Pixel detector (Roman Pot Pixels)

Definition at line 17 of file RPixErrorChecker.h.

Member Typedef Documentation

Definition at line 22 of file RPixErrorChecker.h.

typedef std::map<uint32_t, DetErrors> RPixErrorChecker::Errors

Definition at line 23 of file RPixErrorChecker.h.

typedef uint32_t RPixErrorChecker::Word32

Definition at line 19 of file RPixErrorChecker.h.

typedef uint64_t RPixErrorChecker::Word64

Definition at line 20 of file RPixErrorChecker.h.

Constructor & Destructor Documentation

RPixErrorChecker::RPixErrorChecker ( )

Definition at line 12 of file RPixErrorChecker.cc.

12 { includeErrors_ = false; }

Member Function Documentation

bool RPixErrorChecker::checkCRC ( bool &  errorsInEvent,
int  fedId,
const Word64 trailer,
Errors errors 
) const

Definition at line 16 of file RPixErrorChecker.cc.

References sipixelconstants::CRC_mask, sipixelconstants::CRC_shift, sipixelconstants::dummyDetId, and LogDebug.

Referenced by CTPPSPixelDataFormatter::interpretRawData().

16  {
17  int CRC_BIT = (*trailer >> CRC_shift) & CRC_mask;
18  if (CRC_BIT == 0)
19  return true;
20  errorsInEvent = true;
21  LogDebug("CRCCheck") << "CRC check failed, errorType = 39";
22  if (includeErrors_) {
23  int errorType = 39;
24  errors[dummyDetId].emplace_back(*trailer, errorType, fedId);
25  }
26  return false;
27 }
static constexpr int CRC_shift
static constexpr Word32 dummyDetId
static constexpr Word64 CRC_mask
#define LogDebug(id)
bool RPixErrorChecker::checkHeader ( bool &  errorsInEvent,
int  fedId,
const Word64 header,
Errors errors 
) const

Definition at line 29 of file RPixErrorChecker.cc.

References FEDHeader::check(), sipixelconstants::dummyDetId, l1tstage2_dqm_sourceclient-live_cfg::fedId, LogDebug, FEDHeader::moreHeaders(), and FEDHeader::sourceID().

Referenced by CTPPSPixelDataFormatter::interpretRawData().

29  {
30  FEDHeader fedHeader(reinterpret_cast<const unsigned char*>(header));
31  if (!fedHeader.check())
32  return false;
33  if (fedHeader.sourceID() != fedId) {
34  LogDebug("CTPPSPixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId")
35  << ", sourceID = " << fedHeader.sourceID() << ", fedId = " << fedId << ", errorType = 32";
36  errorsInEvent = true;
37  if (includeErrors_) {
38  int errorType = 32;
39  errors[dummyDetId].emplace_back(*header, errorType, fedId);
40  }
41  }
42  return fedHeader.moreHeaders();
43 }
static constexpr Word32 dummyDetId
#define LogDebug(id)
bool RPixErrorChecker::checkROC ( bool &  errorsInEvent,
int  fedId,
uint32_t  iD,
const Word32 errorWord,
Errors errors 
) const

check to see if overflow error for type 30, change type to 40 if so

store error

Definition at line 68 of file RPixErrorChecker.cc.

References sipixelconstants::ERROR_mask, LIKELY, LogDebug, sipixelconstants::OMIT_ERR_mask, sipixelconstants::OMIT_ERR_shift, and sipixelconstants::ROC_shift.

Referenced by CTPPSPixelDataFormatter::interpretRawData().

69  {
70  int errorType = (errorWord >> ROC_shift) & ERROR_mask;
71  if LIKELY (errorType < 25)
72  return true;
73 
74  switch (errorType) {
75  case (25): {
76  LogDebug("") << " invalid ROC=25 found (errorType=25)";
77  errorsInEvent = true;
78  break;
79  }
80  case (26): {
81  LogDebug("") << " gap word found (errorType=26)";
82  return false;
83  }
84  case (27): {
85  LogDebug("") << " dummy word found (errorType=27)";
86  return false;
87  }
88  case (28): {
89  LogDebug("") << " error fifo nearly full (errorType=28)";
90  errorsInEvent = true;
91  break;
92  }
93  case (29): {
94  LogDebug("") << " timeout on a channel (errorType=29)";
95  errorsInEvent = true;
96  if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) {
97  LogDebug("") << " ...first errorType=29 error, this gets masked out";
98  return false;
99  }
100  break;
101  }
102  case (30): {
103  LogDebug("") << " TBM error trailer (errorType=30)";
104  errorsInEvent = true;
105  break;
106  }
107  case (31): {
108  LogDebug("") << " event number error (errorType=31)";
109  errorsInEvent = true;
110  break;
111  }
112  default:
113  return true;
114  };
115 
116  if (includeErrors_) {
118  if (errorType == 30) {
119  uint32_t stateMach_bits = 4;
120  uint32_t stateMach_shift = 8;
121  uint32_t stateMach_mask = ~(~uint32_t(0) << stateMach_bits);
122  uint32_t stateMach = (errorWord >> stateMach_shift) & stateMach_mask;
123  if (stateMach == 4 || stateMach == 9)
124  errorType = 40;
125  }
126 
128  errors[iD].emplace_back(errorWord, errorType, fedId);
129  }
130 
131  return false;
132 }
static constexpr int OMIT_ERR_shift
#define LIKELY(x)
Definition: Likely.h:20
static constexpr Word32 OMIT_ERR_mask
static constexpr Word32 ERROR_mask
static constexpr int ROC_shift
#define LogDebug(id)
bool RPixErrorChecker::checkTrailer ( bool &  errorsInEvent,
int  fedId,
unsigned int  nWords,
const Word64 trailer,
Errors errors 
) const

Definition at line 45 of file RPixErrorChecker.cc.

References FEDTrailer::check(), sipixelconstants::dummyDetId, FEDTrailer::fragmentLength(), LogDebug, and FEDTrailer::moreTrailers().

Referenced by CTPPSPixelDataFormatter::interpretRawData().

46  {
47  FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
48  if (!fedTrailer.check()) {
49  if (includeErrors_) {
50  int errorType = 33;
51  errors[dummyDetId].emplace_back(*trailer, errorType, fedId);
52  }
53  errorsInEvent = true;
54  LogDebug("FedTrailerCheck") << "fedTrailer.check failed, Fed: " << fedId << ", errorType = 33";
55  return false;
56  }
57  if (fedTrailer.fragmentLength() != nWords) {
58  LogDebug("FedTrailerLenght") << "fedTrailer.fragmentLength()!= nWords !! Fed: " << fedId << ", errorType = 34";
59  errorsInEvent = true;
60  if (includeErrors_) {
61  int errorType = 34;
62  errors[dummyDetId].emplace_back(*trailer, errorType, fedId);
63  }
64  }
65  return fedTrailer.moreTrailers();
66 }
static constexpr Word32 dummyDetId
#define LogDebug(id)
void RPixErrorChecker::conversionError ( int  fedId,
uint32_t  iD,
const State state,
const Word32 errorWord,
Errors errors 
) const

Definition at line 134 of file RPixErrorChecker.cc.

References InvalidLinkId, InvalidPixelId, InvalidROCId, and LogDebug.

Referenced by CTPPSPixelDataFormatter::interpretRawData().

135  {
136  int errorType = 0;
137 
138  switch (state) {
139  case (InvalidLinkId): {
140  LogDebug("ErrorChecker::conversionError") << " Fed: " << fedId << " invalid channel Id (errorType=35)";
141  errorType = 35;
142  break;
143  }
144  case (InvalidROCId): {
145  LogDebug("ErrorChecker::conversionError") << " Fed: " << fedId << " invalid ROC Id (errorType=36)";
146  errorType = 36;
147  break;
148  }
149  case (InvalidPixelId): {
150  LogDebug("ErrorChecker::conversionError") << " Fed: " << fedId << " invalid dcol/pixel value (errorType=37)";
151  errorType = 37;
152  break;
153  }
154 
155  default:
156  LogDebug("ErrorChecker::conversionError") << " cabling check returned unexpected result, status = " << state;
157  };
158 
159  if (includeErrors_ && errorType > 0)
160  errors[iD].emplace_back(errorWord, errorType, fedId);
161 }
#define LogDebug(id)
void RPixErrorChecker::setErrorStatus ( bool  errorStatus)

Definition at line 14 of file RPixErrorChecker.cc.

Referenced by CTPPSPixelDataFormatter::setErrorStatus().

14 { includeErrors_ = errorStatus; }

Member Data Documentation

constexpr int RPixErrorChecker::ADC_bits = 8
static

Definition at line 29 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::ADC_shift = 0
static

Definition at line 33 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::CRC_bits = 1
static

Definition at line 25 of file RPixErrorChecker.h.

constexpr Word64 RPixErrorChecker::CRC_mask = ~(~RPixErrorChecker::Word64(0) << CRC_bits)
static

Definition at line 41 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::CRC_shift = 2
static

Definition at line 32 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::DCOL_bits = 5
static

Definition at line 27 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::DCOL_shift = PXID_shift + PXID_bits
static

Definition at line 35 of file RPixErrorChecker.h.

constexpr RPixErrorChecker::Word32 RPixErrorChecker::dummyDetId = 0xffffffff
static
constexpr Word32 RPixErrorChecker::ERROR_mask = ~(~RPixErrorChecker::Word32(0) << ROC_bits)
static

Definition at line 42 of file RPixErrorChecker.h.

bool RPixErrorChecker::includeErrors_
private

Definition at line 61 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::OMIT_ERR_bits = 1
static

Definition at line 30 of file RPixErrorChecker.h.

constexpr Word32 RPixErrorChecker::OMIT_ERR_mask = ~(~RPixErrorChecker::Word32(0) << OMIT_ERR_bits)
static

Definition at line 43 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::OMIT_ERR_shift = 20
static

Definition at line 37 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::PXID_bits = 8
static

Definition at line 28 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::PXID_shift = ADC_shift + ADC_bits
static

Definition at line 34 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::ROC_bits = 5
static

Definition at line 26 of file RPixErrorChecker.h.

constexpr int RPixErrorChecker::ROC_shift = DCOL_shift + DCOL_bits
static

Definition at line 36 of file RPixErrorChecker.h.