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.
102 {
103 if (debug_) {
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;
109 }
110
111
112 if (debug_)
113 std::cout
114 << "[TrackExtrapolatorTool] Getting outermost track state...\n";
115 auto outermost = *(track.trackStatesReversed().begin());
116 if (debug_)
117 std::cout
118 << "[TrackExtrapolatorTool] Getting innermost track state...\n";
119 auto begin = track.trackStatesReversed().begin();
120 std::advance(begin, track.nTrackStates() - 1);
121 auto innermost = *begin;
122 if (debug_)
123 std::cout << "[TrackExtrapolatorTool] Got innermost and outermost "
124 "track states\n";
125
126
127
128
129 if (debug_)
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));
134
135 double last_dis = std::abs(
136 outermost.referenceSurface().transform(gctx_).translation()(0) -
137 target_surface->transform(gctx_).translation()(0));
138 if (debug_)
139 std::cout << "[TrackExtrapolatorTool] first_dis = " << first_dis
140 << ", last_dis = " << last_dis << std::endl;
141
142
143
144 const auto& ts = first_dis < last_dis ? innermost : outermost;
145 if (debug_) std::cout << "[TrackExtrapolatorTool] Selected track state\n";
146
147
148
149 if (debug_)
150 std::cout << "[TrackExtrapolatorTool] Getting reference surface...\n";
151 const auto& surface = ts.referenceSurface();
152 if (debug_)
153 std::cout << "[TrackExtrapolatorTool] Checking hasSmoothed...\n";
154 bool has_smoothed = ts.hasSmoothed();
155 if (debug_)
156 std::cout << "[TrackExtrapolatorTool] has_smoothed = " << has_smoothed
157 << std::endl;
158
159
160 Acts::BoundVector params;
161 Acts::BoundMatrix cov;
162
163 if (has_smoothed) {
164 if (debug_)
165 std::cout << "[TrackExtrapolatorTool] Using smoothed parameters...\n";
166 params = ts.smoothed();
167 cov = ts.smoothedCovariance();
168 } else {
169 if (debug_)
170 std::cout << "[TrackExtrapolatorTool] Using filtered parameters...\n";
171 params = ts.filtered();
172 cov = ts.filteredCovariance();
173 }
174 if (debug_)
175 std::cout << "[TrackExtrapolatorTool] Got all track state components\n";
176
177 if (debug_) {
178 std::cout << "Surface::" << surface.transform(gctx_).translation()
179 << std::endl;
180 std::cout << "HasSmoothed::" << has_smoothed << std::endl;
181 std::cout << "Parameters::" << params.transpose() << std::endl;
182 }
183
184 if (debug_)
185 std::cout
186 << "[TrackExtrapolatorTool] Creating BoundTrackParameters...\n";
187 auto part_hypo{Acts::SinglyChargedParticleHypothesis::electron()};
188 Acts::BoundTrackParameters sp(surface.getSharedPtr(), params, cov,
189 part_hypo);
190 if (debug_)
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";
195 return result;
196 }