CMS 3D CMS Logo

ErrorCheckerPhase0.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 ErrorCheckerPhase0::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 
33  switch (errorType) {
34  case (25): {
35  LogDebug("") << " invalid ROC=25 found (errorType=25)";
36  errorsInEvent = true;
37  break;
38  }
39  case (26): {
40  return false;
41  }
42  case (27): {
43  return false;
44  }
45  case (28): {
46  LogDebug("") << " error fifo nearly full (errorType=28)";
47  errorsInEvent = true;
48  break;
49  }
50  case (29): {
51  LogDebug("") << " timeout on a channel (errorType=29)";
52  errorsInEvent = true;
53  if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) {
54  LogDebug("") << " ...first errorType=29 error, this gets masked out";
55  return false;
56  }
57  break;
58  }
59  case (30): {
60  LogDebug("") << " TBM error trailer (errorType=30)";
61  errorsInEvent = true;
62  break;
63  }
64  case (31): {
65  LogDebug("") << " event number error (errorType=31)";
66  errorsInEvent = true;
67  break;
68  }
69  default:
70  return true;
71  };
72 
73  if (includeErrors_) {
74  // check to see if overflow error for type 30, change type to 40 if so
75  if (errorType == 30) {
76  int StateMach_bits = 4;
77  int StateMach_shift = 8;
78  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
79  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
80  if (StateMach == 4 || StateMach == 9)
81  errorType = 40;
82  }
83 
84  // store error
85  SiPixelRawDataError error(errorWord, errorType, fedId);
87  detId = errorDetId(converter, errorType, errorWord);
88  errors[detId].push_back(error);
89  }
90  return false;
91 }
92 
93 // this function finds the detId for an error word that cannot be processed in word2digi
95  int errorType,
96  const Word32& word) const {
97  if (!converter)
98  return dummyDetId;
99 
100  ElectronicIndex cabling;
101 
102  switch (errorType) {
103  case 25:
104  case 30:
105  case 31:
106  case 36:
107  case 40: {
108  // set dummy values for cabling just to get detId from link if in Barrel
109  cabling.dcol = 0;
110  cabling.pxid = 2;
111  cabling.roc = 1;
112  cabling.link = (word >> LINK_shift) & LINK_mask;
113 
114  DetectorIndex detIdx;
115  int status = converter->toDetector(cabling, detIdx);
116  if (status)
117  break;
118  if (DetId(detIdx.rawId).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel))
119  return detIdx.rawId;
120  break;
121  }
122  case 29: {
123  int chanNmbr = 0;
124  const int DB0_shift = 0;
125  const int DB1_shift = DB0_shift + 1;
126  const int DB2_shift = DB1_shift + 1;
127  const int DB3_shift = DB2_shift + 1;
128  const int DB4_shift = DB3_shift + 1;
129  const cms_uint32_t DataBit_mask = ~(~cms_uint32_t(0) << 1);
130 
131  int CH1 = (word >> DB0_shift) & DataBit_mask;
132  int CH2 = (word >> DB1_shift) & DataBit_mask;
133  int CH3 = (word >> DB2_shift) & DataBit_mask;
134  int CH4 = (word >> DB3_shift) & DataBit_mask;
135  int CH5 = (word >> DB4_shift) & DataBit_mask;
136  int BLOCK_bits = 3;
137  int BLOCK_shift = 8;
138  cms_uint32_t BLOCK_mask = ~(~cms_uint32_t(0) << BLOCK_bits);
139  int BLOCK = (word >> BLOCK_shift) & BLOCK_mask;
140  int localCH = 1 * CH1 + 2 * CH2 + 3 * CH3 + 4 * CH4 + 5 * CH5;
141  if (BLOCK % 2 == 0)
142  chanNmbr = (BLOCK / 2) * 9 + localCH;
143  else
144  chanNmbr = ((BLOCK - 1) / 2) * 9 + 4 + localCH;
145  if ((chanNmbr < 1) || (chanNmbr > 36))
146  break; // signifies unexpected result
147 
148  // set dummy values for cabling just to get detId from link if in Barrel
149  cabling.dcol = 0;
150  cabling.pxid = 2;
151  cabling.roc = 1;
152  cabling.link = chanNmbr;
153  DetectorIndex detIdx;
154  int status = converter->toDetector(cabling, detIdx);
155  if (status)
156  break;
157  if (DetId(detIdx.rawId).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel))
158  return detIdx.rawId;
159  break;
160  }
161  case 37:
162  case 38: {
163  cabling.dcol = 0;
164  cabling.pxid = 2;
165  cabling.roc = (word >> ROC_shift) & ROC_mask;
166  cabling.link = (word >> LINK_shift) & LINK_mask;
167 
168  DetectorIndex detIdx;
169  int status = converter->toDetector(cabling, detIdx);
170  if (status)
171  break;
172 
173  return detIdx.rawId;
174  break;
175  }
176  default:
177  break;
178  };
179  return dummyDetId;
180 }
constexpr cms_uint32_t dummyDetId
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
constexpr uint32_t ERROR_mask
uint64_t word
constexpr uint32_t OMIT_ERR_shift
cms_uint32_t Word32
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
unsigned int cms_uint32_t
Definition: typedefs.h:15
Definition: DetId.h:17
constexpr uint32_t LINK_shift
constexpr uint32_t LINK_mask
HLT enums.
constexpr uint32_t OMIT_ERR_mask
cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType, const Word32 &word) const override
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)