Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:48

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/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/EventData/SourceLink.hpp"
0014 #include "Acts/EventData/TrackStatePropMask.hpp"
0015 #include "Acts/EventData/Types.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Utilities/HashedString.hpp"
0018 
0019 #include <any>
0020 
0021 namespace Acts {
0022 
0023 namespace detail {
0024 
0025 using Parameters = Eigen::Map<BoundVector>;
0026 using Covariance = Eigen::Map<BoundMatrix>;
0027 
0028 using ConstParameters = Eigen::Map<const BoundVector>;
0029 using ConstCovariance = Eigen::Map<const BoundMatrix>;
0030 
0031 template <typename R>
0032 concept RangeLike = requires(R r) {
0033   { r.begin() };
0034   { r.end() };
0035 
0036   requires std::forward_iterator<decltype(r.begin())>;
0037   requires std::forward_iterator<decltype(r.end())>;
0038 };
0039 
0040 }  // namespace detail
0041 
0042 template <typename T>
0043 concept CommonMultiTrajectoryBackend =
0044     requires(const T& cv, HashedString key, TrackIndexType istate) {
0045       { cv.calibratedSize_impl(istate) } -> std::same_as<TrackIndexType>;
0046 
0047       { cv.getUncalibratedSourceLink_impl(istate) } -> std::same_as<SourceLink>;
0048 
0049       { cv.referenceSurface_impl(istate) } -> std::same_as<const Surface*>;
0050 
0051       { cv.parameters_impl(istate) } -> std::same_as<detail::ConstParameters>;
0052 
0053       { cv.covariance_impl(istate) } -> std::same_as<detail::ConstCovariance>;
0054 
0055       { cv.jacobian_impl(istate) } -> std::same_as<detail::ConstCovariance>;
0056 
0057       {
0058         cv.template calibrated_impl<2>(istate)
0059       } -> std::same_as<Eigen::Map<const Vector2>>;
0060 
0061       {
0062         cv.template calibratedCovariance_impl<2>(istate)
0063       } -> std::same_as<Eigen::Map<const ActsSquareMatrix<2>>>;
0064 
0065       { cv.has_impl(key, istate) } -> std::same_as<bool>;
0066 
0067       { cv.size_impl() } -> std::same_as<TrackIndexType>;
0068 
0069       { cv.component_impl(key, istate) } -> std::same_as<std::any>;
0070 
0071       { cv.hasColumn_impl(key) } -> std::same_as<bool>;
0072 
0073       { cv.dynamicKeys_impl() };
0074       requires detail::RangeLike<decltype(cv.dynamicKeys_impl())>;
0075     };
0076 
0077 template <typename T>
0078 concept ConstMultiTrajectoryBackend =
0079     CommonMultiTrajectoryBackend<T> &&
0080     requires(T v, HashedString key, TrackIndexType istate) {
0081       { v.parameters_impl(istate) } -> std::same_as<detail::ConstParameters>;
0082 
0083       { v.covariance_impl(istate) } -> std::same_as<detail::ConstCovariance>;
0084 
0085       { v.jacobian_impl(istate) } -> std::same_as<detail::ConstCovariance>;
0086 
0087       {
0088         v.template calibrated_impl<2>(istate)
0089       } -> std::same_as<Eigen::Map<const Vector2>>;
0090 
0091       {
0092         v.template calibratedCovariance_impl<2>(istate)
0093       } -> std::same_as<Eigen::Map<const ActsSquareMatrix<2>>>;
0094     };
0095 
0096 template <typename T>
0097 concept MutableMultiTrajectoryBackend =
0098     CommonMultiTrajectoryBackend<T> &&
0099     requires(T v, HashedString key, TrackIndexType istate,
0100              TrackStatePropMask mask, std::string col, std::size_t dim,
0101              SourceLink sl, std::shared_ptr<const Surface> surface) {
0102       { v.parameters_impl(istate) } -> std::same_as<detail::Parameters>;
0103 
0104       { v.covariance_impl(istate) } -> std::same_as<detail::Covariance>;
0105 
0106       { v.jacobian_impl(istate) } -> std::same_as<detail::Covariance>;
0107 
0108       {
0109         v.template calibrated_impl<2>(istate)
0110       } -> std::same_as<Eigen::Map<Vector2>>;
0111 
0112       {
0113         v.template calibratedCovariance_impl<2>(istate)
0114       } -> std::same_as<Eigen::Map<ActsSquareMatrix<2>>>;
0115 
0116       { v.addTrackState_impl() } -> std::same_as<TrackIndexType>;
0117 
0118       { v.shareFrom_impl(istate, istate, mask, mask) };
0119 
0120       { v.unset_impl(mask, istate) };
0121 
0122       { v.clear_impl() };
0123 
0124       // As far as I know there's no good way to assert that there's a generic
0125       // template function
0126       { v.template addColumn_impl<std::uint32_t>(col) };
0127       { v.template addColumn_impl<std::uint64_t>(col) };
0128       { v.template addColumn_impl<std::int32_t>(col) };
0129       { v.template addColumn_impl<std::int64_t>(col) };
0130       { v.template addColumn_impl<float>(col) };
0131       { v.template addColumn_impl<double>(col) };
0132 
0133       {
0134         v.allocateCalibrated_impl(istate, ActsVector<1>{},
0135                                   ActsSquareMatrix<1>{})
0136       };
0137       // Assuming intermediate values also work
0138       {
0139         v.allocateCalibrated_impl(istate, ActsVector<eBoundSize>{},
0140                                   ActsSquareMatrix<eBoundSize>{})
0141       };
0142 
0143       { v.setUncalibratedSourceLink_impl(istate, std::move(sl)) };
0144 
0145       { v.setReferenceSurface_impl(istate, surface) };
0146 
0147       { v.copyDynamicFrom_impl(istate, key, std::declval<const std::any&>()) };
0148     };
0149 
0150 }  // namespace Acts