Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:42

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/floating_point_comparison.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0013 #include "Acts/MagneticField/MultiRangeBField.hpp"
0014 #include "Acts/Utilities/Result.hpp"
0015 
0016 namespace Acts::Test {
0017 
0018 MagneticFieldContext mfContext = MagneticFieldContext();
0019 
0020 BOOST_AUTO_TEST_CASE(TestMultiRangeBField) {
0021   std::vector<std::pair<RangeXD<3, double>, Vector3>> inputs;
0022 
0023   inputs.emplace_back(RangeXD<3, double>{{0., 0., 0.}, {3., 3., 3.}},
0024                       Vector3{0., 0., 2.});
0025   inputs.emplace_back(RangeXD<3, double>{{1., 1., 1.}, {2., 2., 10.}},
0026                       Vector3{2., 0., 0.});
0027 
0028   const MultiRangeBField bfield(std::move(inputs));
0029 
0030   auto bcache = bfield.makeCache(mfContext);
0031 
0032   // Test a point inside the first volume.
0033   {
0034     Result<Vector3> r = bfield.getField({0.5, 0.5, 0.5}, bcache);
0035     BOOST_CHECK(r.ok());
0036     BOOST_CHECK_CLOSE((*r)[0], 0., 0.05);
0037     BOOST_CHECK_CLOSE((*r)[1], 0., 0.05);
0038     BOOST_CHECK_CLOSE((*r)[2], 2., 0.05);
0039   }
0040 
0041   // Test a point inside the second volume, not overlapping the first.
0042   {
0043     Result<Vector3> r = bfield.getField({1.5, 1.5, 5.}, bcache);
0044     BOOST_CHECK(r.ok());
0045     BOOST_CHECK_CLOSE((*r)[0], 2., 0.05);
0046     BOOST_CHECK_CLOSE((*r)[1], 0., 0.05);
0047     BOOST_CHECK_CLOSE((*r)[2], 0., 0.05);
0048   }
0049 
0050   // Test a point inside the first volume again.
0051   {
0052     Result<Vector3> r = bfield.getField({2.5, 2.5, 2.5}, bcache);
0053     BOOST_CHECK(r.ok());
0054     BOOST_CHECK_CLOSE((*r)[0], 0., 0.05);
0055     BOOST_CHECK_CLOSE((*r)[1], 0., 0.05);
0056     BOOST_CHECK_CLOSE((*r)[2], 2., 0.05);
0057   }
0058 
0059   // Test a point inside the second volume in the overlap region.
0060   {
0061     Result<Vector3> r = bfield.getField({1.5, 1.5, 1.5}, bcache);
0062     BOOST_CHECK(r.ok());
0063     BOOST_CHECK_CLOSE((*r)[0], 2., 0.05);
0064     BOOST_CHECK_CLOSE((*r)[1], 0., 0.05);
0065     BOOST_CHECK_CLOSE((*r)[2], 0., 0.05);
0066   }
0067 
0068   // Test a point outside all volumes.
0069   {
0070     Result<Vector3> r = bfield.getField({-1., -1., -1}, bcache);
0071     BOOST_CHECK(!r.ok());
0072   }
0073 }
0074 }  // namespace Acts::Test