Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:22:20

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