File indexing completed on 2025-01-18 09:10:47
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/TrackParameters.hpp"
0012 #include "Acts/EventData/VectorMultiTrajectory.hpp"
0013 #include "Acts/EventData/detail/GenerateParameters.hpp"
0014 #include "Acts/EventData/detail/TestSourceLink.hpp"
0015 #include "Acts/Surfaces/CurvilinearSurface.hpp"
0016 #include "Acts/Utilities/CalibrationContext.hpp"
0017
0018 #include <random>
0019
0020 namespace Acts::detail::Test {
0021
0022 struct TestTrackState {
0023 std::shared_ptr<Surface> surface;
0024 TestSourceLink sourceLink;
0025 BoundTrackParameters predicted;
0026 BoundTrackParameters filtered;
0027 BoundTrackParameters smoothed;
0028 BoundMatrix jacobian;
0029 double chi2;
0030 double pathLength;
0031
0032
0033
0034
0035
0036 template <typename rng_t>
0037 TestTrackState(rng_t& rng, std::size_t measdim)
0038 : surface(
0039 CurvilinearSurface(Vector3::Zero(), Vector3::UnitZ()).surface()),
0040
0041 predicted(surface, someBoundParametersA(), std::nullopt,
0042 ParticleHypothesis::pion()),
0043 filtered(surface, someBoundParametersA(), std::nullopt,
0044 ParticleHypothesis::pion()),
0045 smoothed(surface, someBoundParametersA(), std::nullopt,
0046 ParticleHypothesis::pion()),
0047 jacobian(BoundMatrix::Identity()),
0048 chi2(std::chi_squared_distribution<double>(measdim)(rng)),
0049 pathLength(std::uniform_real_distribution<double>(
0050 1 * Acts::UnitConstants::mm, 10 * Acts::UnitConstants::mm)(rng)) {
0051
0052 auto geoId =
0053 std::uniform_int_distribution<GeometryIdentifier::Value>()(rng);
0054 surface->assignGeometryId(geoId);
0055
0056
0057 if (measdim == 1u) {
0058 auto [par, cov] = generateParametersCovariance<double, 1u>(rng);
0059 sourceLink = TestSourceLink(eBoundLoc0, par[0], cov(0, 0), geoId);
0060 } else if (measdim == 2u) {
0061 auto [par, cov] = generateParametersCovariance<double, 2u>(rng);
0062 sourceLink = TestSourceLink(eBoundLoc1, eBoundQOverP, par, cov, geoId);
0063 } else {
0064 throw std::runtime_error("invalid number of measurement dimensions");
0065 }
0066
0067
0068 auto [trkPar, trkCov] = generateBoundParametersCovariance(rng, {});
0069
0070
0071
0072
0073 predicted = BoundTrackParameters(surface, trkPar, trkCov,
0074 ParticleHypothesis::pion());
0075
0076
0077 filtered = BoundTrackParameters(surface, trkPar, 0.75 * trkCov,
0078 ParticleHypothesis::pion());
0079
0080
0081 smoothed = BoundTrackParameters(surface, trkPar, 0.5 * trkCov,
0082 ParticleHypothesis::pion());
0083
0084
0085 for (Eigen::Index c = 0; c < jacobian.cols(); ++c) {
0086 for (Eigen::Index r = 0; r < jacobian.rows(); ++r) {
0087 jacobian(c, r) +=
0088 std::uniform_real_distribution<double>(-0.125, 0.125)(rng);
0089 }
0090 }
0091 }
0092 };
0093
0094
0095
0096
0097
0098
0099
0100 template <typename trajectory_t, typename track_state_t>
0101 void fillTrackState(const TestTrackState& pc, TrackStatePropMask mask,
0102 track_state_t& ts) {
0103
0104 ts.setReferenceSurface(pc.predicted.referenceSurface().getSharedPtr());
0105
0106 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Predicted)) {
0107 ts.predicted() = pc.predicted.parameters();
0108 assert(pc.predicted.covariance().has_value());
0109 ts.predictedCovariance() = *(pc.predicted.covariance());
0110 }
0111 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Filtered)) {
0112 ts.filtered() = pc.filtered.parameters();
0113 assert(pc.filtered.covariance().has_value());
0114 ts.filteredCovariance() = *(pc.filtered.covariance());
0115 }
0116 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Smoothed)) {
0117 ts.smoothed() = pc.smoothed.parameters();
0118 assert(pc.smoothed.covariance().has_value());
0119 ts.smoothedCovariance() = *(pc.smoothed.covariance());
0120 }
0121 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Jacobian)) {
0122 ts.jacobian() = pc.jacobian;
0123 }
0124 ts.chi2() = pc.chi2;
0125 ts.pathLength() = pc.pathLength;
0126
0127
0128 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Calibrated)) {
0129 testSourceLinkCalibrator<trajectory_t>(Acts::GeometryContext{},
0130 Acts::CalibrationContext{},
0131 SourceLink{pc.sourceLink}, ts);
0132 assert(ts.hasUncalibratedSourceLink());
0133 }
0134 }
0135
0136 }