File indexing completed on 2026-05-17 07:34:21
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/EventData/MultiTrajectory.hpp"
0014 #include "Acts/EventData/SourceLink.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Geometry/GeometryIdentifier.hpp"
0017 #include "Acts/Geometry/TrackingGeometry.hpp"
0018 #include "Acts/Utilities/CalibrationContext.hpp"
0019
0020 #include <array>
0021 #include <cstddef>
0022 #include <iosfwd>
0023 #include <stdexcept>
0024
0025 namespace Acts::detail::Test {
0026
0027 struct TestSourceLinkSurfaceAccessor;
0028
0029
0030
0031
0032
0033
0034
0035
0036 struct TestSourceLink final {
0037 using SurfaceAccessor = TestSourceLinkSurfaceAccessor;
0038
0039 GeometryIdentifier m_geometryId{};
0040 std::size_t sourceId = 0u;
0041
0042 std::array<BoundIndices, 2> indices = {eBoundSize, eBoundSize};
0043 Acts::Vector2 parameters{};
0044 Acts::SquareMatrix<2> covariance{};
0045
0046
0047 TestSourceLink(BoundIndices idx, double val, double var,
0048 GeometryIdentifier gid = GeometryIdentifier(),
0049 std::size_t sid = 0u)
0050 : m_geometryId(gid),
0051 sourceId(sid),
0052 indices{idx, eBoundSize},
0053 parameters(val, 0),
0054 covariance(Acts::Vector2(var, 0).asDiagonal()) {}
0055
0056 TestSourceLink(BoundIndices idx0, BoundIndices idx1,
0057 const Acts::Vector2& params, const Acts::SquareMatrix<2>& cov,
0058 GeometryIdentifier gid = GeometryIdentifier(),
0059 std::size_t sid = 0u)
0060 : m_geometryId(gid),
0061 sourceId(sid),
0062 indices{idx0, idx1},
0063 parameters(params),
0064 covariance(cov) {}
0065
0066 TestSourceLink() = default;
0067 TestSourceLink(const TestSourceLink&) = default;
0068 TestSourceLink(TestSourceLink&&) = default;
0069 TestSourceLink& operator=(const TestSourceLink&) = default;
0070 TestSourceLink& operator=(TestSourceLink&&) = default;
0071
0072 bool operator==(const TestSourceLink& rhs) const {
0073 return (m_geometryId == rhs.m_geometryId) && (sourceId == rhs.sourceId) &&
0074 (indices == rhs.indices) && (parameters == rhs.parameters) &&
0075 (covariance == rhs.covariance);
0076 }
0077
0078 std::ostream& print(std::ostream& os) const {
0079 os << "TestsSourceLink(geometryId=" << m_geometryId
0080 << ",sourceId=" << sourceId;
0081 if (indices[0] != eBoundSize) {
0082 os << ",index0=" << indices[0];
0083 }
0084 if (indices[1] != eBoundSize) {
0085 os << ",index1=" << indices[1];
0086 }
0087 os << ")";
0088 return os;
0089 }
0090 constexpr std::size_t index() const { return sourceId; }
0091 };
0092
0093 struct TestSourceLinkSurfaceAccessor {
0094 const TrackingGeometry& geometry;
0095
0096 const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const {
0097 const auto& testSourceLink = sourceLink.get<TestSourceLink>();
0098 return geometry.findSurface(testSourceLink.m_geometryId);
0099 }
0100 };
0101
0102 inline std::ostream& operator<<(std::ostream& os,
0103 const TestSourceLink& sourceLink) {
0104 return sourceLink.print(os);
0105 }
0106
0107
0108
0109
0110
0111 template <typename trajectory_t>
0112 void testSourceLinkCalibrator(
0113 const GeometryContext& , const CalibrationContext& ,
0114 const SourceLink& sourceLink,
0115 typename trajectory_t::TrackStateProxy trackState) {
0116 TestSourceLink sl = sourceLink.template get<TestSourceLink>();
0117
0118 trackState.setUncalibratedSourceLink(SourceLink{sourceLink});
0119
0120 if ((sl.indices[0] != Acts::eBoundSize) &&
0121 (sl.indices[1] != Acts::eBoundSize)) {
0122 trackState.allocateCalibrated(2);
0123 trackState.template calibrated<2>() = sl.parameters;
0124 trackState.template calibratedCovariance<2>() = sl.covariance;
0125 trackState.setProjectorSubspaceIndices(
0126 std::array{sl.indices[0], sl.indices[1]});
0127 } else if (sl.indices[0] != Acts::eBoundSize) {
0128 trackState.allocateCalibrated(1);
0129 trackState.template calibrated<1>() = sl.parameters.head<1>();
0130 trackState.template calibratedCovariance<1>() =
0131 sl.covariance.topLeftCorner<1, 1>();
0132 trackState.setProjectorSubspaceIndices(std::array{sl.indices[0]});
0133 } else {
0134 throw std::runtime_error(
0135 "Tried to extract measurement from invalid TestSourceLink");
0136 }
0137 }
0138
0139 }