9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
23 using namespace detail;
29 std::vector<double> rPos = {0., 1., 2.};
30 std::vector<double> xPos = {0., 1., 2.};
31 std::vector<double> yPos = {0., 1., 2.};
32 std::vector<double> zPos = {0., 1., 2.};
35 std::vector<Acts::Vector2D> bField_rz;
36 for (
int i = 0; i < 9; i++) {
40 auto localToGlobalBin_rz = [](std::array<size_t, 2> binsRZ,
41 std::array<size_t, 2> nBinsRZ) {
42 return (binsRZ.at(1) * nBinsRZ.at(0) + binsRZ.at(0));
46 bField_rz, 1, 1,
false);
48 std::vector<size_t> nBins_rz = {rPos.size(), zPos.size()};
49 std::vector<double> minima_rz = {0., 0.};
50 std::vector<double> maxima_rz = {3., 3.};
51 BOOST_CHECK(mapper_rz.getNBins() == nBins_rz);
54 BOOST_CHECK(mapper_rz.getMin() == minima_rz);
57 BOOST_CHECK(mapper_rz.getMax() == maxima_rz);
60 std::vector<Acts::Vector3D> bField_xyz;
61 for (
int i = 0; i < 27; i++) {
65 auto localToGlobalBin_xyz = [](std::array<size_t, 3> binsXYZ,
66 std::array<size_t, 3> nBinsXYZ) {
67 return (binsXYZ.at(0) * (nBinsXYZ.at(1) * nBinsXYZ.at(2)) +
68 binsXYZ.at(1) * nBinsXYZ.at(2) + binsXYZ.at(2));
73 bField_xyz, 1, 1,
false);
75 std::vector<size_t> nBins_xyz = {xPos.size(), yPos.size(), zPos.size()};
76 std::vector<double> minima_xyz = {0., 0., 0.};
77 std::vector<double> maxima_xyz = {3., 3., 3.};
78 BOOST_CHECK(mapper_xyz.getNBins() == nBins_xyz);
81 BOOST_CHECK(mapper_xyz.getMin() == minima_xyz);
84 BOOST_CHECK(mapper_xyz.getMax() == maxima_xyz);
90 auto value0_rz = mapper_rz.getField(pos0_rz);
91 auto value1_rz = mapper_rz.getField(pos1_rz);
92 auto value2_rz = mapper_rz.getField(pos2_rz);
95 bField_rz.at(localToGlobalBin_rz({{0, 0}}, {{rPos.size(), zPos.size()}}));
97 bField_rz.at(localToGlobalBin_rz({{1, 1}}, {{rPos.size(), zPos.size()}}));
99 bField_rz.at(localToGlobalBin_rz({{2, 2}}, {{rPos.size(), zPos.size()}}));
116 auto value0_xyz = mapper_xyz.getField(pos0_xyz);
117 auto value1_xyz = mapper_xyz.getField(pos1_xyz);
118 auto value2_xyz = mapper_xyz.getField(pos2_xyz);
120 auto b0_xyz = bField_xyz.at(localToGlobalBin_xyz(
121 {{0, 0, 0}}, {{xPos.size(), yPos.size(), zPos.size()}}));
122 auto b1_xyz = bField_xyz.at(localToGlobalBin_xyz(
123 {{1, 1, 1}}, {{xPos.size(), yPos.size(), zPos.size()}}));
124 auto b2_xyz = bField_xyz.at(localToGlobalBin_xyz(
125 {{2, 2, 2}}, {{xPos.size(), yPos.size(), zPos.size()}}));
127 BOOST_CHECK_EQUAL(value0_xyz, b0_xyz);
128 BOOST_CHECK_EQUAL(value1_xyz, b1_xyz);
129 BOOST_CHECK_EQUAL(value2_xyz, b2_xyz);
140 std::vector<double> rPos = {0., 1., 2.};
141 std::vector<double> xPos = {0., 1., 2.};
142 std::vector<double> yPos = {0., 1., 2.};
143 std::vector<double> zPos = {0., 1., 2.};
145 std::vector<Acts::Vector2D> bField_rz;
146 for (
int i = 0; i < 9; i++) {
151 [](std::array<size_t, 2> binsRZ, std::array<size_t, 2> nBinsRZ) {
152 return (binsRZ.at(1) * nBinsRZ.at(0) + binsRZ.at(0));
154 rPos, zPos, bField_rz, 1, 1,
true);
157 std::vector<size_t> nBins_rz = {rPos.size(), 2 * zPos.size() - 1};
158 std::vector<double> minima_rz = {0., -2.};
159 std::vector<double> maxima_rz = {3., 3.};
160 BOOST_CHECK(mapper_rz.getNBins() == nBins_rz);
161 auto vec = mapper_rz.getNBins();
162 auto vec0 = mapper_rz.getMin();
165 BOOST_CHECK(mapper_rz.getMin() == minima_rz);
168 BOOST_CHECK(mapper_rz.getMax() == maxima_rz);
171 std::vector<Acts::Vector3D> bField_xyz;
172 for (
int i = 0; i < 27; i++) {
177 [](std::array<size_t, 3> binsXYZ, std::array<size_t, 3> nBinsXYZ) {
178 return (binsXYZ.at(0) * (nBinsXYZ.at(1) * nBinsXYZ.at(2)) +
179 binsXYZ.at(1) * nBinsXYZ.at(2) + binsXYZ.at(2));
181 xPos, yPos, zPos, bField_xyz, 1, 1,
true);
184 std::vector<size_t> nBins_xyz = {2 * xPos.size() - 1, 2 * yPos.size() - 1,
185 2 * zPos.size() - 1};
186 std::vector<double> minima_xyz = {-2., -2., -2.};
187 std::vector<double> maxima_xyz = {3., 3., 3.};
188 BOOST_CHECK(mapper_xyz.getNBins() == nBins_xyz);
191 BOOST_CHECK(mapper_xyz.getMin() == minima_xyz);
194 BOOST_CHECK(mapper_xyz.getMax() == maxima_xyz);
202 auto value0_rz = mapper_rz.getField(pos0);
203 auto value1_rz = mapper_rz.getField(pos1);
204 auto value2_rz = mapper_rz.getField(pos2);
205 auto value3_rz = mapper_rz.getField(pos3);
206 auto value4_rz = mapper_rz.getField(pos4);
208 auto value0_xyz = mapper_xyz.getField(pos0);
209 auto value1_xyz = mapper_xyz.getField(pos1);
210 auto value2_xyz = mapper_xyz.getField(pos2);
211 auto value3_xyz = mapper_xyz.getField(pos3);
212 auto value4_xyz = mapper_xyz.getField(pos4);
234 bfield_symmetry_random,
237 bdata::distribution = std::uniform_real_distribution<>(-10., 10.))) ^
239 bdata::distribution =
240 std::uniform_real_distribution<>(-10., 10.))) ^
242 bdata::distribution =
243 std::uniform_real_distribution<>(-20., 20.))) ^
248 std::vector<double> rPos;
249 std::vector<double> xPos;
250 std::vector<double> yPos;
251 std::vector<double> zPos;
257 double stepR = maxR / nBins;
258 double stepZ = maxZ / nBins;
259 double bStepR = maxBr / nBins;
260 double bStepZ = maxBz / nBins;
262 for (
size_t i = 0; i < nBins; i++) {
263 rPos.push_back(i * stepR);
264 xPos.push_back(i * stepR);
265 yPos.push_back(i * stepR);
266 zPos.push_back(i * stepZ);
269 std::vector<Acts::Vector2D> bField_rz;
270 for (
size_t i = 0; i < nBins * nBins; i++) {
275 [](std::array<size_t, 2> binsRZ, std::array<size_t, 2> nBinsRZ) {
276 return (binsRZ.at(1) * nBinsRZ.at(0) + binsRZ.at(0));
278 rPos, zPos, bField_rz, 1, 1,
true);
281 std::vector<size_t> nBins_rz = {rPos.size(), 2 * zPos.size() - 1};
282 std::vector<double> minima_rz = {0., -((nBins - 1) * stepZ)};
283 std::vector<double> maxima_rz = {nBins * stepR, nBins * stepZ};
284 BOOST_CHECK(mapper_rz.getNBins() == nBins_rz);
293 std::vector<Acts::Vector3D> bField_xyz;
294 for (
size_t i = 0; i < nBins * nBins * nBins; i++) {
295 bField_xyz.push_back(
Acts::Vector3D(i * bStepR, i * bStepR, i * bStepZ));
299 [](std::array<size_t, 3> binsXYZ, std::array<size_t, 3> nBinsXYZ) {
300 return (binsXYZ.at(0) * (nBinsXYZ.at(1) * nBinsXYZ.at(2)) +
301 binsXYZ.at(1) * nBinsXYZ.at(2) + binsXYZ.at(2));
303 xPos, yPos, zPos, bField_xyz, 1, 1,
true);
305 std::vector<size_t> nBins_xyz = {2 * xPos.size() - 1, 2 * yPos.size() - 1,
306 2 * zPos.size() - 1};
307 std::vector<double> minima_xyz = {
308 -((nBins - 1) * stepR), -((nBins - 1) * stepR), -((nBins - 1) * stepZ)};
309 std::vector<double> maxima_xyz = {nBins * stepR, nBins * stepR,
311 BOOST_CHECK(mapper_xyz.getNBins() == nBins_xyz);
325 auto value0_rz = mapper_rz.getField(pos0);
326 auto value1_rz = mapper_rz.getField(pos1);
327 auto value2_rz = mapper_rz.getField(pos2);
328 auto value3_rz = mapper_rz.getField(pos3);
329 auto value4_rz = mapper_rz.getField(pos4);
341 auto value0_xyz = mapper_xyz.getField(pos0);
342 auto value1_xyz = mapper_xyz.getField(pos1);
343 auto value2_xyz = mapper_xyz.getField(pos2);
344 auto value3_xyz = mapper_xyz.getField(pos3);
345 auto value4_xyz = mapper_xyz.getField(pos4);