ECCE @ EIC 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"
15 
16 using boost::test_tools::output_test_stream;
17 
18 namespace Acts {
19 namespace Test {
20 
21 BOOST_AUTO_TEST_SUITE(Utilities)
22 BOOST_AUTO_TEST_CASE(ray_construction) {
23  // 2D
24  output_test_stream output;
25 
26  Vector2F dir2(0.5, 0.5);
27  Ray<float, 2> ray2({1, 1}, dir2);
28  dir2.normalize(); // after passing to ray
29 
30  BOOST_CHECK_EQUAL(ray2.origin(), Vector2F(1, 1));
31  CHECK_CLOSE_ABS(ray2.dir(), dir2, 1e-6);
32  Vector2F idir2 = 1. / dir2.array();
33  CHECK_CLOSE_ABS(ray2.idir().matrix(), idir2, 1e-6);
34 
35  ray2.toStream(output);
36  BOOST_CHECK(!output.is_empty(true));
37 
38  // 3D
39 
40  Vector3F dir3(1, 2, 1);
41  Ray<float, 3> ray3({1, 2, 3}, dir3);
42  dir3.normalize(); // after passing to ray
43 
44  BOOST_CHECK_EQUAL(ray3.origin(), Vector3F(1, 2, 3));
45  CHECK_CLOSE_ABS(ray3.dir(), dir3, 1e-6);
46  CHECK_CLOSE_ABS(ray3.idir().matrix(), (1. / dir3.array()).matrix(), 1e-6);
47 
48  ray3.toStream(output);
49  BOOST_CHECK(!output.is_empty(true));
50 
51  // compile draw call, doesn't actually test anything
52  PlyVisualization hlp;
53  ray3.draw(hlp);
54 }
55 BOOST_AUTO_TEST_SUITE_END()
56 
57 } // namespace Test
58 } // namespace Acts