File indexing completed on 2025-01-18 09:11:19
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, double 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, double time, const Acts::Vector3& direction,
0069 double qOverP, const Acts::Surface& surface,
0070 const Acts::GeometryContext& geoCtx, double tolerance) {
0071
0072 BoundVector bp = BoundVector::Zero();
0073
0074 auto result = surface.globalToLocal(geoCtx, position, direction, tolerance);
0075 if (!result.ok()) {
0076 return Result<Acts::BoundVector>::failure(result.error());
0077 }
0078
0079 auto localPosition = result.value();
0080 bp[eBoundLoc0] = localPosition[ePos0];
0081 bp[eBoundLoc1] = localPosition[ePos1];
0082
0083 bp[eBoundTime] = time;
0084 bp[eBoundPhi] = VectorHelpers::phi(direction);
0085 bp[eBoundTheta] = VectorHelpers::theta(direction);
0086 bp[eBoundQOverP] = qOverP;
0087 return Result<Acts::BoundVector>::success(bp);
0088 }
0089
0090 Acts::BoundVector Acts::transformFreeToCurvilinearParameters(double time,
0091 double phi,
0092 double theta,
0093 double qOverP) {
0094 BoundVector bp = BoundVector::Zero();
0095
0096 bp[eBoundTime] = time;
0097 bp[eBoundPhi] = phi;
0098 bp[eBoundTheta] = theta;
0099 bp[eBoundQOverP] = qOverP;
0100 return bp;
0101 }
0102
0103 Acts::BoundVector Acts::transformFreeToCurvilinearParameters(
0104 double time, const Vector3& direction, double qOverP) {
0105 BoundVector bp = BoundVector::Zero();
0106
0107 bp[eBoundTime] = time;
0108 bp[eBoundPhi] = VectorHelpers::phi(direction);
0109 bp[eBoundTheta] = VectorHelpers::theta(direction);
0110 bp[eBoundQOverP] = qOverP;
0111 return bp;
0112 }