File indexing completed on 2025-01-18 09:27:32
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp"
0012
0013 #include <unordered_map>
0014
0015 namespace Acts {
0016
0017 template <typename track_container_t, typename traj_t,
0018 template <typename> class holder_t, typename source_link_hash_t,
0019 typename source_link_equality_t>
0020 void GreedyAmbiguityResolution::computeInitialState(
0021 const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
0022 State& state, 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 if (ts.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) {
0040 SourceLink sourceLink = ts.getUncalibratedSourceLink();
0041
0042 auto emplace = measurementIndexMap.try_emplace(
0043 sourceLink, measurementIndexMap.size());
0044 measurements.push_back(emplace.first->second);
0045 }
0046 }
0047
0048 state.trackTips.push_back(track.index());
0049 state.trackChi2.push_back(track.chi2() / track.nDoF());
0050 state.measurementsPerTrack.push_back(std::move(measurements));
0051 state.selectedTracks.insert(state.numberOfTracks);
0052
0053 ++state.numberOfTracks;
0054 }
0055
0056
0057 for (std::size_t iTrack = 0; iTrack < state.numberOfTracks; ++iTrack) {
0058 for (auto iMeasurement : state.measurementsPerTrack[iTrack]) {
0059 state.tracksPerMeasurement[iMeasurement].insert(iTrack);
0060 }
0061 }
0062
0063
0064 state.sharedMeasurementsPerTrack =
0065 std::vector<std::size_t>(state.trackTips.size(), 0);
0066 for (std::size_t iTrack = 0; iTrack < state.numberOfTracks; ++iTrack) {
0067 for (auto iMeasurement : state.measurementsPerTrack[iTrack]) {
0068 if (state.tracksPerMeasurement[iMeasurement].size() > 1) {
0069 ++state.sharedMeasurementsPerTrack[iTrack];
0070 }
0071 }
0072 }
0073 }
0074
0075 }