Analysis Software
Documentation for sPHENIX simulation 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 
22 
23 #include <cmath>
24 #include <limits>
25 #include <optional>
26 #include <utility>
27 #include <vector>
28 
30 
31 namespace {
32 
33 using namespace Acts;
34 using namespace Acts::UnitLiterals;
35 
36 constexpr auto eps = 8 * std::numeric_limits<ActsScalar>::epsilon();
38 const BoundSquareMatrix cov = BoundSquareMatrix::Identity();
39 
40 void checkParameters(const CurvilinearTrackParameters& params, double phi,
41  double theta, double p, double q, const Vector4& pos4,
42  const Vector3& unitDir) {
43  const auto qOverP = (q != 0) ? (q / p) : (1 / p);
44  const auto pos = pos4.segment<3>(ePos0);
45 
46  // native values
47  CHECK_SMALL(params.template get<eBoundLoc0>(), eps);
48  CHECK_SMALL(params.template get<eBoundLoc1>(), eps);
49  CHECK_CLOSE_OR_SMALL(params.template get<eBoundTime>(), pos4[eTime], eps,
50  eps);
51  CHECK_CLOSE_OR_SMALL(detail::radian_sym(params.template get<eBoundPhi>()),
52  detail::radian_sym(phi), eps, eps);
53  CHECK_CLOSE_OR_SMALL(params.template get<eBoundTheta>(), theta, eps, eps);
54  CHECK_CLOSE_OR_SMALL(params.template get<eBoundQOverP>(), qOverP, eps, eps);
55  // convenience accessorss
58  CHECK_CLOSE_OR_SMALL(params.time(), pos4[eTime], eps, eps);
61  CHECK_CLOSE_OR_SMALL(params.transverseMomentum(), p * std::sin(theta), eps,
62  eps);
63  CHECK_CLOSE_OR_SMALL(params.momentum(), p * unitDir, eps, eps);
64  BOOST_CHECK_EQUAL(params.charge(), q);
65  // curvilinear reference surface
68  eps);
69  // TODO verify reference frame
70 }
71 
72 } // namespace
73 
74 BOOST_AUTO_TEST_SUITE(EventDataCurvilinearTrackParameters)
75 
77  NeutralConstruct,
78  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps, x, y, z,
79  time, phiInput, theta, p) {
80  // phi is ill-defined in forward/backward tracks
81  const auto phi = ((0 < theta) and (theta < M_PI)) ? phiInput : 0.0;
82  const Vector4 pos4(x, y, z, time);
83  const Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
84 
85  CurvilinearTrackParameters params(pos4, dir, 1 / p, std::nullopt,
87  checkParameters(params, phi, theta, p, 0_e, pos4, dir);
88  BOOST_CHECK(not params.covariance());
89 
90  // reassign w/ covariance
91  params = CurvilinearTrackParameters(pos4, dir, 1 / p, cov,
93  BOOST_CHECK(params.covariance());
94  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
95 }
96 
98  ChargedConstruct,
99  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
100  x, y, z, time, phiInput, theta, p, q) {
101  // phi is ill-defined in forward/backward tracks
102  const auto phi = ((0 < theta) and (theta < M_PI)) ? phiInput : 0.0;
103  const Vector4 pos4(x, y, z, time);
104  const Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
105 
106  CurvilinearTrackParameters params(pos4, dir, q / p, std::nullopt,
107  ParticleHypothesis::pionLike(std::abs(q)));
108  checkParameters(params, phi, theta, p, q, pos4, dir);
109  BOOST_CHECK(not params.covariance());
110 
111  // reassign w/ covariance
113  pos4, dir, q / p, cov, ParticleHypothesis::pionLike(std::abs(q)));
114  BOOST_CHECK(params.covariance());
115  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
116 }
117 
119  AnyConstruct,
120  posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsAny, x, y,
121  z, time, phiInput, theta, p, q) {
122  // phi is ill-defined in forward/backward tracks
123  const auto phi = ((0 < theta) and (theta < M_PI)) ? phiInput : 0.0;
124  const Vector4 pos4(x, y, z, time);
125  const Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
126 
128  auto qOverP = particleHypothesis.qOverP(p, q);
129 
130  CurvilinearTrackParameters params(pos4, dir, qOverP, std::nullopt,
132  checkParameters(params, phi, theta, p, q, pos4, dir);
133  BOOST_CHECK(not params.covariance());
134 
135  // reassign w/ covariance
136  params =
138  BOOST_CHECK(params.covariance());
139  BOOST_CHECK_EQUAL(params.covariance().value(), cov);
140 }
141 
142 BOOST_AUTO_TEST_SUITE_END()