Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FreeTrackParametersTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FreeTrackParametersTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 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 
22 
23 #include <limits>
24 #include <optional>
25 #include <utility>
26 #include <vector>
27 
29 
30 namespace {
31 
32 using namespace Acts;
33 using namespace Acts::UnitLiterals;
34 
35 constexpr auto eps = 8 * std::numeric_limits<ActsScalar>::epsilon();
37 const FreeSquareMatrix cov = FreeSquareMatrix::Identity();
38 
39 void checkParameters(const FreeTrackParameters& params, const Vector4& pos4,
40  const Vector3& unitDir, double p, double q) {
41  const auto qOverP = (q != 0) ? (q / p) : (1 / p);
42  const auto pos = pos4.segment<3>(ePos0);
43 
44  // native values
45  CHECK_CLOSE_OR_SMALL(params.template get<eFreePos0>(), pos4[ePos0], eps, eps);
46  CHECK_CLOSE_OR_SMALL(params.template get<eFreePos1>(), pos4[ePos1], eps, eps);
47  CHECK_CLOSE_OR_SMALL(params.template get<eFreePos2>(), pos4[ePos2], eps, eps);
48  CHECK_CLOSE_OR_SMALL(params.template get<eFreeTime>(), pos4[eTime], eps, eps);
49  CHECK_CLOSE_OR_SMALL(params.template get<eFreeDir0>(), unitDir[eMom0], eps,
50  eps);
51  CHECK_CLOSE_OR_SMALL(params.template get<eFreeDir1>(), unitDir[eMom1], eps,
52  eps);
53  CHECK_CLOSE_OR_SMALL(params.template get<eFreeDir2>(), unitDir[eMom2], eps,
54  eps);
55  CHECK_CLOSE_OR_SMALL(params.template get<eFreeQOverP>(), qOverP, eps, eps);
56  // convenience accessors
59  CHECK_CLOSE_OR_SMALL(params.time(), pos4[eFreeTime], eps, eps);
63  p * unitDir.template head<2>().norm(), eps, eps);
64  CHECK_CLOSE_OR_SMALL(params.momentum(), p * unitDir, eps, eps);
65  BOOST_CHECK_EQUAL(params.charge(), q);
66  // self-consistency
68  params.parameters().template segment<3>(eFreePos0), eps,
69  eps);
70  CHECK_CLOSE_OR_SMALL(params.time(), params.template get<eFreeTime>(), eps,
71  eps);
72 }
73 
74 } // namespace
75 
76 BOOST_AUTO_TEST_SUITE(CurvilinearTrackParameters)
77 
79  NeutralConstructFromAngles,
80  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps, x, y, z,
81  time, phi, theta, p) {
82  Vector4 pos4(x, y, z, time);
83  Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
84 
85  FreeTrackParameters params(pos4, phi, theta, 1 / p, std::nullopt,
87  checkParameters(params, pos4, dir, p, 0_e);
88  BOOST_CHECK(not params.covariance());
89 
90  // reassign w/ covariance
91  params = FreeTrackParameters(pos4, phi, theta, 1 / p, cov,
93  BOOST_CHECK(params.covariance());
94  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
95 }
96 
98  ChargedConstructFromAngles,
99  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
100  x, y, z, time, phi, theta, p, q) {
101  Vector4 pos4(x, y, z, time);
103 
104  FreeTrackParameters params(pos4, phi, theta, q / p, std::nullopt,
105  ParticleHypothesis::pionLike(std::abs(q)));
106  checkParameters(params, pos4, dir, p, q);
107  BOOST_CHECK(not params.covariance());
108 
109  // reassign w/ covariance
110  params = FreeTrackParameters(pos4, phi, theta, q / p, cov,
111  ParticleHypothesis::pionLike(std::abs(q)));
112  BOOST_CHECK(params.covariance());
113  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
114 }
115 
117  AnyConstructFromAngles,
118  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
119  x, y, z, time, phi, theta, p, q) {
120  Vector4 pos4(x, y, z, time);
122 
123  FreeTrackParameters params(pos4, phi, theta, q / p, std::nullopt,
124  ParticleHypothesis::pionLike(std::abs(q)));
125  checkParameters(params, pos4, dir, p, q);
126  BOOST_CHECK(not params.covariance());
127 
128  // reassign w/ covariance
129  params = FreeTrackParameters(pos4, phi, theta, q / p, cov,
130  ParticleHypothesis::pionLike(std::abs(q)));
131  BOOST_CHECK(params.covariance());
132  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
133 }
134 
135 BOOST_AUTO_TEST_SUITE_END()