diff --git a/Detectors/CPV/reconstruction/src/RawReaderMemory.cxx b/Detectors/CPV/reconstruction/src/RawReaderMemory.cxx index 4962b0e4be6fc..f1de09027310c 100644 --- a/Detectors/CPV/reconstruction/src/RawReaderMemory.cxx +++ b/Detectors/CPV/reconstruction/src/RawReaderMemory.cxx @@ -41,7 +41,7 @@ o2::header::RDHAny RawReaderMemory::decodeRawHeader(const void* payloadwords) return o2::header::RDHAny(*reinterpret_cast(payloadwords)); } LOG(error) << "RawReaderMemory::decodeRawHeader() : Unknown RDH version"; - return o2::header::RDHAny(*reinterpret_cast(payloadwords)); + throw RawErrorType_t::kRDH_DECODING; } void RawReaderMemory::init() @@ -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); @@ -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; diff --git a/Detectors/CPV/workflow/src/RawToDigitConverterSpec.cxx b/Detectors/CPV/workflow/src/RawToDigitConverterSpec.cxx index d52cf477808ce..22740c178e96f 100644 --- a/Detectors/CPV/workflow/src/RawToDigitConverterSpec.cxx +++ b/Detectors/CPV/workflow/src/RawToDigitConverterSpec.cxx @@ -108,15 +108,7 @@ void RawToDigitConverterSpec::run(framework::ProcessingContext& ctx) gains = gainsPtr.get(); } - /*if (!mIsPedestalData) { - pedestals = const_cast((ctx.inputs().get("peds")).get()); - } - if (mIsUsingBadMap) { - badMap = const_cast((ctx.inputs().get("peds")).get()); - } - if (mIsUsingGainCalibration) { - gains = const_cast((ctx.inputs().get("peds")).get()); - }*/ + bool skipTF = false; // skip TF due to fatal error? std::vector rawFilter{ {"RAWDATA", o2::framework::ConcreteDataTypeMatcher{"CPV", "RAWDATA"}, o2::framework::Lifetime::Timeframe}, @@ -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 @@ -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