31#include <boost/container/flat_set.hpp>
32#include <boost/container/small_vector.hpp>
36constexpr bool useBoundaryMaterialUpdate(
true);
45 cache.m_mcsRecycleBin.emplace_back(std::move(input));
46 cache.m_stateAtBoundary = &(
cache.m_mcsRecycleBin.back());
55 cache.m_recallSurface = &recallSurface;
56 cache.m_recallLayer = &recallLayer;
57 cache.m_recallTrackingVolume = &recallTrackingVolume;
63 cache.m_recallSurface =
nullptr;
64 cache.m_recallLayer =
nullptr;
65 cache.m_recallTrackingVolume =
nullptr;
72 cache.m_stateAtBoundary =
nullptr;
73 cache.m_navigationParameters =
nullptr;
74 cache.m_trackingVolume =
nullptr;
75 cache.m_mcsRecycleBin.clear();
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())
95radialDirectionCheck(
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 =
118 prop.propagateParameters(ctx,
119 *(startParm.begin()->params),
125 const double distToInsideSurface =
127 ? (startPosition - (parsOnInsideSurface->position())).mag()
131 return distToLayer < distToInsideSurface;
142 const std::string& name,
143 const IInterface* parent)
146 declareInterface<IMultiStateExtrapolator>(
this);
162 return StatusCode::SUCCESS;
175 const EventContext& ctx,
182 if (multiComponentState.empty()) {
198 const EventContext& ctx,
204 if (multiComponentState.empty()) {
209 if (!currentVolume) {
211 "Current tracking volume could not be determined... returning {}");
233 const EventContext& ctx,
242 emptyRecycleBins(
cache);
246 std::unique_ptr<Trk::TrackParameters> referenceParameters =
248 associatedLayer, startVolume, destinationVolume,
261 multiComponentState.begin()->params.get();
272 ? referenceParameters->position() - combinedState->
position()
274 const double initialDistance = globalSeparation.mag();
276 combinedState =
nullptr;
285 bool foundFinalBoundary(
true);
286 int fallbackOscillationCounter(0);
290 while (currentVolume && currentVolume != destinationVolume) {
301 currentState =
cache.m_stateAtBoundary;
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 =
331 if (parametersAtDestination) {
332 newDestination = parametersAtDestination->position();
335 newDestination = surface.
center();
338 const double revisedDistance =
339 (
cache.m_navigationParameters->position() - newDestination).mag();
341 const double distanceChange = std::abs(revisedDistance - initialDistance);
343 if (revisedDistance > initialDistance && distanceChange > 0.01) {
344 foundFinalBoundary =
false;
349 previousVolume = currentVolume;
352 currentVolume = nextVolume;
355 associatedLayer =
nullptr;
359 if (!currentState || (currentVolume != destinationVolume)) {
360 currentState = &multiComponentState;
361 foundFinalBoundary =
false;
364 if (!foundFinalBoundary) {
374 emptyRecycleBins(
cache);
397 if (!destinationState.empty() &&
398 &((*(destinationState.begin())).params->associatedSurface()) != &surface) {
399 destinationState.clear();
402 if (destinationState.empty()) {
403 destinationState =
m_propagator->multiStatePropagate(ctx,
411 emptyRecycleBins(
cache);
412 return destinationState;
420 const EventContext& ctx,
440 const EventContext& ctx,
452 cache.m_stateAtBoundary = &multiComponentState;
455 cache.m_stateAtBoundary->begin()->params.get();
458 if (!associatedLayer) {
462 associatedLayer = associatedLayer
473 cache.m_materialEffectsCaches,
474 *(
cache.m_stateAtBoundary),
478 if (!updatedState.empty()) {
479 addMultiComponentToCache(
cache,std::move(updatedState));
486 if (associatedLayer) {
490 *(
cache.m_stateAtBoundary),
507 combinedState =
cache.m_stateAtBoundary->begin()->params.get();
511 cache.m_navigationParameters
512 ?
cache.m_navigationParameters.get()
515 nextNavigationCell =
m_navigator->nextTrackingVolume(
520 std::unique_ptr<Trk::TrackParameters> nextNavigationParameters =
525 resetRecallInformation(
cache);
528 if (useBoundaryMaterialUpdate) {
541 if (nextVolume && layerAtBoundary) {
544 cache.m_materialEffectsCaches,
545 *(
cache.m_stateAtBoundary),
553 if (!matUpdatedState.empty()) {
554 addMultiComponentToCache(
cache, std::move(matUpdatedState));
555 nextNavigationParameters =
556 cache.m_stateAtBoundary->begin()->params->uniqueClone();
560 cache.m_navigationParameters = std::move(nextNavigationParameters);
561 cache.m_trackingVolume = nextVolume;
569 const EventContext& ctx,
586 if (!destinationLayer) {
588 (&surface ==
cache.m_recallSurface)
589 ?
cache.m_recallLayer
596 currentState->begin()->params.get();
601 if (!associatedLayer) {
613 else if (associatedLayer != destinationLayer &&
622 if (!updatedState.empty()) {
624 currentState = &updatedState;
629 combinedState =
nullptr;
631 if (destinationLayer) {
634 if (associatedLayer && associatedLayer != destinationLayer) {
660 setRecallInformation(
cache, surface, *destinationLayer, trackingVolume);
677 resetRecallInformation(
cache);
687 const EventContext& ctx,
691 const Layer* startLayer,
692 const Layer* destinationLayer,
700 multiComponentState.begin()->params.get();
706 currentLayer->
nextLayer(currentPosition, currentDirection);
708 using LayerSet = boost::container::flat_set<
710 std::less<const Trk::Layer*>,
711 boost::container::small_vector<const Trk::Layer*, 8>>;
717 while (nextLayer && nextLayer != destinationLayer) {
725 !currentState.empty() ? currentState : multiComponentState,
731 if (!currentState.empty()) {
732 combinedState = currentState.begin()->params.get();
733 currentPosition = combinedState->
position();
738 currentLayer = nextLayer;
739 nextLayer = currentLayer->
nextLayer(currentPosition, currentDirection);
745 if (destinationLayer && nextLayer != destinationLayer &&
746 !currentState.empty()) {
747 currentState.clear();
758 const EventContext& ctx,
771 layer.surfaceRepresentation(),
777 if (destinationState.empty()) {
785 const int rDirection = radialDirection(multiComponentState,
direction);
786 const int newrDirection = radialDirection(destinationState,
direction);
787 if (newrDirection != rDirection) {
792 if (!radialDirectionCheck(ctx,
813 if (updatedState.empty()) {
814 return destinationState;
825 const EventContext& ctx,
851 if (destinationState.empty()) {
852 combinedState = initialState->begin()->params.get();
854 combinedState->
position(),
true, 0.5 * layer.thickness())) {
855 destinationState =
m_propagator->multiStatePropagate(ctx,
863 combinedState =
nullptr;
864 if (destinationState.empty()) {
874 if (startLayer != &layer) {
881 if (updatedState.empty()) {
882 return destinationState;
891std::unique_ptr<Trk::TrackParameters>
893 const EventContext& ctx,
909 currentLayer = associatedSurface ? associatedSurface->
associatedLayer() : currentLayer;
912 if (!currentVolume) {
914 if (associatedSurface ==
cache.m_recallSurface) {
915 currentVolume =
cache.m_recallTrackingVolume;
916 currentLayer =
cache.m_recallLayer;
921 resetRecallInformation(
cache);
923 currentLayer = currentVolume
931 std::unique_ptr<Trk::TrackParameters> referenceParameters =
933 ctx, *combinedState, surface,
direction,
false,
938 const Amg::Vector3D surfaceDirection(referenceParameters->position() -
952 if (!destinationVolume) {
954 if (&surface ==
cache.m_recallSurface) {
955 destinationVolume =
cache.m_recallTrackingVolume;
959 ctx, referenceParameters ? referenceParameters->position()
963 return referenceParameters;
Scalar mag() const
mag method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Abstract base class for convolution of material effects.
static JobState::Enum nextState(JobState::Enum state, Status::Enum status)
The BoundaryCheck class allows to steer the way surface boundaries are used for inside/outside checks...
Interface class IPropagators It inherits from IAlgTool.
Base Class for a Detector Layer in the Tracking realm.
const Layer * nextLayer(const Amg::Vector3D &gp, const Amg::Vector3D &udir) const
getting the next/previous Layer if registered - unit for direction vector required
const LayerMaterialProperties * layerMaterialProperties() const
getting the LayerMaterialProperties including full/pre/post update
const TrackingVolume * enclosingTrackingVolume() const
get the confining TrackingVolume
magnetic field properties to steer the behavior of the extrapolation
A material layer is a simple helper class to attach material information to a boundary surface.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
Abstract Base Class for tracking surfaces.
virtual bool isOnSurface(const Amg::Vector3D &glopo, const BoundaryCheck &bchk=true, double tol1=0., double tol2=0.) const
This method returns true if the GlobalPosition is on the Surface for both, within or without check of...
virtual const Amg::Vector3D & globalReferencePoint() const
Returns a global reference point on the surface, for PlaneSurface, StraightLineSurface,...
const Trk::Layer * associatedLayer() const
return the associated Layer
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
const LayerArray * confinedLayers() const
Return the subLayer array.
const Layer * associatedLayer(const Amg::Vector3D &gp) const
Return the associated Layer.
std::vector< std::shared_ptr< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
const Layer * nextLayer(const Amg::Vector3D &gp, const Amg::Vector3D &mom, bool asres=true, bool skipNavLayer=false) const
Return the next Layer if existing, NULL if no next layer corresponds.
Eigen::Matrix< double, 3, 1 > Vector3D
PropDirection
PropDirection, enum for direction of the propagation.
std::vector< ComponentParameters > MultiComponentState
const Amg::Vector3D & direction() const
Method to retrieve the direction at the Intersection.
@ FastField
call the fast field access method of the FieldSvc
@ FullField
Field is set to be realistic, but within a given Volume.
ParametersBase< TrackParametersDim, Charged > TrackParameters
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.
prop(alg, name, default=_UNSET)
useful struct for a single navigation cell
const TrackingVolume * nextVolume
std::unique_ptr< TrackParameters > parametersOnBoundary