32 const Acts::GeometryContext& gctx,
33 const Acts::MagneticFieldContext& mctx)
34 : propagator_(std::move(propagator)) {
55 typename propagator_t::template Options<ActionList, AbortList>;
57 std::optional<Acts::BoundTrackParameters> extrapolate(
58 const Acts::BoundTrackParameters pars,
59 const std::shared_ptr<Acts::Surface>& target_surface) {
60 auto intersection = target_surface->intersect(gctx_, pars.position(gctx_),
65 pOptions.direction = intersection.intersections()[0].pathLength() >= 0
66 ? Acts::Direction::Forward
67 : Acts::Direction::Backward;
69 auto result = propagator_.propagate(pars, *target_surface, pOptions);
75 std::cout <<
"INITIAL COV MATRIX" << std::endl;
76 std::cout << (*(pars.covariance())) << std::endl;
78 std::cout <<
"FINAL COV MATRIX" << std::endl;
79 auto opt_pars = *result->endParameters;
80 std::cout << *(opt_pars.covariance()) << std::endl;
85 return *result->endParameters;
100 template <
class track_t>
102 track_t track,
const std::shared_ptr<Acts::Surface>& target_surface) {
104 auto outermost = *(track.trackStatesReversed().begin());
105 auto begin = track.trackStatesReversed().begin();
106 std::advance(begin, track.nTrackStates() - 1);
107 auto innermost = *begin;
112 double first_dis = std::abs(
113 innermost.referenceSurface().transform(gctx_).translation()(0) -
114 target_surface->transform(gctx_).translation()(0));
116 double last_dis = std::abs(
117 outermost.referenceSurface().transform(gctx_).translation()(0) -
118 target_surface->transform(gctx_).translation()(0));
122 const auto& ts = first_dis < last_dis ? innermost : outermost;
126 const auto& surface = ts.referenceSurface();
127 const auto& smoothed = ts.smoothed();
128 bool hasSmoothed = ts.hasSmoothed();
129 const auto& filtered = ts.filtered();
130 const auto& cov = ts.smoothedCovariance();
133 std::cout <<
"Surface::" << surface.transform(gctx_).translation()
136 std::cout <<
"Smoothed::" << smoothed.transpose() << std::endl;
137 std::cout <<
"HasSmoothed::" << hasSmoothed << std::endl;
138 std::cout <<
"Filtered::" << filtered.transpose() << std::endl;
141 auto partHypo{Acts::SinglyChargedParticleHypothesis::electron()};
142 Acts::BoundTrackParameters sp(surface.getSharedPtr(), smoothed, cov,
144 return extrapolate(sp, target_surface);
147 template <
class track_t>
148 std::optional<Acts::BoundTrackParameters> extrapolateToEcal(
149 track_t track,
const std::shared_ptr<Acts::Surface>& target_surface) {
154 auto& tsc = track.container().trackStateContainer();
155 auto begin = track.trackStates().begin();
156 auto ts_last = *begin;
157 const auto& surface = (ts_last).referenceSurface();
158 const auto& smoothed = (ts_last).smoothed();
159 const auto& cov = (ts_last).smoothedCovariance();
163 auto partHypo{Acts::SinglyChargedParticleHypothesis::electron()};
165 Acts::BoundTrackParameters state_parameters(surface.getSharedPtr(),
166 smoothed, cov, partHypo);
171 propagator_.propagate(state_parameters, *target_surface, pOptions);
174 return *result->endParameters;
189 template <
class track_t>
191 const std::shared_ptr<Acts::Surface>& target_surface,
193 ldmx::TrackStateType type) {
194 auto opt_pars = extrapolate(track, target_surface);
197 Acts::Vector3 surf_loc = target_surface->transform(gctx_).translation();
198 ts.refX = surf_loc(0);
199 ts.refY = surf_loc(1);
200 ts.refZ = surf_loc(2);
204 tracking::sim::utils::convertActsToLdmxPars((*opt_pars).parameters());
207 const Acts::BoundMatrix& trk_cov = *((*opt_pars).covariance());
208 tracking::sim::utils::flatCov(trk_cov, ts.cov);
218 propagator_t propagator_;
219 Acts::GeometryContext gctx_;
220 Acts::MagneticFieldContext mctx_;