From a7be441a34b4cfaba9e5447a34b2bfb393d4f7ac Mon Sep 17 00:00:00 2001 From: Eric Torrence <eric.torrence@cern.ch> Date: Fri, 13 Aug 2021 23:49:23 +0000 Subject: [PATCH] Catch error on truncated events --- .../src/FaserByteStreamInputSvc.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx b/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx index e2d65999..d24a2f65 100644 --- a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx +++ b/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx @@ -9,7 +9,7 @@ //#include "ByteStreamData/ByteStreamMetadataContainer.h" #include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" #include "FaserEventStorage/pickFaserDataReader.h" - +#include "FaserEventStorage/EventStorageIssues.h" #include "Gaudi/Property.h" #include "PersistentDataModel/DataHeader.h" @@ -116,10 +116,22 @@ const EventFull* FaserByteStreamInputSvc::nextEvent() { if (m_evtInFile+1 > m_evtOffsets.size()) { // get current event position (cast to long long until native tdaq implementation) + // This is the usual situation, reading past previous point in file ATH_MSG_DEBUG("nextEvent _above_ high water mark"); m_evtFileOffset = (long long)m_reader->getPosition(); m_evtOffsets.push_back(m_evtFileOffset); - m_reader->getData(theEvent); + + // Catch truncated events + try { + m_reader->getData(theEvent); + } catch (const FaserEventStorage::ES_OutOfFileBoundary& e) { + // Attempt to read beyond end of file, likely truncated event + ATH_MSG_WARNING("DataReader reports FaserEventStorage::ES_OutOfFileBoundary, stop reading file!"); + return NULL; + } catch (...) { + // rethrow any other exceptions + throw; + } } else { -- GitLab