Skip to content

Commit baa2c90

Browse files
aphecetcheshahor02
authored andcommitted
[MCH] Update decoder tests (e.g. using new encoders)
1 parent 551e851 commit baa2c90

10 files changed

Lines changed: 624 additions & 1100 deletions

Detectors/MUON/MCH/Raw/Decoder/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if(BUILD_TESTING)
3131
SOURCES src/testUserLogicEndpointDecoder.cxx
3232
COMPONENT_NAME mchraw
3333
LABELS "muon;mch;raw"
34-
PUBLIC_LINK_LIBRARIES O2::MCHRawDecoder O2::MCHRawImplHelpers)
34+
PUBLIC_LINK_LIBRARIES O2::MCHRawDecoder O2::MCHRawImplHelpers
35+
O2::MCHRawEncoderPayload)
3536

3637
endif()

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ void UserLogicElinkDecoder<CHARGESUM>::completeHeader()
273273
template <typename CHARGESUM>
274274
std::ostream& UserLogicElinkDecoder<CHARGESUM>::debugHeader() const
275275
{
276-
//std::cout << fmt::format("--ULDEBUG--{:p}-----------", reinterpret_cast<const void*>(this));
277-
//return std::cout;
278276
return std::cout << "---";
279277
}
280278

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,9 @@ size_t UserLogicEndpointDecoder<CHARGESUM>::append(Payload buffer)
121121

122122
// Get the GBT link associated to this word
123123
int gbt = (word >> 59) & 0x1F;
124+
124125
if (gbt < 0 || gbt > 11) {
125-
throw fmt::format("warning : out-of-range linkId {} word={:08X}\n", gbt, word);
126-
}
127-
if (gbt != 0) {
128-
std::cout << "CAUTION : got gbt = " << gbt << "\n";
126+
throw fmt::format("warning : out-of-range gbt {} word={:08X}\n", gbt, word);
129127
}
130128

131129
// Get the corresponding decoders array, or allocate it if does not exist yet

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

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
using namespace o2::mch::raw;
2828
using o2::header::RAWDataHeaderV4;
2929

30-
std::ostream& operator<<(std::ostream&, const RAWDataHeaderV4&);
30+
namespace o2::header
31+
{
32+
extern std::ostream& operator<<(std::ostream&, const o2::header::RAWDataHeaderV4&);
33+
}
3134

3235
SampaChannelHandler handlePacketStoreAsVec(std::vector<std::string>& result)
3336
{
@@ -74,11 +77,8 @@ BOOST_AUTO_TEST_CASE(Test1)
7477
// showRDHs<RAWDataHeaderV4>(testBuffer);
7578
}
7679

77-
BOOST_AUTO_TEST_CASE(TestDecoding)
80+
bool testDecode(gsl::span<const std::byte> testBuffer)
7881
{
79-
auto testBuffer = REF_BUFFER_CRU<BareFormat, ChargeSumMode>();
80-
int n = countRDHs<RAWDataHeaderV4>(testBuffer);
81-
BOOST_CHECK_EQUAL(n, 28);
8282
std::vector<std::string> result;
8383
std::vector<std::string> expected{
8484

@@ -96,24 +96,46 @@ BOOST_AUTO_TEST_CASE(TestDecoding)
9696
"S448-J6-DS2-ch-24-ts-0-q-440",
9797
"S448-J6-DS2-ch-25-ts-0-q-450",
9898
"S448-J6-DS2-ch-26-ts-0-q-460",
99-
"S448-J6-DS2-ch-12-ts-0-q-420"};
99+
"S448-J6-DS2-ch-42-ts-0-q-420"};
100100

101101
auto pageDecoder = createPageDecoder(testBuffer, handlePacketStoreAsVec(result));
102102

103103
auto parser = createPageParser(testBuffer);
104104

105105
parser(testBuffer, pageDecoder);
106106

107-
BOOST_CHECK_EQUAL(result.size(), expected.size());
108-
BOOST_CHECK(std::is_permutation(begin(result), end(result), begin(expected)));
109-
// std::cout << "Got:\n";
110-
// for (auto s : result) {
111-
// std::cout << s << "\n";
112-
// }
113-
// std::cout << "Expected:\n";
114-
// for (auto s : expected) {
115-
// std::cout << s << "\n";
116-
// }
107+
bool sameSize = result.size() == expected.size();
108+
bool permutation = std::is_permutation(begin(result), end(result), begin(expected));
109+
BOOST_CHECK_EQUAL(sameSize, true);
110+
BOOST_CHECK_EQUAL(permutation, true);
111+
if (!permutation || !sameSize) {
112+
std::cout << "Got:\n";
113+
for (auto s : result) {
114+
std::cout << s << "\n";
115+
}
116+
std::cout << "Expected:\n";
117+
for (auto s : expected) {
118+
std::cout << s << "\n";
119+
}
120+
return false;
121+
}
122+
return true;
123+
}
124+
125+
BOOST_AUTO_TEST_CASE(TestBareDecoding)
126+
{
127+
auto testBuffer = REF_BUFFER_CRU<BareFormat, ChargeSumMode>();
128+
int n = countRDHs<RAWDataHeaderV4>(testBuffer);
129+
BOOST_CHECK_EQUAL(n, 28);
130+
testDecode(testBuffer);
131+
}
132+
133+
BOOST_AUTO_TEST_CASE(TestUserLogicDecoding)
134+
{
135+
auto testBuffer = REF_BUFFER_CRU<UserLogicFormat, ChargeSumMode>();
136+
int n = countRDHs<RAWDataHeaderV4>(testBuffer);
137+
BOOST_CHECK_EQUAL(n, 4);
138+
testDecode(testBuffer);
117139
}
118140

119141
BOOST_AUTO_TEST_CASE(BareGBTDecoderFromBuffer)

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

Lines changed: 0 additions & 237 deletions
This file was deleted.

0 commit comments

Comments
 (0)