9 #include "GaudiKernel/SystemOfUnits.h"
25 : m_sinTheta (trackTrackSurfaceIntersection.direction().
perp()),
26 m_oneOverSinTheta (1./m_sinTheta),
27 m_cotTheta (trackTrackSurfaceIntersection.direction().
z() * m_oneOverSinTheta),
28 m_qOverPt (
qOverP * m_oneOverSinTheta),
30 m_lastPosition (trackTrackSurfaceIntersection.position()),
32 trackTrackSurfaceIntersection.position().
perp(),
33 trackTrackSurfaceIntersection.position().
z(),
39 const std::string&
name,
43 "Trk::RungeKuttaIntersector/RungeKuttaIntersector", this),
57 return StatusCode::SUCCESS;
66 return StatusCode::SUCCESS;
71 std::optional<Trk::TrackSurfaceIntersection>
77 const auto surfaceType = surface.
type();
80 trackIntersection,
qOverP);
94 trackIntersection,
qOverP);
107 std::optional<Trk::TrackSurfaceIntersection>
110 const double qOverP)
const
114 std::optional<Trk::TrackSurfaceIntersection>
117 const double qOverP)
const
121 std::optional<Trk::TrackSurfaceIntersection>
124 const double qOverP)
const
130 if (!solenoidParametrization || endRadius > solenoidParametrization->
maximumR())
135 trackIntersection, *solenoidParametrization,
qOverP, com);
138 double radius2 = isect->position().perp2();
140 && !
extrapolateToR(*isect, radius2, *com, endRadius))
return std::nullopt;
146 std::optional<Trk::TrackSurfaceIntersection>
149 const double qOverP)
const
154 double endZ = surface.
center().z();
155 if (!solenoidParametrization || std::abs(endZ) > solenoidParametrization->
maximumZ())
159 std::optional<TrackSurfaceIntersection> isect =
161 *solenoidParametrization,
177 std::optional<Trk::TrackSurfaceIntersection>
180 const double qOverP)
const
185 if (!solenoidParametrization ||
186 std::abs(surface.
center().z()) > solenoidParametrization->
maximumZ()
191 std::optional<TrackSurfaceIntersection> isect =
193 *solenoidParametrization,
199 double radius2 =
pos.perp2();
213 if (std::abs(
dot) < 0.0001)
221 radius2 =
pos.perp2();
233 (++numberSteps > 5 ||
237 << numberSteps <<
" steps at offset " <<
offset
238 <<
" dot " << surface.
normal().dot(
dir));
241 surface, trackIntersection,
qOverP);
257 return solenoidParametrization &&
259 std::abs(endPosition.z()) < solenoidParametrization->
maximumZ()
261 && endPosition.perp() < solenoidParametrization->
maximumR()
273 const double endR)
const
278 double fieldComponent =
280 double curvature = fieldComponent * com.
m_qOverPt;
283 double radiusOfCurvature = 1. / curvature;
295 pos.x() = xCentre + radiusOfCurvature * sinPhi;
296 pos.y() = yCentre - radiusOfCurvature * cosPhi;
298 radius2 = endR * endR;
313 double sinDPhi = 0.5 * arcLength * curvature;
315 1. - 0.5 * sinDPhi * sinDPhi * (1.0 + 0.25 * sinDPhi * sinDPhi);
316 double temp = cosPhi;
317 cosPhi =
temp * cosDPhi - sinPhi * sinDPhi;
318 sinPhi =
temp * sinDPhi + sinPhi * cosDPhi;
319 dir.x() = (cosPhi * cosDPhi - sinPhi * sinDPhi) * com.
m_sinTheta;
320 dir.y() = (sinPhi * cosDPhi + cosPhi * sinDPhi) * com.
m_sinTheta;
323 pos.x() += arcLength * cosPhi;
324 pos.y() += arcLength * sinPhi;
326 radius2 = endR * endR;
330 radius2 =
pos.perp2();
334 radius2 =
pos.perp2();
349 double firstIntegral = 0.;
350 double secondIntegral = 0.;
362 sinBeta = 1. - 0.166667 * deltaPhi2Squared;
363 cosBeta = -0.5 *
deltaPhi2 * (1. - 0.083333 * deltaPhi2Squared);
372 pos.x() += radialDistance * (sinPhi * cosBeta + cosPhi * sinBeta);
373 pos.y() += radialDistance * (sinPhi * sinBeta - cosPhi * cosBeta);
382 sinAlpha =
deltaPhi1 * (1. - 0.166667 * deltaPhi1Squared);
384 1. - 0.5 * deltaPhi1Squared * (1. - 0.083333 * deltaPhi1Squared);
389 dir.x() = (cosPhi * cosAlpha - sinPhi * sinAlpha) * com.
m_sinTheta;
390 dir.y() = (sinPhi * cosAlpha + cosPhi * sinAlpha) * com.
m_sinTheta;
394 std::optional<TrackSurfaceIntersection>
401 std::unique_ptr<Constants> cache;
405 assert(
typeid(*oldCache) ==
typeid(
Constants));
407 std::make_unique<Constants>(*
static_cast<const Constants*
>(oldCache));
410 cache = std::make_unique<Constants>(solpar, isect,
qOverP);
415 std::make_optional<TrackSurfaceIntersection>(isect, std::move(cache));
417 newIsect->position() = *lastPosition;
423 std::stringstream
msg;
425 throw std::logic_error(
msg.str());