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