Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow reflection of track parameters #3682

Merged
merged 6 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Core/include/Acts/EventData/GenericBoundTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ class GenericBoundTrackParameters {
return m_surface->referenceFrame(geoCtx, position(geoCtx), momentum());
}

/// Reflect the parameters in place.
void reflectInPlace() { m_params = reflectBoundParameters(m_params); }

/// Reflect the parameters.
/// @return Reflected parameters.
GenericBoundTrackParameters<ParticleHypothesis> reflect() const {
GenericBoundTrackParameters<ParticleHypothesis> reflected = *this;
reflected.reflectInPlace();
return reflected;
}

private:
BoundVector m_params;
std::optional<BoundSquareMatrix> m_cov;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class GenericCurvilinearTrackParameters
Vector3 position() const {
return GenericBoundTrackParameters<ParticleHypothesis>::position({});
}

/// Reflect the parameters.
/// @return Reflected parameters.
GenericCurvilinearTrackParameters<ParticleHypothesis> reflect() const {
GenericCurvilinearTrackParameters<ParticleHypothesis> reflected = *this;
reflected.reflectInPlace();
return reflected;
}
};

} // namespace Acts
12 changes: 12 additions & 0 deletions Core/include/Acts/EventData/GenericFreeTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Acts/Definitions/Common.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/EventData/TrackParametersConcept.hpp"
#include "Acts/EventData/TransformationHelpers.hpp"
#include "Acts/EventData/detail/PrintParameters.hpp"
#include "Acts/Utilities/MathHelpers.hpp"
#include "Acts/Utilities/UnitVectors.hpp"
Expand Down Expand Up @@ -175,6 +176,17 @@ class GenericFreeTrackParameters {
return m_particleHypothesis;
}

/// Reflect the parameters in place.
void reflectInPlace() { m_params = reflectFreeParameters(m_params); }

/// Reflect the parameters.
/// @return Reflected parameters.
GenericFreeTrackParameters<ParticleHypothesis> reflect() const {
GenericFreeTrackParameters<ParticleHypothesis> reflected = *this;
reflected.reflectInPlace();
return reflected;
}

private:
FreeVector m_params;
std::optional<FreeSquareMatrix> m_cov;
Expand Down
28 changes: 28 additions & 0 deletions Core/include/Acts/EventData/TransformationHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,39 @@
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Utilities/Result.hpp"
#include "Acts/Utilities/detail/periodic.hpp"

namespace Acts {

class Surface;

/// Reflect bound track parameters.
///
/// @param boundParams Bound track parameters vector
/// @return Reflected bound track parameters vector
inline BoundVector reflectBoundParameters(const BoundVector& boundParams) {
BoundVector reflected = boundParams;
auto [phi, theta] = detail::normalizePhiTheta(
boundParams[eBoundPhi] - M_PI, M_PI - boundParams[eBoundTheta]);
reflected[eBoundPhi] = phi;
reflected[eBoundTheta] = theta;
reflected[eBoundQOverP] = -boundParams[eBoundQOverP];
return reflected;
}

/// Reflect free track parameters.
///
/// @param freeParams Free track parameters vector
/// @return Reflected free track parameters vector
inline FreeVector reflectFreeParameters(const FreeVector& freeParams) {
FreeVector reflected = freeParams;
reflected[eFreeDir0] = -freeParams[eFreeDir0];
reflected[eFreeDir1] = -freeParams[eFreeDir1];
reflected[eFreeDir2] = -freeParams[eFreeDir2];
reflected[eFreeQOverP] = -freeParams[eFreeQOverP];
return reflected;
}

/// Transform bound track parameters into equivalent free track parameters.
///
/// @param surface Surface onto which the input parameters are bound
Expand Down
8 changes: 8 additions & 0 deletions Tests/UnitTests/Core/EventData/BoundTrackParametersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ void checkParameters(const BoundTrackParameters& params, double l0, double l1,
eps);
CHECK_CLOSE_OR_SMALL(params.momentum(), p * unitDir, eps, eps);
BOOST_CHECK_EQUAL(params.charge(), q);

// reflection
BoundTrackParameters reflectedParams = params;
reflectedParams.reflectInPlace();
CHECK_CLOSE_OR_SMALL(params.reflect().parameters(),
reflectedParams.parameters(), eps, eps);
CHECK_CLOSE_OR_SMALL(reflectedParams.reflect().parameters(),
params.parameters(), eps, eps);
}

void runTest(const std::shared_ptr<const Surface>& surface, double l0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ void checkParameters(const CurvilinearTrackParameters& params, double phi,
// curvilinear reference surface
CHECK_CLOSE_OR_SMALL(referenceSurface->center(geoCtx), pos, eps, eps);
CHECK_CLOSE_OR_SMALL(referenceSurface->normal(geoCtx), unitDir, eps, eps);

// reflection
CurvilinearTrackParameters reflectedParams = params;
reflectedParams.reflectInPlace();
CHECK_CLOSE_OR_SMALL(params.reflect().parameters(),
reflectedParams.parameters(), eps, eps);
CHECK_CLOSE_OR_SMALL(reflectedParams.reflect().parameters(),
params.parameters(), eps, eps);

// TODO verify reference frame
}

Expand Down
8 changes: 8 additions & 0 deletions Tests/UnitTests/Core/EventData/FreeTrackParametersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ void checkParameters(const FreeTrackParameters& params, const Vector4& pos4,
eps);
CHECK_CLOSE_OR_SMALL(params.time(), params.template get<eFreeTime>(), eps,
eps);

// reflection
FreeTrackParameters reflectedParams = params;
reflectedParams.reflectInPlace();
CHECK_CLOSE_OR_SMALL(params.reflect().parameters(),
reflectedParams.parameters(), eps, eps);
CHECK_CLOSE_OR_SMALL(reflectedParams.reflect().parameters(),
params.parameters(), eps, eps);
}

} // namespace
Expand Down
Loading