ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConstantBFieldTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ConstantBFieldTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
11 #include <boost/test/data/test_case.hpp>
12 #include <boost/test/unit_test.hpp>
13 
17 #include "Acts/Utilities/Units.hpp"
18 
19 namespace bdata = boost::unit_test::data;
20 namespace tt = boost::test_tools;
21 using namespace Acts::UnitLiterals;
22 
23 namespace Acts {
24 namespace Test {
25 
26 // Create a test context
28 
36 BOOST_DATA_TEST_CASE(ConstantBField_components,
37  bdata::random(-2_T, 2_T) ^ bdata::random(-1_T, 4_T) ^
38  bdata::random(0_T, 10_T) ^ bdata::random(-10_m, 10_m) ^
39  bdata::random(-10_m, 10_m) ^
40  bdata::random(-10_m, 10_m) ^ bdata::xrange(10),
41  x, y, z, bx, by, bz, index) {
42  (void)index;
43  BOOST_TEST_CONTEXT("Eigen interface") {
44  const Vector3D Btrue(bx, by, bz);
45  const Vector3D pos(x, y, z);
46  const ConstantBField BField(Btrue);
47 
49 
50  BOOST_CHECK_EQUAL(Btrue, BField.getField(pos));
51  BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3D(0, 0, 0)));
52  BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos));
53 
54  BOOST_CHECK_EQUAL(Btrue, BField.getField(pos, bCache));
55  BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3D(0, 0, 0), bCache));
56  BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos, bCache));
57  }
58 
59  BOOST_TEST_CONTEXT("C-array initialised - Eigen retrieved") {
60  const ConstantBField BField(bx, by, bz);
61  const Vector3D Btrue(bx, by, bz);
62  const Vector3D pos(x, y, z);
63 
65 
66  BOOST_CHECK_EQUAL(Btrue, BField.getField(pos));
67  BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3D(0, 0, 0)));
68  BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos));
69 
70  BOOST_CHECK_EQUAL(Btrue, BField.getField(pos, bCache));
71  BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3D(0, 0, 0), bCache));
72  BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos, bCache));
73  }
74 }
75 
83 BOOST_DATA_TEST_CASE(ConstantBField_update,
84  bdata::random(-2_T, 2_T) ^ bdata::random(-1_T, 4_T) ^
85  bdata::random(0_T, 10_T) ^ bdata::random(-10_m, 10_m) ^
86  bdata::random(-10_m, 10_m) ^
87  bdata::random(-10_m, 10_m) ^ bdata::xrange(10),
88  x, y, z, bx, by, bz, index) {
89  (void)index;
90  ConstantBField BField(0, 0, 0);
91 
92  BOOST_TEST_CONTEXT("Eigen interface") {
93  const Vector3D Btrue(bx, by, bz);
94  const Vector3D pos(x, y, z);
95  BField.setField(Btrue);
96 
98 
99  BOOST_CHECK_EQUAL(Btrue, BField.getField(pos));
100  BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3D(0, 0, 0)));
101  BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos));
102 
103  BOOST_CHECK_EQUAL(Btrue, BField.getField(pos, bCache));
104  BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3D(0, 0, 0), bCache));
105  BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos, bCache));
106  }
107 
108  BOOST_TEST_CONTEXT("C-array initialised - Eigen retrieved") {
109  const Vector3D Btrue(bx, by, bz);
110  const Vector3D pos(x, y, z);
111  BField.setField(bx, by, bz);
112 
114 
115  BOOST_CHECK_EQUAL(Btrue, BField.getField(pos));
116  BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3D(0, 0, 0)));
117  BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos));
118 
119  BOOST_CHECK_EQUAL(Btrue, BField.getField(pos, bCache));
120  BOOST_CHECK_EQUAL(Btrue, BField.getField(Vector3D(0, 0, 0), bCache));
121  BOOST_CHECK_EQUAL(Btrue, BField.getField(-2 * pos, bCache));
122  }
123 }
124 
125 } // namespace Test
126 } // namespace Acts