Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AmbiguityResolutionMLAlgorithm.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AmbiguityResolutionMLAlgorithm.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 
12 
13 #include <iterator>
14 #include <map>
15 
19  : ActsExamples::AmbiguityResolutionML("AmbiguityResolutionMLAlgorithm",
20  lvl),
21  m_cfg(std::move(cfg)),
22  m_duplicateClassifier(m_cfg.inputDuplicateNN.c_str()) {
23  if (m_cfg.inputTracks.empty()) {
24  throw std::invalid_argument("Missing trajectories input collection");
25  }
26  if (m_cfg.outputTracks.empty()) {
27  throw std::invalid_argument("Missing trajectories output collection");
28  }
31 }
32 
34  const AlgorithmContext& ctx) const {
35  // Read input data
36  const auto& tracks = m_inputTracks(ctx);
37  // Associate measurement to their respective tracks
38  std::multimap<int, std::pair<int, std::vector<int>>> trackMap =
39  mapTrackHits(tracks, m_cfg.nMeasurementsMin);
40  auto cluster = Acts::detail::clusterDuplicateTracks(trackMap);
41  // Select the ID of the track we want to keep
42  std::vector<int> goodTracks =
43  m_duplicateClassifier.solveAmbuguity(cluster, tracks);
44  // Prepare the output track collection from the IDs
45  auto outputTracks = prepareOutputTrack(tracks, goodTracks);
46  m_outputTracks(ctx, std::move(outputTracks));
47 
49 }