9#include "GaudiKernel/SystemOfUnits.h"
32 trackTrackSurfaceIntersection.position().
perp(),
33 trackTrackSurfaceIntersection.position().
z(),
39 const std::string& name,
40 const IInterface* parent)
41 : base_class(
type, name, parent) {}
48 return StatusCode::SUCCESS;
57 return StatusCode::SUCCESS;
62std::optional<Trk::TrackSurfaceIntersection>
68 const auto surfaceType = surface.
type();
71 trackIntersection,
qOverP);
85 trackIntersection,
qOverP);
98std::optional<Trk::TrackSurfaceIntersection>
101 const double qOverP)
const
105std::optional<Trk::TrackSurfaceIntersection>
108 const double qOverP)
const
112std::optional<Trk::TrackSurfaceIntersection>
115 const double qOverP)
const
121 if (!solenoidParametrization || endRadius > solenoidParametrization->
maximumR())
126 trackIntersection, *solenoidParametrization,
qOverP, com);
129 double radius2 = isect->position().perp2();
131 && !
extrapolateToR(*isect, radius2, *com, endRadius))
return std::nullopt;
137std::optional<Trk::TrackSurfaceIntersection>
140 const double qOverP)
const
145 double endZ = surface.
center().z();
146 if (!solenoidParametrization || std::abs(endZ) > solenoidParametrization->
maximumZ())
150 std::optional<TrackSurfaceIntersection> isect =
152 *solenoidParametrization,
168std::optional<Trk::TrackSurfaceIntersection>
171 const double qOverP)
const
176 if (!solenoidParametrization ||
177 std::abs(surface.
center().z()) > solenoidParametrization->
maximumZ()
182 std::optional<TrackSurfaceIntersection> isect =
184 *solenoidParametrization,
190 double radius2 = pos.perp2();
200 double offset = surface.
normal().dot(surface.
center() - pos);
204 if (std::abs(
dot) < 0.0001)
206 double distance = offset /
dot;
212 radius2 = pos.perp2();
215 (pos + distance * dir).
perp()))
224 (++numberSteps > 5 ||
225 std::abs(offset) > 0.5 * std::abs(distance *
dot))) {
228 << numberSteps <<
" steps at offset " << offset
229 <<
" dot " << surface.
normal().dot(dir));
232 surface, trackIntersection,
qOverP);
248 return solenoidParametrization &&
250 std::abs(endPosition.z()) < solenoidParametrization->
maximumZ()
252 && endPosition.perp() < solenoidParametrization->
maximumR()
264 const double endR)
const
269 double fieldComponent =
271 double curvature = fieldComponent * com.
m_qOverPt;
274 double radiusOfCurvature = 1. / curvature;
286 pos.x() = xCentre + radiusOfCurvature * sinPhi;
287 pos.y() = yCentre - radiusOfCurvature * cosPhi;
289 radius2 = endR * endR;
304 double sinDPhi = 0.5 * arcLength * curvature;
306 1. - 0.5 * sinDPhi * sinDPhi * (1.0 + 0.25 * sinDPhi * sinDPhi);
307 double temp = cosPhi;
308 cosPhi =
temp * cosDPhi - sinPhi * sinDPhi;
309 sinPhi =
temp * sinDPhi + sinPhi * cosDPhi;
310 dir.x() = (cosPhi * cosDPhi - sinPhi * sinDPhi) * com.
m_sinTheta;
311 dir.y() = (sinPhi * cosDPhi + cosPhi * sinDPhi) * com.
m_sinTheta;
314 pos.x() += arcLength * cosPhi;
315 pos.y() += arcLength * sinPhi;
317 radius2 = endR * endR;
321 radius2 = pos.perp2();
325 radius2 = pos.perp2();
340 double firstIntegral = 0.;
341 double secondIntegral = 0.;
351 if (std::abs(deltaPhi2) < DFiMax) {
352 double deltaPhi2Squared = deltaPhi2 * deltaPhi2;
353 sinBeta = 1. - 0.166667 * deltaPhi2Squared;
354 cosBeta = -0.5 * deltaPhi2 * (1. - 0.083333 * deltaPhi2Squared);
355 }
else if (2. * std::abs(deltaPhi2) <
M_PI) {
356 sinBeta = std::sin(deltaPhi2) / deltaPhi2;
357 cosBeta = (std::cos(deltaPhi2) - 1.) / deltaPhi2;
362 double radialDistance = (endZ - pos.z()) / com.
m_cotTheta;
363 pos.x() += radialDistance * (sinPhi * cosBeta + cosPhi * sinBeta);
364 pos.y() += radialDistance * (sinPhi * sinBeta - cosPhi * cosBeta);
371 if (std::abs(deltaPhi1) < DFiMax) {
372 double deltaPhi1Squared = deltaPhi1 * deltaPhi1;
373 sinAlpha = deltaPhi1 * (1. - 0.166667 * deltaPhi1Squared);
375 1. - 0.5 * deltaPhi1Squared * (1. - 0.083333 * deltaPhi1Squared);
377 sinAlpha = std::sin(deltaPhi1);
378 cosAlpha = std::cos(deltaPhi1);
380 dir.x() = (cosPhi * cosAlpha - sinPhi * sinAlpha) * com.
m_sinTheta;
381 dir.y() = (sinPhi * cosAlpha + cosPhi * sinAlpha) * com.
m_sinTheta;
385std::optional<TrackSurfaceIntersection>
392 std::unique_ptr<Constants> cache;
394 lastPosition.setZero();
397 assert(
typeid(*oldCache) ==
typeid(
Constants));
399 std::make_unique<Constants>(*
static_cast<const Constants*
>(oldCache));
400 lastPosition = cache->m_lastPosition;
402 cache = std::make_unique<Constants>(solpar, isect,
qOverP);
407 std::make_optional<TrackSurfaceIntersection>(isect, std::move(cache));
409 newIsect->position() = lastPosition;
415 std::stringstream
msg;
417 throw std::logic_error(
msg.str());
Scalar perp() const
perp method - perpendicular length
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Class for a CylinderSurface in the ATLAS detector.
virtual const Amg::Vector3D & globalReferencePoint() const override final
Returns a global reference point: For the Cylinder this is Where denotes the averagePhi() of the cy...
Class for a DiscSurface in the ATLAS detector.
Class describing the Line to which the Perigee refers to.
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
bool validOrigin(const Amg::Vector3D &origin) const
void fieldIntegrals(double &firstIntegral, double &secondIntegral, double zBegin, double zEnd, Parameters &parms) const
double fieldComponent(double z, const Parameters &parms) const
SG::ReadCondHandleKey< SolenoidParametrization > m_solenoidParametrizationKey
virtual std::optional< TrackSurfaceIntersection > intersectDiscSurface(const DiscSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double qOverP) const override
IIntersector interface method for specific Surface type : DiscSurface.
std::optional< TrackSurfaceIntersection > intersection(TrackSurfaceIntersection &&isect, Constants &com, const Surface &surface) const
virtual std::optional< TrackSurfaceIntersection > approachPerigeeSurface(const PerigeeSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double qOverP) const override
IIntersector interface method for specific Surface type : PerigeeSurface.
ToolHandle< IIntersector > m_rungeKuttaIntersector
static bool extrapolateToZ(TrackSurfaceIntersection &isect, Constants &com, const double endZ)
static constexpr double m_deltaPhiTolerance
virtual StatusCode finalize() override
virtual std::optional< TrackSurfaceIntersection > intersectSurface(const Surface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double qOverP) const override
IIntersector interface method for general Surface type.
virtual bool isValid(Amg::Vector3D startPosition, Amg::Vector3D endPosition) const override
IIntersector interface method to check validity of parametrization within extrapolation range.
static std::optional< TrackSurfaceIntersection > newIntersection(const TrackSurfaceIntersection &oldIsect, const SolenoidParametrization &solpar, const double qOverP, Constants *&com)
void throwMissingCondData() const
virtual std::optional< TrackSurfaceIntersection > intersectPlaneSurface(const PlaneSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double qOverP) const override
IIntersector interface method for specific Surface type : PlaneSurface.
virtual StatusCode initialize() override
bool extrapolateToR(TrackSurfaceIntersection &isect, double &radius2, Constants &com, const double endRadius) const
DoubleProperty m_surfaceTolerance
virtual std::optional< TrackSurfaceIntersection > approachStraightLineSurface(const StraightLineSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double qOverP) const override
IIntersector interface method for specific Surface type : StraightLineSurface.
double linearArcLength(const TrackSurfaceIntersection &isect, const Constants &com, const double radius2, const double endRadius) const
std::atomic< unsigned long long > m_countExtrapolations
virtual std::optional< TrackSurfaceIntersection > intersectCylinderSurface(const CylinderSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double qOverP) const override
IIntersector interface method for specific Surface type : CylinderSurface.
const SolenoidParametrization * getSolenoidParametrization() const
double circularArcLength(double, double, double, double, double, double, double &, double &) const
std::atomic< unsigned long long > m_countRKSwitches
SolenoidalIntersector(const std::string &type, const std::string &name, const IInterface *parent)
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
Abstract Base Class for tracking surfaces.
virtual const Amg::Vector3D & normal() const
Returns the normal vector of the Surface (i.e.
virtual constexpr SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Base class for cache block.
An intersection with a Surface is given by.
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.
const Amg::Vector3D & direction() const
Method to retrieve the direction at the Intersection.
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.
double pathlength() const
Method to retrieve the pathlength propagated till the Intersection.
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
@ z
global position (cartesian)
Constants of motion and other cached values.
Constants(const SolenoidParametrization &solpar, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double qOverP)
const SolenoidParametrization & m_solPar
SolenoidParametrization::Parameters m_solParams
Amg::Vector3D m_lastPosition