File indexing completed on 2025-01-18 09:10:44
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp"
0012 #include "Acts/EventData/TrackStateType.hpp"
0013
0014 #include <unordered_map>
0015
0016 namespace Acts {
0017
0018 template <TrackContainerFrontend track_container_t, typename source_link_hash_t,
0019 typename source_link_equality_t>
0020 void GreedyAmbiguityResolution::computeInitialState(
0021 const track_container_t& tracks, State& state,
0022 source_link_hash_t&& sourceLinkHash,
0023 source_link_equality_t&& sourceLinkEquality) const {
0024 auto measurementIndexMap =
0025 std::unordered_map<SourceLink, std::size_t, source_link_hash_t,
0026 source_link_equality_t>(0, sourceLinkHash,
0027 sourceLinkEquality);
0028
0029
0030
0031
0032 for (const auto& track : tracks) {
0033
0034 if (track.nMeasurements() < m_cfg.nMeasurementsMin) {
0035 continue;
0036 }
0037 std::vector<std::size_t> measurements;
0038 for (auto ts : track.trackStatesReversed()) {
0039 bool isMeasurement = ts.typeFlags().test(TrackStateFlag::MeasurementFlag);
0040 bool isOutlier = ts.typeFlags().test(TrackStateFlag::OutlierFlag);
0041 if (isMeasurement && !isOutlier) {
0042 SourceLink sourceLink = ts.getUncalibratedSourceLink();
0043
0044 auto emplace = measurementIndexMap.try_emplace(
0045 sourceLink, measurementIndexMap.size());
0046 measurements.push_back(emplace.first->second);
0047 }
0048 }
0049
0050 state.trackTips.push_back(track.index());
0051 state.trackChi2.push_back(track.chi2() / track.nDoF());
0052 state.measurementsPerTrack.push_back(std::move(measurements));
0053 state.selectedTracks.insert(state.numberOfTracks);
0054
0055 ++state.numberOfTracks;
0056 }
0057
0058
0059 for (std::size_t iTrack = 0; iTrack < state.numberOfTracks; ++iTrack) {
0060 for (auto iMeasurement : state.measurementsPerTrack[iTrack]) {
0061 state.tracksPerMeasurement[iMeasurement].insert(iTrack);
0062 }
0063 }
0064
0065
0066 state.sharedMeasurementsPerTrack =
0067 std::vector<std::size_t>(state.trackTips.size(), 0);
0068 for (std::size_t iTrack = 0; iTrack < state.numberOfTracks; ++iTrack) {
0069 for (auto iMeasurement : state.measurementsPerTrack[iTrack]) {
0070 if (state.tracksPerMeasurement[iMeasurement].size() > 1) {
0071 ++state.sharedMeasurementsPerTrack[iTrack];
0072 }
0073 }
0074 }
0075 }
0076
0077 }