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 
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
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 }
cms_uint32_t
unsigned int cms_uint32_t
Definition: typedefs.h:15
PixelSubdetector.h
ErrorChecker::ErrorChecker
ErrorChecker()
Definition: ErrorChecker.cc:21
MessageLogger.h
SiPixelRawDataError
Pixel error – collection of errors and error information.
Definition: SiPixelRawDataError.h:19
ErrorCheckerBase::includeErrors_
bool includeErrors_
Definition: ErrorCheckerBase.h:43
mps_update.status
status
Definition: mps_update.py:68
converter
Definition: CandidateProducer.h:25
SiPixelFedCabling::findItem
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
edm
HLT enums.
Definition: AlignableModifier.h:19
sipixelconstants::dummyDetId
constexpr cms_uint32_t dummyDetId
Definition: SiPixelDigiConstants.h:11
sipixelconstants::LINK_shift
constexpr uint32_t LINK_shift
Definition: SiPixelDigiConstants.h:27
ErrorChecker::errorDetId
cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType, const Word32 &word) const override
Definition: ErrorChecker.cc:99
sipixelobjects::ElectronicIndex::dcol
int dcol
Definition: ElectronicIndex.h:8
SiPixelFedCabling
Definition: SiPixelFedCabling.h:10
relativeConstraints.error
error
Definition: relativeConstraints.py:53
sipixelconstants::LINK_mask
constexpr uint32_t LINK_mask
Definition: SiPixelDigiConstants.h:32
ErrorChecker.h
sipixelconstants::ROC_shift
constexpr uint32_t ROC_shift
Definition: SiPixelDigiConstants.h:26
ErrorChecker::checkROC
bool checkROC(bool &errorsInEvent, int fedId, const SiPixelFrameConverter *converter, const SiPixelFedCabling *theCablingTree, Word32 &errorWord, SiPixelFormatterErrors &errors) const override
Definition: ErrorChecker.cc:23
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
errors
Definition: errors.py:1
sipixelconstants::OMIT_ERR_shift
constexpr uint32_t OMIT_ERR_shift
Definition: SiPixelDigiConstants.h:28
sipixelobjects
Definition: CablingPathToDetUnit.h:4
sipixelobjects::CablingPathToDetUnit
Definition: CablingPathToDetUnit.h:5
sipixelconstants::OMIT_ERR_mask
constexpr uint32_t OMIT_ERR_mask
Definition: SiPixelDigiConstants.h:34
sipixelconstants
Definition: SiPixelDigiConstants.h:10
sipixelobjects::ElectronicIndex::pxid
int pxid
Definition: ElectronicIndex.h:9
sipixelobjects::ElectronicIndex
Definition: ElectronicIndex.h:5
sipixelobjects::ElectronicIndex::link
int link
Definition: ElectronicIndex.h:6
SiPixelFrameConverter.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
ErrorCheckerBase
Definition: ErrorCheckerBase.h:14
sipixelconstants::ERROR_mask
constexpr uint32_t ERROR_mask
Definition: SiPixelDigiConstants.h:31
sipixelconstants::ROC_mask
constexpr uint32_t ROC_mask
Definition: SiPixelDigiConstants.h:33
SiPixelFrameConverter
Definition: SiPixelFrameConverter.h:15
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:89
Word32
cms_uint32_t Word32
Definition: SiPixelDigiConstants.h:8
std
Definition: JetResolutionObject.h:76
DetId.h
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
SiPixelFormatterErrors
std::map< cms_uint32_t, std::vector< SiPixelRawDataError > > SiPixelFormatterErrors
Definition: SiPixelFormatterErrors.h:10
FEDHeader.h
sipixelobjects::DetectorIndex::rawId
uint32_t rawId
Definition: DetectorIndex.h:7
sipixelobjects::DetectorIndex
Definition: DetectorIndex.h:6
sipixelobjects::ElectronicIndex::roc
int roc
Definition: ElectronicIndex.h:7
FEDTrailer.h