Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 08:20:53

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 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/Utilities/Helpers.hpp"
0013 
0014 #include <cstddef>
0015 
0016 namespace Acts {
0017 
0018 namespace detail {
0019 /// Helper functor for @c visit_measurement. This is the actual functor given
0020 /// to @c template_switch.
0021 /// @tparam I Compile time int value
0022 template <std::size_t I>
0023 struct visit_measurement_callable {
0024   /// The invoked function. It will perform the head/top-left corner
0025   /// extraction, and pass thee results to the given lambda.
0026   /// @tparam L The lambda type
0027   /// @tparam A The parameter vector type
0028   /// @tparam B The covariance matrix type
0029   /// @note No requirements on @c A and @c B are made, to enable a single
0030   /// overload for both const and non-const matrices/vectors.
0031   /// @param param The parameter vector
0032   /// @param cov The covariance matrix
0033   /// @param lambda The lambda to call with the statically sized subsets
0034   template <typename L, typename A, typename B>
0035   auto static constexpr invoke(const A& param, const B& cov, L&& lambda) {
0036     return std::forward<L>(lambda)(param.template head<I>(),
0037                                    cov.template topLeftCorner<I, I>());
0038   }
0039 };
0040 }  // namespace detail
0041 
0042 /// Dispatch a lambda call on an overallocated parameter vector and covariance
0043 /// matrix, based on a runtime dimension value. Inside the lambda call, the
0044 /// vector and matrix will have fixed dimensions, but will still point back to
0045 /// the originally given overallocated values.
0046 /// @tparam L The lambda type
0047 /// @tparam A The parameter vector type
0048 /// @tparam B The covariance matrix type
0049 /// @note No requirements on @c A and @c B are made, to enable a single
0050 /// overload for both const and non-const matrices/vectors.
0051 /// @param param The parameter vector
0052 /// @param cov The covariance matrix
0053 /// @param dim The actual dimension as a runtime value
0054 /// @param lambda The lambda to call with the statically sized subsets
0055 /// @return The result of calling the lambda with the statically sized measurement components
0056 template <typename L, typename A, typename B>
0057 auto visit_measurement(const A& param, const B& cov, std::size_t dim,
0058                        L&& lambda) {
0059   return template_switch<detail::visit_measurement_callable, 1, eBoundSize>(
0060       dim, param, cov, std::forward<L>(lambda));
0061 }
0062 
0063 /// Dispatch a generic lambda on a measurement dimension. This overload doesn't
0064 /// assume anything about what is needed inside the lambda, it communicates the
0065 /// dimension via an integral constant type
0066 /// @tparam L The generic lambda type to call
0067 /// @param dim The runtime dimension of the measurement
0068 /// @param lambda The generic lambda instance to call
0069 /// @param args Additional arguments passed to @p lambda
0070 /// @return Returns the lambda return value
0071 template <typename L, typename... Args>
0072 auto visit_measurement(std::size_t dim, L&& lambda, Args&&... args) {
0073   return template_switch_lambda<1, eBoundSize>(dim, std::forward<L>(lambda),
0074                                                std::forward<Args>(args)...);
0075 }
0076 
0077 }  // namespace Acts