LDMX Software
tracking::reco::TrackExtrapolatorTool< propagator_t > Class Template Reference

Public Types

using PropagatorOptions = typename propagator_t::template Options<ActionList>
 Method to extrapolate to a target surface given a set of BoundTrackParameters.
 

Public Member Functions

 TrackExtrapolatorTool (propagator_t propagator, const Acts::GeometryContext &gctx, const Acts::MagneticFieldContext &mctx)
 
void setDebug (bool debug)
 Turn on/off internal debug flag.
 
void setMaxStepSize (double step)
 
void setPathLimit (double limit)
 
std::optional< Acts::BoundTrackParameters > extrapolate (const Acts::BoundTrackParameters pars, const std::shared_ptr< Acts::Surface > &target_surface)
 
template<class track_t >
std::optional< Acts::BoundTrackParameters > extrapolate (track_t track, const std::shared_ptr< Acts::Surface > &target_surface)
 Method to extrapolate to a target surface given a track The method computes which track state is closest to the surface to choose which one to use to extrapolate.
 
template<class track_t >
std::optional< Acts::BoundTrackParameters > extrapolateToEcal (track_t track, const std::shared_ptr< Acts::Surface > &target_surface)
 Create an ldmx::TrackState to the extrapolated position.
 
template<class track_t >
bool trackStateAtSurface (track_t track, const std::shared_ptr< Acts::Surface > &target_surface, ldmx::Track::TrackState &ts, ldmx::TrackStateType type)
 Create an ldmx::TrackState to the extrapolated position.
 

Private Attributes

propagator_t propagator_
 
Acts::GeometryContext gctx_
 
Acts::MagneticFieldContext mctx_
 
bool debug_ {false}
 
double max_step_size_ {-1}
 
double path_limit_ {-1}
 

Detailed Description

template<class propagator_t>
class tracking::reco::TrackExtrapolatorTool< propagator_t >

Definition at line 29 of file TrackExtrapolatorTool.h.

Member Typedef Documentation

◆ PropagatorOptions

template<class propagator_t >
using tracking::reco::TrackExtrapolatorTool< propagator_t >::PropagatorOptions = typename propagator_t::template Options<ActionList>

Method to extrapolate to a target surface given a set of BoundTrackParameters.

Parameters
parsBound Track Parameters
target_target_surfaceThe target surface
Returns
optional with BoundTrackParameters

Definition at line 54 of file TrackExtrapolatorTool.h.

Constructor & Destructor Documentation

◆ TrackExtrapolatorTool()

template<class propagator_t >
tracking::reco::TrackExtrapolatorTool< propagator_t >::TrackExtrapolatorTool ( propagator_t propagator,
const Acts::GeometryContext & gctx,
const Acts::MagneticFieldContext & mctx )
inline

Definition at line 32 of file TrackExtrapolatorTool.h.

35 : propagator_(std::move(propagator)), gctx_(gctx), mctx_(mctx) {}

Member Function Documentation

◆ extrapolate() [1/2]

template<class propagator_t >
std::optional< Acts::BoundTrackParameters > tracking::reco::TrackExtrapolatorTool< propagator_t >::extrapolate ( const Acts::BoundTrackParameters pars,
const std::shared_ptr< Acts::Surface > & target_surface )
inline

Definition at line 56 of file TrackExtrapolatorTool.h.

58 {
59 auto intersection = target_surface->intersect(gctx_, pars.position(gctx_),
60 pars.direction());
61
62 PropagatorOptions p_options(gctx_, mctx_);
63 if (max_step_size_ > 0) p_options.stepping.maxStepSize = max_step_size_;
64 if (path_limit_ > 0) p_options.pathLimit = path_limit_;
65
66 p_options.direction = intersection[0].pathLength() >= 0
67 ? Acts::Direction::Forward()
68 : Acts::Direction::Backward();
69
70 auto result = propagator_.propagate(pars, *target_surface, p_options);
71
72 // CHECK THE EXTRAPOLATION COVARIANCE MATRIX
73
74 if (debug_) {
75 if (result.ok()) {
76 std::cout << "INITIAL COV MATRIX\n";
77 std::cout << (*(pars.covariance())) << std::endl;
78
79 std::cout << "FINAL COV MATRIX\n";
80 auto opt_pars = *result->endParameters;
81 std::cout << *(opt_pars.covariance()) << std::endl;
82 }
83 }
84
85 if (result.ok())
86 return *result->endParameters;
87 else
88 return std::nullopt;
89 } // end of extrapolate()
typename propagator_t::template Options< ActionList > PropagatorOptions
Method to extrapolate to a target surface given a set of BoundTrackParameters.

◆ extrapolate() [2/2]

template<class propagator_t >
template<class track_t >
std::optional< Acts::BoundTrackParameters > tracking::reco::TrackExtrapolatorTool< propagator_t >::extrapolate ( track_t track,
const std::shared_ptr< Acts::Surface > & target_surface )
inline

Method to extrapolate to a target surface given a track The method computes which track state is closest to the surface to choose which one to use to extrapolate.

This method doesn't use a measurement, but whatever first/last track state is defined.

Parameters
trackAn Acts::Track
target_surfaceThe target surface
Returns
optional containing the bound track parameters.

Definition at line 102 of file TrackExtrapolatorTool.h.

103 {
104 if (debug_) {
105 std::cout << "[TrackExtrapolatorTool] extrapolate START\n";
106 std::cout << "[TrackExtrapolatorTool] track.nTrackStates() = "
107 << track.nTrackStates() << std::endl;
108 std::cout << "[TrackExtrapolatorTool] target_surface = "
109 << target_surface.get() << std::endl;
110 }
111
112 if (track.nTrackStates() == 0) {
113 return std::nullopt;
114 }
115
116 // Use ACTS's built-in helper to find the measurement track state
117 // (first or last) that is closest to the target surface. This correctly
118 // handles holes and material-only states which lack filtered parameters.
119 auto state_result = Acts::findTrackStateForExtrapolation(
120 gctx_, track, *target_surface,
121 Acts::TrackExtrapolationStrategy::firstOrLast);
122
123 if (!state_result.ok()) {
124 return std::nullopt;
125 }
126
127 const auto& ts = state_result->first;
128 const auto& surface = ts.referenceSurface();
129
130 Acts::BoundVector params;
131 Acts::BoundMatrix cov;
132
133 if (ts.hasSmoothed()) {
134 if (debug_)
135 std::cout << "[TrackExtrapolatorTool] Using smoothed parameters\n";
136 params = ts.smoothed();
137 cov = ts.smoothedCovariance();
138 } else if (ts.hasFiltered()) {
139 if (debug_)
140 std::cout << "[TrackExtrapolatorTool] Using filtered parameters\n";
141 params = ts.filtered();
142 cov = ts.filteredCovariance();
143 } else {
144 return std::nullopt;
145 }
146
147 if (debug_) {
148 std::cout << "Surface::"
149 << surface.localToGlobalTransform(gctx_).translation()
150 << std::endl;
151 std::cout << "HasSmoothed::" << ts.hasSmoothed() << std::endl;
152 std::cout << "Parameters::" << params.transpose() << std::endl;
153 }
154
155 auto part_hypo{Acts::ParticleHypothesis::electron()};
156 Acts::BoundTrackParameters sp(surface.getSharedPtr(), params, cov,
157 part_hypo);
158 if (debug_)
159 std::cout << "[TrackExtrapolatorTool] calling extrapolate(BTP)...\n";
160 auto result = extrapolate(sp, target_surface);
161 if (debug_) std::cout << "[TrackExtrapolatorTool] extrapolate DONE\n";
162 return result;
163 }

◆ extrapolateToEcal()

template<class propagator_t >
template<class track_t >
std::optional< Acts::BoundTrackParameters > tracking::reco::TrackExtrapolatorTool< propagator_t >::extrapolateToEcal ( track_t track,
const std::shared_ptr< Acts::Surface > & target_surface )
inline

Create an ldmx::TrackState to the extrapolated position.

Parameters
trackActs::Track
target_surfaceextrapolation surface
tsldmx::Track::TrackState
typeTrackStateType
Returns
optional boolean to check if there was a problem in the extrapolation

Definition at line 175 of file TrackExtrapolatorTool.h.

176 {
177 // get last track state on the track.
178 // Now.. I'm taking whatever it is. I'm not checking here if it is a
179 // measurement.
180
181 auto& tsc = track.container().trackStateContainer();
182 auto begin = track.trackStates().begin();
183 auto ts_last = *begin;
184 const auto& surface = (ts_last).referenceSurface();
185 const auto& smoothed = (ts_last).smoothed();
186 const auto& cov = (ts_last).smoothedCovariance();
187
188 // Get the BoundTrackStateParameters
189 // assume electron for now
190 auto part_hypo{Acts::ParticleHypothesis::electron()};
191
192 Acts::BoundTrackParameters state_parameters(surface.getSharedPtr(),
193 smoothed, cov, part_hypo);
194
195 // One can also use directly the extrapolate method
196 PropagatorOptions p_options(gctx_, mctx_);
197 auto result =
198 propagator_.propagate(state_parameters, *target_surface, p_options);
199
200 if (result.ok())
201 return *result->endParameters;
202 else
203 return std::nullopt;
204 }

◆ setDebug()

template<class propagator_t >
void tracking::reco::TrackExtrapolatorTool< propagator_t >::setDebug ( bool debug)
inline

Turn on/off internal debug flag.

Parameters
debug

Definition at line 42 of file TrackExtrapolatorTool.h.

42{ debug_ = debug; }

◆ setMaxStepSize()

template<class propagator_t >
void tracking::reco::TrackExtrapolatorTool< propagator_t >::setMaxStepSize ( double step)
inline

Definition at line 43 of file TrackExtrapolatorTool.h.

43{ max_step_size_ = step; }

◆ setPathLimit()

template<class propagator_t >
void tracking::reco::TrackExtrapolatorTool< propagator_t >::setPathLimit ( double limit)
inline

Definition at line 44 of file TrackExtrapolatorTool.h.

44{ path_limit_ = limit; }

◆ trackStateAtSurface()

template<class propagator_t >
template<class track_t >
bool tracking::reco::TrackExtrapolatorTool< propagator_t >::trackStateAtSurface ( track_t track,
const std::shared_ptr< Acts::Surface > & target_surface,
ldmx::Track::TrackState & ts,
ldmx::TrackStateType type )
inline

Create an ldmx::TrackState to the extrapolated position.

Parameters
trackActs::Track
target_surfaceextrapolation surface
tsldmx::Track::TrackState
typeTrackStateType
Returns
boolean to check if there was a problem in the extrapolation

Definition at line 217 of file TrackExtrapolatorTool.h.

220 {
221 if (debug_) {
222 std::cout << "[TrackExtrapolatorTool] trackStateAtSurface START\n";
223 std::cout << "[TrackExtrapolatorTool] target_surface = "
224 << target_surface.get() << std::endl;
225 std::cout << "[TrackExtrapolatorTool] track.nTrackStates() = "
226 << track.nTrackStates() << std::endl;
227 std::cout << "[TrackExtrapolatorTool] TrackStateType = "
228 << static_cast<int>(type) << std::endl;
229 std::cout << "[TrackExtrapolatorTool] About to call extrapolate...\n";
230 }
231
232 auto opt_pars = extrapolate(track, target_surface);
233
234 if (debug_) {
235 std::cout << "[TrackExtrapolatorTool] extrapolate returned, "
236 "opt_pars.has_value() = "
237 << opt_pars.has_value() << std::endl;
238 }
239
240 if (opt_pars) {
241 if (debug_) {
242 Acts::Vector3 surf_loc =
243 target_surface->localToGlobalTransform(gctx_).translation();
244 std::cout << "[TrackExtrapolatorTool] Surface location: ("
245 << surf_loc(0) << ", " << surf_loc(1) << ", " << surf_loc(2)
246 << ")\n";
247 }
248
249 ts = tracking::sim::utils::makeTrackState(gctx_, *opt_pars, type);
250 if (debug_)
251 std::cout << "[TrackExtrapolatorTool] trackStateAtSurface SUCCESS\n";
252 return true;
253 } else {
254 if (debug_)
255 std::cout << "[TrackExtrapolatorTool] trackStateAtSurface FAILED - "
256 "opt_pars is empty\n";
257 return false;
258 }
259 }

Member Data Documentation

◆ debug_

template<class propagator_t >
bool tracking::reco::TrackExtrapolatorTool< propagator_t >::debug_ {false}
private

Definition at line 265 of file TrackExtrapolatorTool.h.

265{false};

◆ gctx_

template<class propagator_t >
Acts::GeometryContext tracking::reco::TrackExtrapolatorTool< propagator_t >::gctx_
private

Definition at line 263 of file TrackExtrapolatorTool.h.

◆ max_step_size_

template<class propagator_t >
double tracking::reco::TrackExtrapolatorTool< propagator_t >::max_step_size_ {-1}
private

Definition at line 266 of file TrackExtrapolatorTool.h.

266{-1};

◆ mctx_

template<class propagator_t >
Acts::MagneticFieldContext tracking::reco::TrackExtrapolatorTool< propagator_t >::mctx_
private

Definition at line 264 of file TrackExtrapolatorTool.h.

◆ path_limit_

template<class propagator_t >
double tracking::reco::TrackExtrapolatorTool< propagator_t >::path_limit_ {-1}
private

Definition at line 267 of file TrackExtrapolatorTool.h.

267{-1};

◆ propagator_

template<class propagator_t >
propagator_t tracking::reco::TrackExtrapolatorTool< propagator_t >::propagator_
private

Definition at line 262 of file TrackExtrapolatorTool.h.


The documentation for this class was generated from the following file: