Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for not throwing exception in cpv::RawReaderMemory when processin… #8594

Merged
merged 2 commits into from
Apr 15, 2022
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
37 changes: 19 additions & 18 deletions Detectors/CPV/reconstruction/src/RawReaderMemory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ o2::header::RDHAny RawReaderMemory::decodeRawHeader(const void* payloadwords)
return o2::header::RDHAny(*reinterpret_cast<const o2::header::RAWDataHeaderV6*>(payloadwords));
}
LOG(error) << "RawReaderMemory::decodeRawHeader() : Unknown RDH version";
return o2::header::RDHAny(*reinterpret_cast<const o2::header::RAWDataHeaderV6*>(payloadwords));
throw RawErrorType_t::kRDH_DECODING;
}

void RawReaderMemory::init()
Expand All @@ -66,7 +66,7 @@ RawErrorType_t RawReaderMemory::next()
e == RawErrorType_t::kRDH_DECODING || // incorrect rdh -> fatal error
e == RawErrorType_t::kPAYLOAD_INCOMPLETE || // we reached end of mRawMemoryBuffer but payload size from rdh tells to read more
e == RawErrorType_t::kSTOPBIT_NOTFOUND) { //new HBF orbit started but no stop bit found, need to return
return e; //some principal error occured -> stop reading.
throw e; //some principal error occured -> stop reading.
}
isStopBitFound = RDHDecoder::getStop(mRawHeader);
} while (!isStopBitFound);
Expand All @@ -88,25 +88,26 @@ RawErrorType_t RawReaderMemory::nextPage()
o2::header::RDHAny rawHeader;
try {
rawHeader = decodeRawHeader(mRawMemoryBuffer.data() + mCurrentPosition);
if (RDHDecoder::getSourceID(rawHeader) != 0x8) {
// Not a CPV RDH
mCurrentPosition += RDHDecoder::getOffsetToNext(rawHeader); //moving on
return RawErrorType_t::kNOT_CPV_RDH;
}
if (mIsJustInited || mStopBitWasNotFound) { //reading first time after init() or stopbit was not found
mCurrentHBFOrbit = RDHDecoder::getHeartBeatOrbit(rawHeader);
mRawHeader = rawHeader; //save RDH of first page as mRawHeader
mRawHeaderInitialized = true;
mStopBitWasNotFound = false; //reset this flag as we start to read again
mIsJustInited = false;
} else if (mCurrentHBFOrbit != RDHDecoder::getHeartBeatOrbit(rawHeader)) {
//next HBF started but we didn't find stop bit.
mStopBitWasNotFound = true;
mCurrentPosition += RDHDecoder::getOffsetToNext(mRawHeader); // moving on
return RawErrorType_t::kSTOPBIT_NOTFOUND; // Stop reading, this will be read again by calling next()
}
} catch (...) {
return RawErrorType_t::kRDH_DECODING; //this is fatal error
}
if (RDHDecoder::getSourceID(rawHeader) != 0x8) {
// Not a CPV RDH
mCurrentPosition += RDHDecoder::getOffsetToNext(rawHeader); //moving on
return RawErrorType_t::kNOT_CPV_RDH;
}
if (mIsJustInited || mStopBitWasNotFound) { //reading first time after init() or stopbit was not found
mCurrentHBFOrbit = RDHDecoder::getHeartBeatOrbit(rawHeader);
mRawHeader = rawHeader; //save RDH of first page as mRawHeader
mRawHeaderInitialized = true;
mStopBitWasNotFound = false; //reset this flag as we start to read again
mIsJustInited = false;
} else if (mCurrentHBFOrbit != RDHDecoder::getHeartBeatOrbit(rawHeader)) {
//next HBF started but we didn't find stop bit.
mStopBitWasNotFound = true;
return RawErrorType_t::kSTOPBIT_NOTFOUND; //Stop reading, this will be read again by calling next()
}
mRawHeader = rawHeader; //save RDH of current page as mRawHeader
mRawHeaderInitialized = true;

Expand Down
25 changes: 15 additions & 10 deletions Detectors/CPV/workflow/src/RawToDigitConverterSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,7 @@ void RawToDigitConverterSpec::run(framework::ProcessingContext& ctx)
gains = gainsPtr.get();
}

/*if (!mIsPedestalData) {
pedestals = const_cast<o2::cpv::Pedestals*>((ctx.inputs().get<o2::cpv::Pedestals*>("peds")).get());
}
if (mIsUsingBadMap) {
badMap = const_cast<o2::cpv::BadChannelMap*>((ctx.inputs().get<o2::cpv::BadChannelMap*>("peds")).get());
}
if (mIsUsingGainCalibration) {
gains = const_cast<o2::cpv::CalibParams*>((ctx.inputs().get<o2::cpv::CalibParams*>("peds")).get());
}*/
bool skipTF = false; // skip TF due to fatal error?

std::vector<o2::framework::InputSpec> rawFilter{
{"RAWDATA", o2::framework::ConcreteDataTypeMatcher{"CPV", "RAWDATA"}, o2::framework::Lifetime::Timeframe},
Expand All @@ -135,6 +127,8 @@ void RawToDigitConverterSpec::run(framework::ProcessingContext& ctx)
mOutputHWErrors.emplace_back(25, 0, 0, 0, e); //Put general errors to non-existing ccId 25
//if problem in header, abandon this page
if (e == RawErrorType_t::kRDH_DECODING) {
LOG(error) << "RDH decoding error. Skipping this TF";
skipTF = true;
break;
}
//if problem in payload, try to continue
Expand Down Expand Up @@ -205,7 +199,18 @@ void RawToDigitConverterSpec::run(framework::ProcessingContext& ctx)
for (auto& er : decoder.getErrors()) {
mOutputHWErrors.push_back(er);
}
} //RawReader::hasNext
}
// if corrupted raw data is present in this TF -> skip it
if (skipTF) {
// Send no digits
mOutputDigits.clear();
ctx.outputs().snapshot(o2::framework::Output{"CPV", "DIGITS", 0, o2::framework::Lifetime::Timeframe}, mOutputDigits);
mOutputTriggerRecords.clear();
ctx.outputs().snapshot(o2::framework::Output{"CPV", "DIGITTRIGREC", 0, o2::framework::Lifetime::Timeframe}, mOutputTriggerRecords);
// Send errors
ctx.outputs().snapshot(o2::framework::Output{"CPV", "RAWHWERRORS", 0, o2::framework::Lifetime::Timeframe}, mOutputHWErrors);
return;
}
}

// Loop over BCs, sort digits with increasing digit ID and write to output containers
Expand Down