Back to home page

EIC code displayed by LXR

 
 

    


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

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