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:46

Member Function Documentation

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

Definition at line 56 of file ErrorChecker.cc.

References CRC_mask, CRC_shift, dummyDetId, and 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:46
const int CRC_shift
Definition: ErrorChecker.cc:28
const ErrorChecker::Word64 CRC_mask
Definition: ErrorChecker.cc:38
const cms_uint32_t dummyDetId
Definition: ErrorChecker.cc:36
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(), dummyDetId, error, 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:46
const cms_uint32_t dummyDetId
Definition: ErrorChecker.cc:36
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 error, ERROR_mask, LogDebug, OMIT_ERR_mask, OMIT_ERR_shift, and ROC_shift.

Referenced by PixelDataFormatter::interpretRawData().

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

References error, LogDebug, and ntuplemaker::status.

Referenced by PixelDataFormatter::interpretRawData().

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

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

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

Member Data Documentation

bool ErrorChecker::includeErrors
private

Definition at line 46 of file ErrorChecker.h.