File indexing completed on 2025-08-06 08:11:22
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/tools/floating_point_comparison.hpp>
0011 #include <boost/test/unit_test.hpp>
0012
0013 #include "Acts/Definitions/Algebra.hpp"
0014 #include "Acts/Definitions/Units.hpp"
0015 #include "Acts/MagneticField/ConstantBField.hpp"
0016 #include "Acts/MagneticField/InterpolatedBFieldMap.hpp"
0017 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0018 #include "Acts/MagneticField/MagneticFieldProvider.hpp"
0019 #include "Acts/MagneticField/SolenoidBField.hpp"
0020
0021 namespace Acts {
0022 namespace Test {
0023
0024
0025 MagneticFieldContext mfContext = MagneticFieldContext();
0026
0027
0028
0029
0030
0031
0032
0033
0034 template <class BField_t>
0035 void testInterfaceConsistency(const BField_t& field) {
0036 using Cache_t = typename BField_t::Cache;
0037 Vector3 pos(0, 0, 0);
0038 Vector3 B;
0039 ActsMatrix<3, 3> gradient;
0040
0041
0042 field.getField(pos);
0043 field.getFieldGradient(pos, gradient);
0044
0045
0046 Cache_t cache(mfContext);
0047 field.getField(pos, cache);
0048 field.getFieldGradient(pos, gradient, cache);
0049 }
0050
0051 BOOST_AUTO_TEST_CASE(TestConstantBFieldInterfaceConsistency) {
0052 ConstantBField field(1, 1, 1);
0053 testInterfaceConsistency(field);
0054 }
0055
0056 BOOST_AUTO_TEST_CASE(TestSolenoidBFieldInterfaceConsistency) {
0057 SolenoidBField field({100, 1000, 20, 5});
0058 testInterfaceConsistency(field);
0059 }
0060
0061 BOOST_AUTO_TEST_CASE(TestInterpolatedBFieldMapInterfaceConsistency) {
0062
0063 struct DummyFieldCell {
0064 Vector3 getField(const Vector3&) const { return {0, 0, 0}; }
0065 bool isInside(const Vector3&) const { return true; }
0066 };
0067
0068 struct DummyMapper : DummyFieldCell {
0069 using FieldCell = DummyFieldCell;
0070
0071 DummyFieldCell getFieldCell(const Vector3&) const {
0072 return DummyFieldCell();
0073 }
0074 std::vector<std::size_t> getNBins() const { return {42}; }
0075 std::vector<double> getMin() const { return {5}; }
0076 std::vector<double> getMax() const { return {15}; }
0077 };
0078
0079 DummyMapper m;
0080 InterpolatedBFieldMap<DummyMapper>::Config config(std::move(m));
0081 config.scale = 1.;
0082
0083
0084 InterpolatedBFieldMap<DummyMapper> b(std::move(config));
0085
0086 testInterfaceConsistency(b);
0087 }
0088
0089 }
0090 }