102 track_t track,
const std::shared_ptr<Acts::Surface>& target_surface) {
104 std::cout <<
"[TrackExtrapolatorTool] extrapolate START\n";
105 std::cout <<
"[TrackExtrapolatorTool] track.nTrackStates() = "
106 << track.nTrackStates() << std::endl;
107 std::cout <<
"[TrackExtrapolatorTool] target_surface = "
108 << target_surface.get() << std::endl;
114 <<
"[TrackExtrapolatorTool] Getting outermost track state...\n";
115 auto outermost = *(track.trackStatesReversed().begin());
118 <<
"[TrackExtrapolatorTool] Getting innermost track state...\n";
119 auto begin = track.trackStatesReversed().begin();
120 std::advance(begin, track.nTrackStates() - 1);
121 auto innermost = *begin;
123 std::cout <<
"[TrackExtrapolatorTool] Got innermost and outermost "
130 std::cout <<
"[TrackExtrapolatorTool] Calculating distances...\n";
131 double first_dis = std::abs(
132 innermost.referenceSurface().transform(gctx_).translation()(0) -
133 target_surface->transform(gctx_).translation()(0));
135 double last_dis = std::abs(
136 outermost.referenceSurface().transform(gctx_).translation()(0) -
137 target_surface->transform(gctx_).translation()(0));
139 std::cout <<
"[TrackExtrapolatorTool] first_dis = " << first_dis
140 <<
", last_dis = " << last_dis << std::endl;
144 const auto& ts = first_dis < last_dis ? innermost : outermost;
145 if (debug_) std::cout <<
"[TrackExtrapolatorTool] Selected track state\n";
150 std::cout <<
"[TrackExtrapolatorTool] Getting reference surface...\n";
151 const auto& surface = ts.referenceSurface();
153 std::cout <<
"[TrackExtrapolatorTool] Checking hasSmoothed...\n";
154 bool has_smoothed = ts.hasSmoothed();
156 std::cout <<
"[TrackExtrapolatorTool] has_smoothed = " << has_smoothed
160 Acts::BoundVector params;
161 Acts::BoundMatrix cov;
165 std::cout <<
"[TrackExtrapolatorTool] Using smoothed parameters...\n";
166 params = ts.smoothed();
167 cov = ts.smoothedCovariance();
170 std::cout <<
"[TrackExtrapolatorTool] Using filtered parameters...\n";
171 params = ts.filtered();
172 cov = ts.filteredCovariance();
175 std::cout <<
"[TrackExtrapolatorTool] Got all track state components\n";
178 std::cout <<
"Surface::" << surface.transform(gctx_).translation()
180 std::cout <<
"HasSmoothed::" << has_smoothed << std::endl;
181 std::cout <<
"Parameters::" << params.transpose() << std::endl;
186 <<
"[TrackExtrapolatorTool] Creating BoundTrackParameters...\n";
187 auto part_hypo{Acts::SinglyChargedParticleHypothesis::electron()};
188 Acts::BoundTrackParameters sp(surface.getSharedPtr(), params, cov,
191 std::cout <<
"[TrackExtrapolatorTool] BoundTrackParameters created, "
192 "calling extrapolate(BTP)...\n";
193 auto result = extrapolate(sp, target_surface);
194 if (debug_) std::cout <<
"[TrackExtrapolatorTool] extrapolate DONE\n";
209 track_t track,
const std::shared_ptr<Acts::Surface>& target_surface) {
214 auto& tsc = track.container().trackStateContainer();
215 auto begin = track.trackStates().begin();
216 auto ts_last = *begin;
217 const auto& surface = (ts_last).referenceSurface();
218 const auto& smoothed = (ts_last).smoothed();
219 const auto& cov = (ts_last).smoothedCovariance();
223 auto part_hypo{Acts::SinglyChargedParticleHypothesis::electron()};
225 Acts::BoundTrackParameters state_parameters(surface.getSharedPtr(),
226 smoothed, cov, part_hypo);
231 propagator_.propagate(state_parameters, *target_surface, p_options);
234 return *result->endParameters;
251 const std::shared_ptr<Acts::Surface>& target_surface,
253 ldmx::TrackStateType type) {
255 std::cout <<
"[TrackExtrapolatorTool] trackStateAtSurface START\n";
256 std::cout <<
"[TrackExtrapolatorTool] target_surface = "
257 << target_surface.get() << std::endl;
258 std::cout <<
"[TrackExtrapolatorTool] track.nTrackStates() = "
259 << track.nTrackStates() << std::endl;
260 std::cout <<
"[TrackExtrapolatorTool] TrackStateType = "
261 <<
static_cast<int>(type) << std::endl;
262 std::cout <<
"[TrackExtrapolatorTool] About to call extrapolate...\n";
265 auto opt_pars = extrapolate(track, target_surface);
268 std::cout <<
"[TrackExtrapolatorTool] extrapolate returned, "
269 "opt_pars.has_value() = "
270 << opt_pars.has_value() << std::endl;
275 std::cout <<
"[TrackExtrapolatorTool] Getting surface location...\n";
277 Acts::Vector3 surf_loc = target_surface->transform(gctx_).translation();
278 ts.ref_x_ = surf_loc(0);
279 ts.ref_y_ = surf_loc(1);
280 ts.ref_z_ = surf_loc(2);
282 std::cout <<
"[TrackExtrapolatorTool] Surface location: ("
283 << surf_loc(0) <<
", " << surf_loc(1) <<
", " << surf_loc(2)
288 std::cout <<
"[TrackExtrapolatorTool] Getting parameters...\n";
291 tracking::sim::utils::convertActsToLdmxPars((*opt_pars).parameters());
292 if (debug_) std::cout <<
"[TrackExtrapolatorTool] Parameters set\n";
295 std::cout <<
"[TrackExtrapolatorTool] Getting covariance...\n";
297 const Acts::BoundMatrix& trk_cov = *((*opt_pars).covariance());
299 std::cout <<
"[TrackExtrapolatorTool] Covariance matrix obtained\n";
300 tracking::sim::utils::flatCov(trk_cov, ts.cov_);
302 std::cout <<
"[TrackExtrapolatorTool] Covariance flattened\n";
306 std::cout <<
"[TrackExtrapolatorTool] trackStateAtSurface SUCCESS\n";
310 std::cout <<
"[TrackExtrapolatorTool] trackStateAtSurface FAILED - "
311 "opt_pars is empty\n";