252 {
253
254 const auto& sp_collection =
seed.sp();
255 const std::size_t nSp = sp_collection.size();
256 if (nSp < 3) return {std::nullopt, kNoSeedRefit};
257
258
259 const auto sp_collection_extract = std::views::transform([&sp_collection](std::size_t i) {
260 return sp_collection.at(i);
261 });
262
263
264 Acts::FreeVector freeParams;
266 const Acts::Result<Acts::FreeVector> freeParamsResult = estimateTrackParamsFromAllSpacePoints(
269 if (!freeParamsResult.ok()) {
270 ATH_MSG_DEBUG(
"Fit of " << nSp <<
"-SP seed failed - " << freeParamsResult.error().message());
271 return {std::nullopt, kNoSeedRefit};
272 }
273 freeParams = *freeParamsResult;
274
275
276 if (freeParams[Acts::eFreeQOverP] == 0) {
277 ATH_MSG_DEBUG(
"Fit of " << nSp <<
"-SP seed did not resolve the curvature - skip seed");
278 return {std::nullopt, kNoSeedRefit};
279 }
280 } else {
282 }
283
285 const auto spacePointIndicesFun2 = [](std::size_t nSp) -> std::array<std::size_t, 3> {
286 return {0, nSp / 2ul, nSp - 1};
287 };
288 const Acts::FreeVector freeParams2 = estimateTrackParamsFromSeed(spacePointIndicesFun2(nSp) | sp_collection_extract, bField,
m_stripCalibrationIterations);
289 ATH_MSG_DEBUG(
"update seed p = " << 1.0 / freeParams[Acts::eFreeQOverP] <<
" to " << 1.0 / freeParams2[Acts::eFreeQOverP]);
290 freeParams[Acts::eFreeQOverP] = freeParams2[Acts::eFreeQOverP];
291 }
292
293
294 Acts::BoundTrackParameters curvilinearParams = Acts::BoundTrackParameters::createCurvilinear(
295 freeParams.segment<4>(Acts::eFreePos0),
296 freeParams.segment<3>(Acts::eFreeDir0),
297 freeParams[Acts::eFreeQOverP],
298 std::nullopt,
299 Acts::ParticleHypothesis::pion());
300
301
302 Acts::PropagatorPlainOptions propOptions(geoContext, magFieldContext);
303 propOptions.direction = Acts::Direction::fromScalarZeroAsPositive(
304 surface.intersect(
305 geoContext,
306 freeParams.segment<3>(Acts::eFreePos0),
307 freeParams.segment<3>(Acts::eFreeDir0)
308 ).closest().pathLength());
309
310 std::optional<Acts::BoundTrackParameters> boundParams;
311 auto boundParamsResult =
312 m_extrapolator->propagateToSurface(curvilinearParams, surface, propOptions);
313
314 if (!boundParamsResult.ok()) {
318
319 boundParams = curvilinearParams;
320 } else {
321 return {std::nullopt, kNoSeedRefit};
322 }
323 } else {
324 boundParams = *boundParamsResult;
325 }
326
327
328 Acts::EstimateTrackParamCovarianceConfig covarianceEstimationConfig = {
332 .noTimeVarInflation = 1.0,
333 };
334 boundParams->covariance() = Acts::estimateTrackParamCovariance(
335 covarianceEstimationConfig,
336 boundParams->parameters(),
337 false);
338
340 ATH_MSG_DEBUG(
"estimateTrackParams from " <<
seed.sp().size() <<
"-SP seed succeeded");
341 return {boundParams, kNoSeedRefit};
342 }
343
344 auto refitResult =
doRefit(seed, *boundParams, geoContext, magFieldContext, calContext);
345 ATH_MSG_DEBUG(
"Refit " <<
seed.sp().size() <<
"-SP seed " << (refitResult ?
"succeeded" :
"failed"));
346 if (refitResult) {
347
348
349 refitResult->covariance() = Acts::estimateTrackParamCovariance(
350 covarianceEstimationConfig,
351 refitResult->parameters(),
352 false);
353 return {refitResult, kSeedRefitSuccess};
354 } else {
355 return {boundParams, kSeedRefitFailed};
356 }
357
358 }
#define ATH_MSG_DEBUG(x,...)