11 #include <tracking/trackFindingCDC/geometry/Helix.h>
13 #include <gtest/gtest.h>
17 using namespace TrackFindingCDC;
19 TEST(TrackFindingCDCTest, geometry_Helix_closest)
26 std::vector<Vector3D> bys = {
Vector3D(0.0, 0.0, 0.0),
34 double curvature = +1.0 / 2.0;
35 double phi0 = -M_PI / 2.0;
37 double tanLambda = 1.0 / 2.0;
40 Helix helix(curvature, phi0, impact, tanLambda, z0);
43 Vector3D expectedClosest = helix.perigee();
45 helix.passiveMoveBy(by);
46 expectedClosest.passiveMoveBy(by);
47 point.passiveMoveBy(by);
49 Vector3D realClosest = helix.closest(point,
true);
50 EXPECT_NEAR(expectedClosest.x(), realClosest.x(), 10e-7) <<
"Test for displacement by " << by;
51 EXPECT_NEAR(expectedClosest.y(), realClosest.y(), 10e-7) <<
"Test for displacement by " << by;
52 EXPECT_NEAR(expectedClosest.z(), realClosest.z(), 10e-7) <<
"Test for displacement by " << by;
57 Vector3D realClosest = helix.closest(point,
false);
58 EXPECT_NEAR(expectedClosest.x(), realClosest.x(), 10e-7) <<
"Test for displacement by " << by;
59 EXPECT_NEAR(expectedClosest.y(), realClosest.y(), 10e-7) <<
"Test for displacement by " << by;
60 EXPECT_NEAR(expectedClosest.z(), realClosest.z(), 10e-7) <<
"Test for displacement by " << by;
65 TEST(TrackFindingCDCTest, geometry_Helix_arcLength2DToCylndricalR)
67 double curvature = -1.0;
68 double phi0 = +M_PI / 2.0;
70 double tanLambda = 1.0 / 2.0;
73 Helix helix(curvature, phi0, impact, tanLambda, z0);
74 EXPECT_EQ(-1, helix.radiusXY());
76 double closestArcLength2D = helix.arcLength2DToCylindricalR(1);
77 EXPECT_NEAR(0, closestArcLength2D, 10e-7);
79 double widestArcLength2D = helix.arcLength2DToCylindricalR(3);
80 EXPECT_NEAR(M_PI, widestArcLength2D, 10e-7);
82 double halfArcLength2D = helix.arcLength2DToCylindricalR(sqrt(5.0));
83 EXPECT_NEAR(M_PI / 2, halfArcLength2D, 10e-7);
85 double unreachableHighArcLength2D = helix.arcLength2DToCylindricalR(4);
86 EXPECT_TRUE(std::isnan(unreachableHighArcLength2D));
88 double unreachableLowArcLength2D = helix.arcLength2DToCylindricalR(0.5);
89 EXPECT_TRUE(std::isnan(unreachableLowArcLength2D));
92 TEST(TrackFindingCDCTest, geometry_Helix_arcLength2DToXY)
94 double curvature = -1.0;
95 double phi0 = +M_PI / 2.0;
97 double tanLambda = 1.0 / 2.0;
100 Helix helix(curvature, phi0, impact, tanLambda, z0);
102 Vector2D origin(0.0, 0.0);
103 double closestArcLength2D = helix.arcLength2DToXY(origin);
104 EXPECT_NEAR(0, closestArcLength2D, 10e-7);
106 double widestArcLength2D = helix.arcLength2DToXY(Vector2D(5.0, 0.0));
107 EXPECT_NEAR(M_PI, widestArcLength2D, 10e-7);
109 double halfArcLength2D = helix.arcLength2DToXY(Vector2D(2.0, 5.0));
110 EXPECT_NEAR(M_PI / 2, halfArcLength2D, 10e-7);
112 double otherHalfArcLength2D = helix.arcLength2DToXY(Vector2D(2.0, -5.0));
113 EXPECT_NEAR(-M_PI / 2, otherHalfArcLength2D, 10e-7);