Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AmbiguityResolutionML.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AmbiguityResolutionML.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
13 
16  : ActsExamples::IAlgorithm(name, lvl) {}
17 
18 std::multimap<int, std::pair<int, std::vector<int>>>
21  int nMeasurementsMin) const {
22  std::multimap<int, std::pair<int, std::vector<int>>> trackMap;
23  // Loop over all the trajectories in the events
24  for (const auto& track : tracks) {
25  std::vector<int> hits;
26  int nbMeasurements = 0;
27  // Store the hits id for the trajectory and compute the number of
28  // measurement
29  tracks.trackStateContainer().visitBackwards(
30  track.tipIndex(), [&](const auto& state) {
31  if (state.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) {
32  int indexHit = state.getUncalibratedSourceLink()
33  .template get<ActsExamples::IndexSourceLink>()
34  .index();
35  hits.emplace_back(indexHit);
36  ++nbMeasurements;
37  }
38  });
39  if (nbMeasurements < nMeasurementsMin) {
40  continue;
41  }
42  trackMap.emplace(nbMeasurements, std::make_pair(track.index(), hits));
43  }
44  return trackMap;
45 }
46 
50  std::vector<int>& goodTracks) const {
51  std::shared_ptr<Acts::ConstVectorMultiTrajectory> trackStateContainer =
52  tracks.trackStateContainerHolder();
53  auto trackContainer = std::make_shared<Acts::VectorTrackContainer>();
54  trackContainer->reserve(goodTracks.size());
55  // Temporary empty track state container: we don't change the original one,
56  // but we need one for filtering
57  auto tempTrackStateContainer =
58  std::make_shared<Acts::VectorMultiTrajectory>();
59 
60  TrackContainer solvedTracks{trackContainer, tempTrackStateContainer};
61  solvedTracks.ensureDynamicColumns(tracks);
62 
63  for (auto&& iTrack : goodTracks) {
64  auto destProxy = solvedTracks.getTrack(solvedTracks.addTrack());
65  auto srcProxy = tracks.getTrack(iTrack);
66  destProxy.copyFrom(srcProxy, false);
67  destProxy.tipIndex() = srcProxy.tipIndex();
68  }
69 
71  std::make_shared<Acts::ConstVectorTrackContainer>(
72  std::move(*trackContainer)),
73  trackStateContainer};
74  return outputTracks;
75 }