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