Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PropagationCompareEigenAutodiff.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PropagationCompareEigenAutodiff.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 
20 
21 #include <limits>
22 
23 #include "../PropagationDatasets.hpp"
24 #include "../PropagationTests.hpp"
25 
26 namespace {
27 
28 namespace ds = ActsTests::PropagationDatasets;
29 using namespace Acts::UnitLiterals;
30 
34 
35 using Extension =
37 using AutodiffStepper =
39 using AutodiffPropagator = Acts::Propagator<AutodiffStepper>;
40 
41 // absolute parameter tolerances for position, direction, and absolute momentum
42 constexpr auto epsPos = 1_um;
43 constexpr auto epsDir = 0.125_mrad;
44 constexpr auto epsMom = 1_eV;
45 // relative covariance tolerance
46 constexpr auto epsCov = 0.00125;
47 
48 constexpr auto bz = 2_T;
49 
52 const auto magFieldZero =
53  std::make_shared<MagneticField>(Acts::Vector3::Zero());
54 const auto magFieldNonZero =
55  std::make_shared<MagneticField>(Acts::Vector3::UnitZ() * bz);
56 const EigenPropagator eigenPropagatorZero{EigenStepper(magFieldZero)};
57 const AutodiffPropagator autodiffPropagatorZero{AutodiffStepper(magFieldZero)};
58 
59 } // namespace
60 
61 BOOST_AUTO_TEST_SUITE(PropagationCompareEigenAutodiff)
62 
63 // TODO both the eigen stepper and the straight line stepper do not seem to
64 // handle the neutral parameters correctly. the results contain inf/nan.
65 // fix the propagators and re-enable the tests.
66 
67 // BOOST_DATA_TEST_CASE(NeutralZeroMagneticField,
68 // ds::phi* ds::theta* ds::absMomentum* ds::pathLength,
69 // phi, theta, p, s) {
70 // runFreePropagationComparisonTest(
71 // eigenPropagatorZero, straightPropagator, geoCtx, magCtx,
72 // makeParametersCurvilinearNeutral(phi, theta, p), s, epsPos, epsDir,
73 // epsMom, epsCov, showDebug);
74 // }
75 
76 // BOOST_DATA_TEST_CASE(NeutralNonZeroMagneticField,
77 // ds::phi* ds::theta* ds::absMomentum* ds::pathLength,
78 // phi, theta, p, s) {
79 // runFreePropagationComparisonTest(
80 // eigenPropagatorNonZero, straightPropagator, geoCtx, magCtx,
81 // makeParametersCurvilinearNeutral(phi, theta, p), s, epsPos, epsDir,
82 // epsMom, epsCov, showDebug);
83 // }
84 
86  ChargedZeroMagneticField,
87  ds::phi* ds::theta* ds::absMomentum* ds::chargeNonZero* ds::pathLength, phi,
88  theta, p, q, s) {
89  runForwardComparisonTest(eigenPropagatorZero, autodiffPropagatorZero, geoCtx,
90  magCtx, makeParametersCurvilinear(phi, theta, p, q),
91  s, epsPos, epsDir, epsMom, epsCov);
92 }
93 
94 // TODO add comparison tests between the straight line and eigen propagator for
95 // a charged particle w/ infinite momentum in a non-zero magnetic field.
96 // these should be identical. requires proper handling of q/p=0 in the
97 // track parameters.
98 
99 BOOST_AUTO_TEST_SUITE_END()