Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:20

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 // Project include(s).
0010 #include "detray/geometry/coordinates/cartesian3D.hpp"
0011 
0012 #include "detray/definitions/units.hpp"
0013 #include "detray/geometry/concepts.hpp"
0014 
0015 // Detray test include(s)
0016 #include "detray/test/framework/types.hpp"
0017 
0018 // GTest include(s).
0019 #include <gtest/gtest.h>
0020 
0021 using namespace detray;
0022 
0023 using test_algebra = test::algebra;
0024 using scalar = test::scalar;
0025 using point3 = test::point3;
0026 using vector3 = test::vector3;
0027 using transform3 = test::transform3;
0028 
0029 const scalar isclose{1e-5f};
0030 
0031 // This test cartesian3D coordinate
0032 GTEST_TEST(detray_coordinates, cartesian3D) {
0033   // Preparation work
0034   const vector3 z = {0.f, 0.f, 1.f};
0035   const vector3 x = {1.f, 0.f, 0.f};
0036   const point3 t = {2.f, 3.f, 4.f};
0037   const transform3 trf(t, z, x);
0038   const point3 global1 = {4.f, 7.f, 5.f};
0039   const vector3 mom = {1.f, 2.f, 3.f};
0040   const vector3 d = vector::normalize(mom);
0041 
0042   const cartesian3D<test_algebra> c3;
0043 
0044   static_assert(concepts::coordinate_frame<cartesian3D<test_algebra>>);
0045   static_assert(concepts::rectilinear_frame<cartesian3D<test_algebra>>);
0046 
0047   // Global to local transformation
0048   const point3 local = c3.global_to_local_3D(trf, global1, d);
0049 
0050   // Check if the local position is correct
0051   ASSERT_NEAR(local[0], 2.f, isclose);
0052   ASSERT_NEAR(local[1], 4.f, isclose);
0053   ASSERT_NEAR(local[2], 1.f, isclose);
0054 
0055   // Local to global transformation
0056   const point3 global2 = c3.local_to_global(trf, local);
0057 
0058   // Check if the same global position is obtained
0059   ASSERT_NEAR(global1[0], global2[0], isclose);
0060   ASSERT_NEAR(global1[1], global2[1], isclose);
0061   ASSERT_NEAR(global1[2], global2[2], isclose);
0062 }