CMS 3D CMS Logo

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,
26  const SiPixelFedCabling* theCablingTree,
27  Word32& errorWord,
29  int errorType = (errorWord >> ROC_shift) & ERROR_mask;
30  if LIKELY (errorType < 25)
31  return true;
32  unsigned int channel = (errorWord >> LINK_shift) & LINK_mask;
33  unsigned int roc = 1;
34 
35  switch (errorType) {
36  case (25): {
37  CablingPathToDetUnit cablingPath = {unsigned(fedId), channel, 1};
38  if (!theCablingTree->findItem(cablingPath)) {
39  return false;
40  }
41  LogDebug("") << " invalid ROC=25 found (errorType=25)";
42  errorsInEvent = true;
43  break;
44  }
45  case (26): {
46  //LogDebug("")<<" gap word found (errorType=26)";
47  return false;
48  }
49  case (27): {
50  //LogDebug("")<<" dummy word found (errorType=27)";
51  return false;
52  }
53  case (28): {
54  LogDebug("") << " error fifo nearly full (errorType=28)";
55  errorsInEvent = true;
56  break;
57  }
58  case (29): {
59  LogDebug("") << " timeout on a channel (errorType=29)";
60  errorsInEvent = true;
61  if (!((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask)) { //exit on the 2nd TO word
62  LogDebug("") << " ...2nd errorType=29 error, skip";
63  return false;
64  }
65  break;
66  }
67  case (30): {
68  LogDebug("") << " TBM error trailer (errorType=30)";
69  int StateMatch_bits = 4;
70  int StateMatch_shift = 8;
71  uint32_t StateMatch_mask = ~(~uint32_t(0) << StateMatch_bits);
72  int StateMatch = (errorWord >> StateMatch_shift) & StateMatch_mask;
73  if (StateMatch != 1 && StateMatch != 8) {
74  LogDebug("") << " FED error 30 with unexpected State Bits (errorType=30)";
75  return false;
76  }
77  if (StateMatch == 1)
78  errorType = 40; // 1=Overflow -> 40, 8=number of ROCs -> 30
79  errorsInEvent = true;
80  break;
81  }
82  case (31): {
83  LogDebug("") << " event number error (errorType=31)";
84  errorsInEvent = true;
85  break;
86  }
87  case (37):
88  case (38): {
89  roc = (errorWord >> ROC_shift) & ROC_mask;
90  break;
91  }
92  default:
93  return true;
94  };
95 
96  if (includeErrors_) {
97  // store error
98  SiPixelRawDataError error(errorWord, errorType, fedId);
99  cms_uint32_t detId = errorDetIdSimple(converter, errorType, channel, roc);
100  errors[detId].push_back(error);
101  }
102  return false;
103 }
104 
105 // new, simpler version
107  int errorType,
108  unsigned int channel,
109  unsigned int roc) const {
110  if (!converter) {
111  return dummyDetId;
112  }
113 
114  ElectronicIndex cabling;
115  DetectorIndex detIdx;
116  cabling.dcol = 0;
117  cabling.pxid = 2;
118  cabling.roc = roc;
119  cabling.link = channel;
120  int status = converter->toDetector(cabling, detIdx);
121  if (!status) {
122  return detIdx.rawId;
123  } // all OK return valid module id
124 
125  return dummyDetId; // failed, return dummy
126 }
127 
128 // this function finds the detId for an error word that cannot be processed in word2digi
130  if (!converter) {
131  return dummyDetId;
132  }
133  ElectronicIndex cabling;
134 
135  switch (errorType) {
136  case 25:
137  case 30:
138  case 31:
139  case 36:
140  case 40: {
141  // set dummy values for cabling just to get detId from link
142  cabling.dcol = 0;
143  cabling.pxid = 2;
144  cabling.roc = 1;
145  cabling.link = (word >> LINK_shift) & LINK_mask;
146 
147  DetectorIndex detIdx;
148  int status = converter->toDetector(cabling, detIdx);
149  if (!status) {
150  return detIdx.rawId;
151  }
152  break;
153  }
154  case 29: {
155  int chanNmbr = 0;
156  const int DB0_shift = 0;
157  const int DB1_shift = DB0_shift + 1;
158  const int DB2_shift = DB1_shift + 1;
159  const int DB3_shift = DB2_shift + 1;
160  const int DB4_shift = DB3_shift + 1;
161  const cms_uint32_t DataBit_mask = ~(~cms_uint32_t(0) << 1);
162 
163  int CH1 = (word >> DB0_shift) & DataBit_mask;
164  int CH2 = (word >> DB1_shift) & DataBit_mask;
165  int CH3 = (word >> DB2_shift) & DataBit_mask;
166  int CH4 = (word >> DB3_shift) & DataBit_mask;
167  int CH5 = (word >> DB4_shift) & DataBit_mask;
168  int BLOCK_bits = 3;
169  int BLOCK_shift = 8;
170  cms_uint32_t BLOCK_mask = ~(~cms_uint32_t(0) << BLOCK_bits);
171  int BLOCK = (word >> BLOCK_shift) & BLOCK_mask;
172  int localCH = 1 * CH1 + 2 * CH2 + 3 * CH3 + 4 * CH4 + 5 * CH5;
173  if (BLOCK % 2 == 0)
174  chanNmbr = (BLOCK / 2) * 9 + localCH;
175  else
176  chanNmbr = ((BLOCK - 1) / 2) * 9 + 4 + localCH;
177 
178  if ((chanNmbr < 1) || (chanNmbr > 36)) {
179  break; // signifies unexpected result WRONG!
180  }
181  // set dummy values for cabling just to get detId from link if in Barrel
182  cabling.dcol = 0;
183  cabling.pxid = 2;
184  cabling.roc = 1;
185  cabling.link = chanNmbr;
186  DetectorIndex detIdx;
187  int status = converter->toDetector(cabling, detIdx);
188  if (!status) {
189  return detIdx.rawId;
190  }
191  break;
192  }
193  case 37:
194  case 38: {
195  cabling.dcol = 0;
196  cabling.pxid = 2;
197  cabling.roc = (word >> ROC_shift) & ROC_mask;
198  cabling.link = (word >> LINK_shift) & LINK_mask;
199 
200  DetectorIndex detIdx;
201  int status = converter->toDetector(cabling, detIdx);
202  if (status)
203  break;
204 
205  return detIdx.rawId;
206  break;
207  }
208  default:
209  break;
210  };
211 
212  return dummyDetId;
213 }
constexpr cms_uint32_t dummyDetId
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
cms_uint32_t errorDetIdSimple(const SiPixelFrameConverter *converter, int errorType, unsigned int channel, unsigned int roc) const
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
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
constexpr uint32_t LINK_mask
HLT enums.
constexpr uint32_t OMIT_ERR_mask
Definition: errors.py:1
constexpr uint32_t ROC_mask
std::map< cms_uint32_t, std::vector< SiPixelRawDataError > > SiPixelFormatterErrors
Pixel error – collection of errors and error information.
#define LogDebug(id)