TrkSurfaces: Fix bugs in CylinderSurface::straightLineIntersection.
CylinderSurface::straightLineIntersection has a couple serious bugs that appear to have been there since it was first written.
We had
if (needsTransform){
Amg::Transform3D invTrans = transform().inverse();
point1 = invTrans*pos;
direction = invTrans.linear()*dir;
}
Amg::Vector3D point2 = point1 + dir;
where point1 and point2 are meant to be points along the supplied line,
after the reference frame transform. But the last line here uses the
direction vector before the transform, rather than after. It should
use direction', rather than
dir'.
But, in fact, the expression
double d = (point2.x()*point1.y() - point1.x()*point2.y())/(point2.x()-point1.x());
can be written more efficiently as
double d = point1.y() - point1.x()*k;
in which case, we no longer need the point2 variable. Writing it this way probably also has better precision, since we avoid subtracting large numbers that are close together.
Further, in the section handling the case where direction.x()==0, we have
t1 = y-point1.y();
t2 = -y-point1.y();
which is not correct, since t1 and t2 are meant to be the 3D distances to the intersection; what we have here is the 2D projection. We instead need to do
t1 = (y-point1.y())/direction.y();
t2 = (-y-point1.y())/direction.y();
The code also does not handle the case when both direction.x() and direction.y() are 0.
Finally, we can change some of the repeated divisions by the same value to multiplication by a reciprocal.
Also add a rudimentary unit test for this functionality.
Merge request reports
Activity
added Tracking master review-pending-level-1 labels
CI Result SUCCESSAthena AthSimulation externals cmake make required tests optional tests Full details available at NICOS MR-20736-2019-01-30-04-08
Athena: number of compilation errors 0, warnings 0
AthSimulation: number of compilation errors 0, warnings 0
CI Jenkins server is switched to https://atlas-sit-ci.cern.ch. It is accessible world-wide (behind CERN SSO). In old links to Jenkins server aibuild080.cern.ch:8080 should be replaced with atlas-sit-ci.cern.ch For experts only: Jenkins output [CI-MERGE-REQUEST 32976]Changes and CI look fine. Waiting for comments from @asalzbur. Can be approved then.
Kira (L1)
added review-user-action-required label and removed review-pending-level-1 label
Hi,
Sorry for the delay - the changes look fine! And well spotted.
We were lucky here because:
(1) we use cylinder surfaces as volume and layer containers that were centered around the z axis and thus the linear part of the transform left the direction unchanged.
(2) the case of x() and y() being 0 is the case of particles moving along the z axis which is not tracked in ATLAS.
The suggested changes however should go in of course.
I will check if the infected code made it into the ACTS base as well.
Cheers, Andi
added review-approved label and removed review-user-action-required label
added review-pending-level-1 label and removed review-approved label
CI Result SUCCESSAthena AthSimulation externals cmake make required tests optional tests Full details available at NICOS MR-20736-2019-02-14-06-27
Athena: number of compilation errors 0, warnings 2
AthSimulation: number of compilation errors 0, warnings 0
For experts only: Jenkins output [CI-MERGE-REQUEST 33791]added review-approved label and removed review-pending-level-1 label
mentioned in commit 7f830a24
added sweep:ignore label