Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:09:32

0001 //---------------------------------*-C++-*-----------------------------------//
0002 // Copyright 2020-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file geocel/vg/detail/VecgeomCompatibility.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <VecGeom/base/Vector3D.h>
0011 
0012 #include "corecel/Macros.hh"
0013 #include "corecel/cont/Array.hh"
0014 #include "corecel/cont/Span.hh"
0015 
0016 namespace celeritas
0017 {
0018 namespace detail
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Create a Vector3D from a length-3 span.
0023  */
0024 template<class T>
0025 CELER_FUNCTION inline auto
0026 to_vector(Span<T, 3> s) -> vecgeom::Vector3D<std::remove_cv_t<T>>
0027 {
0028     return {s[0], s[1], s[2]};
0029 }
0030 
0031 //---------------------------------------------------------------------------//
0032 /*!
0033  * Create a Vector3D from a length-3 array.
0034  */
0035 template<class T>
0036 CELER_FUNCTION inline auto
0037 to_vector(Array<T, 3> const& arr) -> vecgeom::Vector3D<T>
0038 {
0039     return to_vector(celeritas::make_span<T, 3>(arr));
0040 }
0041 
0042 //---------------------------------------------------------------------------//
0043 /*!
0044  * Create a length-3 array from a VecGeom vector.
0045  */
0046 template<class T>
0047 CELER_FUNCTION inline auto
0048 to_array(vecgeom::Vector3D<T> const& arr) -> Array<T, 3>
0049 {
0050     return {arr[0], arr[1], arr[2]};
0051 }
0052 
0053 //---------------------------------------------------------------------------//
0054 }  // namespace detail
0055 }  // namespace celeritas