File indexing completed on 2025-01-19 09:23:18
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/Utilities/detail/periodic.hpp"
0013
0014 #include <cmath>
0015 #include <random>
0016 #include <utility>
0017
0018 namespace Acts::detail::Test {
0019
0020
0021
0022
0023 template <typename scalar_t, std::size_t kSize, typename generator_t>
0024 inline auto generateParametersCovariance(generator_t& rng)
0025 -> std::pair<Eigen::Matrix<scalar_t, kSize, 1>,
0026 Eigen::Matrix<scalar_t, kSize, kSize>> {
0027 using Scalar = scalar_t;
0028 using ParametersVector = Eigen::Matrix<scalar_t, kSize, 1>;
0029 using CovarianceMatrix = Eigen::Matrix<scalar_t, kSize, kSize>;
0030
0031 std::normal_distribution<Scalar> distNormal(0, 1);
0032 std::uniform_real_distribution<Scalar> distCorr(-1, 1);
0033
0034
0035 ParametersVector stddev;
0036 for (auto i = 0u; i < kSize; ++i) {
0037 stddev[i] = std::abs(distNormal(rng));
0038 }
0039
0040 CovarianceMatrix corr;
0041 for (auto i = 0u; i < kSize; ++i) {
0042 corr(i, i) = 1;
0043
0044 for (auto j = 0u; j < i; ++j) {
0045 corr(i, j) = corr(j, i) = distCorr(rng);
0046 }
0047 }
0048
0049 CovarianceMatrix cov = stddev.asDiagonal() * corr * stddev.asDiagonal();
0050
0051
0052
0053
0054 ParametersVector params;
0055 for (auto i = 0u; i < kSize; ++i) {
0056 params[i] = stddev[i] * distNormal(rng);
0057 }
0058
0059 return std::make_pair(params, cov);
0060 }
0061
0062
0063 template <typename generator_t>
0064 inline auto generateBoundParametersCovariance(generator_t& rng) {
0065 auto parCov = generateParametersCovariance<ActsScalar, eBoundSize>(rng);
0066 auto [phi, theta] = detail::normalizePhiTheta(parCov.first[eBoundPhi],
0067 parCov.first[eBoundTheta]);
0068 parCov.first[eBoundPhi] = phi;
0069 parCov.first[eBoundTheta] = theta;
0070 return parCov;
0071 }
0072
0073
0074 template <typename generator_t>
0075 inline auto generateFreeParametersCovariance(generator_t& rng) {
0076 return generateParametersCovariance<ActsScalar, eFreeSize>(rng);
0077 }
0078
0079 }