Skip to content

Commit

Permalink
feat: Allow reflection of track parameters (#3682)
Browse files Browse the repository at this point in the history
Add helper functions to reflect track parameters. This is useful when seed parameters are estimated for the spacepoints in reverse direction which is necessary for strip seeds.

---

This pull request introduces functionality to reflect track parameters for both bound and free track parameters in the Acts framework. The key changes include adding new methods to reflect parameters and the corresponding implementation to handle the reflection logic.

### New Methods for Reflecting Track Parameters:

* [`Core/include/Acts/EventData/GenericBoundTrackParameters.hpp`](diffhunk://#diff-b3a2aaa0a0f138a1b44e7e6494aae4f8b905ad83716a4253bbea6446623f0eb1R253-R263): Added `reflectInplace` and `reflect` methods to `GenericBoundTrackParameters` to enable in-place reflection and returning reflected parameters.
* [`Core/include/Acts/EventData/GenericFreeTrackParameters.hpp`](diffhunk://#diff-35a3d07a1eb05110c620e3cdbc38968456e66270c9f9460472f49e65d8b43acdR177-R187): Added `reflectInplace` and `reflect` methods to `GenericFreeTrackParameters` to enable in-place reflection and returning reflected parameters.

### Helper Functions for Reflection:

* [`Core/include/Acts/EventData/TransformationHelpers.hpp`](diffhunk://#diff-73d04b62535d54171256def2e580c39602c9a2ab36db1689ebd74d84b79c127dR21-R32): Introduced `reflectBoundParameters` and `reflectFreeParameters` functions to handle the reflection logic for bound and free track parameters.
* [`Core/src/EventData/TransformationHelpers.cpp`](diffhunk://#diff-59ee8d8625a58700aca8eae78a6655d0162483f2644cdd2c77c668493d7d8b87R16-R40): Implemented the `reflectBoundParameters` and `reflectFreeParameters` functions to perform the actual reflection calculations.
  • Loading branch information
andiwand authored Oct 17, 2024
1 parent f935e25 commit bf36f46
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
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

0 comments on commit bf36f46

Please sign in to comment.