File indexing completed on 2025-01-18 09:55:43
0001
0002
0003
0004 #pragma once
0005
0006 #include <Acts/EventData/TrackParameters.hpp>
0007 #include <Acts/Geometry/GeometryContext.hpp>
0008 #include <Acts/Geometry/GeometryIdentifier.hpp>
0009 #include <Acts/MagneticField/MagneticFieldContext.hpp>
0010 #include <Acts/Surfaces/Surface.hpp>
0011 #include <Acts/Utilities/Result.hpp>
0012 #include <ActsExamples/EventData/Track.hpp>
0013 #include <ActsExamples/EventData/Trajectories.hpp>
0014 #include <DD4hep/Detector.h>
0015 #include <edm4eic/TrackCollection.h>
0016 #include <edm4eic/TrackPoint.h>
0017 #include <edm4eic/TrackSegmentCollection.h>
0018 #include <fmt/core.h>
0019 #include <spdlog/logger.h>
0020 #include <stddef.h>
0021 #include <memory>
0022 #include <tuple>
0023 #include <vector>
0024
0025 #include "algorithms/interfaces/WithPodConfig.h"
0026 #include "algorithms/tracking/ActsGeometryProvider.h"
0027 #include "algorithms/tracking/TrackPropagationConfig.h"
0028
0029 namespace eicrecon {
0030
0031 using ActsTrackPropagationResult = Acts::Result<std::unique_ptr<const Acts::BoundTrackParameters>>;
0032
0033
0034
0035
0036
0037 class TrackPropagation: public eicrecon::WithPodConfig<TrackPropagationConfig> {
0038
0039
0040 public:
0041
0042
0043 void init(const dd4hep::Detector* detector, std::shared_ptr<const ActsGeometryProvider> geo_svc, std::shared_ptr<spdlog::logger> logger);
0044
0045 void process(
0046 const std::tuple<const edm4eic::TrackCollection&, const std::vector<const ActsExamples::Trajectories*>, const std::vector<const ActsExamples::ConstTrackContainer*>> input,
0047 const std::tuple<edm4eic::TrackSegmentCollection*> output) const {
0048
0049 const auto [tracks, acts_trajectories, acts_tracks] = input;
0050 auto [propagated_tracks] = output;
0051
0052 for (size_t i = 0; auto traj: acts_trajectories) {
0053 auto this_propagated_track = propagated_tracks->create();
0054 if (tracks.size() == acts_trajectories.size()) {
0055 m_log->trace("track segment connected to track {}", i);
0056 this_propagated_track.setTrack(tracks[i]);
0057 }
0058 for (auto& surf : m_target_surfaces) {
0059 auto prop_point = propagate(
0060 tracks.size() == acts_trajectories.size() ? tracks[i] : edm4eic::Track{},
0061 traj, surf);
0062 if (!prop_point) continue;
0063 prop_point->surface = surf->geometryId().layer();
0064 prop_point->system = surf->geometryId().extra();
0065 this_propagated_track.addToPoints(*prop_point);
0066 }
0067 ++i;
0068 }
0069 }
0070
0071
0072 std::unique_ptr<edm4eic::TrackPoint> propagate(
0073 const edm4eic::Track&,
0074 const ActsExamples::Trajectories*,
0075 const std::shared_ptr<const Acts::Surface>& targetSurf) const;
0076
0077
0078
0079
0080
0081 void propagateToSurfaceList(
0082 const std::tuple<const edm4eic::TrackCollection&, const std::vector<const ActsExamples::Trajectories*>, const std::vector<const ActsExamples::ConstTrackContainer*>> input,
0083 const std::tuple<edm4eic::TrackSegmentCollection*> output) const;
0084
0085 private:
0086
0087 Acts::GeometryContext m_geoContext;
0088 Acts::MagneticFieldContext m_fieldContext;
0089 std::shared_ptr<const ActsGeometryProvider> m_geoSvc;
0090 std::shared_ptr<spdlog::logger> m_log;
0091
0092 std::vector<std::shared_ptr<Acts::Surface>> m_filter_surfaces;
0093 std::vector<std::shared_ptr<Acts::Surface>> m_target_surfaces;
0094 };
0095 }