CMS 3D CMS Logo

RPixErrorChecker.cc
Go to the documentation of this file.
2 
5 
7 
8 using namespace edm;
9 
11 
13 {
14  includeErrors_ = false;
15 }
16 
17 void RPixErrorChecker::setErrorStatus(bool errorStatus)
18 {
19  includeErrors_ = errorStatus;
20 }
21 
22 bool RPixErrorChecker::checkCRC(bool& errorsInEvent, int fedId, const Word64* trailer, Errors& errors) const
23 {
24  int CRC_BIT = (*trailer >> CRC_shift) & CRC_mask;
25  if (CRC_BIT == 0) return true;
26  errorsInEvent = true;
27  LogDebug("CRCCheck")
28  <<"CRC check failed, errorType = 39";
29  if (includeErrors_) {
30  int errorType = 39;
31  CTPPSPixelDataError error(*trailer, errorType, fedId);
32  errors[dummyDetId].push_back(error);
33  }
34  return false;
35 }
36 
37 bool RPixErrorChecker::checkHeader(bool& errorsInEvent, int fedId, const Word64* header, Errors& errors) const
38 {
39  FEDHeader fedHeader( reinterpret_cast<const unsigned char*>(header));
40  if ( !fedHeader.check() ) return false;
41  if ( fedHeader.sourceID() != fedId) {
42  LogDebug("CTPPSPixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId")
43  <<", sourceID = " <<fedHeader.sourceID()
44  <<", fedId = "<<fedId<<", errorType = 32";
45  errorsInEvent = true;
46  if (includeErrors_) {
47  int errorType = 32;
48  CTPPSPixelDataError error(*header, errorType, fedId);
49  errors[dummyDetId].push_back(error);
50  }
51  }
52  return fedHeader.moreHeaders();
53 }
54 
55 bool RPixErrorChecker::checkTrailer(bool& errorsInEvent, int fedId, unsigned int nWords, const Word64* trailer, Errors& errors) const
56 {
57  FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
58  if ( !fedTrailer.check()) {
59  if(includeErrors_) {
60  int errorType = 33;
61  CTPPSPixelDataError error(*trailer, errorType, fedId);
62  errors[dummyDetId].push_back(error);
63  }
64  errorsInEvent = true;
65  LogDebug("FedTrailerCheck")
66  <<"fedTrailer.check failed, Fed: " << fedId << ", errorType = 33";
67  return false;
68  }
69  if ( fedTrailer.fragmentLength()!= nWords) {
70  LogDebug("FedTrailerLenght")<< "fedTrailer.fragmentLength()!= nWords !! Fed: " << fedId << ", errorType = 34";
71  errorsInEvent = true;
72  if(includeErrors_) {
73  int errorType = 34;
74  CTPPSPixelDataError error(*trailer, errorType, fedId);
75  errors[dummyDetId].push_back(error);
76  }
77  }
78  return fedTrailer.moreTrailers();
79 }
80 
81 bool RPixErrorChecker::checkROC(bool& errorsInEvent, int fedId, uint32_t iD, const Word32& errorWord, Errors& errors) const
82 {
83  int errorType = (errorWord >> ROC_shift) & ERROR_mask;
84  if LIKELY(errorType<25) return true;
85 
86  switch (errorType) {
87  case(25) : {
88  LogDebug("")<<" invalid ROC=25 found (errorType=25)";
89  errorsInEvent = true;
90  break;
91  }
92  case(26) : {
93  LogDebug("")<<" gap word found (errorType=26)";
94  return false;
95  }
96  case(27) : {
97  LogDebug("")<<" dummy word found (errorType=27)";
98  return false;
99  }
100  case(28) : {
101  LogDebug("")<<" error fifo nearly full (errorType=28)";
102  errorsInEvent = true;
103  break;
104  }
105  case(29) : {
106  LogDebug("")<<" timeout on a channel (errorType=29)";
107  errorsInEvent = true;
108  if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) {
109  LogDebug("")<<" ...first errorType=29 error, this gets masked out";
110  return false;
111  }
112  break;
113  }
114  case(30) : {
115  LogDebug("")<<" TBM error trailer (errorType=30)";
116  errorsInEvent = true;
117  break;
118  }
119  case(31) : {
120  LogDebug("")<<" event number error (errorType=31)";
121  errorsInEvent = true;
122  break;
123  }
124  default: return true;
125  };
126 
127  if(includeErrors_) {
129  if(errorType==30) {
130  uint32_t stateMach_bits = 4;
131  uint32_t stateMach_shift = 8;
132  uint32_t stateMach_mask = ~(~uint32_t(0) << stateMach_bits);
133  uint32_t stateMach = (errorWord >> stateMach_shift) & stateMach_mask;
134  if( stateMach==4 || stateMach==9 ) errorType = 40;
135  }
136 
138  CTPPSPixelDataError error(errorWord, errorType, fedId);
139 
140  errors[iD].push_back(error);
141 }
142 
143  return false;
144 }
145 
146 void RPixErrorChecker::conversionError(int fedId, uint32_t iD, const State& state, const Word32& errorWord, Errors& errors) const
147 {
148  int errorType = 0;
149 
150  switch (state) {
151  case(InvalidLinkId) : {
152  LogDebug("ErrorChecker::conversionError") << " Fed: " << fedId << " invalid channel Id (errorType=35)";
153  errorType = 35;
154  break;
155  }
156  case(InvalidROCId) : {
157  LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << " invalid ROC Id (errorType=36)";
158  errorType = 36;
159  break;
160  }
161  case(InvalidPixelId) : {
162  LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << " invalid dcol/pixel value (errorType=37)";
163  errorType = 37;
164  break;
165  }
166 
167  default: LogDebug("ErrorChecker::conversionError")<<" cabling check returned unexpected result, status = "<< state;
168  };
169 
170  if(includeErrors_ && errorType>0){
171  CTPPSPixelDataError error(errorWord, errorType, fedId);
172  errors[iD].push_back(error);
173  }
174 }
#define LogDebug(id)
void conversionError(int fedId, uint32_t iD, const State &state, const Word32 &errorWord, Errors &errors) const
bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer, Errors &errors) const
bool moreHeaders() const
Definition: FEDHeader.cc:42
bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header, Errors &errors) const
bool check() const
Check that the header is OK.
Definition: FEDHeader.cc:72
uint16_t sourceID() const
Identifier of the FED.
Definition: FEDHeader.cc:32
bool check() const
Check that the trailer is OK.
Definition: FEDTrailer.cc:83
bool moreTrailers() const
Definition: FEDTrailer.cc:37
std::map< uint32_t, DetErrors > Errors
#define constexpr
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:17
static constexpr Word32 dummyDetId
void setErrorStatus(bool errorStatus)
HLT enums.
#define LIKELY(x)
bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords, const Word64 *trailer, Errors &errors) const
Definition: errors.py:1
bool checkROC(bool &errorsInEvent, int fedId, uint32_t iD, const Word32 &errorWord, Errors &errors) const
Pixel error – collection of errors.