50 template <
typename propagator_t,
typename bethe_heitler_approx_t,
54 std::unique_ptr<const Logger> _logger =
80 template <
typename source_link_it_t,
typename start_parameters_t,
81 typename track_container_t,
template <
typename>
class holder_t>
83 const start_parameters_t& sParameters,
85 const std::vector<const Surface*>& sSequence,
90 std::is_same_v<DirectNavigator, typename propagator_t::Navigator>);
93 auto fwdPropInitializer = [&sSequence,
this](
const auto&
opts) {
94 using Actors = ActionList<GsfActor, DirectNavigator::Initializer>;
95 using Aborters = AbortList<>;
98 opts.magFieldContext);
102 propOptions.
actionList.template get<DirectNavigator::Initializer>()
103 .navSurfaces = sSequence;
104 propOptions.
actionList.template get<GsfActor>()
111 auto bwdPropInitializer = [&sSequence,
this](
const auto&
opts) {
112 using Actors = ActionList<GsfActor, DirectNavigator::Initializer>;
113 using Aborters = AbortList<>;
115 std::vector<const Surface*> backwardSequence(
116 std::next(sSequence.rbegin()), sSequence.rend());
117 backwardSequence.push_back(
opts.referenceSurface);
120 opts.magFieldContext);
124 propOptions.
actionList.template get<DirectNavigator::Initializer>()
125 .navSurfaces =
std::move(backwardSequence);
126 propOptions.
actionList.template get<GsfActor>()
132 return fit_impl(begin, end, sParameters, options, fwdPropInitializer,
133 bwdPropInitializer, trackContainer);
137 template <
typename source_link_it_t,
typename start_parameters_t,
138 typename track_container_t,
template <
typename>
class holder_t>
140 const start_parameters_t& sParameters,
145 static_assert(std::is_same_v<Navigator, typename propagator_t::Navigator>);
148 auto fwdPropInitializer = [
this](
const auto&
opts) {
149 using Actors = ActionList<GsfActor>;
150 using Aborters = AbortList<EndOfWorldReached>;
153 opts.magFieldContext);
155 propOptions.
actionList.template get<GsfActor>()
162 auto bwdPropInitializer = [
this](
const auto&
opts) {
163 using Actors = ActionList<GsfActor>;
164 using Aborters = AbortList<EndOfWorldReached>;
167 opts.magFieldContext);
171 propOptions.
actionList.template get<GsfActor>()
177 return fit_impl(begin, end, sParameters, options, fwdPropInitializer,
178 bwdPropInitializer, trackContainer);
184 template <
typename source_link_it_t,
typename start_parameters_t,
185 typename fwd_prop_initializer_t,
typename bwd_prop_initializer_t,
186 typename track_container_t,
template <
typename>
class holder_t>
190 const start_parameters_t& sParameters,
192 const fwd_prop_initializer_t& fwdPropInitializer,
193 const bwd_prop_initializer_t& bwdPropInitializer,
197 auto return_error_or_abort = [&](
auto error) {
207 const auto gsfBackward = gsfForward.invert();
210 auto intersectionStatusStartSurface =
211 sParameters.referenceSurface()
214 sParameters.direction(),
true)
218 if (intersectionStatusStartSurface != Intersection3D::Status::onSurface) {
220 "Surface intersection of start parameters with bound-check failed");
221 return GsfError::StartParametersNotOnStartSurface;
227 <<
" input measurements");
228 std::map<GeometryIdentifier, SourceLink> inputMeasurements;
231 inputMeasurements.emplace(
236 "Gsf: Final measurement map size: " << inputMeasurements.size());
238 if (sParameters.covariance() == std::nullopt) {
239 return GsfError::StartParametersHaveNoCovariance;
249 auto fwdResult = [&]() {
250 auto fwdPropOptions = fwdPropInitializer(options);
253 auto& actor = fwdPropOptions.actionList.template get<GsfActor>();
254 actor.setOptions(options);
255 actor.m_cfg.inputMeasurements = &inputMeasurements;
256 actor.m_cfg.numberMeasurements = inputMeasurements.size();
257 actor.m_cfg.inReversePass =
false;
260 fwdPropOptions.direction = gsfForward;
263 using IsMultiParameters =
266 typename propagator_t::template action_list_t_result_t<
268 decltype(fwdPropOptions.actionList)>
271 auto&
r = inputResult.template get<typename GsfActor::result_type>();
273 r.fittedStates = &trackContainer.trackStateContainer();
279 sParameters.referenceSurface().getSharedPtr(),
280 sParameters.parameters(), *sParameters.covariance(),
281 sParameters.particleHypothesis());
283 return m_propagator.propagate(params, fwdPropOptions,
false,
286 return m_propagator.propagate(sParameters, fwdPropOptions,
false,
291 if (!fwdResult.ok()) {
292 return return_error_or_abort(fwdResult.error());
296 fwdResult->template get<typename GsfActor::result_type>();
298 if (!fwdGsfResult.result.ok()) {
299 return return_error_or_abort(fwdGsfResult.result.error());
302 if (fwdGsfResult.measurementStates == 0) {
303 return return_error_or_abort(GsfError::NoMeasurementStatesCreatedForward);
307 ACTS_VERBOSE(
"- visited surfaces: " << fwdGsfResult.visitedSurfaces.size());
308 ACTS_VERBOSE(
"- processed states: " << fwdGsfResult.processedStates);
309 ACTS_VERBOSE(
"- measurement states: " << fwdGsfResult.measurementStates);
311 std::size_t nInvalidBetheHeitler = fwdGsfResult.nInvalidBetheHeitler;
320 auto bwdResult = [&]() {
321 auto bwdPropOptions = bwdPropInitializer(options);
323 auto& actor = bwdPropOptions.actionList.template get<GsfActor>();
324 actor.setOptions(options);
325 actor.m_cfg.inputMeasurements = &inputMeasurements;
326 actor.m_cfg.inReversePass =
true;
328 actor.setOptions(options);
330 bwdPropOptions.direction = gsfBackward;
334 : sParameters.referenceSurface();
338 typename propagator_t::template action_list_t_result_t<
340 decltype(bwdPropOptions.actionList)>
347 MultiComponentBoundTrackParameters, decltype(bwdPropOptions),
349 std::declval<MultiComponentBoundTrackParameters>(),
350 std::declval<Acts::Surface&>(),
351 std::declval<decltype(bwdPropOptions)>(),
352 std::declval<decltype(inputResult)>()));
354 auto&
r = inputResult.template get<typename GsfActor::result_type>();
356 r.fittedStates = &trackContainer.trackStateContainer();
363 r.fittedStates->getTrackState(fwdGsfResult.lastMeasurementTip);
364 proxy.shareFrom(TrackStatePropMask::Filtered,
365 TrackStatePropMask::Smoothed);
367 r.currentTip = fwdGsfResult.lastMeasurementTip;
368 r.visitedSurfaces.push_back(&proxy.referenceSurface());
369 r.surfacesVisitedBwdAgain.push_back(&proxy.referenceSurface());
370 r.measurementStates++;
373 const auto& params = *fwdGsfResult.lastMeasurementState;
375 return m_propagator.template propagate<std::decay_t<decltype(params)>,
376 decltype(bwdPropOptions),
381 if (!bwdResult.ok()) {
382 return return_error_or_abort(bwdResult.error());
386 bwdResult->template get<typename GsfActor::result_type>();
388 if (!bwdGsfResult.result.ok()) {
389 return return_error_or_abort(bwdGsfResult.result.error());
392 if (bwdGsfResult.measurementStates == 0) {
393 return return_error_or_abort(
394 GsfError::NoMeasurementStatesCreatedBackward);
397 nInvalidBetheHeitler += bwdGsfResult.nInvalidBetheHeitler;
399 if (nInvalidBetheHeitler > 0) {
401 << nInvalidBetheHeitler
402 <<
" cases where the material thickness exceeds the range "
403 "of the Bethe-Heitler-Approximation. Enable DEBUG output "
404 "for more information.");
411 ACTS_VERBOSE(
"- Fwd measurement states: " << fwdGsfResult.measurementStates
413 << fwdGsfResult.measurementHoles);
414 ACTS_VERBOSE(
"- Bwd measurement states: " << bwdGsfResult.measurementStates
416 << bwdGsfResult.measurementHoles);
419 if (bwdGsfResult.measurementStates != fwdGsfResult.measurementStates) {
420 ACTS_DEBUG(
"Fwd and bwd measurement states do not match");
425 const auto& foundBwd = bwdGsfResult.surfacesVisitedBwdAgain;
426 std::size_t measurementStatesFinal = 0;
428 for (
auto state : fwdGsfResult.fittedStates->reverseTrackStateRange(
429 fwdGsfResult.currentTip)) {
430 const bool found = std::find(foundBwd.begin(), foundBwd.end(),
431 &
state.referenceSurface()) != foundBwd.end();
435 state.unset(TrackStatePropMask::Smoothed);
438 measurementStatesFinal +=
442 if (measurementStatesFinal == 0) {
443 return return_error_or_abort(GsfError::NoMeasurementStatesCreatedFinal);
446 auto track = trackContainer.getTrack(trackContainer.addTrack());
447 track.tipIndex() = fwdGsfResult.lastMeasurementTip;
450 const auto& params = *bwdResult->endParameters;
453 params.components(), params.referenceSurface(),
455 return std::tie(std::get<0>(
t), std::get<1>(
t), *std::get<2>(
t));
458 track.parameters() = finalPars;
459 track.covariance() = finalCov;
461 track.setReferenceSurface(params.referenceSurface().getSharedPtr());
463 if (trackContainer.hasColumn(
465 ACTS_DEBUG(
"Add final multi-component state to track")
466 track.template component<GsfConstants::FinalMultiComponentState>(
473 track.nMeasurements() = measurementStatesFinal;
474 track.nHoles() = fwdGsfResult.measurementHoles;