File indexing completed on 2026-09-18 08:21:29
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/EventData/TransformationHelpers.hpp"
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Common.hpp"
0013 #include "Acts/Surfaces/Surface.hpp"
0014 #include "Acts/Utilities/Result.hpp"
0015 #include "Acts/Utilities/UnitVectors.hpp"
0016
0017 Acts::FreeVector Acts::transformBoundToFreeParameters(
0018 const Acts::Surface& surface, const GeometryContext& geoCtx,
0019 const Acts::BoundVector& boundParams) {
0020
0021 Vector3 direction = makeDirectionFromPhiTheta(boundParams[eBoundPhi],
0022 boundParams[eBoundTheta]);
0023
0024
0025 Vector2 local(boundParams[eBoundLoc0], boundParams[eBoundLoc1]);
0026 Vector3 position = surface.localToGlobal(geoCtx, local, direction);
0027
0028
0029 FreeVector freeParams = FreeVector::Zero();
0030 freeParams[eFreePos0] = position[ePos0];
0031 freeParams[eFreePos1] = position[ePos1];
0032 freeParams[eFreePos2] = position[ePos2];
0033 freeParams[eFreeTime] = boundParams[eBoundTime];
0034 freeParams[eFreeDir0] = direction[eMom0];
0035 freeParams[eFreeDir1] = direction[eMom1];
0036 freeParams[eFreeDir2] = direction[eMom2];
0037 freeParams[eFreeQOverP] = boundParams[eBoundQOverP];
0038 return freeParams;
0039 }
0040
0041 Acts::Result<Acts::BoundVector> Acts::transformFreeToBoundParameters(
0042 const FreeVector& freeParams, const Surface& surface,
0043 const GeometryContext& geoCtx, double tolerance) {
0044
0045 BoundVector bp = BoundVector::Zero();
0046
0047 auto position = freeParams.segment<3>(eFreePos0);
0048 auto direction = freeParams.segment<3>(eFreeDir0);
0049 auto result = surface.globalToLocal(geoCtx, position, direction, tolerance);
0050 if (!result.ok()) {
0051 return Result<Acts::BoundVector>::failure(result.error());
0052 }
0053
0054 auto localPosition = result.value();
0055 bp[eBoundLoc0] = localPosition[ePos0];
0056 bp[eBoundLoc1] = localPosition[ePos1];
0057
0058 bp[eBoundTime] = freeParams[eFreeTime];
0059 bp[eBoundPhi] = VectorHelpers::phi(direction);
0060 bp[eBoundTheta] = VectorHelpers::theta(direction);
0061 bp[eBoundQOverP] = freeParams[eFreeQOverP];
0062 return Result<Acts::BoundVector>::success(bp);
0063 }
0064
0065 Acts::Result<Acts::BoundVector> Acts::transformFreeToBoundParameters(
0066 const Acts::Vector3& position, double time, const Acts::Vector3& direction,
0067 double qOverP, const Acts::Surface& surface,
0068 const Acts::GeometryContext& geoCtx, double tolerance) {
0069
0070 BoundVector bp = BoundVector::Zero();
0071
0072 auto result = surface.globalToLocal(geoCtx, position, direction, tolerance);
0073 if (!result.ok()) {
0074 return Result<Acts::BoundVector>::failure(result.error());
0075 }
0076
0077 auto localPosition = result.value();
0078 bp[eBoundLoc0] = localPosition[ePos0];
0079 bp[eBoundLoc1] = localPosition[ePos1];
0080
0081 bp[eBoundTime] = time;
0082 bp[eBoundPhi] = VectorHelpers::phi(direction);
0083 bp[eBoundTheta] = VectorHelpers::theta(direction);
0084 bp[eBoundQOverP] = qOverP;
0085 return Result<Acts::BoundVector>::success(bp);
0086 }
0087
0088 Acts::BoundVector Acts::transformFreeToCurvilinearParameters(double time,
0089 double phi,
0090 double theta,
0091 double qOverP) {
0092 BoundVector bp = BoundVector::Zero();
0093
0094 bp[eBoundTime] = time;
0095 bp[eBoundPhi] = phi;
0096 bp[eBoundTheta] = theta;
0097 bp[eBoundQOverP] = qOverP;
0098 return bp;
0099 }
0100
0101 Acts::BoundVector Acts::transformFreeToCurvilinearParameters(
0102 double time, const Vector3& direction, double qOverP) {
0103 BoundVector bp = BoundVector::Zero();
0104
0105 bp[eBoundTime] = time;
0106 bp[eBoundPhi] = VectorHelpers::phi(direction);
0107 bp[eBoundTheta] = VectorHelpers::theta(direction);
0108 bp[eBoundQOverP] = qOverP;
0109 return bp;
0110 }