Skip to content

Commit

Permalink
fix: Fix RootSimHitReader for empty events (#2478)
Browse files Browse the repository at this point in the history
Looking at the writer this can happen for non recorded hits so the
reader should also support that.

I discovered this while simulating single particles with Geant4 in our
Examples framework

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
andiwand and kodiakhq[bot] authored Sep 26, 2023
1 parent 2b922b0 commit 5d65fd0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Examples/Io/Root/src/RootSimHitReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,20 @@ ActsExamples::ProcessCode ActsExamples::RootSimHitReader::read(
m_eventMap.begin(), m_eventMap.end(),
[&](const auto& a) { return std::get<0>(a) == context.eventNumber; });

if (m_inputChain == nullptr || it == m_eventMap.end()) {
ACTS_ERROR("Cannot read hits of event " << context.eventNumber);
return ActsExamples::ProcessCode::ABORT;
if (it == m_eventMap.end()) {
// explicitly warn if it happens for the first or last event as that might
// indicate a human error
if ((context.eventNumber == availableEvents().first) &&
(context.eventNumber == availableEvents().second - 1)) {
ACTS_WARNING("Reading empty event: " << context.eventNumber);
} else {
ACTS_DEBUG("Reading empty event: " << context.eventNumber);
}

m_outputSimHits(context, {});

// Return success flag
return ActsExamples::ProcessCode::SUCCESS;
}

// lock the mutex
Expand Down

0 comments on commit 5d65fd0

Please sign in to comment.