31 #include <boost/container/flat_set.hpp>
32 #include <boost/container/small_vector.hpp>
36 constexpr
bool useBoundaryMaterialUpdate(
true);
82 const double prePositionR =
pars.begin()->params->position().perp();
83 return (prePositionR > (
pars.begin()->params->position() +
84 static_cast<int>(
dir) * 0.5 * prePositionR *
85 pars.begin()->params->momentum().unit())
95 radialDirectionCheck(
const EventContext& ctx,
103 const Amg::Vector3D& startPosition = startParm.begin()->params->position();
104 const Amg::Vector3D& onLayerPosition = parsOnLayer.begin()->params->position();
107 const double distToLayer = (startPosition - onLayerPosition).
mag();
111 if (boundarySurfaces.size() == 4) {
117 auto parsOnInsideSurface =
119 *(startParm.begin()->params),
125 const double distToInsideSurface =
127 ? (startPosition - (parsOnInsideSurface->position())).mag()
131 return distToLayer < distToInsideSurface;
142 const std::string&
name,
146 declareInterface<IMultiStateExtrapolator>(
this);
158 m_fieldProperties = m_fastField
162 return StatusCode::SUCCESS;
175 const EventContext& ctx,
182 if (multiComponentState.empty()) {
185 return extrapolateImpl(ctx,
198 const EventContext& ctx,
204 if (multiComponentState.empty()) {
209 if (!currentVolume) {
211 "Current tracking volume could not be determined... returning {}");
214 return extrapolateDirectlyImpl(ctx,
233 const EventContext& ctx,
242 emptyRecycleBins(cache);
246 std::unique_ptr<Trk::TrackParameters> referenceParameters =
247 initialiseNavigation(ctx, cache, multiComponentState, surface,
248 associatedLayer, startVolume, destinationVolume,
253 return extrapolateDirectlyImpl(ctx,
261 multiComponentState.begin()->params.get();
274 const double initialDistance = globalSeparation.mag();
276 combinedState =
nullptr;
285 bool foundFinalBoundary(
true);
286 int fallbackOscillationCounter(0);
290 while (currentVolume && currentVolume != destinationVolume) {
292 extrapolateToVolumeBoundary(ctx,
306 if (!nextVolume || nextVolume == currentVolume) {
307 foundFinalBoundary =
false;
311 if (previousVolume == nextVolume) {
312 ++fallbackOscillationCounter;
314 if (fallbackOscillationCounter > 10) {
315 foundFinalBoundary =
false;
320 combinedState = currentState->begin()->params.get();
322 auto parametersAtDestination =
323 m_propagator->propagateParameters(ctx,
331 if (parametersAtDestination) {
332 newDestination = parametersAtDestination->
position();
335 newDestination = surface.
center();
338 const double revisedDistance =
341 const double distanceChange = std::abs(revisedDistance - initialDistance);
343 if (revisedDistance > initialDistance && distanceChange > 0.01) {
344 foundFinalBoundary =
false;
348 combinedState =
nullptr;
350 previousVolume = currentVolume;
353 currentVolume = nextVolume;
356 associatedLayer =
nullptr;
360 if (!currentState || (currentVolume != destinationVolume)) {
361 currentState = &multiComponentState;
362 foundFinalBoundary =
false;
365 if (!foundFinalBoundary) {
367 m_propagator->multiStatePropagate(ctx,
375 emptyRecycleBins(cache);
385 extrapolateInsideVolume(ctx,
398 if (!destinationState.empty() &&
399 &((*(destinationState.begin())).params->associatedSurface()) != &surface) {
400 destinationState.clear();
403 if (destinationState.empty()) {
404 destinationState = m_propagator->multiStatePropagate(ctx,
412 emptyRecycleBins(cache);
413 return destinationState;
421 const EventContext& ctx,
427 return m_propagator->multiStatePropagate(ctx,
441 const EventContext& ctx,
459 if (!associatedLayer) {
463 associatedLayer = associatedLayer
467 direction * combinedState->
momentum().unit(),
479 if (!updatedState.empty()) {
480 addMultiComponentToCache(cache,std::move(updatedState));
487 if (associatedLayer) {
497 if (!nextState.empty()) {
498 addMultiComponentToCache(cache,std::move(nextState));
516 nextNavigationCell = m_navigator->nextTrackingVolume(
517 ctx, *m_propagator, *navigationParameters, direction, trackingVolume);
521 std::unique_ptr<Trk::TrackParameters> nextNavigationParameters =
526 resetRecallInformation(cache);
529 if (useBoundaryMaterialUpdate) {
542 if (nextVolume && layerAtBoundary) {
544 matUpdatedState = m_materialUpdator->postUpdate(
554 if (!matUpdatedState.empty()) {
555 addMultiComponentToCache(cache, std::move(matUpdatedState));
556 nextNavigationParameters =
570 const EventContext& ctx,
587 if (!destinationLayer) {
597 currentState->begin()->params.get();
602 if (!associatedLayer) {
610 direction * combinedState->
momentum().unit(),
614 else if (associatedLayer != destinationLayer &&
623 if (!updatedState.empty()) {
625 currentState = &updatedState;
630 combinedState =
nullptr;
632 if (destinationLayer) {
635 if (associatedLayer && associatedLayer != destinationLayer) {
636 nextState = extrapolateFromLayerToLayer(ctx,
645 if (!nextState.empty()) {
647 currentState = &nextState;
652 extrapolateToDestinationLayer(ctx,
661 setRecallInformation(cache, surface, *destinationLayer, trackingVolume);
668 m_propagator->multiStatePropagate(ctx,
678 resetRecallInformation(cache);
688 const EventContext& ctx,
692 const Layer* startLayer,
693 const Layer* destinationLayer,
701 multiComponentState.begin()->params.get();
707 currentLayer->
nextLayer(currentPosition, currentDirection);
711 std::less<const Trk::Layer*>,
712 boost::container::small_vector<const Trk::Layer*, 8>>;
715 layersHit.insert(currentLayer);
718 while (nextLayer && nextLayer != destinationLayer) {
719 layersHit.insert(nextLayer);
723 currentState = extrapolateToIntermediateLayer(
726 !currentState.empty() ? currentState : multiComponentState,
732 if (!currentState.empty()) {
733 combinedState = currentState.begin()->params.get();
734 currentPosition = combinedState->
position();
735 currentDirection = direction * combinedState->
momentum().unit();
739 currentLayer = nextLayer;
740 nextLayer = currentLayer->
nextLayer(currentPosition, currentDirection);
741 if (layersHit.find(nextLayer) != layersHit.end()) {
746 if (destinationLayer && nextLayer != destinationLayer &&
747 !currentState.empty()) {
748 currentState.clear();
759 const EventContext& ctx,
770 m_propagator->multiStatePropagate(ctx,
772 layer.surfaceRepresentation(),
778 if (destinationState.empty()) {
786 const int rDirection = radialDirection(multiComponentState, direction);
787 const int newrDirection = radialDirection(destinationState, direction);
788 if (newrDirection != rDirection) {
793 if (!radialDirectionCheck(ctx,
814 if (updatedState.empty()) {
815 return destinationState;
826 const EventContext& ctx,
841 m_propagator->multiStatePropagate(ctx,
852 if (destinationState.empty()) {
853 combinedState = initialState->begin()->params.get();
856 destinationState = m_propagator->multiStatePropagate(ctx,
864 combinedState =
nullptr;
865 if (destinationState.empty()) {
875 if (startLayer != &
layer) {
882 if (updatedState.empty()) {
883 return destinationState;
892 std::unique_ptr<Trk::TrackParameters>
894 const EventContext& ctx,
910 currentLayer = associatedSurface ? associatedSurface->
associatedLayer() : currentLayer;
913 if (!currentVolume) {
922 resetRecallInformation(cache);
923 currentVolume = m_navigator->volume(ctx, combinedState->
position());
924 currentLayer = currentVolume
932 std::unique_ptr<Trk::TrackParameters> referenceParameters =
933 currentVolume ? m_propagator->propagateParameters(
934 ctx, *combinedState, surface, direction,
false,
941 direction = (surfaceDirection.dot(combinedState->
momentum()) > 0.)
953 if (!destinationVolume) {
959 destinationVolume = m_navigator->volume(
960 ctx, referenceParameters ? referenceParameters->
position()
964 return referenceParameters;