1717// / \date 17/11/2020
1818
1919/* ------ HISTORY ---------
20- */
20+ */
2121
2222#include " FairLogger.h" // for LOG
2323#include " Framework/Logger.h"
@@ -530,7 +530,7 @@ void HmpidDecoder2::decodePage(uint32_t** streamBuf)
530530 bool isIt;
531531
532532 int payIndex = 0 ;
533- while (payIndex < mNumberWordToRead ) { // start the payload loop word by word
533+ while (payIndex < mNumberWordToRead ) { // start the payload loop word by word
534534 if (newOne == true ) {
535535 wpprev = wp;
536536 if (!getWordFromStream (&wp)) { // end the stream
@@ -805,7 +805,7 @@ void HmpidDecoder2::setPad(HmpidEquipment* eq, int col, int dil, int ch, uint16_
805805{
806806 eq->setPad (col, dil, ch, charge);
807807 mDigits .push_back (o2::hmpid::Digit (charge, eq->getEquipmentId (), col, dil, ch));
808- // std::cout << "DI " << mDigits.back() << " "<<col<<","<< dil<<","<< ch<<"="<< charge<<std::endl;
808+ // std::cout << "DI " << mDigits.back() << " "<<col<<","<< dil<<","<< ch<<"="<< charge<<std::endl;
809809 return ;
810810}
811811
@@ -849,12 +849,9 @@ void HmpidDecoder2::decodePageFast(uint32_t** streamBuf)
849849 int Column, Dilogic, Channel, Charge;
850850 int pwer;
851851 int payIndex = 0 ;
852- while (payIndex < mNumberWordToRead ) { // start the payload loop word by word
852+ while (payIndex < mNumberWordToRead ) { // start the payload loop word by word
853853 wpprev = wp;
854- if (!getWordFromStream (&wp)) { // end the stream
855- // mPayloadTail = 0;
856- throw TH_BUFFEREMPTY;
857- }
854+ wp = readWordFromStream ();
858855 if (wp == wpprev) {
859856 if (mVerbose > 8 ) {
860857 std::cout << " HMPID Decoder2 : [DEBUG] "
@@ -871,9 +868,7 @@ void HmpidDecoder2::decodePageFast(uint32_t** streamBuf)
871868 payIndex += 1 ;
872869 }
873870 for (int i = 0 ; i < mPayloadTail ; i++) { // move the pointer to skip the Payload Tail
874- if (!getWordFromStream (&wp)) {
875- throw TH_BUFFEREMPTY;
876- }
871+ wp = readWordFromStream ();
877872 }
878873 *streamBuf = mActualStreamPtr ;
879874 return ;
@@ -1232,6 +1227,17 @@ bool HmpidDecoder2::getWordFromStream(uint32_t* word)
12321227 return (false );
12331228}
12341229
1230+ // / Gets a Word from the stream.
1231+ // / @returns The word read
1232+ uint32_t HmpidDecoder2::readWordFromStream ()
1233+ {
1234+ mActualStreamPtr ++;
1235+ if (mActualStreamPtr > mEndStreamPtr ) {
1236+ throw TH_WRONGBUFFERDIM;
1237+ }
1238+ return (*mActualStreamPtr );
1239+ }
1240+
12351241// / Setup the Input Stream with a Memory Pointer
12361242// / the buffer length is in byte, some controls are done
12371243// /
@@ -1267,7 +1273,7 @@ bool HmpidDecoder2::setUpStream(void* Buffer, long BufferLen)
12671273 }
12681274
12691275 mActualStreamPtr = (uint32_t *)Buffer; // sets the pointer to the Buffer
1270- mEndStreamPtr = ((uint32_t *)Buffer) + wordsBufferLen; // sets the End of buffer
1276+ mEndStreamPtr = ((uint32_t *)Buffer) + wordsBufferLen; // sets the End of buffer
12711277 mStartStreamPtr = ((uint32_t *)Buffer);
12721278 return (true );
12731279}
0 commit comments