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 25 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 50 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 28 of file TrackExtrapolatorTool.h.

31 : 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 52 of file TrackExtrapolatorTool.h.

54 {
55 auto intersection = target_surface->intersect(gctx_, pars.position(gctx_),
56 pars.direction());
57
58 PropagatorOptions p_options(gctx_, mctx_);
59 if (max_step_size_ > 0) p_options.stepping.maxStepSize = max_step_size_;
60 if (path_limit_ > 0) p_options.pathLimit = path_limit_;
61
62 p_options.direction = intersection[0].pathLength() >= 0
63 ? Acts::Direction::Forward()
64 : Acts::Direction::Backward();
65
66 auto result = propagator_.propagate(pars, *target_surface, p_options);
67
68 // CHECK THE EXTRAPOLATION COVARIANCE MATRIX
69
70 if (debug_) {
71 if (result.ok()) {
72 std::cout << "INITIAL COV MATRIX\n";
73 std::cout << (*(pars.covariance())) << std::endl;
74
75 std::cout << "FINAL COV MATRIX\n";
76 auto opt_pars = *result->endParameters;
77 std::cout << *(opt_pars.covariance()) << std::endl;
78 }
79 }
80
81 if (result.ok())
82 return *result->endParameters;
83 else
84 return std::nullopt;
85 } // 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 98 of file TrackExtrapolatorTool.h.

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

◆ 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 171 of file TrackExtrapolatorTool.h.

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

◆ 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 38 of file TrackExtrapolatorTool.h.

38{ debug_ = debug; }

◆ setMaxStepSize()

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

Definition at line 39 of file TrackExtrapolatorTool.h.

39{ max_step_size_ = step; }

◆ setPathLimit()

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

Definition at line 40 of file TrackExtrapolatorTool.h.

40{ 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 213 of file TrackExtrapolatorTool.h.

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

Member Data Documentation

◆ debug_

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

Definition at line 261 of file TrackExtrapolatorTool.h.

261{false};

◆ gctx_

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

Definition at line 259 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 262 of file TrackExtrapolatorTool.h.

262{-1};

◆ mctx_

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

Definition at line 260 of file TrackExtrapolatorTool.h.

◆ path_limit_

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

Definition at line 263 of file TrackExtrapolatorTool.h.

263{-1};

◆ propagator_

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

Definition at line 258 of file TrackExtrapolatorTool.h.


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