CMS 3D CMS Logo

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

#include <ErrorChecker.h>

Public Types

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)
 
bool checkHeader (bool &errorsInEvent, int fedId, const Word64 *header, Errors &errors)
 
bool checkROC (bool &errorsInEvent, int fedId, const SiPixelFrameConverter *converter, const SiPixelFedCabling *theCablingTree, Word32 &errorWord, Errors &errors)
 
bool checkTrailer (bool &errorsInEvent, int fedId, unsigned int nWords, const Word64 *trailer, Errors &errors)
 
void conversionError (int fedId, const SiPixelFrameConverter *converter, int status, Word32 &errorWord, Errors &errors)
 
 ErrorChecker ()
 
void setErrorStatus (bool ErrorStatus)
 

Private Member Functions

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

Private Attributes

bool includeErrors
 

Detailed Description

Definition at line 19 of file ErrorChecker.h.

Member Typedef Documentation

Definition at line 27 of file ErrorChecker.h.

Definition at line 28 of file ErrorChecker.h.

Definition at line 24 of file ErrorChecker.h.

Definition at line 25 of file ErrorChecker.h.

Constructor & Destructor Documentation

ErrorChecker::ErrorChecker ( )

Definition at line 48 of file ErrorChecker.cc.

48  {
49 
50  includeErrors = false;
51 }
bool includeErrors
Definition: ErrorChecker.h:51

Member Function Documentation

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

Definition at line 58 of file ErrorChecker.cc.

References relativeConstraints::error.

Referenced by PixelDataFormatter::interpretRawData().

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

Definition at line 71 of file ErrorChecker.cc.

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

Referenced by PixelDataFormatter::interpretRawData().

72 {
73  FEDHeader fedHeader( reinterpret_cast<const unsigned char*>(header));
74  if ( !fedHeader.check() ) return false; // throw exception?
75  if ( fedHeader.sourceID() != fedId) {
76  LogDebug("PixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId")
77  <<", sourceID = " <<fedHeader.sourceID()
78  <<", fedId = "<<fedId<<", errorType = 32";
79  errorsInEvent = true;
80  if (includeErrors) {
81  int errorType = 32;
82  SiPixelRawDataError error(*header, errorType, fedId);
83  errors[dummyDetId].push_back(error);
84  }
85  }
86  return fedHeader.moreHeaders();
87 }
#define LogDebug(id)
bool includeErrors
Definition: ErrorChecker.h:51
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 
)

Definition at line 115 of file ErrorChecker.cc.

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

Referenced by PixelDataFormatter::interpretRawData().

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

Definition at line 89 of file ErrorChecker.cc.

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

Referenced by PixelDataFormatter::interpretRawData().

90 {
91  FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
92  if ( !fedTrailer.check()) {
93  if(includeErrors) {
94  int errorType = 33;
95  SiPixelRawDataError error(*trailer, errorType, fedId);
96  errors[dummyDetId].push_back(error);
97  }
98  errorsInEvent = true;
99  LogError("FedTrailerCheck")
100  <<"fedTrailer.check failed, Fed: " << fedId << ", errorType = 33";
101  return false;
102  }
103  if ( fedTrailer.fragmentLength()!= nWords) {
104  LogError("FedTrailerLenght")<< "fedTrailer.fragmentLength()!= nWords !! Fed: " << fedId << ", errorType = 34";
105  errorsInEvent = true;
106  if(includeErrors) {
107  int errorType = 34;
108  SiPixelRawDataError error(*trailer, errorType, fedId);
109  errors[dummyDetId].push_back(error);
110  }
111  }
112  return fedTrailer.moreTrailers();
113 }
bool includeErrors
Definition: ErrorChecker.h:51
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 
)

Definition at line 183 of file ErrorChecker.cc.

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

Referenced by PixelDataFormatter::interpretRawData().

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

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

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

Definition at line 53 of file ErrorChecker.cc.

Referenced by PixelDataFormatter::setErrorStatus().

54 {
55  includeErrors = ErrorStatus;
56 }
bool includeErrors
Definition: ErrorChecker.h:51

Member Data Documentation

bool ErrorChecker::includeErrors
private

Definition at line 51 of file ErrorChecker.h.