Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-19 07:59:22

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Visualization/Interpolation3D.hpp"
0012 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0013 
0014 #include <numbers>
0015 
0016 using namespace Acts;
0017 
0018 namespace ActsTests {
0019 
0020 BOOST_AUTO_TEST_SUITE(VisualizationSuite)
0021 
0022 BOOST_AUTO_TEST_CASE(SplineInterpolationEigen) {
0023   /// Define the input vector
0024   double R = 10.;
0025   std::vector<Acts::Vector3> inputs;
0026 
0027   // Interpolate the points options
0028   std::vector<Acts::Vector3> trajectory;
0029 
0030   // Empty in empty out check
0031   trajectory = Acts::Interpolation3D::spline(inputs, 10);
0032   BOOST_CHECK(trajectory.empty());
0033 
0034   for (double phi = 0; phi < 2 * std::numbers::pi;
0035        phi += std::numbers::pi / 4) {
0036     inputs.push_back(Acts::Vector3(R * cos(phi), R * sin(phi), 0.));
0037   }
0038 
0039   // (0) - nothing happens
0040   trajectory = Acts::Interpolation3D::spline(inputs, 1);
0041   // Check input and output size are the same
0042   BOOST_CHECK_EQUAL(trajectory.size(), inputs.size());
0043 
0044   // (1) - interpolate between the points with 12 points in total
0045   trajectory = Acts::Interpolation3D::spline(inputs, 12);
0046   // Check the output size is correct
0047   BOOST_CHECK_EQUAL(trajectory.size(), 12);
0048 
0049   for (const auto& point : trajectory) {
0050     // Check the interpolated points are on the circle
0051     // with a tolerance of course
0052     CHECK_CLOSE_ABS(point.norm(), R, 0.1);
0053     // Verify points remain in the XY plane
0054     CHECK_CLOSE_ABS(point.z(), 0., 0.1);
0055   }
0056 }
0057 
0058 BOOST_AUTO_TEST_CASE(SplineInterpolationArray) {
0059   /// Define the input vector
0060   std::vector<std::array<double, 3u>> inputs;
0061 
0062   for (double x = 0; x < 10; x += 1) {
0063     inputs.push_back({x, x * x, 0.});
0064   }
0065 
0066   // This time we keep the original hits
0067   auto trajectory = Acts::Interpolation3D::spline(inputs, 100, true);
0068 
0069   // Check the outpu type is correct
0070   constexpr bool isOutput =
0071       std::is_same_v<decltype(trajectory), decltype(inputs)>;
0072   BOOST_CHECK(isOutput);
0073 
0074   // Check the output size is correct
0075   BOOST_CHECK_EQUAL(trajectory.size(), 108);
0076 }
0077 
0078 BOOST_AUTO_TEST_CASE(SplineInterpolationErrors) {
0079   std::vector<std::array<double, 3u>> inputs;
0080 
0081   // Test with single point
0082   inputs.push_back({0., 0., 0.});
0083   auto result = Acts::Interpolation3D::spline(inputs, 10);
0084   BOOST_CHECK_EQUAL(result.size(), 1);
0085 
0086   // Test with two points
0087   inputs.push_back({1., 1., 1.});
0088   result = Acts::Interpolation3D::spline(inputs, 10);
0089   BOOST_CHECK_EQUAL(result.size(), 2);
0090 }
0091 
0092 BOOST_AUTO_TEST_SUITE_END()
0093 
0094 }  // namespace ActsTests