Skip to content

Commit

Permalink
refactor: Add tolerance to transformFreeToBoundParameters (#2112)
Browse files Browse the repository at this point in the history
configurable tolerance for `transformFreeToBoundParameters` which is otherwise defaulted by the surface
  • Loading branch information
andiwand committed May 9, 2023
1 parent 6e613f0 commit 9bafb2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 8 additions & 2 deletions Core/include/Acts/EventData/detail/TransformationFreeToBound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Tolerance.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Utilities/Result.hpp"
Expand All @@ -24,10 +25,12 @@ namespace detail {
/// @param freeParams Free track parameters vector
/// @param surface Surface onto which the parameters are bound
/// @param geoCtx Geometry context for the global-to-local transformation
/// @param tolerance Tolerance used for globalToLocal
///
/// @return Bound track parameters vector on the given surface
Result<BoundVector> transformFreeToBoundParameters(
const FreeVector& freeParams, const Surface& surface,
const GeometryContext& geoCtx);
const GeometryContext& geoCtx, ActsScalar tolerance = s_onSurfaceTolerance);

/// Convert position and direction to bound track parameters.
///
Expand All @@ -37,10 +40,13 @@ Result<BoundVector> transformFreeToBoundParameters(
/// @param qOverP Charge-over-momentum-like parameter
/// @param surface Surface onto which the parameters are bound
/// @param geoCtx Geometry context for the global-to-local transformation
/// @param tolerance Tolerance used for globalToLocal
///
/// @return Equivalent bound parameters vector on the given surface
Result<BoundVector> transformFreeToBoundParameters(
const Vector3& position, ActsScalar time, const Vector3& direction,
ActsScalar qOverP, const Surface& surface, const GeometryContext& geoCtx);
ActsScalar qOverP, const Surface& surface, const GeometryContext& geoCtx,
ActsScalar tolerance = s_onSurfaceTolerance);

/// Convert direction to curvilinear track parameters.
///
Expand Down
9 changes: 5 additions & 4 deletions Core/src/EventData/TransformationFreeToBound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

Acts::Result<Acts::BoundVector> Acts::detail::transformFreeToBoundParameters(
const FreeVector& freeParams, const Surface& surface,
const GeometryContext& geoCtx) {
const GeometryContext& geoCtx, ActsScalar tolerance) {
// initialize the bound vector
BoundVector bp = BoundVector::Zero();
// convert global to local position on the surface
auto position = freeParams.segment<3>(eFreePos0);
auto direction = freeParams.segment<3>(eFreeDir0);
auto result = surface.globalToLocal(geoCtx, position, direction);
auto result = surface.globalToLocal(geoCtx, position, direction, tolerance);
if (!result.ok()) {
return Result<Acts::BoundVector>::failure(result.error());
}
Expand All @@ -40,11 +40,12 @@ Acts::Result<Acts::BoundVector> Acts::detail::transformFreeToBoundParameters(
Acts::Result<Acts::BoundVector> Acts::detail::transformFreeToBoundParameters(
const Acts::Vector3& position, ActsScalar time,
const Acts::Vector3& direction, ActsScalar qOverP,
const Acts::Surface& surface, const Acts::GeometryContext& geoCtx) {
const Acts::Surface& surface, const Acts::GeometryContext& geoCtx,
ActsScalar tolerance) {
// initialize the bound vector
BoundVector bp = BoundVector::Zero();
// convert global to local position on the surface
auto result = surface.globalToLocal(geoCtx, position, direction);
auto result = surface.globalToLocal(geoCtx, position, direction, tolerance);
if (!result.ok()) {
return Result<Acts::BoundVector>::failure(result.error());
}
Expand Down

0 comments on commit 9bafb2f

Please sign in to comment.