Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class HmpidDecoder2
bool getBlockFromStream(uint32_t** streamPtr, uint32_t Size);
bool getHeaderFromStream(uint32_t** streamPtr);
bool getWordFromStream(uint32_t* word);
uint32_t readWordFromStream();
uint32_t* getActualStreamPtr()
{
return (mActualStreamPtr);
Expand Down
30 changes: 18 additions & 12 deletions Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// \date 17/11/2020

/* ------ HISTORY ---------
*/
*/

#include "FairLogger.h" // for LOG
#include "Framework/Logger.h"
Expand Down Expand Up @@ -530,7 +530,7 @@ void HmpidDecoder2::decodePage(uint32_t** streamBuf)
bool isIt;

int payIndex = 0;
while (payIndex < mNumberWordToRead) { //start the payload loop word by word
while (payIndex < mNumberWordToRead) { // start the payload loop word by word
if (newOne == true) {
wpprev = wp;
if (!getWordFromStream(&wp)) { // end the stream
Expand Down Expand Up @@ -805,7 +805,7 @@ void HmpidDecoder2::setPad(HmpidEquipment* eq, int col, int dil, int ch, uint16_
{
eq->setPad(col, dil, ch, charge);
mDigits.push_back(o2::hmpid::Digit(charge, eq->getEquipmentId(), col, dil, ch));
//std::cout << "DI " << mDigits.back() << " "<<col<<","<< dil<<","<< ch<<"="<< charge<<std::endl;
// std::cout << "DI " << mDigits.back() << " "<<col<<","<< dil<<","<< ch<<"="<< charge<<std::endl;
return;
}

Expand Down Expand Up @@ -849,12 +849,9 @@ void HmpidDecoder2::decodePageFast(uint32_t** streamBuf)
int Column, Dilogic, Channel, Charge;
int pwer;
int payIndex = 0;
while (payIndex < mNumberWordToRead) { //start the payload loop word by word
while (payIndex < mNumberWordToRead) { // start the payload loop word by word
wpprev = wp;
if (!getWordFromStream(&wp)) { // end the stream
//mPayloadTail = 0;
throw TH_BUFFEREMPTY;
}
wp = readWordFromStream();
if (wp == wpprev) {
if (mVerbose > 8) {
std::cout << "HMPID Decoder2 : [DEBUG] "
Expand All @@ -871,9 +868,7 @@ void HmpidDecoder2::decodePageFast(uint32_t** streamBuf)
payIndex += 1;
}
for (int i = 0; i < mPayloadTail; i++) { // move the pointer to skip the Payload Tail
if (!getWordFromStream(&wp)) {
throw TH_BUFFEREMPTY;
}
wp = readWordFromStream();
}
*streamBuf = mActualStreamPtr;
return;
Expand Down Expand Up @@ -1232,6 +1227,17 @@ bool HmpidDecoder2::getWordFromStream(uint32_t* word)
return (false);
}

/// Gets a Word from the stream.
/// @returns The word read
uint32_t HmpidDecoder2::readWordFromStream()
{
mActualStreamPtr++;
if (mActualStreamPtr > mEndStreamPtr) {
throw TH_WRONGBUFFERDIM;
}
return (*mActualStreamPtr);
}

/// Setup the Input Stream with a Memory Pointer
/// the buffer length is in byte, some controls are done
///
Expand Down Expand Up @@ -1267,7 +1273,7 @@ bool HmpidDecoder2::setUpStream(void* Buffer, long BufferLen)
}

mActualStreamPtr = (uint32_t*)Buffer; // sets the pointer to the Buffer
mEndStreamPtr = ((uint32_t*)Buffer) + wordsBufferLen; //sets the End of buffer
mEndStreamPtr = ((uint32_t*)Buffer) + wordsBufferLen; // sets the End of buffer
mStartStreamPtr = ((uint32_t*)Buffer);
return (true);
}