Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 08:18:03

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/SubspaceHelpers.hpp"
0015 #include "Acts/EventData/TrackStatePropMask.hpp"
0016 #include "Acts/EventData/TrackStateType.hpp"
0017 #include "Acts/EventData/Types.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include "Acts/Utilities/HashedString.hpp"
0020 
0021 #include <utility>
0022 
0023 namespace Acts {
0024 
0025 namespace detail {
0026 
0027 using Parameters = Eigen::Map<BoundVector>;
0028 using Covariance = Eigen::Map<BoundMatrix>;
0029 
0030 using ConstParameters = Eigen::Map<const BoundVector>;
0031 using ConstCovariance = Eigen::Map<const BoundMatrix>;
0032 
0033 using Measurement = Eigen::Map<Vector2>;
0034 using MeasurementCovariance = Eigen::Map<SquareMatrix<2>>;
0035 
0036 using ConstMeasurement = Eigen::Map<const Vector2>;
0037 using ConstMeasurementCovariance = Eigen::Map<const SquareMatrix<2>>;
0038 
0039 using DynamicMeasurement =
0040     Eigen::Map<Eigen::Matrix<Covariance::Scalar, Eigen::Dynamic, 1,
0041                              Eigen::ColMajor | Eigen::AutoAlign>>;
0042 using DynamicMeasurementCovariance =
0043     Eigen::Map<Eigen::Matrix<Covariance::Scalar, Eigen::Dynamic, Eigen::Dynamic,
0044                              Eigen::ColMajor | Eigen::AutoAlign>>;
0045 
0046 using ConstDynamicMeasurement =
0047     Eigen::Map<const Eigen::Matrix<Covariance::Scalar, Eigen::Dynamic, 1,
0048                                    Eigen::ColMajor | Eigen::AutoAlign>>;
0049 using ConstDynamicMeasurementCovariance = Eigen::Map<
0050     const Eigen::Matrix<Covariance::Scalar, Eigen::Dynamic, Eigen::Dynamic,
0051                         Eigen::ColMajor | Eigen::AutoAlign>>;
0052 
0053 constexpr static auto ProjectorFlags = Eigen::RowMajor | Eigen::AutoAlign;
0054 using Projector = Eigen::Matrix<typename Covariance::Scalar, eBoundSize,
0055                                 eBoundSize, ProjectorFlags>;
0056 using EffectiveProjector =
0057     Eigen::Matrix<typename Projector::Scalar, Eigen::Dynamic, eBoundSize,
0058                   ProjectorFlags, eBoundSize, eBoundSize>;
0059 
0060 }  // namespace detail
0061 
0062 template <typename T>
0063 concept TrackStateProxyConcept =
0064     requires(const T& cv, T v, HashedString key,
0065              std::shared_ptr<const Surface> surface) {
0066       { cv.index() } -> std::same_as<TrackIndexType>;
0067 
0068       { cv.previous() } -> std::same_as<TrackIndexType>;
0069 
0070       { cv.hasPrevious() } -> std::same_as<bool>;
0071 
0072       { cv.getMask() } -> std::same_as<TrackStatePropMask>;
0073 
0074       { cv.referenceSurface() } -> std::same_as<const Surface&>;
0075 
0076       { cv.hasReferenceSurface() } -> std::same_as<bool>;
0077 
0078       { cv.template has<hashString("blubb")>() } -> std::same_as<bool>;
0079 
0080       { cv.has(key) } -> std::same_as<bool>;
0081 
0082       { cv.has("blubb") } -> std::same_as<bool>;
0083 
0084       // Cannot verify for all types, so just check int
0085       {
0086         cv.template component<int, hashString("blubb")>()
0087       } -> std::same_as<const int&>;
0088 
0089       { cv.template component<int>(key) } -> std::same_as<const int&>;
0090 
0091       { cv.parameters() } -> std::same_as<detail::ConstParameters>;
0092       { cv.covariance() } -> std::same_as<detail::ConstCovariance>;
0093 
0094       { cv.predicted() } -> std::same_as<detail::ConstParameters>;
0095       { cv.predictedCovariance() } -> std::same_as<detail::ConstCovariance>;
0096       { cv.hasPredicted() } -> std::same_as<bool>;
0097       { v.hasPredicted() } -> std::same_as<bool>;
0098 
0099       { cv.filtered() } -> std::same_as<detail::ConstParameters>;
0100       { cv.filteredCovariance() } -> std::same_as<detail::ConstCovariance>;
0101       { cv.hasFiltered() } -> std::same_as<bool>;
0102       { v.hasFiltered() } -> std::same_as<bool>;
0103 
0104       { cv.smoothed() } -> std::same_as<detail::ConstParameters>;
0105       { cv.smoothedCovariance() } -> std::same_as<detail::ConstCovariance>;
0106       { cv.hasSmoothed() } -> std::same_as<bool>;
0107       { v.hasSmoothed() } -> std::same_as<bool>;
0108 
0109       { cv.jacobian() } -> std::same_as<detail::ConstCovariance>;
0110       { cv.hasJacobian() } -> std::same_as<bool>;
0111       { v.hasJacobian() } -> std::same_as<bool>;
0112 
0113       { cv.hasProjector() } -> std::same_as<bool>;
0114       { v.hasProjector() } -> std::same_as<bool>;
0115 
0116       { v.projectorSubspaceIndices() } -> std::same_as<BoundSubspaceIndices>;
0117       { cv.projectorSubspaceIndices() } -> std::same_as<BoundSubspaceIndices>;
0118 
0119       {
0120         v.template projectorSubspaceIndices<4>()
0121       } -> std::same_as<SubspaceIndices<4>>;
0122       {
0123         cv.template projectorSubspaceIndices<4>()
0124       } -> std::same_as<SubspaceIndices<4>>;
0125 
0126       {
0127         v.projectorSubspaceHelper()
0128       } -> std::same_as<VariableBoundSubspaceHelper>;
0129       {
0130         cv.projectorSubspaceHelper()
0131       } -> std::same_as<VariableBoundSubspaceHelper>;
0132 
0133       {
0134         v.template projectorSubspaceHelper<4>()
0135       } -> std::same_as<FixedBoundSubspaceHelper<4>>;
0136       {
0137         cv.template projectorSubspaceHelper<4>()
0138       } -> std::same_as<FixedBoundSubspaceHelper<4>>;
0139 
0140       { cv.hasUncalibratedSourceLink() } -> std::same_as<bool>;
0141       { v.hasUncalibratedSourceLink() } -> std::same_as<bool>;
0142 
0143       { cv.getUncalibratedSourceLink() } -> std::same_as<SourceLink>;
0144       { v.getUncalibratedSourceLink() } -> std::same_as<SourceLink>;
0145 
0146       { cv.hasCalibrated() } -> std::same_as<bool>;
0147       { v.hasCalibrated() } -> std::same_as<bool>;
0148 
0149       { cv.template calibrated<2>() } -> std::same_as<detail::ConstMeasurement>;
0150       {
0151         cv.template calibratedCovariance<2>()
0152       } -> std::same_as<detail::ConstMeasurementCovariance>;
0153 
0154       {
0155         cv.effectiveCalibrated()
0156       } -> std::same_as<detail::ConstDynamicMeasurement>;
0157       {
0158         cv.effectiveCalibratedCovariance()
0159       } -> std::same_as<detail::ConstDynamicMeasurementCovariance>;
0160 
0161       { cv.calibratedSize() } -> std::same_as<TrackIndexType>;
0162       { v.calibratedSize() } -> std::same_as<TrackIndexType>;
0163 
0164       { cv.chi2() } -> std::same_as<float>;
0165 
0166       { cv.pathLength() } -> std::same_as<double>;
0167 
0168       { cv.typeFlags() } -> std::same_as<ConstTrackStateTypeMap>;
0169     };
0170 
0171 template <typename T>
0172 concept ConstTrackStateProxyConcept =
0173     TrackStateProxyConcept<T> && requires(T v, HashedString key) {
0174       // Cannot verify for all types, so just check int
0175       {
0176         v.template component<int, hashString("blubb")>()
0177       } -> std::same_as<const int&>;
0178 
0179       { v.template component<int>(key) } -> std::same_as<const int&>;
0180 
0181       { v.predicted() } -> std::same_as<detail::ConstParameters>;
0182       { v.predictedCovariance() } -> std::same_as<detail::ConstCovariance>;
0183 
0184       { v.filtered() } -> std::same_as<detail::ConstParameters>;
0185       { v.filteredCovariance() } -> std::same_as<detail::ConstCovariance>;
0186 
0187       { v.smoothed() } -> std::same_as<detail::ConstParameters>;
0188       { v.smoothedCovariance() } -> std::same_as<detail::ConstCovariance>;
0189 
0190       { v.jacobian() } -> std::same_as<detail::ConstCovariance>;
0191 
0192       { v.template calibrated<2>() } -> std::same_as<detail::ConstMeasurement>;
0193       {
0194         v.template calibratedCovariance<2>()
0195       } -> std::same_as<detail::ConstMeasurementCovariance>;
0196 
0197       {
0198         v.effectiveCalibrated()
0199       } -> std::same_as<detail::ConstDynamicMeasurement>;
0200       {
0201         v.effectiveCalibratedCovariance()
0202       } -> std::same_as<detail::ConstDynamicMeasurementCovariance>;
0203 
0204       { v.chi2() } -> std::same_as<float>;
0205 
0206       { v.pathLength() } -> std::same_as<double>;
0207 
0208       { v.typeFlags() } -> std::same_as<ConstTrackStateTypeMap>;
0209     };
0210 
0211 template <typename T>
0212 concept MutableTrackStateProxyConcept =
0213     TrackStateProxyConcept<T> &&
0214     requires(T v, HashedString key, TrackStatePropMask mask,
0215              TrackIndexType index, std::shared_ptr<const Surface> surface,
0216              Eigen::Matrix<double, 3, 6> projector,
0217              ProjectorBitset projectorBitset, SourceLink sl,
0218              std::size_t measdim) {
0219       { v.unset(mask) };
0220 
0221       // Cannot verify for all types, so just check int
0222       {
0223         v.template component<int, hashString("blubb")>()
0224       } -> std::same_as<int&>;
0225 
0226       { v.template component<int>(key) } -> std::same_as<int&>;
0227 
0228       { v.predicted() } -> std::same_as<detail::Parameters>;
0229       { v.predictedCovariance() } -> std::same_as<detail::Covariance>;
0230 
0231       { v.filtered() } -> std::same_as<detail::Parameters>;
0232       { v.filteredCovariance() } -> std::same_as<detail::Covariance>;
0233 
0234       { v.smoothed() } -> std::same_as<detail::Parameters>;
0235       { v.smoothedCovariance() } -> std::same_as<detail::Covariance>;
0236 
0237       { v.jacobian() } -> std::same_as<detail::Covariance>;
0238 
0239       requires requires(BoundSubspaceIndices m) {
0240         v.setProjectorSubspaceIndices(m);
0241       };
0242 
0243       { v.setUncalibratedSourceLink(std::move(sl)) };
0244 
0245       { v.template calibrated<2>() } -> std::same_as<detail::Measurement>;
0246       {
0247         v.template calibratedCovariance<2>()
0248       } -> std::same_as<detail::MeasurementCovariance>;
0249 
0250       { v.effectiveCalibrated() } -> std::same_as<detail::DynamicMeasurement>;
0251       {
0252         v.effectiveCalibratedCovariance()
0253       } -> std::same_as<detail::DynamicMeasurementCovariance>;
0254 
0255       { v.allocateCalibrated(measdim) };
0256 
0257       { v.allocateCalibrated(Vector<1>{}, SquareMatrix<1>{}) };
0258       // Assuming intermediate values are also allowed
0259       {
0260         v.allocateCalibrated(Vector<eBoundSize>{}, SquareMatrix<eBoundSize>{})
0261       };
0262 
0263       { v.chi2() } -> std::same_as<float&>;
0264 
0265       { v.pathLength() } -> std::same_as<double&>;
0266 
0267       { v.typeFlags() } -> std::same_as<MutableTrackStateTypeMap>;
0268     };
0269 
0270 }  // namespace Acts