ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PropagationTestBase.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PropagationTestBase.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2019 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 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
11 
12 #include <cmath>
13 
17 #include "Acts/Utilities/Units.hpp"
18 
19 using namespace Acts::UnitLiterals;
20 
21 unsigned int itest = 0;
22 
23 // datasets for Boost::Test data-driven test cases
24 namespace ds {
25 // track parameters
26 auto pT = bdata::xrange(0.5_GeV, 10_GeV, 500_MeV);
27 auto phi = bdata::xrange(-180_degree, 180_degree, 30_degree);
28 auto theta = bdata::xrange(15_degree, 90_degree, 15_degree);
29 auto charge = bdata::make({1_e, -1_e});
30 // combined track parameters as cartesian product of all possible combinations
32 auto propagationFraction = bdata::xrange(0.0, 1.0, 0.25);
33 auto propagationLimit = bdata::xrange(10_cm, 1_m, 10_cm);
34 // additional random numbers
35 auto rand1 = bdata::random(
36  (bdata::seed = 1515,
37  bdata::distribution = std::uniform_real_distribution<>(-1., 1.)));
38 auto rand2 = bdata::random(
39  (bdata::seed = 1616,
40  bdata::distribution = std::uniform_real_distribution<>(-1., 1.)));
41 auto rand3 = bdata::random(
42  (bdata::seed = 1717,
43  bdata::distribution = std::uniform_real_distribution<>(-1., 1.)));
45 } // namespace ds
46 
48 BOOST_DATA_TEST_CASE(forward_backward_propagation_,
50  charge, plimit) {
51  ++itest;
52 
53  // foward backward check atlas stepper
55  debug);
56  // foward backward check eigen stepper
58  debug);
59  // foward backward check straight line stepper
61  debug);
62 }
63 
65 BOOST_DATA_TEST_CASE(propagation_to_cylinder_,
68  pT, phi, theta, charge, pfrac, rand1, rand2, rand3) {
69  // just make sure we can reach it
70  double r = pfrac * std::abs(pT / Bz);
71  r = (r > 2.5_m) ? 2.5_m : r;
72 
73  if (r > 0.) {
74  // check atlas stepper
75  auto a_at_cylinder = to_cylinder(apropagator, pT, phi, theta, charge, r,
77  // check eigen stepper
78  auto e_at_cylinder = to_cylinder(epropagator, pT, phi, theta, charge, r,
80  CHECK_CLOSE_ABS(e_at_cylinder.first, a_at_cylinder.first, 10_um);
81 
82  // check without charge
83  auto s_at_cylinder = to_cylinder(spropagator, pT, phi, theta, 0., r, rand1,
84  rand2, rand3, covtpr, debug);
85  e_at_cylinder = to_cylinder(epropagator, pT, phi, theta, 0., r, rand1,
86  rand2, rand3, covtpr, debug);
87 
88  CHECK_CLOSE_ABS(s_at_cylinder.first, e_at_cylinder.first, 1_um);
89  }
90 }
91 
93 BOOST_DATA_TEST_CASE(propagation_to_plane_,
96  pT, phi, theta, charge, plimit, rand1, rand2, rand3) {
97  // to a plane with the atlas stepper
98  auto a_at_plane = to_surface<AtlasPropagatorType, PlaneSurface>(
99  apropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3, true,
100  covtpr);
101  // to a plane with the eigen stepper
102  auto e_at_plane = to_surface<EigenPropagatorType, PlaneSurface>(
103  epropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3, true,
104  covtpr);
105  CHECK_CLOSE_ABS(e_at_plane.first, a_at_plane.first, 1_um);
106 
107  // to a plane with the straight line stepper
108  auto s_at_plane = to_surface<StraightPropagatorType, PlaneSurface>(
109  spropagator, pT, phi, theta, 0., plimit, rand1, rand2, rand3, true,
110  covtpr);
111  // to a plane with the eigen stepper without charge
112  e_at_plane = to_surface<EigenPropagatorType, PlaneSurface>(
113  epropagator, pT, phi, theta, 0., plimit, rand1, rand2, rand3, true,
114  covtpr);
115  CHECK_CLOSE_ABS(e_at_plane.first, s_at_plane.first, 1_um);
116 }
117 
119 BOOST_DATA_TEST_CASE(propagation_to_disc_,
122  pT, phi, theta, charge, plimit, rand1, rand2, rand3) {
123  // to a disc with the atlas stepper
124  auto a_at_disc = to_surface<AtlasPropagatorType, DiscSurface>(
125  apropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3, true,
126  covtpr);
127  // to a disc with the eigen stepper
128  auto e_at_disc = to_surface<EigenPropagatorType, DiscSurface>(
129  epropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3, true,
130  covtpr);
131  CHECK_CLOSE_ABS(e_at_disc.first, a_at_disc.first, 1_um);
132 
133  // to a disc with the straight line stepper
134  auto s_at_disc = to_surface<StraightPropagatorType, DiscSurface>(
135  spropagator, pT, phi, theta, 0., plimit, rand1, rand2, rand3, true,
136  covtpr);
137  // to a disc with the eigen stepper without charge
138  e_at_disc = to_surface<EigenPropagatorType, DiscSurface>(
139  epropagator, pT, phi, theta, 0., plimit, rand1, rand2, rand3, true,
140  covtpr);
141 
142  CHECK_CLOSE_ABS(e_at_disc.first, s_at_disc.first, 1_um);
143 }
144 
146 BOOST_DATA_TEST_CASE(propagation_to_line_,
149  pT, phi, theta, charge, plimit, rand1, rand2, rand3) {
150  // to a line with the atlas stepper
151  if (debug) {
152  std::cout << "[ >>>> Testing Atlas Propagator <<<< ]" << std::endl;
153  }
154  auto a_at_line = to_surface<AtlasPropagatorType, StrawSurface>(
155  apropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3, false,
156  covtpr, debug);
157  // to a line with the eigen stepper
158  if (debug) {
159  std::cout << "[ >>>> Testing Eigen Propagator <<<< ]" << std::endl;
160  }
161  auto e_at_line = to_surface<EigenPropagatorType, StrawSurface>(
162  epropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3, false,
163  covtpr, debug);
164  CHECK_CLOSE_ABS(e_at_line.first, a_at_line.first, 10_um);
165 
166  if (debug) {
167  std::cout << "[ >>>> Testing Neutral Propagators <<<< ]" << std::endl;
168  }
169  // to a straw with the straight line stepper
170  auto s_at_line = to_surface<StraightPropagatorType, StrawSurface>(
171  spropagator, pT, phi, theta, 0., plimit, rand1, rand2, rand3, false,
172  covtpr, debug);
173  // to a straw with the eigen stepper without charge
174  e_at_line = to_surface<EigenPropagatorType, StrawSurface>(
175  epropagator, pT, phi, theta, 0., plimit, rand1, rand2, rand3, false,
176  covtpr, debug);
177 
178  CHECK_CLOSE_ABS(e_at_line.first, s_at_line.first, 1_um);
179 }
180 
184 BOOST_DATA_TEST_CASE(covariance_transport_curvilinear_curvilinear_,
186  charge, plimit) {
187  // covariance check for straight line stepper
191  1e-3);
192  // covariance check for eigen stepper
196  1e-3);
197  // covariance check fo atlas stepper
201  1e-3);
202 }
203 
204 // test correct covariance transport from disc to disc
205 BOOST_DATA_TEST_CASE(covariance_transport_disc_disc_,
208  pT, phi, theta, charge, plimit, rand1, rand2, rand3) {
209  // covariance check for straight line stepper
210  auto covCalculated =
211  covariance_bound<RiddersStraightPropagatorType, DiscSurface, DiscSurface>(
212  rspropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3,
213  true, true);
214  auto covObtained =
215  covariance_bound<StraightPropagatorType, DiscSurface, DiscSurface>(
216  spropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3,
217  true, true);
218  if (covCalculated != Covariance::Zero()) {
219  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 5e-1);
220  }
221 
222  // covariance check for eigen stepper
223  covCalculated =
224  covariance_bound<RiddersEigenPropagatorType, DiscSurface, DiscSurface>(
225  repropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3,
226  true, true);
227  covObtained = covariance_bound<EigenPropagatorType, DiscSurface, DiscSurface>(
228  epropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3, true,
229  true);
230  if (covCalculated != Covariance::Zero()) {
231  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 1e-1);
232  }
233 
234  // covariance check for atlas stepper
235  covCalculated =
236  covariance_bound<RiddersAtlasPropagatorType, DiscSurface, DiscSurface>(
237  rapropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3,
238  true, true);
239  covObtained = covariance_bound<AtlasPropagatorType, DiscSurface, DiscSurface>(
240  apropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3, true,
241  true);
242  if (covCalculated != Covariance::Zero()) {
243  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 1e-1);
244  }
245 }
246 
247 // test correct covariance transport from plane to plane
248 BOOST_DATA_TEST_CASE(covariance_transport_plane_plane_,
251  pT, phi, theta, charge, plimit, rand1, rand2, rand3) {
252  // covariance check for straight line stepper
253  auto covCalculated = covariance_bound<RiddersStraightPropagatorType,
254  PlaneSurface, PlaneSurface>(
255  rspropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3);
256  auto covObtained =
257  covariance_bound<StraightPropagatorType, PlaneSurface, PlaneSurface>(
258  spropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3);
259  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 1e-3);
260 
261  // covariance check for eigen stepper
262  covCalculated =
263  covariance_bound<RiddersEigenPropagatorType, PlaneSurface, PlaneSurface>(
264  repropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3);
265  covObtained =
266  covariance_bound<EigenPropagatorType, PlaneSurface, PlaneSurface>(
267  epropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3);
268  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 1e-2);
269 
270  // covariance check for atlas stepper
271  covCalculated =
272  covariance_bound<RiddersAtlasPropagatorType, PlaneSurface, PlaneSurface>(
273  rapropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3);
274  covObtained =
275  covariance_bound<AtlasPropagatorType, PlaneSurface, PlaneSurface>(
276  apropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3);
277  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 1e-2);
278 }
279 
280 // test correct covariance transport from straw to straw
281 // for straw surfaces the numerical fixture is actually more difficult
282 // to calculate
283 BOOST_DATA_TEST_CASE(covariance_transport_line_line_,
286  pT, phi, theta, charge, plimit, rand1, rand2, rand3) {
287  // covariance check for straight line stepper
288  auto covCalculated =
290  StrawSurface>(rspropagator, pT, phi, theta, charge,
291  plimit, rand1, rand2, rand3, false, false);
292  auto covObtained =
293  covariance_bound<StraightPropagatorType, StrawSurface, StrawSurface>(
294  spropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3,
295  false, false);
296  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 1e-1);
297 
298  // covariance check for eigen stepper
299  covCalculated =
300  covariance_bound<RiddersEigenPropagatorType, StrawSurface, StrawSurface>(
301  repropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3,
302  false, false);
303  covObtained =
304  covariance_bound<EigenPropagatorType, StrawSurface, StrawSurface>(
305  epropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3,
306  false, false);
307  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 1e-1);
308 
309  // covariance check for atlas stepper
310  covCalculated =
311  covariance_bound<RiddersAtlasPropagatorType, StrawSurface, StrawSurface>(
312  rapropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3,
313  false, false);
314  covObtained =
315  covariance_bound<AtlasPropagatorType, StrawSurface, StrawSurface>(
316  apropagator, pT, phi, theta, charge, plimit, rand1, rand2, rand3,
317  false, false);
318  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 1e-1);
319 }
320 
325 BOOST_DATA_TEST_CASE(dense_covariance_transport_curvilinear_curvilinear_,
327  rand1, rand2, rand3) {
328  // covariance check for eigen stepper in dense environment
330  RiddersPropagator rdpropagator(dpropagator);
331 
333  covariance_curvilinear(rdpropagator, pT, 0_degree, 45_degree, 1_e,
334  plimit),
335  covariance_curvilinear(dpropagator, pT, 0_degree, 45_degree, 1_e, plimit),
336  3e-1);
337 
338  auto covCalculated =
339  covariance_bound<RiddersPropagator<DensePropagatorType>, DiscSurface,
340  DiscSurface>(rdpropagator, pT, 0_degree, 45_degree, 1_e,
341  plimit, rand1, rand2, rand3, true, true);
342  auto covObtained =
343  covariance_bound<DensePropagatorType, DiscSurface, DiscSurface>(
344  dpropagator, pT, 0_degree, 45_degree, 1_e, plimit, rand1, rand2,
345  rand3, true, true);
346  if (covCalculated != Covariance::Zero()) {
347  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 8e-1);
348  }
349 
350  covCalculated = covariance_bound<RiddersPropagator<DensePropagatorType>,
351  PlaneSurface, PlaneSurface>(
352  rdpropagator, pT, 0_degree, 45_degree, 1, plimit, rand1, rand2, rand3);
353  covObtained =
354  covariance_bound<DensePropagatorType, PlaneSurface, PlaneSurface>(
355  dpropagator, pT, 0_degree, 45_degree, 1, plimit, rand1, rand2, rand3);
356  CHECK_CLOSE_COVARIANCE(covCalculated, covObtained, 8e-1);
357 }