9#include <tracking/trackFindingCDC/geometry/Helix.h>
11#include <gtest/gtest.h>
15using namespace TrackFindingCDC;
17TEST(TrackFindingCDCTest, geometry_Helix_closest)
24 std::vector<Vector3D> bys = {
Vector3D(0.0, 0.0, 0.0),
32 double curvature = +1.0 / 2.0;
33 double phi0 = -M_PI / 2.0;
35 double tanLambda = 1.0 / 2.0;
38 Helix helix(curvature, phi0, impact, tanLambda, z0);
41 Vector3D expectedClosest = helix.perigee();
45 point.passiveMoveBy(by);
47 Vector3D realClosest = helix.closest(point,
true);
48 EXPECT_NEAR(expectedClosest.
x(), realClosest.
x(), 10e-7) <<
"Test for displacement by " << by;
49 EXPECT_NEAR(expectedClosest.
y(), realClosest.
y(), 10e-7) <<
"Test for displacement by " << by;
50 EXPECT_NEAR(expectedClosest.
z(), realClosest.
z(), 10e-7) <<
"Test for displacement by " << by;
55 Vector3D realClosest = helix.closest(point,
false);
56 EXPECT_NEAR(expectedClosest.
x(), realClosest.
x(), 10e-7) <<
"Test for displacement by " << by;
57 EXPECT_NEAR(expectedClosest.
y(), realClosest.
y(), 10e-7) <<
"Test for displacement by " << by;
58 EXPECT_NEAR(expectedClosest.
z(), realClosest.
z(), 10e-7) <<
"Test for displacement by " << by;
63TEST(TrackFindingCDCTest, geometry_Helix_arcLength2DToCylndricalR)
65 double curvature = -1.0;
66 double phi0 = +M_PI / 2.0;
68 double tanLambda = 1.0 / 2.0;
71 Helix helix(curvature, phi0, impact, tanLambda, z0);
72 EXPECT_EQ(-1, helix.radiusXY());
74 double closestArcLength2D = helix.arcLength2DToCylindricalR(1);
75 EXPECT_NEAR(0, closestArcLength2D, 10e-7);
77 double widestArcLength2D = helix.arcLength2DToCylindricalR(3);
78 EXPECT_NEAR(M_PI, widestArcLength2D, 10e-7);
80 double halfArcLength2D = helix.arcLength2DToCylindricalR(
sqrt(5.0));
81 EXPECT_NEAR(M_PI / 2, halfArcLength2D, 10e-7);
83 double unreachableHighArcLength2D = helix.arcLength2DToCylindricalR(4);
84 EXPECT_TRUE(std::isnan(unreachableHighArcLength2D));
86 double unreachableLowArcLength2D = helix.arcLength2DToCylindricalR(0.5);
87 EXPECT_TRUE(std::isnan(unreachableLowArcLength2D));
90TEST(TrackFindingCDCTest, geometry_Helix_arcLength2DToXY)
92 double curvature = -1.0;
93 double phi0 = +M_PI / 2.0;
95 double tanLambda = 1.0 / 2.0;
98 Helix helix(curvature, phi0, impact, tanLambda, z0);
101 double closestArcLength2D = helix.arcLength2DToXY(origin);
102 EXPECT_NEAR(0, closestArcLength2D, 10e-7);
104 double widestArcLength2D = helix.arcLength2DToXY(
Vector2D(5.0, 0.0));
105 EXPECT_NEAR(M_PI, widestArcLength2D, 10e-7);
107 double halfArcLength2D = helix.arcLength2DToXY(
Vector2D(2.0, 5.0));
108 EXPECT_NEAR(M_PI / 2, halfArcLength2D, 10e-7);
110 double otherHalfArcLength2D = helix.arcLength2DToXY(
Vector2D(2.0, -5.0));
111 EXPECT_NEAR(-M_PI / 2, otherHalfArcLength2D, 10e-7);
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
A three dimensional vector.
void passiveMoveBy(const Vector3D &by)
Passively moves the vector inplace by the given vector.
double x() const
Getter for the x coordinate.
double y() const
Getter for the y coordinate.
double z() const
Getter for the z coordinate.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.