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

CKFTracking: remove Acts tracks that failed to extrapolate, not just the trajectories #1677

Merged
merged 4 commits into from
Dec 1, 2024
Merged
Changes from 2 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
26 changes: 17 additions & 9 deletions src/algorithms/tracking/CKFTracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <Acts/Definitions/TrackParametrization.hpp>
#include <Acts/Definitions/Units.hpp>
#include <Acts/EventData/GenericBoundTrackParameters.hpp>
#include <Acts/EventData/TrackStateProxy.hpp>
veprbl marked this conversation as resolved.
Show resolved Hide resolved
#include <Acts/EventData/Types.hpp>
#if Acts_VERSION_MAJOR < 36
#include <Acts/EventData/Measurement.hpp>
#endif
Expand Down Expand Up @@ -56,6 +58,7 @@
#include <functional>
#include <list>
#include <optional>
#include <ranges>
#include <utility>

#include "ActsGeometryProvider.h"
Expand Down Expand Up @@ -260,6 +263,7 @@ namespace eicrecon {
#else
Acts::TrackAccessor<unsigned int> seedNumber("seed");
#endif
std::vector<Acts::TrackIndexType> failed_tracks;

// Loop over seeds
for (std::size_t iseed = 0; iseed < acts_init_trk_params.size(); ++iseed) {
Expand Down Expand Up @@ -291,6 +295,7 @@ namespace eicrecon {
ACTS_ERROR("Extrapolation for seed "
<< iseed << " and track " << track.index()
<< " failed with error " << extrapolationResult.error());
failed_tracks.push_back(track.index());
continue;
}
#endif
Expand All @@ -299,6 +304,18 @@ namespace eicrecon {
}
}

for (Acts::TrackIndexType track_index : std::ranges::reverse_view(failed_tracks)) {
// NOTE This does not remove track states corresponding to the
// removed tracks. Doing so would require implementing some garbage
// collection. We'll just assume no algorithm will access them
// directly.
acts_tracks.removeTrack(track_index);
#if Acts_VERSION_MAJOR < 36
// Workaround an upstream bug in Acts::VectorTrackContainer::removeTrack_impl()
// https://github.com/acts-project/acts/commit/94cf81f3f1109210b963977e0904516b949b1154
trackContainer->m_particleHypothesis.erase(trackContainer->m_particleHypothesis.begin() + track_index);
#endif
}

// Move track states and track container to const containers
// NOTE Using the non-const containers leads to references to
Expand Down Expand Up @@ -336,15 +353,6 @@ namespace eicrecon {

std::optional<unsigned int> lastSeed;
for (const auto& track : constTracks) {
#if Acts_VERSION_MAJOR >= 34
// Some B0 tracks fail to extrapolate to the perigee surface. The
// Acts::extrapolateTrackToReferenceSurface will not set
// referenceSurface in that case, which is what we check here.
if (not track.hasReferenceSurface()) {
m_log->warn("Skipping a track not on perigee surface");
continue;
}
#endif
if (!lastSeed) {
lastSeed = constSeedNumber(track);
}
Expand Down
Loading