8 #include <framework/utilities/Angle.h>
10 #include <gtest/gtest.h>
16 double constexpr epsilon = 1e-7;
22 TestBaseAngle(
double angle,
double error) :
BaseAngle(angle, error) {};
25 const double angle = TMath::PiOver2();
26 const double error = TMath::PiOver4();
28 TestBaseAngle myBaseAngle(angle, error);
29 EXPECT_DOUBLE_EQ(angle, myBaseAngle.getAngle());
30 EXPECT_DOUBLE_EQ(error, myBaseAngle.getError());
31 EXPECT_DOUBLE_EQ(angle * TMath::RadToDeg(), myBaseAngle.getAngleInDeg());
32 EXPECT_DOUBLE_EQ(error * TMath::RadToDeg(), myBaseAngle.getErrorInDeg());
33 EXPECT_DOUBLE_EQ(angle - error, myBaseAngle.getLowerIntervalBoundary());
34 EXPECT_DOUBLE_EQ(angle + error, myBaseAngle.getUpperIntervalBoundary());
39 const double angle = 0.4;
40 const double error = 0.2;
43 EXPECT_FALSE(myThetaAngle.contains(
ThetaAngle(0., 0.)));
44 EXPECT_FALSE(myThetaAngle.contains(
ThetaAngle(1.6, 0.)));
45 EXPECT_TRUE(myThetaAngle.contains(
ThetaAngle(angle - error / 2, 0.)));
46 EXPECT_TRUE(myThetaAngle.contains(
ThetaAngle(angle + error / 2, 0.)));
48 EXPECT_FLOAT_EQ(TMath::PiOver2(),
ThetaAngle(TMath::Pi() + TMath::PiOver2(), 0.).getAngle());
51 TEST(Angle, PhiAngleIntervalNormalCase)
56 EXPECT_FALSE(myPhiAngle.contains(
PhiAngle(0., 0.)));
57 EXPECT_FALSE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi(), 0.)));
58 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle - error / 2, 0.)));
59 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle + error / 2, 0.)));
61 EXPECT_FLOAT_EQ(TMath::Pi(),
PhiAngle(TMath::TwoPi() + TMath::Pi(), 0.).getAngle());
64 TEST(Angle, PhiAngleIntervalBreaksZero)
66 const double angle = 0.1;
67 const double error = 0.3;
69 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(0 + epsilon, 0.)));
70 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(0 - epsilon, 0.)));
71 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() + epsilon, 0.)));
72 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() - epsilon, 0.)));
73 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle - error / 2, 0.)));
74 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle + error / 2, 0.)));
77 TEST(Angle, PhiAngleIntervalBreaksTwoPi)
79 const double angle = TMath::TwoPi() - 0.1;
80 const double error = 0.3;
82 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(0 + epsilon, 0.)));
83 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(0 - epsilon, 0.)));
84 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() + epsilon, 0.)));
85 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() - epsilon, 0.)));
86 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle - error / 2, 0.)));
87 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle + error / 2, 0.)));
90 TEST(Angle, PhiAngleNormalCase)
92 const double angle = TMath::Pi();
93 const double error = 0.0;
95 EXPECT_FALSE(myPhiAngle.contains(
PhiAngle(0 + epsilon, 0.2)));
96 EXPECT_FALSE(myPhiAngle.contains(
PhiAngle(0 - epsilon, 0.2)));
97 EXPECT_FALSE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() + epsilon, 0.2)));
98 EXPECT_FALSE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() - epsilon, 0.2)));
99 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle - error / 2, 0.2)));
100 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle + error / 2, 0.2)));
103 TEST(Angle, PhiAngleBreaksZero)
105 const double angle = 0.1;
106 const double error = 0.0;
108 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(0 + epsilon, 0.2)));
109 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(0 - epsilon, 0.2)));
110 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() + epsilon, 0.2)));
111 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() - epsilon, 0.2)));
112 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle - error / 2, 0.2)));
113 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle + error / 2, 0.2)));
116 TEST(Angle, PhiAngleBreaksTwoPi)
118 const double angle = TMath::TwoPi() - 0.1;
119 const double error = 0.0;
121 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(0 + epsilon, 0.2)));
122 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(0 - epsilon, 0.2)));
123 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() + epsilon, 0.2)));
124 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(TMath::TwoPi() - epsilon, 0.2)));
125 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle - error / 2, 0.2)));
126 EXPECT_TRUE(myPhiAngle.contains(
PhiAngle(angle + error / 2, 0.2)));
129 TEST(Angle, PhiAngleAndErrorBreakTwoPi)
131 const double angle = -0.0275 + TMath::TwoPi();
132 const double error = 3 * 0.0104;
134 EXPECT_FALSE(myPhiAngle.containsIn(
PhiAngle(2.6, 0), 1));
Class to compare if two angles are compatible withing a given error range.
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.