EIC 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 
18 #include "Acts/Utilities/Units.hpp"
19 
20 #include <limits>
21 
23 
24 namespace {
25 
26 using namespace Acts;
27 using namespace Acts::UnitLiterals;
28 using AnyFreeTrackParameters = SingleFreeTrackParameters<AnyCharge>;
29 
30 constexpr auto eps = 8 * std::numeric_limits<FreeScalar>::epsilon();
32 const FreeSymMatrix cov = FreeSymMatrix::Identity();
33 
34 template <typename charge_t>
35 void checkParameters(const SingleFreeTrackParameters<charge_t>& params,
36  const Vector4D& pos4, const Vector3D& unitDir, double p,
37  double q) {
38  const auto qOverP = (q != 0) ? (q / p) : (1 / p);
39  const auto pos = pos4.segment<3>(ePos0);
40 
41  // native values
42  CHECK_CLOSE_OR_SMALL(params.template get<eFreePos0>(), pos4[ePos0], eps, eps);
43  CHECK_CLOSE_OR_SMALL(params.template get<eFreePos1>(), pos4[ePos1], eps, eps);
44  CHECK_CLOSE_OR_SMALL(params.template get<eFreePos2>(), pos4[ePos2], eps, eps);
45  CHECK_CLOSE_OR_SMALL(params.template get<eFreeTime>(), pos4[eTime], eps, eps);
46  CHECK_CLOSE_OR_SMALL(params.template get<eFreeDir0>(), unitDir[eMom0], eps,
47  eps);
48  CHECK_CLOSE_OR_SMALL(params.template get<eFreeDir1>(), unitDir[eMom1], eps,
49  eps);
50  CHECK_CLOSE_OR_SMALL(params.template get<eFreeDir2>(), unitDir[eMom2], eps,
51  eps);
52  CHECK_CLOSE_OR_SMALL(params.template get<eFreeQOverP>(), qOverP, eps, eps);
53  // convenience accessors
56  CHECK_CLOSE_OR_SMALL(params.time(), pos4[eFreeTime], eps, eps);
60  p * unitDir.template head<2>().norm(), eps, eps);
61  CHECK_CLOSE_OR_SMALL(params.momentum(), p * unitDir, eps, eps);
62  BOOST_CHECK_EQUAL(params.charge(), q);
63  // self-consistency
65  params.parameters().template segment<3>(eFreePos0), eps,
66  eps);
67  CHECK_CLOSE_OR_SMALL(params.time(), params.template get<eFreeTime>(), eps,
68  eps);
69 }
70 
71 } // namespace
72 
73 BOOST_AUTO_TEST_SUITE(CurvilinearTrackParameters)
74 
76  NeutralConstructFromAngles,
77  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps, x, y, z,
78  time, phi, theta, p) {
79  Vector4D pos4(x, y, z, time);
80  Vector3D dir = makeDirectionUnitFromPhiTheta(phi, theta);
81 
82  NeutralFreeTrackParameters params(pos4, phi, theta, 1 / p);
83  checkParameters(params, pos4, dir, p, 0_e);
84  BOOST_CHECK(not params.covariance());
85 
86  // reassign w/ covariance
87  params = NeutralFreeTrackParameters(pos4, phi, theta, 1 / p, cov);
88  BOOST_CHECK(params.covariance());
89  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
90 }
91 
93  ChargedConstructFromAngles,
94  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
95  x, y, z, time, phi, theta, p, q) {
96  Vector4D pos4(x, y, z, time);
98 
99  FreeTrackParameters params(pos4, phi, theta, q / p);
100  checkParameters(params, pos4, dir, p, q);
101  BOOST_CHECK(not params.covariance());
102 
103  // reassign w/ covariance
104  params = FreeTrackParameters(pos4, phi, theta, q / p, cov);
105  BOOST_CHECK(params.covariance());
106  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
107 }
108 
110  AnyConstructFromAngles,
111  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
112  x, y, z, time, phi, theta, p, q) {
113  Vector4D pos4(x, y, z, time);
115 
116  AnyFreeTrackParameters params(pos4, phi, theta, p, q);
117  checkParameters(params, pos4, dir, p, q);
118  BOOST_CHECK(not params.covariance());
119 
120  // reassign w/ covariance
121  params = AnyFreeTrackParameters(pos4, phi, theta, p, q, cov);
122  BOOST_CHECK(params.covariance());
123  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
124 }
125 
126 BOOST_AUTO_TEST_SUITE_END()