Skip to content

Commit 8e1a57b

Browse files
mfasDashahor02
authored andcommitted
[EMCAL-675] Handling of pages without trailer
In the new version of the raw format the trailer will be only on the last page. In order to be compatible with both version the last trailer word is checked for bit 30 (trailer marker), in case it found the trailer is decoded and chopped from the page as it is re-encoded when the multi-page payload is combined. Otherwise the full payload is added to the multi-page buffer. This works for single and multi-page payload and therefore consequently for the old and new raw format.
1 parent f8a5ae4 commit 8e1a57b

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

Detectors/EMCAL/reconstruction/src/RawReaderMemory.cxx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,30 @@ void RawReaderMemory::nextPage(bool doResetPayload)
113113
} else {
114114
mRawBuffer.readFromMemoryBuffer(gsl::span<const char>(mRawMemoryBuffer.data() + mCurrentPosition + RDHDecoder::getHeaderSize(mRawHeader), RDHDecoder::getMemorySize(mRawHeader) - RDHDecoder::getHeaderSize(mRawHeader)));
115115

116-
// Read off and chop trailer
116+
// Read off and chop trailer (if required)
117117
//
118-
// Every page gets a trailer. The trailers from the single pages need to be removed.
119-
// There will be a combined trailer which keeps the sum of the payloads for all trailers.
120-
// This will be appended to the chopped payload.
121-
auto trailer = RCUTrailer::constructFromPayloadWords(mRawBuffer.getDataWords());
122-
if (!mCurrentTrailer.isInitialized()) {
123-
mCurrentTrailer = trailer;
118+
// In case every page gets a trailer (intermediate format). The trailers from the single
119+
// pages need to be removed. There will be a combined trailer which keeps the sum of the
120+
// payloads for all trailers. This will be appended to the chopped payload.
121+
//
122+
// Trailer only at the last page (new format): Only last page gets trailer. The trailer is
123+
// also chopped from the payload as it will be added later again.
124+
auto lastword = *(mRawBuffer.getDataWords().rbegin());
125+
gsl::span<const uint32_t> payloadWithoutTrailer;
126+
if (lastword >> 30 == 3) {
127+
// lastword is a trailer word
128+
// decode trailer and chop
129+
auto trailer = RCUTrailer::constructFromPayloadWords(mRawBuffer.getDataWords());
130+
if (!mCurrentTrailer.isInitialized()) {
131+
mCurrentTrailer = trailer;
132+
} else {
133+
mCurrentTrailer.setPayloadSize(mCurrentTrailer.getPayloadSize() + trailer.getPayloadSize());
134+
}
135+
payloadWithoutTrailer = gsl::span<const uint32_t>(mRawBuffer.getDataWords().data(), mRawBuffer.getDataWords().size() - trailer.getTrailerSize());
124136
} else {
125-
mCurrentTrailer.setPayloadSize(mCurrentTrailer.getPayloadSize() + trailer.getPayloadSize());
137+
// Not a trailer word = copy page as it is
138+
payloadWithoutTrailer = mRawBuffer.getDataWords(); // No trailer to be chopped
126139
}
127-
gsl::span<const uint32_t> payloadWithoutTrailer(mRawBuffer.getDataWords().data(), mRawBuffer.getDataWords().size() - trailer.getTrailerSize());
128140

129141
mRawPayload.appendPayloadWords(payloadWithoutTrailer);
130142
mRawPayload.increasePageCount();

0 commit comments

Comments
 (0)