ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CurvilinearParametersTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CurvilinearParametersTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-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/unit_test.hpp>
10 
15 #include "Acts/Utilities/Units.hpp"
16 
17 #include "ParametersTestHelper.hpp"
18 
19 namespace Acts {
20 using VectorHelpers::phi;
22 namespace Test {
23 
26 BOOST_AUTO_TEST_CASE(curvilinear_initialization) {
27  using namespace Acts::UnitLiterals;
28 
29  // Create a test context
31 
32  // some position and momentum
33  Vector3D pos(1.34_mm, 2.34_mm, 3.45_mm);
34  Vector3D mom(1000_GeV, 1000_GeV, -0.100_GeV);
35  Vector3D dir(mom.normalized());
36  Vector3D z_axis_global(0., 0., 1.);
38  CurvilinearParameters curvilinear_pos(std::nullopt, pos, mom, 1_e, 1_s);
39  CurvilinearParameters curvilinear_neg(std::nullopt, pos, mom, -1_e, 2.5_s);
40  NeutralCurvilinearParameters curvilinear_neut(std::nullopt, pos, mom,
41  33.33_s);
42 
44  const auto fphi = phi(mom);
45  const auto ftheta = theta(mom);
46  const double oOp = 1. / mom.norm();
47 
48  // check parameters
49  consistencyCheck(curvilinear_pos, pos, mom, +1_e, 1_s,
50  {0., 0., fphi, ftheta, oOp, 1_s});
51  consistencyCheck(curvilinear_neg, pos, mom, -1_e, 2.5_s,
52  {0., 0., fphi, ftheta, -oOp, 2.5_s});
53  consistencyCheck(curvilinear_neut, pos, mom, 0., 33.33_s,
54  {0., 0., fphi, ftheta, oOp, 33.33_s});
55 
56  // check that the created surface is at the position
58  1e-6);
60  1e-6);
62  1e-6);
63 
64  // check that the z-axis of the created surface is along momentum direction
65  CHECK_CLOSE_REL(curvilinear_pos.referenceSurface().normal(tgContext, pos),
66  dir, 1e-6);
67  CHECK_CLOSE_REL(curvilinear_neg.referenceSurface().normal(tgContext, pos),
68  dir, 1e-6);
69  CHECK_CLOSE_REL(curvilinear_neut.referenceSurface().normal(tgContext, pos),
70  dir, 1e-6);
71 
72  // check the reference frame of curvilinear parameters
73  // it is the x-y frame of the created surface
74  RotationMatrix3D mFrame = RotationMatrix3D::Zero();
75  Vector3D tAxis = dir;
76  Vector3D uAxis = (z_axis_global.cross(tAxis)).normalized();
77  Vector3D vAxis = tAxis.cross(uAxis);
78  mFrame.col(0) = uAxis;
79  mFrame.col(1) = vAxis;
80  mFrame.col(2) = tAxis;
81  CHECK_CLOSE_OR_SMALL(mFrame, curvilinear_pos.referenceFrame(tgContext), 1e-6,
82  1e-9);
83  CHECK_CLOSE_OR_SMALL(mFrame, curvilinear_neg.referenceFrame(tgContext), 1e-6,
84  1e-9);
85  CHECK_CLOSE_OR_SMALL(mFrame, curvilinear_neut.referenceFrame(tgContext), 1e-6,
86  1e-9);
87 
89  CurvilinearParameters curvilinear_pos_copy(curvilinear_pos);
90  CurvilinearParameters curvilinear_neg_copy(curvilinear_neg);
91  NeutralCurvilinearParameters curvilinear_neut_copy(curvilinear_neut);
92 
93  BOOST_CHECK_EQUAL(curvilinear_pos_copy, curvilinear_pos);
94  BOOST_CHECK_EQUAL(curvilinear_neg_copy, curvilinear_neg);
95  BOOST_CHECK_EQUAL(curvilinear_neut_copy, curvilinear_neut);
96 
98  double ux = 0.1_mm;
99  double uy = 0.5_mm;
100  curvilinear_pos_copy.set<eLOC_0>(tgContext, ux);
101  curvilinear_pos_copy.set<eLOC_1>(tgContext, uy);
102  // the local parameter should still be (0,0) for Curvilinear
103  BOOST_CHECK_EQUAL(curvilinear_pos_copy.parameters()[eLOC_0], 0u);
104  BOOST_CHECK_EQUAL(curvilinear_pos_copy.parameters()[eLOC_1], 0u);
105  // the position should be updated though
106  Vector3D uposition =
107  curvilinear_neg_copy.referenceSurface().transform(tgContext) *
108  Vector3D(ux, uy, 0.);
109  // the position should be updated
110  CHECK_CLOSE_REL(curvilinear_pos_copy.position(), uposition, 1e-6);
111  // it should be the position of the surface
112  CHECK_CLOSE_REL(curvilinear_pos_copy.referenceSurface().center(tgContext),
113  uposition, 1e-6);
114 
115  double uphi = 1.2;
116  double utheta = 0.2;
117  double uqop = 0.025_e / 1_GeV;
118  double ut = 1337_s;
119 
120  curvilinear_pos_copy.set<ePHI>(tgContext, uphi);
121  curvilinear_pos_copy.set<eTHETA>(tgContext, utheta);
122  curvilinear_pos_copy.set<eQOP>(tgContext, uqop);
123  curvilinear_pos_copy.set<eT>(tgContext, ut);
124  // we should have a new updated momentum
125  Vector3D umomentum =
126  40. *
127  Vector3D(cos(uphi) * sin(utheta), sin(uphi) * sin(utheta), cos(utheta)) *
128  1_GeV;
129  CHECK_CLOSE_REL(umomentum, curvilinear_pos_copy.momentum(), 1e-6);
130  // the updated momentum should be the col(2) of the transform
131  CHECK_CLOSE_REL(umomentum.normalized(),
132  curvilinear_pos_copy.referenceSurface()
133  .transform(tgContext)
134  .rotation()
135  .col(2),
136  1e-6);
137 }
138 } // namespace Test
139 } // namespace Acts