Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:35

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0013 #include "Acts/Utilities/Ray.hpp"
0014 
0015 using boost::test_tools::output_test_stream;
0016 
0017 namespace Acts {
0018 namespace Test {
0019 
0020 BOOST_AUTO_TEST_SUITE(Utilities)
0021 BOOST_AUTO_TEST_CASE(ray_construction) {
0022   // 2D
0023 
0024   using Vector2F = Eigen::Matrix<float, 2, 1>;
0025 
0026   output_test_stream output;
0027 
0028   Vector2F dir2(0.5, 0.5);
0029   Ray<float, 2> ray2({1, 1}, dir2);
0030   dir2.normalize();  // after passing to ray
0031 
0032   BOOST_CHECK_EQUAL(ray2.origin(), Vector2F(1, 1));
0033   CHECK_CLOSE_ABS(ray2.dir(), dir2, 1e-6);
0034   Vector2F idir2 = 1. / dir2.array();
0035   CHECK_CLOSE_ABS(ray2.idir().matrix(), idir2, 1e-6);
0036 
0037   ray2.toStream(output);
0038   BOOST_CHECK(!output.is_empty(true));
0039 
0040   // 3D
0041   using Vector3F = Eigen::Matrix<float, 3, 1>;
0042 
0043   Vector3F dir3(1, 2, 1);
0044   Ray<float, 3> ray3({1, 2, 3}, dir3);
0045   dir3.normalize();  // after passing to ray
0046 
0047   BOOST_CHECK_EQUAL(ray3.origin(), Vector3F(1, 2, 3));
0048   CHECK_CLOSE_ABS(ray3.dir(), dir3, 1e-6);
0049   CHECK_CLOSE_ABS(ray3.idir().matrix(), (1. / dir3.array()).matrix(), 1e-6);
0050 
0051   ray3.toStream(output);
0052   BOOST_CHECK(!output.is_empty(true));
0053 
0054   // compile draw call, doesn't actually test anything
0055   // PlyVisualization3D hlp;
0056   // ray3.draw(hlp);
0057 }
0058 BOOST_AUTO_TEST_SUITE_END()
0059 
0060 }  // namespace Test
0061 }  // namespace Acts