Skip to content

Commit ed8efb7

Browse files
committed
[MCH] added detection of mis-placed SYNC packet
1 parent becc679 commit ed8efb7

5 files changed

Lines changed: 40 additions & 14 deletions

File tree

Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/ErrorCodes.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ enum ErrorCodes {
3131
ErrorBadClusterSize = 1 << 6, // 64
3232
ErrorBadIncompleteWord = 1 << 7, // 128
3333
ErrorTruncatedData = 1 << 8, // 256
34-
ErrorBadELinkID = 1 << 9, // 512
35-
ErrorBadLinkID = 1 << 10, // 1024
36-
ErrorUnknownLinkID = 1 << 11, // 2048
37-
ErrorBadHBTime = 1 << 12, // 4096
38-
ErrorNonRecoverableDecodingError = 1 << 13 // 8192
34+
ErrorUnexpectedSyncPacket = 1 << 9, // 512
35+
ErrorBadELinkID = 1 << 10, // 1024
36+
ErrorBadLinkID = 1 << 11, // 2048
37+
ErrorUnknownLinkID = 1 << 12, // 4096
38+
ErrorBadHBTime = 1 << 13, // 8192
39+
ErrorNonRecoverableDecodingError = 1 << 14 // 16384
3940
};
4041

4142
uint32_t getErrorCodesSize();

Detectors/MUON/MCH/Raw/Decoder/src/ErrorCodes.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace raw
2020

2121
uint32_t getErrorCodesSize()
2222
{
23-
return 14;
23+
return 15;
2424
}
2525

2626
void append(const char* msg, std::string& to)
@@ -52,6 +52,9 @@ std::string errorCodeAsString(uint32_t ec)
5252
if (ec & ErrorBadSyncPacket) {
5353
append("Bad Sync Packet", msg);
5454
}
55+
if (ec & ErrorUnexpectedSyncPacket) {
56+
append("Unexpected Sync", msg);
57+
}
5558
if (ec & ErrorBadHeartBeatPacket) {
5659
append("Bad HB Packet", msg);
5760
}

Detectors/MUON/MCH/Raw/Decoder/src/UserLogicElinkDecoder.cxx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ bool UserLogicElinkDecoder<SampleMode>::checkDataHeader()
5151
return false;
5252
}
5353

54+
// we expect at least 3 10-bit words
55+
int nof10BitWords = mSampaHeader.nof10BitWords();
56+
if (nof10BitWords <= 2) {
57+
return false;
58+
}
59+
5460
return true;
5561
}
5662

@@ -67,8 +73,12 @@ bool UserLogicElinkDecoder<ChargeSumMode>::checkDataHeader()
6773
return false;
6874
}
6975

70-
// in cluster sum mode the number of 10-bit words must be a multiple of 4
76+
// we expect at least 3 10-bit words
7177
int nof10BitWords = mSampaHeader.nof10BitWords();
78+
if (nof10BitWords <= 2) {
79+
return false;
80+
}
81+
// in cluster sum mode the number of 10-bit words must be a multiple of 4
7282
if ((nof10BitWords % 4) != 0) {
7383
return false;
7484
}

Detectors/MUON/MCH/Raw/Decoder/src/UserLogicElinkDecoder.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,18 @@ void UserLogicElinkDecoder<CHARGESUM>::append(uint64_t data50, uint8_t error, bo
119119

120120
if (isSync(data50)) {
121121
#ifdef ULDEBUG
122-
debugHeader() << (*this) << fmt::format(" --> SYNC word found {:013x}\n", data50);
122+
debugHeader() << (*this) << fmt::format(" --> SYNC word found {:013x} state={}\n", data50, asString(mState));
123123
#endif
124-
clear();
125-
transition(State::WaitingHeader);
124+
if (mState != State::WaitingHeader && mState != State::WaitingSync) {
125+
#ifdef ULDEBUG
126+
debugHeader() << (*this) << " SYNC word found while decoding payload --> resetting\n"
127+
#endif
128+
sendError(static_cast<int8_t>(mSampaHeader.chipAddress()), static_cast<uint32_t>(ErrorUnexpectedSyncPacket));
129+
reset();
130+
} else {
131+
clear();
132+
transition(State::WaitingHeader);
133+
}
126134
return;
127135
}
128136

@@ -179,7 +187,7 @@ bool UserLogicElinkDecoder<CHARGESUM>::append10(uint10_t data10)
179187
{
180188
bool result = false;
181189
#ifdef ULDEBUG
182-
debugHeader() << (*this) << fmt::format(" --> data10 {:d}\n", data10);
190+
debugHeader() << (*this) << fmt::format(" --> data10 {:d} state {}\n", data10, asString(mState));
183191
#endif
184192
switch (mState) {
185193
case State::WaitingHeader:
@@ -276,6 +284,9 @@ std::string UserLogicElinkDecoder<CHARGESUM>::asString(State s) const
276284
case State::WaitingSample:
277285
return "WaitingSample";
278286
break;
287+
default:
288+
return "Unknown";
289+
break;
279290
};
280291
}
281292

Detectors/MUON/MCH/Raw/Decoder/src/testUserLogicEndpointDecoder.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,10 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SyncInTheMiddleChargeSumModeTwoChannels, V, testTy
367367
DsElecId{361, 6, 2}, 63, {cl1, cl2},
368368
DsElecId{361, 6, 2}, 47, {cl3, cl4},
369369
5);
370-
BOOST_CHECK_EQUAL(r,
371-
"S361-J6-DS2-ch-63-ts-345-q-123456-cs-789\n"
372-
"S361-J6-DS2-ch-63-ts-346-q-789012-cs-345\n");
370+
std::string r2 = "S361-J6-DS2-ch-63-ts-345-q-123456-cs-789\n";
371+
r2 += "S361-J6-DS2-ch-63-ts-346-q-789012-cs-345\n";
372+
r2 += fmt::format("S361-J6-DS2-chip-5-error-{}\n", ErrorUnexpectedSyncPacket);
373+
BOOST_CHECK_EQUAL(r, r2);
373374
}
374375

375376
BOOST_AUTO_TEST_CASE_TEMPLATE(TestCruPageOK, V, testTypes)

0 commit comments

Comments
 (0)