File indexing completed on 2025-01-18 09:11:30
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/TrackFinding/detail/AmbiguityTrackClustering.hpp"
0010
0011 #include <iterator>
0012
0013 std::unordered_map<std::size_t, std::vector<std::size_t>>
0014 Acts::detail::clusterDuplicateTracks(
0015 const std::multimap<int, std::pair<std::size_t, std::vector<std::size_t>>>&
0016 trackMap) {
0017
0018
0019 std::unordered_map<std::size_t, std::vector<std::size_t>> cluster;
0020
0021
0022 std::unordered_map<std::size_t, std::size_t> hitToTrack;
0023
0024
0025 for (auto track = trackMap.rbegin(); track != trackMap.rend(); ++track) {
0026 const auto& trackValue = track->second;
0027 std::vector<std::size_t> hits = trackValue.second;
0028 auto matchedTrack = hitToTrack.end();
0029
0030 for (const auto& hit : hits) {
0031
0032 matchedTrack = hitToTrack.find(hit);
0033 if (matchedTrack != hitToTrack.end()) {
0034
0035 cluster.at(matchedTrack->second).push_back(trackValue.first);
0036 break;
0037 }
0038 }
0039
0040 if (matchedTrack == hitToTrack.end()) {
0041 cluster.emplace(trackValue.first,
0042 std::vector<std::size_t>(1, trackValue.first));
0043 for (const auto& hit : hits) {
0044
0045 hitToTrack.emplace(hit, trackValue.first);
0046 }
0047 }
0048 }
0049 return cluster;
0050 }