CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
< SiPixelRawDataError
DetErrors
 
typedef std::map< cms_uint32_t,
DetErrors
Errors
 
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, Word32 &errorWord, Errors &errors)
 
bool checkTrailer (bool &errorsInEvent, int fedId, 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 18 of file ErrorChecker.h.

Member Typedef Documentation

Definition at line 26 of file ErrorChecker.h.

Definition at line 27 of file ErrorChecker.h.

Definition at line 23 of file ErrorChecker.h.

Definition at line 24 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:49

Member Function Documentation

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

Definition at line 56 of file ErrorChecker.cc.

References relativeConstraints::error.

Referenced by PixelDataFormatter::interpretRawData().

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:49
Pixel error – collection of errors and error information.
bool ErrorChecker::checkHeader ( bool &  errorsInEvent,
int  fedId,
const Word64 header,
Errors errors 
)

Definition at line 69 of file ErrorChecker.cc.

References FEDHeader::check(), relativeConstraints::error, stage2MP7BufferRaw_cfi::fedId, LogDebug, FEDHeader::moreHeaders(), and FEDHeader::sourceID().

Referenced by PixelDataFormatter::interpretRawData().

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:49
Pixel error – collection of errors and error information.
bool ErrorChecker::checkROC ( bool &  errorsInEvent,
int  fedId,
const SiPixelFrameConverter converter,
Word32 errorWord,
Errors errors 
)

Definition at line 113 of file ErrorChecker.cc.

References relativeConstraints::error, likely, and LogDebug.

Referenced by PixelDataFormatter::interpretRawData().

114 {
115  int errorType = (errorWord >> ROC_shift) & ERROR_mask;
116  if likely(errorType<25) return true;
117 
118  switch (errorType) {
119  case(25) : {
120  LogDebug("")<<" invalid ROC=25 found (errorType=25)";
121  errorsInEvent = true;
122  break;
123  }
124  case(26) : {
125  //LogDebug("")<<" gap word found (errorType=26)";
126  return false;
127  }
128  case(27) : {
129  //LogDebug("")<<" dummy word found (errorType=27)";
130  return false;
131  }
132  case(28) : {
133  LogDebug("")<<" error fifo nearly full (errorType=28)";
134  errorsInEvent = true;
135  break;
136  }
137  case(29) : {
138  LogDebug("")<<" timeout on a channel (errorType=29)";
139  errorsInEvent = true;
140  if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) {
141  LogDebug("")<<" ...first errorType=29 error, this gets masked out";
142  return false;
143  }
144  break;
145  }
146  case(30) : {
147  LogDebug("")<<" TBM error trailer (errorType=30)";
148  errorsInEvent = true;
149  break;
150  }
151  case(31) : {
152  LogDebug("")<<" event number error (errorType=31)";
153  errorsInEvent = true;
154  break;
155  }
156  default: return true;
157  };
158 
159  if(includeErrors) {
160  // check to see if overflow error for type 30, change type to 40 if so
161  if(errorType==30) {
162  int StateMach_bits = 4;
163  int StateMach_shift = 8;
164  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
165  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
166  if( StateMach==4 || StateMach==9 ) errorType = 40;
167  }
168 
169  // store error
170  SiPixelRawDataError error(errorWord, errorType, fedId);
171  cms_uint32_t detId;
172  detId = errorDetId(converter, errorType, errorWord);
173  errors[detId].push_back(error);
174  }
175  return false;
176 }
#define LogDebug(id)
bool includeErrors
Definition: ErrorChecker.h:49
cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType, const Word32 &word) const
#define likely(x)
unsigned int cms_uint32_t
Definition: typedefs.h:15
return(e1-e2)*(e1-e2)+dp *dp
Pixel error – collection of errors and error information.
bool ErrorChecker::checkTrailer ( bool &  errorsInEvent,
int  fedId,
int  nWords,
const Word64 trailer,
Errors errors 
)

Definition at line 87 of file ErrorChecker.cc.

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

Referenced by PixelDataFormatter::interpretRawData().

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.lenght()!= nWords) {
102  LogError("FedTrailerLenght")<< "fedTrailer.lenght()!= 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:49
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 178 of file ErrorChecker.cc.

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

Referenced by PixelDataFormatter::interpretRawData().

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

References sipixelobjects::ElectronicIndex::dcol, sipixelobjects::ElectronicIndex::link, PixelSubdetector::PixelBarrel, sipixelobjects::ElectronicIndex::pxid, sipixelobjects::DetectorIndex::rawId, sipixelobjects::ElectronicIndex::roc, ntuplemaker::status, DetId::subdetId(), and SiPixelFrameConverter::toDetector().

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

Definition at line 51 of file ErrorChecker.cc.

Referenced by PixelDataFormatter::setErrorStatus().

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

Member Data Documentation

bool ErrorChecker::includeErrors
private

Definition at line 49 of file ErrorChecker.h.