31#include <boost/container/flat_set.hpp>
32#include <boost/container/small_vector.hpp>
36constexpr 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())
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 =
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) {
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 =
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) {
375 emptyRecycleBins(cache);
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,
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) {
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) {
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) {
661 setRecallInformation(cache, surface, *destinationLayer, trackingVolume);
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);
709 using LayerSet = boost::container::flat_set<
711 std::less<const Trk::Layer*>,
712 boost::container::small_vector<const Trk::Layer*, 8>>;
718 while (nextLayer && nextLayer != destinationLayer) {
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);
746 if (destinationLayer && nextLayer != destinationLayer &&
747 !currentState.empty()) {
748 currentState.clear();
759 const EventContext& 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,
852 if (destinationState.empty()) {
853 combinedState = initialState->begin()->params.get();
855 combinedState->
position(),
true, 0.5 * layer.thickness())) {
856 destinationState =
m_propagator->multiStatePropagate(ctx,
864 combinedState =
nullptr;
865 if (destinationState.empty()) {
875 if (startLayer != &layer) {
882 if (updatedState.empty()) {
883 return destinationState;
892std::unique_ptr<Trk::TrackParameters>
894 const EventContext& ctx,
910 currentLayer = associatedSurface ? associatedSurface->
associatedLayer() : currentLayer;
913 if (!currentVolume) {
922 resetRecallInformation(cache);
924 currentLayer = currentVolume
932 std::unique_ptr<Trk::TrackParameters> referenceParameters =
934 ctx, *combinedState, surface, direction,
false,
939 const Amg::Vector3D surfaceDirection(referenceParameters->position() -
941 direction = (surfaceDirection.dot(combinedState->
momentum()) > 0.)
953 if (!destinationVolume) {
960 ctx, referenceParameters ? referenceParameters->position()
964 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.
virtual std::unique_ptr< TrackParameters > propagateParameters(const EventContext &ctx, const TrackParameters &parm, const Surface &sf, PropDirection dir, const BoundaryCheck &bcheck, const MagneticFieldProperties &mprop, ParticleHypothesis particle=pion, bool returnCurv=false, const TrackingVolume *tVol=nullptr) const =0
Main propagation method for parameters only.
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 const Amg::Vector3D & globalReferencePoint() const
Returns a global reference point on the surface, for PlaneSurface, StraightLineSurface,...
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...
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
@ 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
useful struct for a single navigation cell
const TrackingVolume * nextVolume
std::unique_ptr< TrackParameters > parametersOnBoundary