Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:21:58

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2021-2026 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 #pragma once
0009 
0010 // Local include(s).
0011 #include "traccc/definitions/qualifiers.hpp"
0012 
0013 // VecMem include(s).
0014 #include <vecmem/edm/container.hpp>
0015 
0016 // System include(s).
0017 #include <array>
0018 #include <compare>
0019 #include <limits>
0020 
0021 namespace traccc::edm {
0022 
0023 /// Interface for the @c traccc::edm::spacepoint_collection class.
0024 ///
0025 /// It provides the API that users would interact with, while using the
0026 /// columns/arrays of the SoA containers, or the variables of the AoS proxies
0027 /// created on top of the SoA containers.
0028 ///
0029 template <typename BASE>
0030 class spacepoint : public BASE {
0031  public:
0032   /// @name Functions inherited from the base class
0033   /// @{
0034 
0035   /// Inherit the base class's constructor(s)
0036   using BASE::BASE;
0037   /// Inherit the base class's assignment operator(s).
0038   using BASE::operator=;
0039 
0040   /// @}
0041 
0042   /// @name Spacepoint Information
0043   /// @{
0044 
0045   /// Invalid measurement index
0046   static constexpr unsigned int INVALID_MEASUREMENT_INDEX =
0047       std::numeric_limits<unsigned int>::max();
0048 
0049   /// The index of the measurement producing this spacepoint (non-const)
0050   ///
0051   /// @return A (non-const) vector of <tt>unsigned int</tt> values
0052   ///
0053   TRACCC_HOST_DEVICE
0054   auto& measurement_index_1() { return BASE::template get<0>(); }
0055   /// The index of the measurement producing this spacepoint (const)
0056   ///
0057   /// @return A (const) vector of <tt>unsigned int</tt> values
0058   ///
0059   TRACCC_HOST_DEVICE
0060   const auto& measurement_index_1() const { return BASE::template get<0>(); }
0061 
0062   /// The index of the measurement producing this spacepoint (non-const)
0063   ///
0064   /// @return A (non-const) vector of <tt>unsigned int</tt> values
0065   ///
0066   TRACCC_HOST_DEVICE
0067   auto& measurement_index_2() { return BASE::template get<1>(); }
0068   /// The index of the measurement producing this spacepoint (const)
0069   ///
0070   /// @return A (const) vector of <tt>unsigned int</tt> values
0071   ///
0072   TRACCC_HOST_DEVICE
0073   const auto& measurement_index_2() const { return BASE::template get<1>(); }
0074 
0075   /// Global / 3D position of the spacepoint
0076   ///
0077   /// @return A (non-const) vector of @c std::array<float,3> values
0078   ///
0079   TRACCC_HOST_DEVICE auto& global() { return BASE::template get<2>(); }
0080   /// Global / 3D position of the spacepoint
0081   ///
0082   /// @return A (const) vector of @c std::array<float,3> values
0083   ///
0084   TRACCC_HOST_DEVICE const auto& global() const {
0085     return BASE::template get<2>();
0086   }
0087 
0088   /// The X position of the spacepoint (non-const)
0089   ///
0090   /// @note This function must only be used on proxy objects, not on
0091   ///       containers!
0092   ///
0093   /// @return A (non-const) reference to a @c float value
0094   ///
0095   TRACCC_HOST_DEVICE
0096   auto& x();
0097   /// The X position of the spacepoint (const)
0098   ///
0099   /// @note This function must only be used on proxy objects, not on
0100   ///       containers!
0101   ///
0102   /// @return A (const) reference to a @c float value
0103   ///
0104   TRACCC_HOST_DEVICE
0105   const auto& x() const;
0106 
0107   /// The Y position of the spacepoint (non-const)
0108   ///
0109   /// @note This function must only be used on proxy objects, not on
0110   ///       containers!
0111   ///
0112   /// @return A (non-const) reference to a @c float value
0113   ///
0114   TRACCC_HOST_DEVICE
0115   auto& y();
0116   /// The Y position of the spacepoint (const)
0117   ///
0118   /// @return A (const) reference to a @c float value
0119   ///
0120   TRACCC_HOST_DEVICE
0121   const auto& y() const;
0122 
0123   /// The Z position of the spacepoint (non-const)
0124   ///
0125   /// @note This function must only be used on proxy objects, not on
0126   ///       containers!
0127   ///
0128   /// @return A (non-const) reference to a @c float value
0129   ///
0130   TRACCC_HOST_DEVICE
0131   auto& z();
0132   /// The Z position of the spacepoint (const)
0133   ///
0134   /// @note This function must only be used on proxy objects, not on
0135   ///       containers!
0136   ///
0137   /// @return A (const) reference to a @c float value
0138   ///
0139   TRACCC_HOST_DEVICE
0140   const auto& z() const;
0141 
0142   /// The variation on the spacepoint's Z coordinate (non-const)
0143   ///
0144   /// @return A (non-const) vector of @c float values
0145   ///
0146   TRACCC_HOST_DEVICE auto& z_variance() { return BASE::template get<3>(); }
0147   /// The variation on the spacepoint's Z coordinate (const)
0148   ///
0149   /// @return A (const) vector of @c float values
0150   ///
0151   TRACCC_HOST_DEVICE const auto& z_variance() const {
0152     return BASE::template get<3>();
0153   }
0154 
0155   /// The radius of the spacepoint in the XY plane (non-const)
0156   ///
0157   /// @note This function must only be used on proxy objects, not on
0158   ///       containers!
0159   ///
0160   /// @return A @c float value
0161   ///
0162   TRACCC_HOST_DEVICE auto radius() const;
0163 
0164   /// The variation on the spacepoint radious (non-const)
0165   ///
0166   /// @return A (non-const) vector of @c float values
0167   ///
0168   TRACCC_HOST_DEVICE auto& radius_variance() { return BASE::template get<4>(); }
0169   /// The variation on the spacepoint radious (const)
0170   ///
0171   /// @return A (non-const) vector of @c float values
0172   ///
0173   TRACCC_HOST_DEVICE const auto& radius_variance() const {
0174     return BASE::template get<4>();
0175   }
0176 
0177   /// The azimuthal angle of the spacepoint in the XY plane (non-const)
0178   ///
0179   /// @note This function must only be used on proxy objects, not on
0180   ///       containers!
0181   ///
0182   /// @return A @c float value
0183   ///
0184   TRACCC_HOST_DEVICE auto phi() const;
0185 
0186   /// @}
0187 
0188   /// @name Utility functions
0189   /// @{
0190 
0191   /// Equality operator
0192   ///
0193   /// @note This function must only be used on proxy objects, not on
0194   ///       containers!
0195   ///
0196   /// @param[in] other The object to compare with
0197   /// @return @c true if the objects are equal, @c false otherwise
0198   ///
0199   template <typename T>
0200   TRACCC_HOST_DEVICE bool operator==(const spacepoint<T>& other) const;
0201 
0202   /// Comparison operator
0203   ///
0204   /// @note This function must only be used on proxy objects, not on
0205   ///       containers!
0206   ///
0207   /// @param[in] other The object to compare with
0208   /// @return A weak ordering object, describing the relation between the
0209   ///         two objects
0210   ///
0211   template <typename T>
0212   TRACCC_HOST_DEVICE std::weak_ordering operator<=>(
0213       const spacepoint<T>& other) const;
0214 
0215   /// @}
0216 
0217 };  // class spacepoint
0218 
0219 /// SoA container describing reconstructed spacepoints
0220 using spacepoint_collection =
0221     vecmem::edm::container<spacepoint,
0222                            // measurement_index_1
0223                            vecmem::edm::type::vector<unsigned int>,
0224                            // measurement_index_2
0225                            vecmem::edm::type::vector<unsigned int>,
0226                            // global
0227                            vecmem::edm::type::vector<std::array<float, 3u>>,
0228                            // z_variance
0229                            vecmem::edm::type::vector<float>,
0230                            // radius_variance
0231                            vecmem::edm::type::vector<float>>;
0232 
0233 }  // namespace traccc::edm
0234 
0235 // Include the implementation.
0236 #include "traccc/edm/impl/spacepoint_collection.ipp"