Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:10:00

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