EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CurvilinearTrackParametersTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CurvilinearTrackParametersTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-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/unit_test.hpp>
10 
15 #include "Acts/Utilities/Units.hpp"
17 
18 #include <limits>
19 
21 
22 namespace {
23 
24 using namespace Acts;
25 using namespace Acts::UnitLiterals;
26 using AnyCurvilinearTrackParameters =
28 
29 constexpr auto eps = 8 * std::numeric_limits<BoundScalar>::epsilon();
31 const BoundSymMatrix cov = BoundSymMatrix::Identity();
32 
33 template <typename charge_t>
34 void checkParameters(const SingleCurvilinearTrackParameters<charge_t>& params,
35  double phi, double theta, double p, double q,
36  const Vector4D& pos4, const Vector3D& unitDir) {
37  const auto qOverP = (q != 0) ? (q / p) : (1 / p);
38  const auto pos = pos4.segment<3>(ePos0);
39 
40  // native values
41  CHECK_SMALL(params.template get<eBoundLoc0>(), eps);
42  CHECK_SMALL(params.template get<eBoundLoc1>(), eps);
43  CHECK_CLOSE_OR_SMALL(params.template get<eBoundTime>(), pos4[eTime], eps,
44  eps);
45  CHECK_CLOSE_OR_SMALL(detail::radian_sym(params.template get<eBoundPhi>()),
46  detail::radian_sym(phi), eps, eps);
47  CHECK_CLOSE_OR_SMALL(params.template get<eBoundTheta>(), theta, eps, eps);
48  CHECK_CLOSE_OR_SMALL(params.template get<eBoundQOverP>(), qOverP, eps, eps);
49  // convenience accessorss
52  CHECK_CLOSE_OR_SMALL(params.time(), pos4[eTime], eps, eps);
55  CHECK_CLOSE_OR_SMALL(params.transverseMomentum(), p * std::sin(theta), eps,
56  eps);
57  CHECK_CLOSE_OR_SMALL(params.momentum(), p * unitDir, eps, eps);
58  BOOST_CHECK_EQUAL(params.charge(), q);
59  // curvilinear reference surface
62  eps);
63  // TODO verify reference frame
64 }
65 
66 } // namespace
67 
68 BOOST_AUTO_TEST_SUITE(EventDataCurvilinearTrackParameters)
69 
71  NeutralConstruct,
72  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps, x, y, z,
73  time, phiInput, theta, p) {
74  // phi is ill-defined in forward/backward tracks
75  const auto phi = ((0 < theta) and (theta < M_PI)) ? phiInput : 0.0;
76  const Vector4D pos4(x, y, z, time);
77  const Vector3D dir = makeDirectionUnitFromPhiTheta(phi, theta);
78 
79  NeutralCurvilinearTrackParameters params(pos4, dir, 1 / p);
80  checkParameters(params, phi, theta, p, 0_e, pos4, dir);
81  BOOST_CHECK(not params.covariance());
82 
83  // reassign w/ covariance
84  params = NeutralCurvilinearTrackParameters(pos4, dir, 1 / p, cov);
85  BOOST_CHECK(params.covariance());
86  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
87 }
88 
90  ChargedConstruct,
91  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
92  x, y, z, time, phiInput, theta, p, q) {
93  // phi is ill-defined in forward/backward tracks
94  const auto phi = ((0 < theta) and (theta < M_PI)) ? phiInput : 0.0;
95  const Vector4D pos4(x, y, z, time);
96  const Vector3D dir = makeDirectionUnitFromPhiTheta(phi, theta);
97 
98  CurvilinearTrackParameters params(pos4, dir, q / p);
99  checkParameters(params, phi, theta, p, q, pos4, dir);
100  BOOST_CHECK(not params.covariance());
101 
102  // reassign w/ covariance
103  params = CurvilinearTrackParameters(pos4, dir, q / p, cov);
104  BOOST_CHECK(params.covariance());
105  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
106 }
107 
109  AnyConstruct,
110  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsAny, x, y,
111  z, time, phiInput, theta, p, q) {
112  // phi is ill-defined in forward/backward tracks
113  const auto phi = ((0 < theta) and (theta < M_PI)) ? phiInput : 0.0;
114  const Vector4D pos4(x, y, z, time);
115  const Vector3D dir = makeDirectionUnitFromPhiTheta(phi, theta);
116 
117  AnyCurvilinearTrackParameters params(pos4, dir, p, q);
118  checkParameters(params, phi, theta, p, q, pos4, dir);
119  BOOST_CHECK(not params.covariance());
120 
121  // reassign w/ covariance
122  params = AnyCurvilinearTrackParameters(pos4, dir, p, q, cov);
123  BOOST_CHECK(params.covariance());
124  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
125 }
126 
127 BOOST_AUTO_TEST_SUITE_END()