CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
ErrorChecker Class Reference

#include <ErrorChecker.h>

Inheritance diagram for ErrorChecker:
ErrorCheckerBase

Public Types

typedef std::vector< SiPixelRawDataErrorDetErrors
 
typedef std::map< cms_uint32_t, DetErrorsErrors
 
typedef cms_uint32_t Word32
 
typedef cms_uint64_t Word64
 
- Public Types inherited from ErrorCheckerBase
typedef std::vector< SiPixelRawDataErrorDetErrors
 
typedef std::map< cms_uint32_t, DetErrorsErrors
 
typedef cms_uint32_t Word32
 
typedef cms_uint64_t Word64
 

Public Member Functions

bool checkCRC (bool &errorsInEvent, int fedId, const Word64 *trailer, Errors &errors) override
 
bool checkHeader (bool &errorsInEvent, int fedId, const Word64 *header, Errors &errors) override
 
bool checkROC (bool &errorsInEvent, int fedId, const SiPixelFrameConverter *converter, const SiPixelFedCabling *theCablingTree, Word32 &errorWord, Errors &errors) override
 
bool checkTrailer (bool &errorsInEvent, int fedId, unsigned int nWords, const Word64 *trailer, Errors &errors) override
 
void conversionError (int fedId, const SiPixelFrameConverter *converter, int status, Word32 &errorWord, Errors &errors) override
 
 ErrorChecker ()
 
void setErrorStatus (bool ErrorStatus) override
 
- Public Member Functions inherited from ErrorCheckerBase
virtual ~ErrorCheckerBase ()
 

Private Member Functions

cms_uint32_t errorDetId (const SiPixelFrameConverter *converter, int errorType, const Word32 &word) const override
 

Private Attributes

bool includeErrors
 

Detailed Description

Definition at line 12 of file ErrorChecker.h.

Member Typedef Documentation

Definition at line 18 of file ErrorChecker.h.

Definition at line 19 of file ErrorChecker.h.

Definition at line 15 of file ErrorChecker.h.

Definition at line 16 of file ErrorChecker.h.

Constructor & Destructor Documentation

ErrorChecker::ErrorChecker ( )

Definition at line 46 of file ErrorChecker.cc.

46  {
47 
48  includeErrors = false;
49 }
bool includeErrors
Definition: ErrorChecker.h:42

Member Function Documentation

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

Implements ErrorCheckerBase.

Definition at line 56 of file ErrorChecker.cc.

References relativeConstraints::error.

57 {
58  int CRC_BIT = (*trailer >> CRC_shift) & CRC_mask;
59  if (CRC_BIT == 0) return true;
60  errorsInEvent = true;
61  if (includeErrors) {
62  int errorType = 39;
63  SiPixelRawDataError error(*trailer, errorType, fedId);
64  errors[dummyDetId].push_back(error);
65  }
66  return false;
67 }
bool includeErrors
Definition: ErrorChecker.h:42
Definition: errors.py:1
Pixel error – collection of errors and error information.
bool ErrorChecker::checkHeader ( bool &  errorsInEvent,
int  fedId,
const Word64 header,
Errors errors 
)
overridevirtual

Implements ErrorCheckerBase.

Definition at line 69 of file ErrorChecker.cc.

References FEDHeader::check(), relativeConstraints::error, l1t::stage2::layer2::fedId, LogDebug, FEDHeader::moreHeaders(), and FEDHeader::sourceID().

70 {
71  FEDHeader fedHeader( reinterpret_cast<const unsigned char*>(header));
72  if ( !fedHeader.check() ) return false; // throw exception?
73  if ( fedHeader.sourceID() != fedId) {
74  LogDebug("PixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId")
75  <<", sourceID = " <<fedHeader.sourceID()
76  <<", fedId = "<<fedId<<", errorType = 32";
77  errorsInEvent = true;
78  if (includeErrors) {
79  int errorType = 32;
80  SiPixelRawDataError error(*header, errorType, fedId);
81  errors[dummyDetId].push_back(error);
82  }
83  }
84  return fedHeader.moreHeaders();
85 }
#define LogDebug(id)
bool includeErrors
Definition: ErrorChecker.h:42
Definition: errors.py:1
Pixel error – collection of errors and error information.
bool ErrorChecker::checkROC ( bool &  errorsInEvent,
int  fedId,
const SiPixelFrameConverter converter,
const SiPixelFedCabling theCablingTree,
Word32 errorWord,
Errors errors 
)
overridevirtual

Implements ErrorCheckerBase.

Definition at line 113 of file ErrorChecker.cc.

References relativeConstraints::error, SiPixelFedCabling::findItem(), LIKELY, and LogDebug.

115 {
116  int errorType = (errorWord >> ROC_shift) & ERROR_mask;
117  if LIKELY(errorType<25) return true;
118 
119  switch (errorType) {
120  case(25) : {
121  CablingPathToDetUnit cablingPath = { unsigned(fedId), (errorWord >> LINK_shift) & LINK_mask, 1 };
122  if (!theCablingTree->findItem(cablingPath)) return false;
123  LogDebug("")<<" invalid ROC=25 found (errorType=25)";
124  errorsInEvent = true;
125  break;
126  }
127  case(26) : {
128  //LogDebug("")<<" gap word found (errorType=26)";
129  return false;
130  }
131  case(27) : {
132  //LogDebug("")<<" dummy word found (errorType=27)";
133  return false;
134  }
135  case(28) : {
136  LogDebug("")<<" error fifo nearly full (errorType=28)";
137  errorsInEvent = true;
138  break;
139  }
140  case(29) : {
141  LogDebug("")<<" timeout on a channel (errorType=29)";
142  errorsInEvent = true;
143  if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) {
144  LogDebug("")<<" ...first errorType=29 error, this gets masked out";
145  return false;
146  }
147  break;
148  }
149  case(30) : {
150  LogDebug("")<<" TBM error trailer (errorType=30)";
151  int StateMatch_bits = 4;
152  int StateMatch_shift = 8;
153  uint32_t StateMatch_mask = ~(~uint32_t(0) << StateMatch_bits);
154  int StateMatch = (errorWord >> StateMatch_shift) & StateMatch_mask;
155  if( StateMatch!=1 && StateMatch!=8 ) {
156  LogDebug("")<<" FED error 30 with unexpected State Bits (errorType=30)";
157  return false;
158  }
159  if( StateMatch==1 ) errorType = 40; // 1=Overflow -> 40, 8=number of ROCs -> 30
160  errorsInEvent = true;
161  break;
162  }
163  case(31) : {
164  LogDebug("")<<" event number error (errorType=31)";
165  errorsInEvent = true;
166  break;
167  }
168  default: return true;
169  };
170 
171  if(includeErrors) {
172  // store error
173  SiPixelRawDataError error(errorWord, errorType, fedId);
174  cms_uint32_t detId;
175  detId = errorDetId(converter, errorType, errorWord);
176  errors[detId].push_back(error);
177  }
178  return false;
179 }
#define LogDebug(id)
bool includeErrors
Definition: ErrorChecker.h:42
#define LIKELY(x)
Definition: Likely.h:20
return((rh^lh)&mask)
unsigned int cms_uint32_t
Definition: typedefs.h:15
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType, const Word32 &word) const override
Definition: errors.py:1
Pixel error – collection of errors and error information.
bool ErrorChecker::checkTrailer ( bool &  errorsInEvent,
int  fedId,
unsigned int  nWords,
const Word64 trailer,
Errors errors 
)
overridevirtual

Implements ErrorCheckerBase.

Definition at line 87 of file ErrorChecker.cc.

References FEDTrailer::check(), relativeConstraints::error, FEDTrailer::fragmentLength(), and FEDTrailer::moreTrailers().

88 {
89  FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
90  if ( !fedTrailer.check()) {
91  if(includeErrors) {
92  int errorType = 33;
93  SiPixelRawDataError error(*trailer, errorType, fedId);
94  errors[dummyDetId].push_back(error);
95  }
96  errorsInEvent = true;
97  LogError("FedTrailerCheck")
98  <<"fedTrailer.check failed, Fed: " << fedId << ", errorType = 33";
99  return false;
100  }
101  if ( fedTrailer.fragmentLength()!= nWords) {
102  LogError("FedTrailerLenght")<< "fedTrailer.fragmentLength()!= nWords !! Fed: " << fedId << ", errorType = 34";
103  errorsInEvent = true;
104  if(includeErrors) {
105  int errorType = 34;
106  SiPixelRawDataError error(*trailer, errorType, fedId);
107  errors[dummyDetId].push_back(error);
108  }
109  }
110  return fedTrailer.moreTrailers();
111 }
bool includeErrors
Definition: ErrorChecker.h:42
Definition: errors.py:1
Pixel error – collection of errors and error information.
void ErrorChecker::conversionError ( int  fedId,
const SiPixelFrameConverter converter,
int  status,
Word32 errorWord,
Errors errors 
)
overridevirtual

Implements ErrorCheckerBase.

Definition at line 181 of file ErrorChecker.cc.

References relativeConstraints::error, LogDebug, and mps_update::status.

182 {
183  switch (status) {
184  case(1) : {
185  LogDebug("ErrorChecker::conversionError") << " Fed: " << fedId << " invalid channel Id (errorType=35)";
186  if(includeErrors) {
187  int errorType = 35;
188  SiPixelRawDataError error(errorWord, errorType, fedId);
189  cms_uint32_t detId = errorDetId(converter, errorType, errorWord);
190  errors[detId].push_back(error);
191  }
192  break;
193  }
194  case(2) : {
195  LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << " invalid ROC Id (errorType=36)";
196  if(includeErrors) {
197  int errorType = 36;
198  SiPixelRawDataError error(errorWord, errorType, fedId);
199  cms_uint32_t detId = errorDetId(converter, errorType, errorWord);
200  errors[detId].push_back(error);
201  }
202  break;
203  }
204  case(3) : {
205  LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << " invalid dcol/pixel value (errorType=37)";
206  if(includeErrors) {
207  int errorType = 37;
208  SiPixelRawDataError error(errorWord, errorType, fedId);
209  cms_uint32_t detId = errorDetId(converter, errorType, errorWord);
210  errors[detId].push_back(error);
211  }
212  break;
213  }
214  case(4) : {
215  LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << " dcol/pixel read out of order (errorType=38)";
216  if(includeErrors) {
217  int errorType = 38;
218  SiPixelRawDataError error(errorWord, errorType, fedId);
219  cms_uint32_t detId = errorDetId(converter, errorType, errorWord);
220  errors[detId].push_back(error);
221  }
222  break;
223  }
224  default: LogDebug("ErrorChecker::conversionError")<<" cabling check returned unexpected result, status = "<< status;
225  };
226 }
#define LogDebug(id)
bool includeErrors
Definition: ErrorChecker.h:42
unsigned int cms_uint32_t
Definition: typedefs.h:15
cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType, const Word32 &word) const override
Definition: errors.py:1
Pixel error – collection of errors and error information.
cms_uint32_t ErrorChecker::errorDetId ( const SiPixelFrameConverter converter,
int  errorType,
const Word32 word 
) const
overrideprivatevirtual

Implements ErrorCheckerBase.

Definition at line 229 of file ErrorChecker.cc.

References sipixelobjects::ElectronicIndex::dcol, sipixelobjects::ElectronicIndex::link, sipixelobjects::ElectronicIndex::pxid, sipixelobjects::DetectorIndex::rawId, sipixelobjects::ElectronicIndex::roc, mps_update::status, and SiPixelFrameConverter::toDetector().

231 {
232  if (!converter) return dummyDetId;
233 
234  ElectronicIndex cabling;
235 
236  switch (errorType) {
237  case 25 : case 30 : case 31 : case 36 : case 40 : {
238  // set dummy values for cabling just to get detId from link
239  cabling.dcol = 0;
240  cabling.pxid = 2;
241  cabling.roc = 1;
242  cabling.link = (word >> LINK_shift) & LINK_mask;
243 
244  DetectorIndex detIdx;
245  int status = converter->toDetector(cabling, detIdx);
246  if (!status) return detIdx.rawId;
247  break;
248  }
249  case 29 : {
250  int chanNmbr = 0;
251  const int DB0_shift = 0;
252  const int DB1_shift = DB0_shift + 1;
253  const int DB2_shift = DB1_shift + 1;
254  const int DB3_shift = DB2_shift + 1;
255  const int DB4_shift = DB3_shift + 1;
256  const cms_uint32_t DataBit_mask = ~(~cms_uint32_t(0) << 1);
257 
258  int CH1 = (word >> DB0_shift) & DataBit_mask;
259  int CH2 = (word >> DB1_shift) & DataBit_mask;
260  int CH3 = (word >> DB2_shift) & DataBit_mask;
261  int CH4 = (word >> DB3_shift) & DataBit_mask;
262  int CH5 = (word >> DB4_shift) & DataBit_mask;
263  int BLOCK_bits = 3;
264  int BLOCK_shift = 8;
265  cms_uint32_t BLOCK_mask = ~(~cms_uint32_t(0) << BLOCK_bits);
266  int BLOCK = (word >> BLOCK_shift) & BLOCK_mask;
267  int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
268  if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
269  else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
270  if ((chanNmbr<1)||(chanNmbr>36)) break; // signifies unexpected result
271 
272  // set dummy values for cabling just to get detId from link if in Barrel
273  cabling.dcol = 0;
274  cabling.pxid = 2;
275  cabling.roc = 1;
276  cabling.link = chanNmbr;
277  DetectorIndex detIdx;
278  int status = converter->toDetector(cabling, detIdx);
279  if (!status) return detIdx.rawId;
280  break;
281  }
282  case 37 : case 38: {
283  cabling.dcol = 0;
284  cabling.pxid = 2;
285  cabling.roc = (word >> ROC_shift) & ROC_mask;
286  cabling.link = (word >> LINK_shift) & LINK_mask;
287 
288  DetectorIndex detIdx;
289  int status = converter->toDetector(cabling, detIdx);
290  if (status) break;
291 
292  return detIdx.rawId;
293  break;
294  }
295  default : break;
296  };
297  return dummyDetId;
298 }
unsigned int cms_uint32_t
Definition: typedefs.h:15
int toDetector(const sipixelobjects::ElectronicIndex &cabling, sipixelobjects::DetectorIndex &detector) const
void ErrorChecker::setErrorStatus ( bool  ErrorStatus)
overridevirtual

Implements ErrorCheckerBase.

Definition at line 51 of file ErrorChecker.cc.

52 {
53  includeErrors = ErrorStatus;
54 }
bool includeErrors
Definition: ErrorChecker.h:42

Member Data Documentation

bool ErrorChecker::includeErrors
private

Definition at line 42 of file ErrorChecker.h.