1212#include " InfoLogger/InfoLogger.hxx"
1313#include " PHOSReconstruction/AltroDecoder.h"
1414#include " PHOSReconstruction/RawReaderMemory.h"
15+ #include " PHOSReconstruction/RawDecodingError.h"
1516
1617#include " DetectorsRaw/RDHUtils.h"
1718#include < FairLogger.h>
@@ -46,9 +47,9 @@ AltroDecoderError::ErrorType_t AltroDecoder::decode()
4647void AltroDecoder::readRCUTrailer ()
4748{
4849 try {
49- auto payloadwordsOrig = mRawReader .getPayload ().getPayloadWords ();
50- gsl::span<const uint32_t > payloadwords (payloadwordsOrig .data (), payloadwordsOrig .size ());
51- mRCUTrailer .constructFromRawPayload (payloadwords );
50+ auto payloadwords = mRawReader .getPayload ().getPayloadWords ();
51+ gsl::span<const uint32_t > tmp (payloadwords .data (), payloadwords .size ());
52+ mRCUTrailer .constructFromRawPayload (tmp );
5253 } catch (RCUTrailer::Error& e) {
5354 throw e;
5455 }
@@ -64,13 +65,18 @@ void AltroDecoder::readChannels()
6465 mChannels .clear ();
6566 int currentpos = 0 ;
6667 auto & buffer = mRawReader .getPayload ().getPayloadWords ();
67- while (currentpos < buffer.size () - mRCUTrailer .getTrailerSize ()) {
68+
69+ int payloadend = mRCUTrailer .getPayloadSize ();
70+ while (currentpos < payloadend) {
6871 auto currentword = buffer[currentpos++];
69- if (currentword >> 30 != 1 ) {
72+ ChannelHeader header = {currentword};
73+
74+ if (header.mMark != 1 ) {
75+ LOG (ERROR) << " Channel header mark not found" ;
7076 continue ;
7177 }
7278 // starting a new channel
73- mChannels .emplace_back (currentword & 0xFFF , (currentword >> 16 ) & 0x3FF );
79+ mChannels .emplace_back (int (header. mHardwareAddress ), int (header. mPayloadSize ) );
7480 auto & currentchannel = mChannels .back ();
7581 // / decode all words for channel
7682 int numberofwords = (currentchannel.getPayloadSize () + 2 ) / 3 ;
@@ -101,18 +107,9 @@ void AltroDecoder::readChannels()
101107 mChannelsInitialized = true ;
102108}
103109
104- const RCUTrailer& AltroDecoder::getRCUTrailer () const
105- {
106- if (!mRCUTrailer .isInitialized ()) {
107- throw AltroDecoderError::ErrorType_t::RCU_TRAILER_ERROR; // "RCU trailer was not initialized");
108- }
109- return mRCUTrailer ;
110- }
111-
112110const std::vector<Channel>& AltroDecoder::getChannels () const
113111{
114- if (!mChannelsInitialized ) {
112+ if (!mChannelsInitialized )
115113 throw AltroDecoderError::ErrorType_t::CHANNEL_ERROR; // "Channels not initizalized");
116- }
117114 return mChannels ;
118115}
0 commit comments