File indexing completed on 2025-01-18 09:12:42
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "Acts/MagneticField/ConstantBField.hpp"
0015 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0016 #include "Acts/Utilities/Result.hpp"
0017
0018 namespace bdata = boost::unit_test::data;
0019 using namespace Acts::UnitLiterals;
0020
0021 namespace Acts::Test {
0022
0023
0024 MagneticFieldContext mfContext = MagneticFieldContext();
0025
0026
0027
0028
0029
0030
0031
0032
0033 BOOST_DATA_TEST_CASE(
0034 ConstantBField_components,
0035 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1,
0036 bdata::distribution =
0037 std::uniform_real_distribution<double>(-2_T, 2_T))) ^
0038 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
0039 bdata::distribution =
0040 std::uniform_real_distribution<double>(-1_T, 4_T))) ^
0041 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3,
0042 bdata::distribution =
0043 std::uniform_real_distribution<double>(0_T, 10_T))) ^
0044 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 4,
0045 bdata::distribution =
0046 std::uniform_real_distribution<double>(-10_m,
0047 10_m))) ^
0048 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 5,
0049 bdata::distribution =
0050 std::uniform_real_distribution<double>(-10_m,
0051 10_m))) ^
0052 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 6,
0053 bdata::distribution =
0054 std::uniform_real_distribution<double>(-10_m,
0055 10_m))) ^
0056 bdata::xrange(10),
0057 x, y, z, bx, by, bz, index) {
0058 (void)index;
0059 const Vector3 Btrue(bx, by, bz);
0060 const Vector3 pos(x, y, z);
0061 const ConstantBField BField(Btrue);
0062
0063 auto bCache = BField.makeCache(mfContext);
0064
0065 BOOST_CHECK_EQUAL(Btrue, BField.getField());
0066
0067 BOOST_CHECK_EQUAL(Btrue, BField.getField(pos, bCache).value());
0068 BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3(0, 0, 0), bCache).value());
0069 BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos, bCache).value());
0070 }
0071
0072
0073
0074
0075
0076
0077
0078
0079 BOOST_DATA_TEST_CASE(
0080 ConstantBField_update,
0081 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1,
0082 bdata::distribution =
0083 std::uniform_real_distribution<double>(-2_T, 2_T))) ^
0084 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
0085 bdata::distribution =
0086 std::uniform_real_distribution<double>(-1_T, 4_T))) ^
0087 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3,
0088 bdata::distribution =
0089 std::uniform_real_distribution<double>(0_T, 10_T))) ^
0090 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 4,
0091 bdata::distribution =
0092 std::uniform_real_distribution<double>(-10_m,
0093 10_m))) ^
0094 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 5,
0095 bdata::distribution =
0096 std::uniform_real_distribution<double>(-10_m,
0097 10_m))) ^
0098 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 6,
0099 bdata::distribution =
0100 std::uniform_real_distribution<double>(-10_m,
0101 10_m))) ^
0102 bdata::xrange(10),
0103 x, y, z, bx, by, bz, index) {
0104 (void)index;
0105
0106 ConstantBField BField{Vector3{0, 0, 0}};
0107 const Vector3 Btrue(bx, by, bz);
0108 const Vector3 pos(x, y, z);
0109 BField.setField(Vector3{bx, by, bz});
0110
0111 auto bCache = BField.makeCache(mfContext);
0112
0113 BOOST_CHECK_EQUAL(Btrue, BField.getField());
0114
0115 BOOST_CHECK_EQUAL(Btrue, BField.getField(pos, bCache).value());
0116 BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3(0, 0, 0), bCache).value());
0117 BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos, bCache).value());
0118 }
0119
0120 }