Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransformFreeToBoundTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TransformFreeToBoundTests.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 <algorithm>
22 #include <cmath>
23 #include <limits>
24 #include <utility>
25 #include <vector>
26 
28 
29 using namespace Acts;
30 using namespace Acts::UnitLiterals;
31 
32 namespace {
33 constexpr auto eps = std::numeric_limits<ActsScalar>::epsilon();
34 }
35 
36 BOOST_AUTO_TEST_SUITE(TransformFreeToBound)
37 
39  GlobalToBoundTrackParameters,
40  surfaces* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
41  surface, l0, l1, time, phiInput, theta, p, q) {
42  // phi is ill-defined in forward/backward tracks
43  const auto phi = ((0 < theta) and (theta < M_PI)) ? phiInput : 0.0;
44  const auto qOverP = q / p;
45 
47  Vector2 loc(l0, l1);
49  // transform reference position
50  Vector3 pos = surface->localToGlobal(geoCtx, loc, dir);
51 
52  // convert free parameters to bound parameters
53  {
54  BOOST_TEST_INFO("Transform free parameters vector onto surface "
55  << surface->name());
56 
57  FreeVector fv = FreeVector::Zero();
58  fv[eFreePos0] = pos[ePos0];
59  fv[eFreePos1] = pos[ePos1];
60  fv[eFreePos2] = pos[ePos2];
61  fv[eFreeTime] = time;
62  fv[eFreeDir0] = dir[eMom0];
63  fv[eFreeDir1] = dir[eMom1];
64  fv[eFreeDir2] = dir[eMom2];
65  fv[eFreeQOverP] = qOverP;
66  BoundVector bv =
67  detail::transformFreeToBoundParameters(fv, *surface, geoCtx).value();
74  }
75 
76  // Assert failure when trying to convert a position that is not on-surface.
77  {
78  Vector3 posOff = pos + surface->normal(geoCtx, loc) * 0.5;
79  BOOST_TEST_INFO("Transform free parameters vector onto surface "
80  << surface->name());
81 
82  FreeVector fv = FreeVector::Zero();
83  fv[eFreePos0] = posOff[ePos0];
84  fv[eFreePos1] = posOff[ePos1];
85  fv[eFreePos2] = posOff[ePos2];
86  fv[eFreeTime] = time;
87  fv[eFreeDir0] = dir[eMom0];
88  fv[eFreeDir1] = dir[eMom1];
89  fv[eFreeDir2] = dir[eMom2];
90  fv[eFreeQOverP] = qOverP;
91  auto res = detail::transformFreeToBoundParameters(fv, *surface, geoCtx);
92  BOOST_CHECK(!res.ok());
93  }
94 
95  // convert separate components to bound parameters
96  {
97  BOOST_TEST_INFO("Transform free parameters components onto surface "
98  << surface->name());
99 
101  pos, time, dir, qOverP, *surface, geoCtx)
102  .value();
105  CHECK_CLOSE_OR_SMALL(bv[eBoundTime], time, eps, eps);
107  CHECK_CLOSE_OR_SMALL(bv[eBoundTheta], theta, eps, eps);
108  CHECK_CLOSE_OR_SMALL(bv[eBoundQOverP], qOverP, eps, eps);
109  }
110 
111  // Assert failure when trying to convert a position that is not on-surface.
112  {
113  BOOST_TEST_INFO("Transform free parameters components onto surface "
114  << surface->name());
115 
116  Vector3 posOff = pos + surface->normal(geoCtx, loc) * 0.5;
117  auto res = detail::transformFreeToBoundParameters(posOff, time, dir, qOverP,
118  *surface, geoCtx);
119  BOOST_CHECK(!res.ok());
120  }
121 }
122 
123 BOOST_DATA_TEST_CASE(GlobalToCurvilinearParameters,
124  ts* phis* thetas* ps* qsNonZero, time, phiInput, theta, p,
125  q) {
126  // phi is ill-defined in forward/backward tracks
127  const auto phi = ((0 < theta) and (theta < M_PI)) ? phiInput : 0.0;
128  const auto qOverP = q / p;
129 
132 
133  // convert w/ direction
134  {
135  BoundVector bv =
137  CHECK_SMALL(bv[eBoundLoc0], eps);
138  CHECK_SMALL(bv[eBoundLoc1], eps);
142  CHECK_CLOSE_OR_SMALL(bv[eBoundQOverP], qOverP, eps, eps);
143  }
144  // convert w/ angles
145  {
146  BoundVector bv =
148  CHECK_SMALL(bv[eBoundLoc0], eps);
149  CHECK_SMALL(bv[eBoundLoc1], eps);
153  CHECK_CLOSE_OR_SMALL(bv[eBoundQOverP], qOverP, eps, eps);
154  }
155 }
156 
157 BOOST_AUTO_TEST_SUITE_END()