CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ErrorChecker.cc
Go to the documentation of this file.
2 
4 
9 
11 
12 #include <bitset>
13 #include <sstream>
14 #include <iostream>
15 
16 using namespace std;
17 using namespace edm;
18 using namespace sipixelobjects;
19 using namespace sipixelconstants;
20 
22 
23 bool ErrorChecker::checkROC(bool& errorsInEvent,
24  int fedId,
25  const SiPixelFrameConverter* converter,
26  const SiPixelFedCabling* theCablingTree,
27  Word32& errorWord,
28  SiPixelFormatterErrors& errors) const {
29  int errorType = (errorWord >> ROC_shift) & ERROR_mask;
30  if LIKELY (errorType < 25)
31  return true;
32 
33  switch (errorType) {
34  case (25): {
35  CablingPathToDetUnit cablingPath = {unsigned(fedId), (errorWord >> LINK_shift) & LINK_mask, 1};
36  if (!theCablingTree->findItem(cablingPath))
37  return false;
38  LogDebug("") << " invalid ROC=25 found (errorType=25)";
39  errorsInEvent = true;
40  break;
41  }
42  case (26): {
43  //LogDebug("")<<" gap word found (errorType=26)";
44  return false;
45  }
46  case (27): {
47  //LogDebug("")<<" dummy word found (errorType=27)";
48  return false;
49  }
50  case (28): {
51  LogDebug("") << " error fifo nearly full (errorType=28)";
52  errorsInEvent = true;
53  break;
54  }
55  case (29): {
56  LogDebug("") << " timeout on a channel (errorType=29)";
57  errorsInEvent = true;
58  if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) {
59  LogDebug("") << " ...first errorType=29 error, this gets masked out";
60  return false;
61  }
62  break;
63  }
64  case (30): {
65  LogDebug("") << " TBM error trailer (errorType=30)";
66  int StateMatch_bits = 4;
67  int StateMatch_shift = 8;
68  uint32_t StateMatch_mask = ~(~uint32_t(0) << StateMatch_bits);
69  int StateMatch = (errorWord >> StateMatch_shift) & StateMatch_mask;
70  if (StateMatch != 1 && StateMatch != 8) {
71  LogDebug("") << " FED error 30 with unexpected State Bits (errorType=30)";
72  return false;
73  }
74  if (StateMatch == 1)
75  errorType = 40; // 1=Overflow -> 40, 8=number of ROCs -> 30
76  errorsInEvent = true;
77  break;
78  }
79  case (31): {
80  LogDebug("") << " event number error (errorType=31)";
81  errorsInEvent = true;
82  break;
83  }
84  default:
85  return true;
86  };
87 
88  if (includeErrors_) {
89  // store error
90  SiPixelRawDataError error(errorWord, errorType, fedId);
91  cms_uint32_t detId;
92  detId = errorDetId(converter, errorType, errorWord);
93  errors[detId].push_back(error);
94  }
95  return false;
96 }
97 
98 // this function finds the detId for an error word that cannot be processed in word2digi
99 cms_uint32_t ErrorChecker::errorDetId(const SiPixelFrameConverter* converter, int errorType, const Word32& word) const {
100  if (!converter)
101  return dummyDetId;
102 
103  ElectronicIndex cabling;
104 
105  switch (errorType) {
106  case 25:
107  case 30:
108  case 31:
109  case 36:
110  case 40: {
111  // set dummy values for cabling just to get detId from link
112  cabling.dcol = 0;
113  cabling.pxid = 2;
114  cabling.roc = 1;
115  cabling.link = (word >> LINK_shift) & LINK_mask;
116 
117  DetectorIndex detIdx;
118  int status = converter->toDetector(cabling, detIdx);
119  if (!status)
120  return detIdx.rawId;
121  break;
122  }
123  case 29: {
124  int chanNmbr = 0;
125  const int DB0_shift = 0;
126  const int DB1_shift = DB0_shift + 1;
127  const int DB2_shift = DB1_shift + 1;
128  const int DB3_shift = DB2_shift + 1;
129  const int DB4_shift = DB3_shift + 1;
130  const cms_uint32_t DataBit_mask = ~(~cms_uint32_t(0) << 1);
131 
132  int CH1 = (word >> DB0_shift) & DataBit_mask;
133  int CH2 = (word >> DB1_shift) & DataBit_mask;
134  int CH3 = (word >> DB2_shift) & DataBit_mask;
135  int CH4 = (word >> DB3_shift) & DataBit_mask;
136  int CH5 = (word >> DB4_shift) & DataBit_mask;
137  int BLOCK_bits = 3;
138  int BLOCK_shift = 8;
139  cms_uint32_t BLOCK_mask = ~(~cms_uint32_t(0) << BLOCK_bits);
140  int BLOCK = (word >> BLOCK_shift) & BLOCK_mask;
141  int localCH = 1 * CH1 + 2 * CH2 + 3 * CH3 + 4 * CH4 + 5 * CH5;
142  if (BLOCK % 2 == 0)
143  chanNmbr = (BLOCK / 2) * 9 + localCH;
144  else
145  chanNmbr = ((BLOCK - 1) / 2) * 9 + 4 + localCH;
146  if ((chanNmbr < 1) || (chanNmbr > 36))
147  break; // signifies unexpected result
148 
149  // set dummy values for cabling just to get detId from link if in Barrel
150  cabling.dcol = 0;
151  cabling.pxid = 2;
152  cabling.roc = 1;
153  cabling.link = chanNmbr;
154  DetectorIndex detIdx;
155  int status = converter->toDetector(cabling, detIdx);
156  if (!status)
157  return detIdx.rawId;
158  break;
159  }
160  case 37:
161  case 38: {
162  cabling.dcol = 0;
163  cabling.pxid = 2;
164  cabling.roc = (word >> ROC_shift) & ROC_mask;
165  cabling.link = (word >> LINK_shift) & LINK_mask;
166 
167  DetectorIndex detIdx;
168  int status = converter->toDetector(cabling, detIdx);
169  if (status)
170  break;
171 
172  return detIdx.rawId;
173  break;
174  }
175  default:
176  break;
177  };
178  return dummyDetId;
179 }
constexpr cms_uint32_t dummyDetId
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
list status
Definition: mps_update.py:107
constexpr uint32_t ROC_shift
#define LIKELY(x)
Definition: Likely.h:20
bool checkROC(bool &errorsInEvent, int fedId, const SiPixelFrameConverter *converter, const SiPixelFedCabling *theCablingTree, Word32 &errorWord, SiPixelFormatterErrors &errors) const override
Definition: ErrorChecker.cc:23
constexpr uint32_t ERROR_mask
uint64_t word
constexpr uint32_t OMIT_ERR_shift
std::map< cms_uint32_t, std::vector< SiPixelRawDataError >> SiPixelFormatterErrors
cms_uint32_t Word32
unsigned int cms_uint32_t
Definition: typedefs.h:15
constexpr uint32_t LINK_shift
cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType, const Word32 &word) const override
Definition: ErrorChecker.cc:99
constexpr uint32_t LINK_mask
constexpr uint32_t OMIT_ERR_mask
int toDetector(const sipixelobjects::ElectronicIndex &cabling, sipixelobjects::DetectorIndex &detector) const
constexpr uint32_t ROC_mask
Pixel error – collection of errors and error information.
#define LogDebug(id)