26 double& previousDistance,
27 unsigned long long& stepsUntilTrapped)
34 if (stepsUntilTrapped <= 0) {
51 const std::string&
name,
54 m_productionMode (true),
83 m_stepsUntilTrapped (2000),
98 m_countExtrapolations (0),
101 m_countStepReduction (0)
129 return StatusCode::SUCCESS;
139 msg(MSG::INFO) << std::setiosflags(std::ios::fixed)
140 <<
" taking an average" << std::setw(7) << std::setprecision(1)
142 <<
" full steps," << std::setw(5) << std::setprecision(2)
144 <<
" step reductions and" << std::setw(5) << std::setprecision(2)
146 <<
" short final steps";
150 return StatusCode::SUCCESS;
154 std::optional<Trk::TrackSurfaceIntersection>
157 const double qOverP)
const
166 const auto surfaceType = surface.
type();
169 trackIntersection,
qOverP);
183 trackIntersection,
qOverP);
187 trackIntersection,
qOverP);
195 std::optional<Trk::TrackSurfaceIntersection>
198 const double qOverP)
const
203 const double rStart =
pos.perp();
204 const double zStart =
pos.z();
211 double stepLength = 0;
214 double previousDistance = 1.1*
distance;
219 if (isTrapped(
distance, previousDistance, stepsUntilTrapped)) {
222 rStart, zStart,
true);
237 std::optional<Trk::TrackSurfaceIntersection>
240 const double qOverP)
const
245 const double rStart =
pos.perp();
246 const double zStart =
pos.z();
253 double stepLength = 0;
256 double previousDistance = 1.1*
distance;
261 if (isTrapped(
distance, previousDistance, stepsUntilTrapped)) {
264 rStart, zStart,
true);
279 std::optional<Trk::TrackSurfaceIntersection>
282 const double qOverP)
const
287 const double rStart =
pos.perp();
288 const double zStart =
pos.z();
296 double rCurrent =
offset.perp();
297 double stepLength = 0;
300 double previousDistance = 1.1*
distance;
301 bool trapped =
false;
306 if (isTrapped(
distance, previousDistance, stepsUntilTrapped)) {
311 double rPrevious= rCurrent;
315 double deltaR1 = rCurrent - rPrevious;
316 double deltaR2 = cylinderRadius - rCurrent;
346 rStart, zStart,
true);
351 std::optional<Trk::TrackSurfaceIntersection>
354 const double qOverP)
const
359 const double rStart =
pos.perp();
360 const double zStart =
pos.z();
366 double stepLength = 0;
369 double previousDistance = 1.1*
distance;
374 if (isTrapped(
distance, previousDistance, stepsUntilTrapped)) {
377 rStart, zStart,
true);
392 std::optional<Trk::TrackSurfaceIntersection>
395 const double qOverP)
const
400 const double rStart =
pos.perp();
401 const double zStart =
pos.z();
407 double stepLength = 0;
410 double previousDistance = 1.1*
distance;
415 if (isTrapped(
distance, previousDistance, stepsUntilTrapped)) {
418 rStart, zStart,
true);
437 double& stepLength)
const
440 const double sinTheta = isect.
direction().perp();
445 const double zCurrent = std::abs(
pos.z());
446 const double rCurrent =
pos.perp();
460 }
else if (zCurrent >
m_inDetZ2 || sinTheta < 0.35) {
466 else if (zCurrent >
m_inDetZ1 && sinTheta < 0.60) {
489 else if (rCurrent < 1000.)
491 if (zCurrent > 700.) {
498 else if (zCurrent > 420. && sinTheta < 0.60) {
503 if (rCurrent > 900.) {
514 if (zCurrent < 3000.)
545 }
else if (
radius < 5300.) {
553 else if (
phi > 0.04 ||
604 }
else if (zCurrent < m_toroidZ0 || zCurrent >
m_toroidZ1 ||
629 if (std::abs(stepLength) < stepMax)
631 if (stepLength > 0.) {
632 stepLength = stepMax;
634 stepLength = -stepMax;
644 const bool trapped)
const
650 const double sinTheta = isect.direction().perp();
653 const double rCurrent = isect.position().perp();
656 if (rCurrent > rStart)
658 log <<
MSG::DEBUG << std::setiosflags(std::ios::fixed|std::ios::right)
659 <<
" fail to intersect surface when extrapolating outwards from R,Z"
660 << std::setw(8) << std::setprecision(1) << rStart <<
","
661 << std::setw(7) << std::setprecision(0) << zStart <<
" mm, with pt"
662 << std::setw(7) << std::setprecision(2) <<
pt <<
" GeV, direction eta"
663 << std::setw(5) << std::setprecision(2) << isect.direction().eta();
667 log <<
MSG::DEBUG << std::setiosflags(std::ios::fixed|std::ios::right)
668 <<
" fail to intersect surface when extrapolating inwards from R,Z"
669 << std::setw(8) << std::setprecision(1) << rStart <<
","
670 << std::setw(7) << std::setprecision(0) << zStart <<
" mm, with pt"
671 << std::setw(7) << std::setprecision(2) <<
pt <<
" GeV, direction eta"
672 << std::setw(5) << std::setprecision(2) << isect.direction().eta();
679 double stepLength = 0;
681 log <<
MSG::DEBUG << std::setiosflags(std::ios::fixed|std::ios::right) <<
" PlaneSurface"
682 <<
" at R,Z" << std::setw(8) << std::setprecision(1) << surface.
center().perp() <<
","
683 << std::setw(7) << std::setprecision(0) << surface.
center().z()
684 <<
" at line distance " << std::setw(9) << std::setprecision(1) << stepLength;
692 double rCurrent =
offset.perp();
693 double stepLength = 0;
697 log <<
MSG::DEBUG << std::setiosflags(std::ios::fixed|std::ios::right)
698 <<
" closest approach to CylinderSurface at radius "
699 << std::setw(9) << std::setprecision(4) << rCurrent
700 <<
" mm. Cylinder radius " << std::setw(9) << std::setprecision(4) << cylinderRadius <<
" mm"
705 log <<
MSG::DEBUG << std::setiosflags(std::ios::fixed|std::ios::right) <<
" CylinderSurface"
706 <<
" radius " << std::setw(6) << std::setprecision(1) << cylinderRadius
707 <<
" rCurrent " << std::setw(6) << std::setprecision(1) << rCurrent
708 <<
" distance " << std::setw(6) << std::setprecision(1) << stepLength;
713 else if (
dynamic_cast<const DiscSurface*
>(&surface))
715 double stepLength = 0;
717 log <<
MSG::DEBUG << std::setiosflags(std::ios::fixed|std::ios::right) <<
" DiscSurface"
718 <<
" at R,Z" << std::setw(8) << std::setprecision(1) << surface.
center().perp() <<
","
719 << std::setw(7) << std::setprecision(0) << surface.
center().z()
720 <<
" at line distance " << std::setw(9) << std::setprecision(1) << stepLength;
726 log <<
MSG::DEBUG << std::setiosflags(std::ios::fixed|std::ios::right) <<
" PerigeeSurface "
731 log <<
MSG::DEBUG << std::setiosflags(std::ios::fixed|std::ios::right) <<
" StraightLineSurface "
740 const double stepLength,
741 const double qOverP)
const
748 double stepOverP = 0.5*stepLength*cOverP;
756 pos += stepLength*(
dir +
m_third*(product0+product1+product2));
759 dir +=
m_third*(product0+product3 + 2.*(product1+product2));
775 double stepOverP = 0.5*stepLength*cOverP;
782 Amg::Vector3D product1 = stepOverP*direction1.cross(fieldValue1);
784 Amg::Vector3D product2 = stepOverP*direction2.cross(fieldValue1);
791 if ((fieldValue1 - 0.5 * (
fieldValue + fieldAtEnd)).
mag() > 0.00001 &&
793 if (stepLength > 0.) {
799 stepOverP = 0.5 * stepLength * cOverP;
803 pos + 0.5 * stepLength * (
dir + 0.5 * product0);
806 product1 = stepOverP * direction1p.cross(fieldValue1p);
808 product2 = stepOverP * direction2p.cross(fieldValue1p);
811 stepLength * (
dir +
m_third * (product0 + product1 + product2));
812 fieldAtEnd =
field(
pos + offsetAtEnd, fieldCache);
816 Amg::Vector3D product3 = stepOverP * direction3.cross(fieldAtEnd);
817 dir +=
m_third * (product0 + product3 + 2. * (product1 + product2));