File indexing completed on 2025-01-18 09:11:43
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Utilities/TrackSelectorAlgorithm.hpp"
0010
0011 #include "Acts/EventData/TrackContainer.hpp"
0012 #include "Acts/EventData/TrackProxy.hpp"
0013 #include "Acts/EventData/VectorMultiTrajectory.hpp"
0014 #include "Acts/EventData/VectorTrackContainer.hpp"
0015 #include "ActsExamples/EventData/Track.hpp"
0016
0017 #include <cmath>
0018 #include <memory>
0019 #include <stdexcept>
0020 #include <utility>
0021
0022 namespace ActsExamples {
0023 struct AlgorithmContext;
0024 }
0025
0026 ActsExamples::TrackSelectorAlgorithm::TrackSelectorAlgorithm(
0027 const Config& config, Acts::Logging::Level level)
0028 : IAlgorithm("TrackSelector", level),
0029 m_cfg(config),
0030 m_selector(config.selectorConfig) {
0031 if (m_cfg.inputTracks.empty()) {
0032 throw std::invalid_argument("Input track collection is empty");
0033 }
0034
0035 if (m_cfg.outputTracks.empty()) {
0036 throw std::invalid_argument("Output track collection is empty");
0037 }
0038
0039 m_inputTrackContainer.initialize(m_cfg.inputTracks);
0040 m_outputTrackContainer.initialize(m_cfg.outputTracks);
0041 }
0042
0043 ActsExamples::ProcessCode ActsExamples::TrackSelectorAlgorithm::execute(
0044 const ActsExamples::AlgorithmContext& ctx) const {
0045 ACTS_VERBOSE("Reading tracks from: " << m_cfg.inputTracks);
0046
0047 const auto& inputTracks = m_inputTrackContainer(ctx);
0048
0049 std::shared_ptr<Acts::ConstVectorMultiTrajectory> trackStateContainer =
0050 inputTracks.trackStateContainerHolder();
0051
0052 auto trackContainer = std::make_shared<Acts::VectorTrackContainer>();
0053
0054
0055
0056 auto tempTrackStateContainer =
0057 std::make_shared<Acts::VectorMultiTrajectory>();
0058
0059 TrackContainer filteredTracks{trackContainer, tempTrackStateContainer};
0060 filteredTracks.ensureDynamicColumns(inputTracks);
0061
0062 ACTS_DEBUG("Track container size before filtering: " << inputTracks.size());
0063
0064 m_selector.selectTracks(inputTracks, filteredTracks);
0065
0066 ACTS_DEBUG("Track container size after filtering: " << filteredTracks.size());
0067
0068 ConstTrackContainer outputTracks{
0069 std::make_shared<Acts::ConstVectorTrackContainer>(
0070 std::move(*trackContainer)),
0071 trackStateContainer};
0072
0073 m_outputTrackContainer(ctx, std::move(outputTracks));
0074
0075 return ProcessCode::SUCCESS;
0076 }