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) 2022-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/common.hpp"
0012 #include "traccc/definitions/qualifiers.hpp"
0013 
0014 // Detray include(s).
0015 #include <detray/geometry/identifier.hpp>
0016 
0017 // VecMem include(s).
0018 #include <vecmem/edm/container.hpp>
0019 
0020 // System include(s).
0021 #include <array>
0022 #include <compare>
0023 #include <cstdint>
0024 #include <ostream>
0025 
0026 namespace traccc::edm {
0027 
0028 /// Interface for the @c traccc::edm::measurement_collection type.
0029 ///
0030 /// It provides the API that users would interact with, while using the
0031 /// columns/arrays of the SoA containers, or the variables of the AoS proxies
0032 /// created on top of the SoA containers.
0033 ///
0034 template <typename BASE>
0035 class measurement : public BASE {
0036  public:
0037   /// @name Functions inherited from the base class
0038   /// @{
0039 
0040   /// Inherit the base class's constructor(s)
0041   using BASE::BASE;
0042   /// Inherit the base class's assignment operator(s).
0043   using BASE::operator=;
0044 
0045   /// @}
0046 
0047   /// @name Measurement Information
0048   /// @{
0049 
0050   /// Local position of the measurement (non-const)
0051   ///
0052   /// @return A (non-const) vector of 1D/2D points
0053   ///
0054   TRACCC_HOST_DEVICE
0055   auto& local_position() { return BASE::template get<0>(); }
0056   /// Local position of the measurement (const)
0057   ///
0058   /// @return A (const) vector of 1D/2D points
0059   ///
0060   TRACCC_HOST_DEVICE
0061   const auto& local_position() const { return BASE::template get<0>(); }
0062 
0063   /// Variance of the local position of the measurement (non-const)
0064   ///
0065   /// @return A (non-const) vector of 1D/2D variances
0066   ///
0067   TRACCC_HOST_DEVICE
0068   auto& local_variance() { return BASE::template get<1>(); }
0069   /// Variance of the local position of the measurement (const)
0070   ///
0071   /// @return A (const) vector of 1D/2D variances
0072   ///
0073   TRACCC_HOST_DEVICE
0074   const auto& local_variance() const { return BASE::template get<1>(); }
0075 
0076   /// Dimensionality of the measurement (non-const)
0077   ///
0078   /// @return A (non-const) vector of unsigned integers
0079   ///
0080   TRACCC_HOST_DEVICE
0081   auto& dimensions() { return BASE::template get<2>(); }
0082   /// Dimensionality of the measurement (const)
0083   ///
0084   /// @return A (const) vector of unsigned integers
0085   ///
0086   TRACCC_HOST_DEVICE
0087   const auto& dimensions() const { return BASE::template get<2>(); }
0088 
0089   /// Time assigned to the measurement (non-const)
0090   ///
0091   /// @return A (non-const) vector of @c float values
0092   ///
0093   TRACCC_HOST_DEVICE
0094   auto& time() { return BASE::template get<3>(); }
0095   /// Time assigned to the measurement (const)
0096   ///
0097   /// @return A (const) vector of @c float values
0098   ///
0099   TRACCC_HOST_DEVICE
0100   const auto& time() const { return BASE::template get<3>(); }
0101 
0102   /// Diameter of the measurement (non-const)
0103   ///
0104   /// @return A (non-const) vector of @c float values
0105   ///
0106   TRACCC_HOST_DEVICE
0107   auto& diameter() { return BASE::template get<4>(); }
0108   /// Diameter of the measurement (const)
0109   ///
0110   /// @return A (const) vector of @c float values
0111   ///
0112   TRACCC_HOST_DEVICE
0113   const auto& diameter() const { return BASE::template get<4>(); }
0114 
0115   /// Unique measurement identifier (non-const)
0116   ///
0117   /// @return A (non-const) vector of unsigned integer values
0118   ///
0119   TRACCC_HOST_DEVICE
0120   auto& identifier() { return BASE::template get<5>(); }
0121   /// Unique measurement identifier (const)
0122   ///
0123   /// @return A (const) vector of unsigned integer values
0124   ///
0125   TRACCC_HOST_DEVICE
0126   const auto& identifier() const { return BASE::template get<5>(); }
0127 
0128   /// Identifier of the tracking sufrace of the measurement (non-const)
0129   ///
0130   /// @return A (non-const) vector of geometry identifiers
0131   ///
0132   TRACCC_HOST_DEVICE
0133   auto& surface_link() { return BASE::template get<6>(); }
0134   /// Identifier of the tracking sufrace of the measurement (const)
0135   ///
0136   /// @return A (const) vector of geometry identifiers
0137   ///
0138   TRACCC_HOST_DEVICE
0139   const auto& surface_link() const { return BASE::template get<6>(); }
0140 
0141   /// Subspace of the measurement (non-const)
0142   ///
0143   /// @return A (non-const) vector of subspace objects
0144   ///
0145   TRACCC_HOST_DEVICE
0146   auto& subspace() { return BASE::template get<7>(); }
0147   /// Subspace of the measurement (const)
0148   ///
0149   /// @return A (const) vector of subspace objects
0150   ///
0151   TRACCC_HOST_DEVICE
0152   const auto& subspace() const { return BASE::template get<7>(); }
0153   /// Set the subspace of the measurement
0154   ///
0155   /// Using a possibly slightly different array than the one used by the
0156   /// object itself.
0157   ///
0158   /// @note This function must only be used on proxy objects, not on
0159   ///       containers!
0160   ///
0161   /// @param subs The subspace to set
0162   ///
0163   template <std::integral TYPE>
0164   TRACCC_HOST_DEVICE void set_subspace(const std::array<TYPE, 2u>& subs);
0165 
0166   /// Index of the cluster that the measurement was created from (non-const)
0167   ///
0168   /// @return A (non-const) vector of unsigned integers
0169   ///
0170   TRACCC_HOST_DEVICE
0171   auto& cluster_index() { return BASE::template get<8>(); }
0172   /// Index of the cluster that the measurement was created from (const)
0173   ///
0174   /// @return A (const) vector of unsigned integers
0175   ///
0176   TRACCC_HOST_DEVICE
0177   const auto& cluster_index() const { return BASE::template get<8>(); }
0178 
0179   /// @}
0180 
0181   /// @name Utility functions
0182   /// @{
0183 
0184   /// Equality operator
0185   ///
0186   /// @note This function must only be used on proxy objects, not on
0187   ///       containers!
0188   ///
0189   /// @param[in] other The object to compare with
0190   /// @return @c true if the objects are equal, @c false otherwise
0191   ///
0192   template <typename T>
0193   TRACCC_HOST_DEVICE bool operator==(const measurement<T>& other) const;
0194 
0195   /// Comparison operator
0196   ///
0197   /// @note This function must only be used on proxy objects, not on
0198   ///       containers!
0199   ///
0200   /// @param[in] other The object to compare with
0201   /// @return A weak ordering object, describing the relation between the
0202   ///         two objects
0203   ///
0204   template <typename T>
0205   TRACCC_HOST_DEVICE std::partial_ordering operator<=>(
0206       const measurement<T>& other) const;
0207 
0208   /// @}
0209 
0210  private:
0211   /// @returns a string stream that prints the measurement details
0212   TRACCC_HOST
0213   friend std::ostream& operator<<(std::ostream& os, const measurement& m) {
0214     os << "ID = " << m.identifier() << ", dim = " << m.dimensions()
0215        << ", surface: " << m.surface_link() << std::endl;
0216 
0217     os << " -> cluster idx = " << m.cluster_index() << std::endl;
0218 
0219     os << " -> loc pos     = [" << m.local_position()[0];
0220     for (unsigned int i = 1u; i < m.dimensions(); ++i) {
0221       os << ", " << m.local_position()[i];
0222     }
0223     os << "]\n -> loc var     = [" << m.local_variance()[0];
0224     for (unsigned int i = 1u; i < m.dimensions(); ++i) {
0225       os << ", " << m.local_variance()[i];
0226     }
0227     os << "]" << std::endl;
0228 
0229     os << " -> t           = " << m.time() * traccc::unit<float>::s << "s"
0230        << std::endl;
0231     os << " -> diameter    = " << m.diameter() * traccc::unit<float>::mm << "mm"
0232        << std::endl;
0233 
0234     return os;
0235   }
0236 
0237 };  // class measurement
0238 
0239 /// SoA container of measurements
0240 using measurement_collection = vecmem::edm::container<
0241     measurement,
0242     // local_position
0243     vecmem::edm::type::vector<std::array<float, 2u>>,
0244     // local_variance
0245     vecmem::edm::type::vector<std::array<float, 2u>>,
0246     // dimensions
0247     vecmem::edm::type::vector<unsigned int>,
0248     // time
0249     vecmem::edm::type::vector<float>,
0250     // diameter
0251     vecmem::edm::type::vector<float>,
0252     // identifier
0253     vecmem::edm::type::vector<unsigned int>,
0254     // surface_link
0255     vecmem::edm::type::vector<detray::geometry::identifier>,
0256     // subspace
0257     vecmem::edm::type::vector<std::array<std::uint8_t, 2u>>,
0258     // cluster_index
0259     vecmem::edm::type::vector<unsigned int>>;
0260 
0261 }  // namespace traccc::edm
0262 
0263 // Include the implementation.
0264 #include "traccc/edm/impl/measurement_collection.ipp"