Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RayTest.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RayTest.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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/tools/output_test_stream.hpp>
10 #include <boost/test/unit_test.hpp>
11 
13 #include "Acts/Utilities/Ray.hpp"
14 
15 using boost::test_tools::output_test_stream;
16 
17 namespace Acts {
18 namespace Test {
19 
20 BOOST_AUTO_TEST_SUITE(Utilities)
21 BOOST_AUTO_TEST_CASE(ray_construction) {
22  // 2D
23 
24  using Vector2F = Eigen::Matrix<float, 2, 1>;
25 
26  output_test_stream output;
27 
28  Vector2F dir2(0.5, 0.5);
29  Ray<float, 2> ray2({1, 1}, dir2);
30  dir2.normalize(); // after passing to ray
31 
32  BOOST_CHECK_EQUAL(ray2.origin(), Vector2F(1, 1));
33  CHECK_CLOSE_ABS(ray2.dir(), dir2, 1e-6);
34  Vector2F idir2 = 1. / dir2.array();
35  CHECK_CLOSE_ABS(ray2.idir().matrix(), idir2, 1e-6);
36 
37  ray2.toStream(output);
38  BOOST_CHECK(!output.is_empty(true));
39 
40  // 3D
41  using Vector3F = Eigen::Matrix<float, 3, 1>;
42 
43  Vector3F dir3(1, 2, 1);
44  Ray<float, 3> ray3({1, 2, 3}, dir3);
45  dir3.normalize(); // after passing to ray
46 
47  BOOST_CHECK_EQUAL(ray3.origin(), Vector3F(1, 2, 3));
48  CHECK_CLOSE_ABS(ray3.dir(), dir3, 1e-6);
49  CHECK_CLOSE_ABS(ray3.idir().matrix(), (1. / dir3.array()).matrix(), 1e-6);
50 
51  ray3.toStream(output);
52  BOOST_CHECK(!output.is_empty(true));
53 
54  // compile draw call, doesn't actually test anything
55  // PlyVisualization3D hlp;
56  // ray3.draw(hlp);
57 }
58 BOOST_AUTO_TEST_SUITE_END()
59 
60 } // namespace Test
61 } // namespace Acts