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-2025 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 #include "traccc/edm/track_constituent_link.hpp"
0013 #include "traccc/edm/track_fit_outcome.hpp"
0014 #include "traccc/edm/track_parameters.hpp"
0015 
0016 // Detray include(s).
0017 #include <detray/definitions/algebra.hpp>
0018 
0019 // VecMem include(s).
0020 #include <vecmem/edm/container.hpp>
0021 
0022 // System include(s)
0023 #include <ostream>
0024 
0025 namespace traccc::edm {
0026 
0027 /// Interface for the @c traccc::edm::track_collection type.
0028 ///
0029 /// It provides the API that users would interact with, while using the
0030 /// columns/arrays of the SoA containers, or the variables of the AoS proxies
0031 /// created on top of the SoA containers.
0032 ///
0033 template <typename BASE>
0034 class track : public BASE {
0035  public:
0036   /// @name Functions inherited from the base class
0037   /// @{
0038 
0039   /// Inherit the base class's constructor(s)
0040   using BASE::BASE;
0041   /// Inherit the base class's assignment operator(s).
0042   using BASE::operator=;
0043 
0044   /// @}
0045 
0046   /// @name Track Information
0047   /// @{
0048 
0049   /// The outcome of the track fit (non-const)
0050   ///
0051   /// @return A (non-const) vector of @c traccc::track_fit_outcome
0052   ///
0053   TRACCC_HOST_DEVICE
0054   auto& fit_outcome() { return BASE::template get<0>(); }
0055   /// The outcome of the track fit (non-const)
0056   ///
0057   /// @return A (const) vector of @c traccc::track_fit_outcome
0058   ///
0059   TRACCC_HOST_DEVICE
0060   const auto& fit_outcome() const { return BASE::template get<0>(); }
0061 
0062   /// The parameters of the track (non-const)
0063   ///
0064   /// @return A (non-const) vector of bound track parameters
0065   ///
0066   TRACCC_HOST_DEVICE
0067   auto& params() { return BASE::template get<1>(); }
0068   /// The parameters of the track (const)
0069   ///
0070   /// @return A (const) vector of bound track parameters
0071   ///
0072   TRACCC_HOST_DEVICE
0073   const auto& params() const { return BASE::template get<1>(); }
0074 
0075   /// The number of degrees of freedom of the track fit (non-const)
0076   ///
0077   /// @return A (non-const) vector of scalar values
0078   ///
0079   TRACCC_HOST_DEVICE
0080   auto& ndf() { return BASE::template get<2>(); }
0081   /// The number of degrees of freedom of the track fit (const)
0082   ///
0083   /// @return A (const) vector of scalar values
0084   ///
0085   TRACCC_HOST_DEVICE
0086   const auto& ndf() const { return BASE::template get<2>(); }
0087 
0088   /// The chi square of the track fit (non-const)
0089   ///
0090   /// @return A (non-const) vector of scalar values
0091   ///
0092   TRACCC_HOST_DEVICE
0093   auto& chi2() { return BASE::template get<3>(); }
0094   /// The chi square of the track fit (const)
0095   ///
0096   /// @return A (const) vector of scalar values
0097   ///
0098   TRACCC_HOST_DEVICE
0099   const auto& chi2() const { return BASE::template get<3>(); }
0100 
0101   /// The p-value of the track fit (non-const)
0102   ///
0103   /// @return A (non-const) vector of scalar values
0104   ///
0105   TRACCC_HOST_DEVICE
0106   auto& pval() { return BASE::template get<4>(); }
0107   /// The p-value of the track fit (const)
0108   ///
0109   /// @return A (const) vector of scalar values
0110   ///
0111   TRACCC_HOST_DEVICE
0112   const auto& pval() const { return BASE::template get<4>(); }
0113 
0114   /// The number of holes in the track pattern (non-const)
0115   ///
0116   /// @return A (non-const) vector of unsigned integers
0117   ///
0118   TRACCC_HOST_DEVICE
0119   auto& nholes() { return BASE::template get<5>(); }
0120   /// The number of holes in the track pattern (const)
0121   ///
0122   /// @return A (const) vector of unsigned integers
0123   ///
0124   TRACCC_HOST_DEVICE
0125   const auto& nholes() const { return BASE::template get<5>(); }
0126 
0127   /// Links to the constituents associated with the track (non-const)
0128   ///
0129   /// @return A (non-const) jagged vector of links
0130   ///
0131   TRACCC_HOST_DEVICE
0132   auto& constituent_links() { return BASE::template get<6>(); }
0133   /// Links to the constituents associated with the track (const)
0134   ///
0135   /// @return A (const) jagged vector of links
0136   ///
0137   TRACCC_HOST_DEVICE
0138   const auto& constituent_links() const { return BASE::template get<6>(); }
0139 
0140   /// @}
0141 
0142   /// @name Utility functions
0143   /// @{
0144 
0145   /// Reset the fit quality variables
0146   TRACCC_HOST_DEVICE
0147   void reset_quality();
0148 
0149   /// Equality operator
0150   ///
0151   /// @note This function must only be used on proxy objects, not on
0152   ///       containers!
0153   ///
0154   /// @param[in] other The object to compare with
0155   /// @return @c true if the objects are equal, @c false otherwise
0156   ///
0157   template <typename T>
0158   TRACCC_HOST_DEVICE bool operator==(const track<T>& other) const;
0159 
0160   /// @}
0161 
0162  private:
0163   /// @returns a string stream that prints the track details
0164   TRACCC_HOST
0165   friend std::ostream& operator<<(std::ostream& os, const track& t) {
0166     os << "Track: [states: " << t.constituent_links().size()
0167        << ", holes: " << t.nholes() << ", chi2 sum: " << t.chi2()
0168        << ", ndf: " << t.ndf() << ", pval: " << t.pval() << ", fit res. "
0169        << fit_outcome_debug_msg{t.fit_outcome()}() << ", seed:\n " << t.params()
0170        << "\n]";
0171 
0172     return os;
0173   }
0174 
0175 };  // class track_fit
0176 
0177 /// SoA container describing the fitted tracks
0178 ///
0179 /// @tparam ALGEBRA The algebra type used to describe the tracks
0180 ///
0181 template <detray::concepts::algebra ALGEBRA>
0182 using track_collection = vecmem::edm::container<
0183     track,
0184     // fit_outcome
0185     vecmem::edm::type::vector<track_fit_outcome>,
0186     // params
0187     vecmem::edm::type::vector<bound_track_parameters<ALGEBRA>>,
0188     // ndf
0189     vecmem::edm::type::vector<detray::dscalar<ALGEBRA>>,
0190     // chi2
0191     vecmem::edm::type::vector<detray::dscalar<ALGEBRA>>,
0192     // pval
0193     vecmem::edm::type::vector<detray::dscalar<ALGEBRA>>,
0194     // nholes
0195     vecmem::edm::type::vector<unsigned int>,
0196     // constituent_links
0197     vecmem::edm::type::jagged_vector<track_constituent_link>>;
0198 
0199 }  // namespace traccc::edm
0200 
0201 // Include the implementation.
0202 #include "traccc/edm/impl/track_collection.ipp"