ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtentTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ExtentTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
12 
13 // Helper
15 
16 // The class to test
17 #include "Acts/Geometry/Extent.hpp"
18 
20 #include "Acts/Utilities/Units.hpp"
21 
22 namespace Acts {
23 
24 using namespace UnitLiterals;
25 
26 namespace Test {
27 
28 BOOST_AUTO_TEST_SUITE(Geometry)
29 
30 
31 BOOST_AUTO_TEST_CASE(ExtentTest) {
32  std::vector<Vector3D> vertices = {
33  Vector3D(15_mm, -3_mm, -10_mm), Vector3D(18_mm, 0_mm, -10_mm),
34  Vector3D(15_mm, 3_mm, -10_mm), Vector3D(15_mm, -3_mm, 10_mm),
35  Vector3D(18_mm, 0_mm, 10_mm), Vector3D(15_mm, 3_mm, 10_mm)};
36 
37  // Create an Extent
38  Extent gExt;
39  for (const auto& v : vertices) {
40  gExt.check(v);
41  }
42 
43  double phiMin = std::atan2(-3_mm, 15_mm);
44  double phiMax = std::atan2(3_mm, 15_mm);
45  double rMin = std::sqrt(15_mm * 15_mm + 3_mm * 3_mm);
46 
47  CHECK_CLOSE_ABS(gExt.min(binX), 15_mm, 1e-6);
48  CHECK_CLOSE_ABS(gExt.max(binX), 18_mm, 1e-6);
49  CHECK_CLOSE_ABS(gExt.min(binY), -3_mm, 1e-6);
50  CHECK_CLOSE_ABS(gExt.max(binY), 3_mm, 1e-6);
51  CHECK_CLOSE_ABS(gExt.min(binZ), -10_mm, 1e-6);
52  CHECK_CLOSE_ABS(gExt.max(binZ), 10_mm, 1e-6);
53  CHECK_CLOSE_ABS(gExt.min(binR), rMin, 1e-6);
54  CHECK_CLOSE_ABS(gExt.max(binR), 18_mm, 1e-6);
55  CHECK_CLOSE_ABS(gExt.min(binPhi), phiMin, 1e-6);
56  CHECK_CLOSE_ABS(gExt.max(binPhi), phiMax, 1e-6);
57 
58  // Create a second Extent
59  Extent otherExt;
60  otherExt.extend(gExt);
61 
62  CHECK_CLOSE_ABS(otherExt.min(binX), 15_mm, 1e-6);
63  CHECK_CLOSE_ABS(otherExt.max(binX), 18_mm, 1e-6);
64  CHECK_CLOSE_ABS(otherExt.min(binY), -3_mm, 1e-6);
65  CHECK_CLOSE_ABS(otherExt.max(binY), 3_mm, 1e-6);
66  CHECK_CLOSE_ABS(otherExt.min(binZ), -10_mm, 1e-6);
67  CHECK_CLOSE_ABS(otherExt.max(binZ), 10_mm, 1e-6);
68  CHECK_CLOSE_ABS(otherExt.min(binR), rMin, 1e-6);
69  CHECK_CLOSE_ABS(otherExt.max(binR), 18_mm, 1e-6);
70  CHECK_CLOSE_ABS(otherExt.min(binPhi), phiMin, 1e-6);
71  CHECK_CLOSE_ABS(otherExt.max(binPhi), phiMax, 1e-6);
72 }
73 
74 BOOST_AUTO_TEST_SUITE_END()
75 
76 } // namespace Test
77 } // namespace Acts