Skip to content

Commit

Permalink
fix uninitilised and tie nMajorityHits
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger committed Sep 8, 2024
1 parent 16828c0 commit b217434
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
7 changes: 5 additions & 2 deletions Core/include/Acts/Navigation/MultiLayerNavigation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@ class MultiLayerNavigation : public IInternalNavigation {
std::vector<const Acts::Surface*>& surfaces) const {
// sorting the surfaces according to their radial distance
std::ranges::sort(surfaces, {}, [&gctx](const auto& s) {
return std::tie(s->center(gctx).x(), s->center(gctx).y(),
s->center(gctx).z());
// copy to prevent problem with uninitialised variables
auto centerX = s->center(gctx).x();
auto centerY = s->center(gctx).y();
auto centerZ = s->center(gctx).z();
return std::tie(centerX, centerY, centerZ);
});

// Remove the duplicates
Expand Down
3 changes: 2 additions & 1 deletion Core/src/TrackFitting/GsfMixtureReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void reduceWithKLDistanceImpl(std::vector<Acts::GsfComponent> &cmpCache,
}

// Remove all components which are labeled with weight -1
std::ranges::sort(cmpCache, {}, [](const auto &c) { return proj(c).weight; });
std::ranges::sort(cmpCache, {},
[&](const auto &c) { return proj(c).weight; });
cmpCache.erase(
std::remove_if(cmpCache.begin(), cmpCache.end(),
[&](const auto &a) { return proj(a).weight == -1.0; }),
Expand Down
22 changes: 9 additions & 13 deletions Examples/Io/Csv/src/CsvTrackWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <memory>
#include <stdexcept>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
Expand Down Expand Up @@ -159,19 +160,14 @@ ProcessCode CsvTrackWriter::writeT(const AlgorithmContext& context,
// Find duplicates
std::unordered_set<std::size_t> listGoodTracks;
for (auto& [particleId, matchedTracks] : matched) {
std::sort(matchedTracks.begin(), matchedTracks.end(),
[](const RecoTrackInfo& lhs, const RecoTrackInfo& rhs) {
// sort by nMajorityHits
if (lhs.first.nMajorityHits != rhs.first.nMajorityHits) {
return (lhs.first.nMajorityHits > rhs.first.nMajorityHits);
}
// sort by nOutliers
if (lhs.first.nOutliers != rhs.first.nOutliers) {
return (lhs.first.nOutliers < rhs.first.nOutliers);
}
// sort by chi2
return (lhs.first.chi2Sum < rhs.first.chi2Sum);
});
std::ranges::sort(
matchedTracks, [](const RecoTrackInfo& lhs, const RecoTrackInfo& rhs) {
// nMajorityHits are sorted descending, others ascending
return std::tie(rhs.first.nMajorityHits, lhs.first.nOutliers,
lhs.first.chi2Sum) < std::tie(lhs.first.nMajorityHits,
rhs.first.nOutliers,
rhs.first.chi2Sum);
});

listGoodTracks.insert(matchedTracks.front().first.trackId);
}
Expand Down

0 comments on commit b217434

Please sign in to comment.