File indexing completed on 2026-09-19 09:18:34
0001
0002
0003
0004 #pragma once
0005
0006 #if Acts_VERSION_MAJOR >= 46
0007 #include <Acts/EventData/BoundTrackParameters.hpp>
0008 #else
0009 #include <Acts/EventData/TrackParameters.hpp>
0010 #endif
0011 #include <Acts/EventData/TrackProxy.hpp>
0012 #include <Acts/EventData/VectorMultiTrajectory.hpp>
0013 #include <Acts/EventData/VectorTrackContainer.hpp>
0014 #include <Acts/Geometry/GeometryIdentifier.hpp>
0015 #include <Acts/Surfaces/Surface.hpp>
0016 #include <Acts/Utilities/Result.hpp>
0017 #include <ActsExamples/EventData/Track.hpp>
0018 #include <DD4hep/Detector.h>
0019 #include <algorithms/algorithm.h>
0020 #include <algorithms/geo.h>
0021 #include <edm4eic/TrackCollection.h>
0022 #include <edm4eic/TrackPoint.h>
0023 #include <edm4eic/TrackSegmentCollection.h>
0024 #include <cstddef>
0025 #include <gsl/pointers>
0026 #include <memory>
0027 #include <string>
0028 #include <string_view>
0029 #include <tuple>
0030 #include <vector>
0031
0032 #include "algorithms/interfaces/ActsSvc.h"
0033 #include "algorithms/interfaces/WithPodConfig.h"
0034 #include "algorithms/tracking/ActsGeometryProvider.h"
0035 #include "algorithms/tracking/TrackPropagationConfig.h"
0036
0037 namespace eicrecon {
0038
0039 using ActsTrackPropagationResult = Acts::Result<std::unique_ptr<const Acts::BoundTrackParameters>>;
0040
0041 using TrackPropagationAlgorithm = algorithms::Algorithm<
0042 algorithms::Input<edm4eic::TrackCollection, Acts::ConstVectorMultiTrajectory,
0043 Acts::ConstVectorTrackContainer>,
0044 algorithms::Output<edm4eic::TrackSegmentCollection>>;
0045
0046
0047
0048
0049
0050 class TrackPropagation : public TrackPropagationAlgorithm,
0051 public WithPodConfig<TrackPropagationConfig> {
0052
0053 public:
0054 TrackPropagation(std::string_view name)
0055 : TrackPropagationAlgorithm{name,
0056 {"inputTracks", "inputActsTrackStates", "inputActsTracks"},
0057 {"outputTrackSegments"},
0058 "Track propagation to surfaces"} {}
0059
0060
0061 void init() final;
0062
0063 void process(const Input& input, const Output& output) const final {
0064 const auto [tracks, track_states, tracks_acts] = input;
0065 auto [propagated_tracks] = output;
0066
0067
0068 auto trackStateContainer = std::make_shared<Acts::ConstVectorMultiTrajectory>(*track_states);
0069 auto trackContainer = std::make_shared<Acts::ConstVectorTrackContainer>(*tracks_acts);
0070 ActsExamples::ConstTrackContainer constTracks(trackContainer, trackStateContainer);
0071
0072 std::size_t i = 0;
0073 for (const auto& track : constTracks) {
0074 auto this_propagated_track = propagated_tracks->create();
0075 if (tracks->size() == constTracks.size()) {
0076 trace("track segment connected to track {}", i);
0077 this_propagated_track.setTrack((*tracks)[i]);
0078 }
0079 for (auto& surf : m_target_surfaces) {
0080 auto prop_point =
0081 propagate(tracks->size() == constTracks.size() ? (*tracks)[i] : edm4eic::Track{}, track,
0082 constTracks, surf);
0083 if (!prop_point)
0084 continue;
0085 prop_point->surface = surf->geometryId().layer();
0086 prop_point->system = surf->geometryId().extra();
0087 this_propagated_track.addToPoints(*prop_point);
0088 }
0089 ++i;
0090 }
0091 }
0092
0093
0094 std::unique_ptr<edm4eic::TrackPoint>
0095 propagate(const edm4eic::Track&, const ActsExamples::ConstTrackProxy&,
0096 const ActsExamples::ConstTrackContainer&,
0097 const std::shared_ptr<const Acts::Surface>& targetSurf) const;
0098
0099
0100
0101
0102
0103 void propagateToSurfaceList(const Input& input, const Output& output) const;
0104
0105 private:
0106 std::shared_ptr<const ActsGeometryProvider> m_geoSvc{
0107 algorithms::ActsSvc::instance().acts_geometry_provider()};
0108 const dd4hep::Detector* m_detector{algorithms::GeoSvc::instance().detector()};
0109
0110 std::vector<std::shared_ptr<Acts::Surface>> m_filter_surfaces;
0111 std::vector<std::shared_ptr<Acts::Surface>> m_target_surfaces;
0112 };
0113 }