Belle II Software  release-08-01-10
Vector2D.test.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
10 
11 #include <gtest/gtest.h>
12 
13 
14 using namespace Belle2;
15 using namespace TrackFindingCDC;
16 
17 TEST(TrackFindingCDCTest, geometry_Vector2D_isBetween)
18 {
19  {
20  Vector2D lower = Vector2D::Phi(0);
21  Vector2D upper = Vector2D::Phi(M_PI);
22 
23  Vector2D test = Vector2D::Phi(M_PI / 2);
24  Vector2D test2 = Vector2D::Phi(3 * M_PI / 2);
25 
26  EXPECT_TRUE(test.isBetween(lower, upper));
27  EXPECT_FALSE(test.isBetween(upper, lower));
28  EXPECT_FALSE(test2.isBetween(lower, upper));
29  EXPECT_TRUE(test2.isBetween(upper, lower));
30  }
31 
32  {
33  Vector2D lower = Vector2D::Phi(0);
34  Vector2D upper = Vector2D::Phi(M_PI / 2);
35 
36  Vector2D test1 = Vector2D::Phi(M_PI / 4);
37  Vector2D test2 = Vector2D::Phi(3 * M_PI / 4);
38  Vector2D test3 = Vector2D::Phi(5 * M_PI / 4);
39  Vector2D test4 = Vector2D::Phi(7 * M_PI / 4);
40 
41  EXPECT_TRUE(test1.isBetween(lower, upper));
42  EXPECT_FALSE(test1.isBetween(upper, lower));
43 
44  EXPECT_FALSE(test2.isBetween(lower, upper));
45  EXPECT_TRUE(test2.isBetween(upper, lower));
46 
47  EXPECT_FALSE(test3.isBetween(lower, upper));
48  EXPECT_TRUE(test3.isBetween(upper, lower));
49 
50  EXPECT_FALSE(test4.isBetween(lower, upper));
51  EXPECT_TRUE(test4.isBetween(upper, lower));
52  }
53 
54  {
55  Vector2D lower = Vector2D::Phi(-M_PI / 4);
56  Vector2D upper = Vector2D::Phi(M_PI);
57 
58  Vector2D test = Vector2D::Phi(0);
59  Vector2D test2 = Vector2D::Phi(M_PI / 2);
60 
61  EXPECT_TRUE(test.isBetween(lower, upper));
62  EXPECT_FALSE(test.isBetween(upper, lower));
63  EXPECT_TRUE(test2.isBetween(lower, upper));
64  EXPECT_FALSE(test2.isBetween(upper, lower));
65  }
66 }
67 
68 TEST(TrackFindingCDCTest, geometry_Vector2D_flippedOver)
69 {
70  Vector2D diag(0.5, 0.5);
71  Vector2D test(1, 0);
72  Vector2D flippedOver = test.flippedOver(diag);
73 
74  EXPECT_EQ(0, flippedOver.x());
75  EXPECT_EQ(1, flippedOver.y());
76 }
77 
78 TEST(TrackFindingCDCTest, geometry_Vector2D_flippedAlong)
79 {
80  Vector2D diag(0.5, 0.5);
81  Vector2D test(1, 0);
82  Vector2D flippedAlong = test.flippedAlong(diag);
83 
84  EXPECT_EQ(0, flippedAlong.x());
85  EXPECT_EQ(-1, flippedAlong.y());
86 }
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:35
double x() const
Getter for the x coordinate.
Definition: Vector2D.h:607
bool isBetween(const Vector2D &lower, const Vector2D &upper) const
Checks if this vector is between two other vectors Between means here that when rotating the lower ve...
Definition: Vector2D.h:537
double y() const
Getter for the y coordinate.
Definition: Vector2D.h:617
static Vector2D Phi(const double phi)
Constucts a unit vector with azimuth angle equal to phi.
Definition: Vector2D.h:71
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.