CMS 3D CMS Logo

ErrorCheckerBase.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 void ErrorCheckerBase::setErrorStatus(bool ErrorStatus) { includeErrors_ = ErrorStatus; }
24 
26  int fedId,
27  Word64 word,
29  if (includeErrors_) {
30  SiPixelRawDataError error(word, errorType, fedId);
32  }
33 }
34 
35 bool ErrorCheckerBase::checkCRC(bool& errorsInEvent,
36  int fedId,
37  const Word64* trailer,
39  const int CRC_BIT = (*trailer >> CRC_shift) & CRC_mask;
40  const bool isCRCcorrect = (CRC_BIT == 0);
41  if (!isCRCcorrect)
42  addErrorToCollectionDummy(39, fedId, *trailer, errors);
43  errorsInEvent = (errorsInEvent || !isCRCcorrect);
44  return isCRCcorrect;
45 }
46 
47 bool ErrorCheckerBase::checkHeader(bool& errorsInEvent,
48  int fedId,
49  const Word64* header,
51  FEDHeader fedHeader(reinterpret_cast<const unsigned char*>(header));
52  const bool fedHeaderCorrect = fedHeader.check();
53  // if not fedHeaderCorrect throw exception?
54  if (fedHeaderCorrect && (fedHeader.sourceID() != fedId)) {
55  int errorType = 32;
57  LogDebug("PixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId")
58  << ", sourceID = " << fedHeader.sourceID() << ", fedId = " << fedId << ", errorType = " << errorType;
59  errorsInEvent = true;
60  }
61  return fedHeaderCorrect && fedHeader.moreHeaders();
62 }
63 
65  bool& errorsInEvent, int fedId, unsigned int nWords, const Word64* trailer, SiPixelFormatterErrors& errors) const {
66  FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
67  const bool fedTrailerCorrect = fedTrailer.check();
68  if (!fedTrailerCorrect) {
69  int errorType = 33;
70  addErrorToCollectionDummy(errorType, fedId, *trailer, errors);
71  LogError("FedTrailerCheck") << "fedTrailer.check failed, Fed: " << fedId << ", errorType = " << errorType;
72  errorsInEvent = true;
73  } else if (fedTrailer.fragmentLength() != nWords) {
74  int errorType = 34;
75  addErrorToCollectionDummy(errorType, fedId, *trailer, errors);
76  LogError("FedTrailerLenght") << "fedTrailer.fragmentLength()!= nWords !! Fed: " << fedId
77  << ", errorType = " << errorType;
78  errorsInEvent = true;
79  }
80  return fedTrailerCorrect && fedTrailer.moreTrailers();
81 }
82 
85  int status,
86  Word32& errorWord,
89  // errorType == 0 means unexpected error, in this case we don't include it in the error collection
90  if (errorType && includeErrors_) {
91  SiPixelRawDataError error(errorWord, errorType, fedId);
92  cms_uint32_t detId = errorDetId(converter, errorType, errorWord);
93  errors[detId].push_back(error);
94  }
95 }
96 
98  int errorType = 0;
99  std::string debugMessage;
100  switch (status) {
101  case (1): {
102  debugMessage = "invalid channel Id";
103  errorType = 35;
104  break;
105  }
106  case (2): {
107  debugMessage = "invalid ROC Id";
108  errorType = 36;
109  break;
110  }
111  case (3): {
112  debugMessage = "invalid dcol/pixel value";
113  errorType = 37;
114  break;
115  }
116  case (4): {
117  debugMessage = "dcol/pixel read out of order";
118  errorType = 38;
119  break;
120  }
121  };
122  if (errorType) {
123  LogDebug("ErrorChecker::conversionError") << "Fed:" << fedId << debugMessage << "(errorType =" << errorType << ")";
124  } else {
125  LogDebug("ErrorChecker::conversionError") << "cabling check returned unexpected result, status =" << status;
126  }
127  return errorType;
128 }
void conversionError(int fedId, const SiPixelFrameConverter *converter, int status, Word32 &errorWord, SiPixelFormatterErrors &errors) const
constexpr cms_uint32_t dummyDetId
bool check() const
Check that the header is OK.
Definition: FEDHeader.cc:44
uint16_t sourceID() const
Identifier of the FED.
Definition: FEDHeader.cc:19
virtual cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType, const Word32 &word) const =0
Log< level::Error, false > LogError
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:13
uint64_t word
void setErrorStatus(bool ErrorStatus)
constexpr uint64_t CRC_mask
cms_uint32_t Word32
bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header, SiPixelFormatterErrors &errors) const
bool moreHeaders() const
Definition: FEDHeader.cc:23
bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords, const Word64 *trailer, SiPixelFormatterErrors &errors) const
unsigned int cms_uint32_t
Definition: typedefs.h:15
constexpr uint32_t CRC_shift
HLT enums.
bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer, SiPixelFormatterErrors &errors) const
int getConversionErrorTypeAndIssueLogMessage(int status, int fedId) const
Definition: errors.py:1
std::map< cms_uint32_t, std::vector< SiPixelRawDataError > > SiPixelFormatterErrors
bool check() const
Check that the trailer is OK.
Definition: FEDTrailer.cc:45
bool moreTrailers() const
Definition: FEDTrailer.cc:21
Pixel error – collection of errors and error information.
cms_uint64_t Word64
#define LogDebug(id)
void addErrorToCollectionDummy(int errorType, int fedId, Word64 word, SiPixelFormatterErrors &errors) const