File indexing completed on 2025-01-18 09:11:28
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Seeding/EstimateTrackParamsFromSeed.hpp"
0010
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/Utilities/MathHelpers.hpp"
0013
0014 #include <numbers>
0015
0016 Acts::FreeVector Acts::estimateTrackParamsFromSeed(const Vector3& sp0,
0017 const Vector3& sp1,
0018 const Vector3& sp2,
0019 const Vector3& bField) {
0020
0021
0022
0023
0024
0025 Vector3 relVec = sp1 - sp0;
0026 Vector3 newZAxis = bField.normalized();
0027 Vector3 newYAxis = newZAxis.cross(relVec).normalized();
0028 Vector3 newXAxis = newYAxis.cross(newZAxis);
0029 RotationMatrix3 rotation;
0030 rotation.col(0) = newXAxis;
0031 rotation.col(1) = newYAxis;
0032 rotation.col(2) = newZAxis;
0033
0034 Translation3 trans(sp0);
0035
0036 Transform3 transform(trans * rotation);
0037
0038
0039 Vector3 local1 = transform.inverse() * sp1;
0040 Vector3 local2 = transform.inverse() * sp2;
0041
0042
0043
0044
0045
0046
0047
0048 Vector2 circleCenter;
0049 circleCenter(0) = 0.5 * local1(0);
0050
0051 double deltaX21 = local2(0) - local1(0);
0052 double sumX21 = local2(0) + local1(0);
0053
0054
0055
0056
0057 double ia = deltaX21 / local2(1);
0058
0059
0060
0061 double b = 0.5 * (local2(1) + ia * sumX21);
0062 circleCenter(1) = -ia * circleCenter(0) + b;
0063
0064
0065 int sign = ia > 0 ? -1 : 1;
0066 const double R = circleCenter.norm();
0067 double invTanTheta =
0068 local2.z() / (2 * R * std::asin(local2.head<2>().norm() / (2 * R)));
0069
0070
0071 double A = -circleCenter(0) / circleCenter(1);
0072 Vector3 transDirection(1., A, fastHypot(1, A) * invTanTheta);
0073
0074 Vector3 direction = rotation * transDirection.normalized();
0075
0076
0077 FreeVector params = FreeVector::Zero();
0078
0079
0080 params.segment<3>(eFreePos0) = sp0;
0081
0082
0083 params.segment<3>(eFreeDir0) = direction;
0084
0085
0086
0087 double qOverPt = sign / (bField.norm() * R);
0088
0089 params[eFreeQOverP] = qOverPt / fastHypot(1., invTanTheta);
0090
0091 return params;
0092 }
0093
0094 Acts::BoundMatrix Acts::estimateTrackParamCovariance(
0095 const EstimateTrackParamCovarianceConfig& config, const BoundVector& params,
0096 bool hasTime) {
0097 assert((params[eBoundTheta] > 0 && params[eBoundTheta] < std::numbers::pi) &&
0098 "Theta must be in the range (0, pi)");
0099
0100 BoundSquareMatrix result = BoundSquareMatrix::Zero();
0101
0102 for (std::size_t i = eBoundLoc0; i < eBoundSize; ++i) {
0103 double sigma = config.initialSigmas[i];
0104 double variance = sigma * sigma;
0105
0106 if (i == eBoundQOverP) {
0107
0108 double varianceTheta = result(eBoundTheta, eBoundTheta);
0109
0110
0111 variance += std::pow(config.initialSigmaPtRel * params[eBoundQOverP], 2);
0112
0113
0114 variance +=
0115 varianceTheta *
0116 std::pow(params[eBoundQOverP] / std::tan(params[eBoundTheta]), 2);
0117 }
0118
0119 if (i == eBoundTime && !hasTime) {
0120
0121 variance *= config.noTimeVarInflation;
0122 }
0123
0124
0125 variance *= config.initialVarInflation[i];
0126
0127 result(i, i) = variance;
0128 }
0129
0130 return result;
0131 }