Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:23:59

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 #pragma once
0010 
0011 // Project include(s)
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/definitions/detail/qualifiers.hpp"
0014 #include "detray/geometry/detail/tracking_surface_kernels.hpp"
0015 #include "detray/geometry/surface.hpp"
0016 
0017 // System include(s)
0018 #include <type_traits>
0019 
0020 namespace detray {
0021 
0022 /// @brief Facade for a detray detector surface with extra tracking capabilities
0023 template <typename det_t>  // @TODO: This needs a concept
0024 class tracking_surface : public geometry::surface<const det_t> {
0025   /// Make sure the detector is always evaluated as constant type
0026   using detector_t = std::add_const_t<det_t>;
0027 
0028   using base_surface_t = geometry::surface<detector_t>;
0029 
0030   /// Implementation of tracking functionality
0031   using kernels =
0032       detail::tracking_surface_kernels<typename detector_t::algebra_type>;
0033   /// Vector type for track parameters in global coordinates
0034   using free_param_vector_type = typename kernels::free_param_vector_type;
0035   /// Vector type for track parameters in local (bound) coordinates
0036   using bound_param_vector_type = typename kernels::bound_param_vector_type;
0037 
0038  public:
0039   using algebra_type = typename base_surface_t::algebra_type;
0040   using scalar_type = typename base_surface_t::scalar_type;
0041   using point2_type = typename base_surface_t::point2_type;
0042   using point3_type = typename base_surface_t::point3_type;
0043   using vector3_type = typename base_surface_t::vector3_type;
0044   using transform3_type = typename base_surface_t::transform3_type;
0045   using context = typename base_surface_t::context;
0046 
0047   /// Use base class constructors
0048   using base_surface_t::base_surface_t;
0049 
0050   /// Decorate a geometric surface with tracking functionality
0051   DETRAY_HOST_DEVICE
0052   explicit constexpr tracking_surface(const base_surface_t sf)
0053       : base_surface_t(sf) {}
0054 
0055   /// Conversion to surface interface around constant detector type,
0056   /// which has no semantic difference (the detector is always const internally)
0057   template <typename detector_type = detector_t>
0058     requires(!std::is_const_v<detector_type>)
0059   // NOLINTNEXTLINE
0060   DETRAY_HOST_DEVICE constexpr operator tracking_surface<const detector_type>()
0061       const {
0062     return tracking_surface<const detector_type>{this->m_detector,
0063                                                  this->m_desc};
0064   }
0065 
0066   /// @returns the track parametrization projected onto the surface (bound)
0067   DETRAY_HOST_DEVICE
0068   constexpr auto free_to_bound_vector(
0069       const context &ctx, const free_param_vector_type &free_vec) const {
0070     return this->template visit_mask<typename kernels::free_to_bound_vector>(
0071         this->transform(ctx), free_vec);
0072   }
0073 
0074   /// @returns the global track parametrization from a bound representation
0075   DETRAY_HOST_DEVICE
0076   constexpr auto bound_to_free_vector(
0077       const context &ctx, const bound_param_vector_type &bound_vec) const {
0078     return this->template visit_mask<typename kernels::bound_to_free_vector>(
0079         this->transform(ctx), bound_vec);
0080   }
0081 
0082   /// @returns the jacobian to go from a free to a bound track parametrization
0083   DETRAY_HOST_DEVICE
0084   constexpr auto free_to_bound_jacobian(
0085       const context &ctx, const free_param_vector_type &free_vec) const {
0086     return this->template visit_mask<typename kernels::free_to_bound_jacobian>(
0087         this->transform(ctx), free_vec);
0088   }
0089 
0090   /// @returns the jacobian to go from a bound to a free track parametrization
0091   DETRAY_HOST_DEVICE
0092   constexpr auto bound_to_free_jacobian(
0093       const context &ctx, const bound_param_vector_type &bound_vec) const {
0094     return this->template visit_mask<typename kernels::bound_to_free_jacobian>(
0095         this->transform(ctx), bound_vec);
0096   }
0097 
0098   /// @returns the path correction term
0099   DETRAY_HOST_DEVICE
0100   constexpr auto path_correction(const context &ctx, const vector3_type &pos,
0101                                  const vector3_type &dir,
0102                                  const vector3_type &dtds,
0103                                  const scalar_type dqopds) const {
0104     return this->template visit_mask<typename kernels::path_correction>(
0105         this->transform(ctx), pos, dir, dtds, dqopds);
0106   }
0107 
0108   /// @returns the free to path derivative
0109   DETRAY_HOST_DEVICE
0110   constexpr auto free_to_path_derivative(const context &ctx,
0111                                          const vector3_type &pos,
0112                                          const vector3_type &dir,
0113                                          const vector3_type &dtds) const {
0114     return this->template visit_mask<typename kernels::free_to_path_derivative>(
0115         this->transform(ctx), pos, dir, dtds);
0116   }
0117 };
0118 
0119 template <typename detector_t, typename descr_t>
0120 DETRAY_HOST_DEVICE tracking_surface(const detector_t &, const descr_t &)
0121     -> tracking_surface<detector_t>;
0122 
0123 template <typename detector_t>
0124 DETRAY_HOST_DEVICE tracking_surface(const detector_t &,
0125                                     const geometry::identifier)
0126     -> tracking_surface<detector_t>;
0127 
0128 template <typename detector_t>
0129 DETRAY_HOST_DEVICE tracking_surface(const geometry::surface<detector_t>)
0130     -> tracking_surface<detector_t>;
0131 
0132 template <typename detector_t>
0133 DETRAY_HOST_DEVICE tracking_surface(const geometry::surface<const detector_t>)
0134     -> tracking_surface<detector_t>;
0135 
0136 }  // namespace detray