13 #include <unordered_map>
17 template <
typename track_container_t,
typename traj_t,
18 template <
typename>
class holder_t,
typename source_link_hash_t,
19 typename source_link_equality_t>
20 void GreedyAmbiguityResolution::computeInitialState(
21 const TrackContainer<track_container_t, traj_t, holder_t>&
tracks,
22 State&
state, source_link_hash_t&& sourceLinkHash,
23 source_link_equality_t&& sourceLinkEquality)
const {
24 auto measurementIndexMap =
25 std::unordered_map<
SourceLink, std::size_t, source_link_hash_t,
26 source_link_equality_t>(0, sourceLinkHash,
32 for (
const auto& track : tracks) {
37 std::vector<std::size_t> measurements;
38 for (
auto ts : track.trackStatesReversed()) {
40 SourceLink sourceLink = ts.getUncalibratedSourceLink();
42 auto emplace = measurementIndexMap.try_emplace(
43 sourceLink, measurementIndexMap.size());
44 measurements.push_back(emplace.first->second);
48 state.trackTips.push_back(track.index());
49 state.trackChi2.push_back(track.chi2() / track.nDoF());
50 state.measurementsPerTrack.push_back(
std::move(measurements));
51 state.selectedTracks.insert(state.numberOfTracks);
53 ++state.numberOfTracks;
57 for (std::size_t iTrack = 0; iTrack < state.numberOfTracks; ++iTrack) {
58 for (
auto iMeasurement : state.measurementsPerTrack[iTrack]) {
59 state.tracksPerMeasurement[iMeasurement].insert(iTrack);
64 state.sharedMeasurementsPerTrack =
65 std::vector<std::size_t>(state.trackTips.size(), 0);
66 for (std::size_t iTrack = 0; iTrack < state.numberOfTracks; ++iTrack) {
67 for (
auto iMeasurement : state.measurementsPerTrack[iTrack]) {
68 if (state.tracksPerMeasurement[iMeasurement].size() > 1) {
69 ++state.sharedMeasurementsPerTrack[iTrack];