Skip to content

Commit

Permalink
fix: Let Root writers accept empty Trajectories object (#1864)
Browse files Browse the repository at this point in the history
The Root Writers crash when they encounter an empty Trajectories object (e.g., from a failed fit) which should be fixed by this PR.

One thing that is not optimal is that we seem not to test a case with failing tracks, but I'm not sure how to setup such a test in the best way...
  • Loading branch information
benjaminhuth committed Feb 14, 2023
1 parent ae51d11 commit 3623733
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 9 additions & 2 deletions Examples/Io/Root/src/RootTrajectoryStatesWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,17 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectoryStatesWriter::writeT(
// The trajectory index
m_multiTrajNr = itraj;

// The trajectory entry indices and the multiTrajectory
const auto& mj = traj.multiTrajectory();
// The trajectory entry indices
const auto& trackTips = traj.tips();

// Dont write empty MultiTrajectory
if (trackTips.empty()) {
continue;
}

// The MultiTrajectory
const auto& mj = traj.multiTrajectory();

// Loop over the entry indices for the subtrajectories
for (unsigned int isubtraj = 0; isubtraj < trackTips.size(); ++isubtraj) {
// The subtrajectory index
Expand Down
6 changes: 4 additions & 2 deletions Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::writeT(
for (size_t itraj = 0; itraj < trajectories.size(); ++itraj) {
const auto& traj = trajectories[itraj];

// The trajectory entry indices and the multiTrajectory
const auto& mj = traj.multiTrajectory();
// The trajectory entry indices
const auto& trackTips = traj.tips();

// Dont write empty MultiTrajectory
if (trackTips.empty()) {
continue;
}

// Get the MultiTrajectory
const auto& mj = traj.multiTrajectory();

// The trajectory index
m_multiTrajNr.push_back(itraj);

Expand Down

0 comments on commit 3623733

Please sign in to comment.