CMS 3D CMS Logo

RPixErrorChecker.cc
Go to the documentation of this file.
2 
5 
7 
8 #include <bitset>
9 #include <sstream>
10 #include <iostream>
11 
12 using namespace std;
13 using namespace edm;
14 
15 namespace {
16  constexpr int CRC_bits = 1;
17  constexpr int ROC_bits = 5;
18  constexpr int DCOL_bits = 5;
19  constexpr int PXID_bits = 8;
20  constexpr int ADC_bits = 8;
21  constexpr int OMIT_ERR_bits = 1;
22 
23  constexpr int CRC_shift = 2;
24  constexpr int ADC_shift = 0;
25  constexpr int PXID_shift = ADC_shift + ADC_bits;
26  constexpr int DCOL_shift = PXID_shift + PXID_bits;
27  constexpr int ROC_shift = DCOL_shift + DCOL_bits;
28  constexpr int OMIT_ERR_shift = 20;
29 
30  constexpr RPixErrorChecker::Word64 CRC_mask = ~(~RPixErrorChecker::Word64(0) << CRC_bits);
31  constexpr RPixErrorChecker::Word32 ERROR_mask = ~(~RPixErrorChecker::Word32(0) << ROC_bits);
32  constexpr RPixErrorChecker::Word32 OMIT_ERR_mask = ~(~RPixErrorChecker::Word32(0) << OMIT_ERR_bits);
33 }
34 
36 
37 }
38 
39 bool RPixErrorChecker::checkCRC(bool& errorsInEvent, int fedId, const Word64* trailer) const
40 {
41  int CRC_BIT = (*trailer >> CRC_shift) & CRC_mask;
42  if (CRC_BIT == 0) return true;
43  errorsInEvent = true;
44  LogError("CRCCheck")
45  <<"CRC check failed, errorType = 39";
46  return false;
47 }
48 
49 bool RPixErrorChecker::checkHeader(bool& errorsInEvent, int fedId, const Word64* header) const
50 {
51  FEDHeader fedHeader( reinterpret_cast<const unsigned char*>(header));
52  if ( !fedHeader.check() ) return false; // throw exception?
53  if ( fedHeader.sourceID() != fedId) {
54  LogError("CTPPSPixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId")
55  <<", sourceID = " <<fedHeader.sourceID()
56  <<", fedId = "<<fedId<<", errorType = 32";
57  errorsInEvent = true;
58 
59  }
60  return fedHeader.moreHeaders();
61 }
62 
63 bool RPixErrorChecker::checkTrailer(bool& errorsInEvent, int fedId, int nWords, const Word64* trailer) const
64 {
65  FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
66  if ( !fedTrailer.check()) {
67 
68  errorsInEvent = true;
69  LogError("FedTrailerCheck")
70  <<"fedTrailer.check failed, Fed: " << fedId << ", errorType = 33";
71  return false;
72  }
73  if ( fedTrailer.lenght()!= nWords) {
74  LogError("FedTrailerLenght")<< "fedTrailer.lenght()!= nWords !! Fed: " << fedId << ", errorType = 34";
75  errorsInEvent = true;
76 
77  }
78  return fedTrailer.moreTrailers();
79 }
80 
81 bool RPixErrorChecker::checkROC(bool& errorsInEvent, int fedId, Word32& errorWord) const
82 {
83  int errorType = (errorWord >> ROC_shift) & ERROR_mask;
84  if likely(errorType<25) return true;
85 
86  switch (errorType) {
87  case(25) : {
88  LogDebug("")<<" invalid ROC=25 found (errorType=25)";
89  errorsInEvent = true;
90  break;
91  }
92  case(26) : {
93  //LogDebug("")<<" gap word found (errorType=26)";
94  return false;
95  }
96  case(27) : {
97  //LogDebug("")<<" dummy word found (errorType=27)";
98  return false;
99  }
100  case(28) : {
101  LogDebug("")<<" error fifo nearly full (errorType=28)";
102  errorsInEvent = true;
103  break;
104  }
105  case(29) : {
106  LogDebug("")<<" timeout on a channel (errorType=29)";
107  errorsInEvent = true;
108  if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) {
109  LogDebug("")<<" ...first errorType=29 error, this gets masked out";
110  return false;
111  }
112  break;
113  }
114  case(30) : {
115  LogDebug("")<<" TBM error trailer (errorType=30)";
116  errorsInEvent = true;
117  break;
118  }
119  case(31) : {
120  LogDebug("")<<" event number error (errorType=31)";
121  errorsInEvent = true;
122  break;
123  }
124  default: return true;
125  };
126 
127  return false;
128 }
129 
#define LogDebug(id)
bool check()
Definition: FEDTrailer.cc:64
bool moreTrailers()
Definition: FEDTrailer.cc:37
bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer) const
bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header) const
#define constexpr
#define likely(x)
int sourceID()
Identifier of the FED.
Definition: FEDHeader.cc:28
bool moreHeaders()
Definition: FEDHeader.cc:36
bool checkTrailer(bool &errorsInEvent, int fedId, int nWords, const Word64 *trailer) const
bool check()
Check that the header is OK.
Definition: FEDHeader.cc:64
uint64_t Word64
int lenght()
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:17
bool checkROC(bool &errorsInEvent, int fedId, Word32 &errorWord) const
HLT enums.