Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-27 07:57:11

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/Surfaces/CurvilinearSurface.hpp"
0014 #include "Acts/Utilities/VectorHelpers.hpp"
0015 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0016 
0017 #include <cmath>
0018 
0019 using namespace Acts;
0020 
0021 namespace ActsTests {
0022 
0023 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0024 
0025 BOOST_AUTO_TEST_CASE(jacobian_test) {
0026   // (1a) Standard test with curvilinear not glazingly close to z axis
0027   Vector3 direction = Vector3(7., 8., 9.).normalized();
0028   CurvilinearSurface surface = CurvilinearSurface(direction);
0029   FreeToBoundMatrix f2cJacobian = surface.freeToBoundJacobian();
0030 
0031   double phi = VectorHelpers::phi(direction);
0032   double theta = VectorHelpers::theta(direction);
0033   double sinPhi = std::sin(phi);
0034   double cosPhi = std::cos(phi);
0035   double sinTheta = std::sin(theta);
0036   double cosTheta = std::cos(theta);
0037 
0038   CHECK_CLOSE_REL(f2cJacobian(eBoundLoc0, eFreePos0), -sinPhi, 1e-5);
0039   CHECK_CLOSE_REL(f2cJacobian(eBoundLoc0, eFreePos1), cosPhi, 1e-5);
0040   CHECK_CLOSE_REL(f2cJacobian(eBoundLoc1, eFreePos0), -cosPhi * cosTheta, 1e-5);
0041   CHECK_CLOSE_REL(f2cJacobian(eBoundLoc1, eFreePos1), -sinPhi * cosTheta, 1e-5);
0042   CHECK_CLOSE_REL(f2cJacobian(eBoundLoc1, eFreePos2), sinTheta, 1e-5);
0043   CHECK_CLOSE_REL(f2cJacobian(eBoundTime, eFreeTime), 1., 1e-5);
0044   CHECK_CLOSE_REL(f2cJacobian(eBoundPhi, eFreeDir0), -sinPhi / sinTheta, 1e-5);
0045   CHECK_CLOSE_REL(f2cJacobian(eBoundPhi, eFreeDir1), cosPhi / sinTheta, 1e-5);
0046   CHECK_CLOSE_REL(f2cJacobian(eBoundTheta, eFreeDir0), cosPhi * cosTheta, 1e-5);
0047   CHECK_CLOSE_REL(f2cJacobian(eBoundTheta, eFreeDir1), sinPhi * cosTheta, 1e-5);
0048   CHECK_CLOSE_REL(f2cJacobian(eBoundTheta, eFreeDir2), -sinTheta, 1e-5);
0049   CHECK_CLOSE_REL(f2cJacobian(eBoundQOverP, eFreeQOverP), 1., 1e-5);
0050 
0051   // (2a) Standard test with curvilinear not glazingly close to z axis
0052   direction = Vector3(7., 8., 9.).normalized();
0053   surface = CurvilinearSurface(direction);
0054   BoundToFreeMatrix c2fJacobian = surface.boundToFreeJacobian();
0055 
0056   phi = VectorHelpers::phi(direction);
0057   theta = VectorHelpers::theta(direction);
0058   sinPhi = std::sin(phi);
0059   cosPhi = std::cos(phi);
0060   sinTheta = std::sin(theta);
0061   cosTheta = std::cos(theta);
0062 
0063   CHECK_CLOSE_REL(c2fJacobian(eFreePos0, eBoundLoc0), -sinPhi, 1e-5);
0064   CHECK_CLOSE_REL(c2fJacobian(eFreePos0, eBoundLoc1), -cosPhi * cosTheta, 1e-5);
0065   CHECK_CLOSE_REL(c2fJacobian(eFreePos1, eBoundLoc0), cosPhi, 1e-5);
0066   CHECK_CLOSE_REL(c2fJacobian(eFreePos1, eBoundLoc1), -sinPhi * cosTheta, 1e-5);
0067   CHECK_CLOSE_REL(c2fJacobian(eFreePos2, eBoundLoc1), sinTheta, 1e-5);
0068   // Time parameter: stays as is
0069   CHECK_CLOSE_REL(c2fJacobian(eFreeTime, eBoundTime), 1, 1e-5);
0070   CHECK_CLOSE_REL(c2fJacobian(eFreeDir0, eBoundPhi), -sinTheta * sinPhi, 1e-5);
0071   CHECK_CLOSE_REL(c2fJacobian(eFreeDir0, eBoundTheta), cosTheta * cosPhi, 1e-5);
0072   CHECK_CLOSE_REL(c2fJacobian(eFreeDir1, eBoundPhi), sinTheta * cosPhi, 1e-5);
0073   CHECK_CLOSE_REL(c2fJacobian(eFreeDir1, eBoundTheta), cosTheta * sinPhi, 1e-5);
0074   CHECK_CLOSE_REL(c2fJacobian(eFreeDir2, eBoundTheta), -sinTheta, 1e-5);
0075   // Q/P parameter: stays as is
0076   CHECK_CLOSE_REL(c2fJacobian(eFreeQOverP, eBoundQOverP), 1, 1e-5);
0077 }
0078 
0079 BOOST_AUTO_TEST_SUITE_END()
0080 
0081 }  // namespace ActsTests