Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-18 07:36:47

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/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0014 #include "Acts/MagneticField/ToroidField.hpp"
0015 #include "Acts/Utilities/Result.hpp"
0016 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0017 
0018 using namespace Acts;
0019 using namespace Acts::UnitLiterals;
0020 
0021 namespace ActsTests {
0022 
0023 BOOST_AUTO_TEST_SUITE(MagneticFieldSuite)
0024 
0025 BOOST_AUTO_TEST_CASE(TestToroidField) {
0026   MagneticFieldContext mfContext = MagneticFieldContext();
0027 
0028   ToroidField::Config cfg{};
0029   cfg.layout.nArc = 20;
0030   cfg.layout.nStraight = 10;
0031   ToroidField field(cfg);
0032 
0033   auto cache = field.makeCache(mfContext);
0034 
0035   const Vector3 positionR(6.0_m, 0.0, 0.0);
0036   auto resultR = field.getField(positionR, cache);
0037   BOOST_CHECK(resultR.ok());
0038   const Vector3 fieldR = resultR.value();
0039   BOOST_CHECK_GT(fieldR.norm(), 0.0);
0040 
0041   const Vector3 positionPhi(0.0, 6.0_m, 0.0);
0042   const Vector3 fieldPhi = field.getField(positionPhi, cache).value();
0043   CHECK_CLOSE_REL(fieldR.norm(), fieldPhi.norm(), 0.1);
0044 
0045   const Vector3 positionZ(6.0_m, 0.0, 5.0_m);
0046   const Vector3 positionZn(6.0_m, 0.0, -5.0_m);
0047   const Vector3 fieldZ = field.getField(positionZ, cache).value();
0048   const Vector3 fieldZn = field.getField(positionZn, cache).value();
0049   CHECK_CLOSE_REL(fieldZ.norm(), fieldZn.norm(), 0.1);
0050 }
0051 
0052 BOOST_AUTO_TEST_SUITE_END()
0053 
0054 }  // namespace ActsTests