Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackSelectorAlgorithm.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackSelectorAlgorithm.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-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 
16 
17 #include <cmath>
18 #include <memory>
19 #include <stdexcept>
20 #include <utility>
21 
22 namespace ActsExamples {
23 struct AlgorithmContext;
24 } // namespace ActsExamples
25 
28  : IAlgorithm("TrackSelector", level),
29  m_cfg(config),
30  m_selector(config.selectorConfig) {
31  if (m_cfg.inputTracks.empty()) {
32  throw std::invalid_argument("Input track collection is empty");
33  }
34 
35  if (m_cfg.outputTracks.empty()) {
36  throw std::invalid_argument("Output track collection is empty");
37  }
38 
41 }
42 
44  const ActsExamples::AlgorithmContext& ctx) const {
45  ACTS_VERBOSE("Reading tracks from: " << m_cfg.inputTracks);
46 
47  const auto& inputTracks = m_inputTrackContainer(ctx);
48 
49  std::shared_ptr<Acts::ConstVectorMultiTrajectory> trackStateContainer =
50  inputTracks.trackStateContainerHolder();
51 
52  auto trackContainer = std::make_shared<Acts::VectorTrackContainer>();
53 
54  // temporary empty track state container: we don't change the original one,
55  // but we need one for filtering
56  auto tempTrackStateContainer =
57  std::make_shared<Acts::VectorMultiTrajectory>();
58 
59  TrackContainer filteredTracks{trackContainer, tempTrackStateContainer};
60  filteredTracks.ensureDynamicColumns(inputTracks);
61 
62  ACTS_DEBUG("Track container size before filtering: " << inputTracks.size());
63 
64  m_selector.selectTracks(inputTracks, filteredTracks);
65 
66  ACTS_DEBUG("Track container size after filtering: " << filteredTracks.size());
67 
69  std::make_shared<Acts::ConstVectorTrackContainer>(
70  std::move(*trackContainer)),
71  trackStateContainer};
72 
73  m_outputTrackContainer(ctx, std::move(outputTracks));
74 
75  return ProcessCode::SUCCESS;
76 }