Skip to content

Commit

Permalink
refactor!: Consistent naming for direction (#2343)
Browse files Browse the repository at this point in the history
The last PR in the series of having consistent naming for `direction`

After
- #2251
- #2250
  • Loading branch information
andiwand committed Aug 17, 2023
1 parent 49de0d3 commit 62ec2e1
Show file tree
Hide file tree
Showing 43 changed files with 118 additions and 132 deletions.
12 changes: 6 additions & 6 deletions Core/include/Acts/EventData/GenericBoundTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class GenericBoundTrackParameters {
Vector4 fourPosition(const GeometryContext& geoCtx) const {
Vector4 pos4;
pos4.segment<3>(ePos0) =
m_surface->localToGlobal(geoCtx, localPosition(), unitDirection());
m_surface->localToGlobal(geoCtx, localPosition(), direction());
pos4[eTime] = m_params[eBoundTime];
return pos4;
}
Expand All @@ -197,16 +197,16 @@ class GenericBoundTrackParameters {
/// select the appropriate transformation and might be a computationally
/// expensive operation.
Vector3 position(const GeometryContext& geoCtx) const {
return m_surface->localToGlobal(geoCtx, localPosition(), unitDirection());
return m_surface->localToGlobal(geoCtx, localPosition(), direction());
}
/// Time coordinate.
Scalar time() const { return m_params[eBoundTime]; }

/// Unit direction three-vector, i.e. the normalized momentum
/// three-vector.
Vector3 unitDirection() const {
return makeDirectionUnitFromPhiTheta(m_params[eBoundPhi],
m_params[eBoundTheta]);
Vector3 direction() const {
return makeDirectionFromPhiTheta(m_params[eBoundPhi],
m_params[eBoundTheta]);
}
/// Absolute momentum.
Scalar absoluteMomentum() const {
Expand All @@ -217,7 +217,7 @@ class GenericBoundTrackParameters {
return std::sin(m_params[eBoundTheta]) * absoluteMomentum();
}
/// Momentum three-vector.
Vector3 momentum() const { return absoluteMomentum() * unitDirection(); }
Vector3 momentum() const { return absoluteMomentum() * direction(); }

/// Particle electric charge.
Scalar charge() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ class GenericCurvilinearTrackParameters
const Vector4& pos4, Scalar phi, Scalar theta, Scalar p, Scalar q,
std::optional<CovarianceMatrix> cov = std::nullopt)
: Base(Surface::makeShared<PlaneSurface>(
pos4.segment<3>(ePos0),
makeDirectionUnitFromPhiTheta(phi, theta)),
pos4.segment<3>(ePos0), makeDirectionFromPhiTheta(phi, theta)),
detail::transformFreeToCurvilinearParameters(
pos4[eTime], phi, theta, (q != Scalar(0)) ? (q / p) : (1 / p)),
q, std::move(cov)) {
Expand All @@ -105,8 +104,7 @@ class GenericCurvilinearTrackParameters
const Vector4& pos4, Scalar phi, Scalar theta, Scalar qOverP,
std::optional<CovarianceMatrix> cov = std::nullopt)
: Base(Surface::makeShared<PlaneSurface>(
pos4.segment<3>(ePos0),
makeDirectionUnitFromPhiTheta(phi, theta)),
pos4.segment<3>(ePos0), makeDirectionFromPhiTheta(phi, theta)),
detail::transformFreeToCurvilinearParameters(pos4[eTime], phi,
theta, qOverP),
std::move(cov)) {}
Expand Down
8 changes: 4 additions & 4 deletions Core/include/Acts/EventData/GenericFreeTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class GenericFreeTrackParameters {
m_chargeInterpreter(std::abs(q)) {
assert((0 <= p) and "Absolute momentum must be positive");

auto dir = makeDirectionUnitFromPhiTheta(phi, theta);
auto dir = makeDirectionFromPhiTheta(phi, theta);
m_params[eFreePos0] = pos4[ePos0];
m_params[eFreePos1] = pos4[ePos1];
m_params[eFreePos2] = pos4[ePos2];
Expand All @@ -110,7 +110,7 @@ class GenericFreeTrackParameters {
Scalar qOverP,
std::optional<CovarianceMatrix> cov = std::nullopt)
: m_params(FreeVector::Zero()), m_cov(std::move(cov)) {
auto dir = makeDirectionUnitFromPhiTheta(phi, theta);
auto dir = makeDirectionFromPhiTheta(phi, theta);
m_params[eFreePos0] = pos4[ePos0];
m_params[eFreePos1] = pos4[ePos1];
m_params[eFreePos2] = pos4[ePos2];
Expand Down Expand Up @@ -158,7 +158,7 @@ class GenericFreeTrackParameters {
Scalar time() const { return m_params[eFreeTime]; }

/// Unit direction three-vector, i.e. the normalized momentum three-vector.
Vector3 unitDirection() const {
Vector3 direction() const {
return m_params.segment<3>(eFreeDir0).normalized();
}
/// Absolute momentum.
Expand All @@ -179,7 +179,7 @@ class GenericFreeTrackParameters {
return (transverseMagnitude / magnitude) * absoluteMomentum();
}
/// Momentum three-vector.
Vector3 momentum() const { return absoluteMomentum() * unitDirection(); }
Vector3 momentum() const { return absoluteMomentum() * direction(); }

/// Particle electric charge.
Scalar charge() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ class MultiComponentBoundTrackParameters {

/// Unit direction three-vector, i.e. the normalized momentum
/// three-vector.
Vector3 unitDirection() const {
return reduce([](const SingleParameters& p) { return p.unitDirection(); })
Vector3 direction() const {
return reduce([](const SingleParameters& p) { return p.direction(); })
.normalized();
}

Expand Down
20 changes: 9 additions & 11 deletions Core/include/Acts/EventData/TrackParametersConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using ReturnTypePosition = decltype(std::declval<T>().position());
template <typename T>
using ReturnTypeTime = decltype(std::declval<T>().time());
template <typename T>
using ReturnTypeUnitDirection = decltype(std::declval<T>().unitDirection());
using ReturnTypeDirection = decltype(std::declval<T>().direction());
template <typename T>
using ReturnTypeAbsoluteMomentum =
decltype(std::declval<T>().absoluteMomentum());
Expand Down Expand Up @@ -78,8 +78,8 @@ struct BoundTrackParametersConceptImpl {
identical_to<Vector3, ReturnTypePositionFromContext, const T>;
constexpr static bool hasMethodTime =
identical_to<TypeScalar<T>, ReturnTypeTime, const T>;
constexpr static bool hasMethodUnitDirection =
identical_to<Vector3, ReturnTypeUnitDirection, const T>;
constexpr static bool hasMethodDirection =
identical_to<Vector3, ReturnTypeDirection, const T>;
constexpr static bool hasMethodAbsoluteMomentum =
identical_to<TypeScalar<T>, ReturnTypeAbsoluteMomentum, const T>;
constexpr static bool hasMethodCharge =
Expand All @@ -98,8 +98,7 @@ struct BoundTrackParametersConceptImpl {
static_assert(hasMethodPositionFromContext,
"Missing or invalid 'position' method");
static_assert(hasMethodTime, "Missing or invalid 'time' method");
static_assert(hasMethodUnitDirection,
"Missing or invalid 'unitDirection' method");
static_assert(hasMethodDirection, "Missing or invalid 'direction' method");
static_assert(hasMethodAbsoluteMomentum,
"Missing or invalid 'absoluteMomentum' method");
static_assert(hasMethodCharge, "Missing or invalid 'charge' method");
Expand All @@ -110,7 +109,7 @@ struct BoundTrackParametersConceptImpl {
require<hasTypeScalar, hasTypeParametersVector, hasTypeCovarianceMatrix,
hasMethodParameters, hasMethodCovariance,
hasMethodFourPositionFromContext, hasMethodPositionFromContext,
hasMethodTime, hasMethodUnitDirection, hasMethodAbsoluteMomentum,
hasMethodTime, hasMethodDirection, hasMethodAbsoluteMomentum,
hasMethodCharge, hasMethodReferenceSurface>;
};

Expand All @@ -135,8 +134,8 @@ struct FreeTrackParametersConceptImpl {
identical_to<Vector3, ReturnTypePosition, const T>;
constexpr static bool hasMethodTime =
identical_to<TypeScalar<T>, ReturnTypeTime, const T>;
constexpr static bool hasMethodUnitDirection =
identical_to<Vector3, ReturnTypeUnitDirection, const T>;
constexpr static bool hasMethodDirection =
identical_to<Vector3, ReturnTypeDirection, const T>;
constexpr static bool hasMethodAbsoluteMomentum =
identical_to<TypeScalar<T>, ReturnTypeAbsoluteMomentum, const T>;
constexpr static bool hasMethodCharge =
Expand All @@ -152,16 +151,15 @@ struct FreeTrackParametersConceptImpl {
"Missing or invalid 'fourPosition' method");
static_assert(hasMethodPosition, "Missing or invalid 'position' method");
static_assert(hasMethodTime, "Missing or invalid 'time' method");
static_assert(hasMethodUnitDirection,
"Missing or invalid 'unitDirection' method");
static_assert(hasMethodDirection, "Missing or invalid 'direction' method");
static_assert(hasMethodAbsoluteMomentum,
"Missing or invalid 'absoluteMomentum' method");
static_assert(hasMethodCharge, "Missing or invalid 'charge' method");

constexpr static bool value =
require<hasTypeScalar, hasTypeParametersVector, hasTypeCovarianceMatrix,
hasMethodParameters, hasMethodCovariance, hasMethodFourPosition,
hasMethodPosition, hasMethodTime, hasMethodUnitDirection,
hasMethodPosition, hasMethodTime, hasMethodDirection,
hasMethodAbsoluteMomentum, hasMethodCharge>;
};

Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/EventData/TrackProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,14 @@ class TrackProxy {

/// Get a unit vector along the track direction at the reference surface
/// @return The direction unit vector
Vector3 unitDirection() const {
return makeDirectionUnitFromPhiTheta(phi(), theta());
Vector3 direction() const {
return makeDirectionFromPhiTheta(phi(), theta());
}

/// Get the global momentum vector
/// @return the global momentum vector
Vector3 momentum() const {
return absoluteMomentum() * unitDirection();
return absoluteMomentum() * direction();
}

/// Get a range over the track states of this track. Return value is
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/AtlasStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class AtlasStepper {
covTransport = true;
useJacobian = true;
const auto transform = pars.referenceSurface().referenceFrame(
geoContext, pos, pars.unitDirection());
geoContext, pos, pars.direction());

pVector[8] = transform(0, eBoundLoc0);
pVector[16] = transform(0, eBoundLoc1);
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/EigenStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class EigenStepper {
fieldCache(std::move(fieldCacheIn)),
geoContext(gctx) {
pars.template segment<3>(eFreePos0) = par.position(gctx);
pars.template segment<3>(eFreeDir0) = par.unitDirection();
pars.template segment<3>(eFreeDir0) = par.direction();
pars[eFreeTime] = par.time();
pars[eFreeQOverP] = par.parameters()[eBoundQOverP];

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ auto MultiEigenStepperLoop<E, R, A>::curvilinearState(State& state,
state.components[i].state, transportCov);

pos4 += state.components[i].weight * cp.fourPosition(state.geoContext);
dir += state.components[i].weight * cp.unitDirection();
dir += state.components[i].weight * cp.direction();
qop += state.components[i].weight * (cp.charge() / cp.absoluteMomentum());
if (cp.covariance()) {
cov += state.components[i].weight * *cp.covariance();
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/RiddersPropagator.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ auto Acts::RiddersPropagator<propagator_t>::propagate(
// replace the covariance of the nominal result w/ the ridders covariance
nominalResult.endParameters = CurvilinearTrackParameters(
nominalFinalParameters.fourPosition(options.geoContext),
nominalFinalParameters.unitDirection(),
nominalFinalParameters.direction(),
nominalFinalParameters.absoluteMomentum(),
nominalFinalParameters.charge(), std::move(cov));
}
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/StraightLineStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class StraightLineStepper {
geoContext(gctx) {
(void)mctx;
pars.template segment<3>(eFreePos0) = par.position(gctx);
pars.template segment<3>(eFreeDir0) = par.unitDirection();
pars.template segment<3>(eFreeDir0) = par.direction();
pars[eFreeTime] = par.time();
pars[eFreeQOverP] = par.parameters()[eBoundQOverP];
if (par.covariance()) {
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/TrackFitting/GaussianSumFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ struct GaussianSumFitter {
sParameters.referenceSurface()
.intersect(GeometryContext{},
sParameters.position(GeometryContext{}),
sParameters.unitDirection(), true)
sParameters.direction(), true)
.intersection.status;

if (intersectionStatusStartSurface != Intersection3D::Status::onSurface) {
Expand Down
7 changes: 3 additions & 4 deletions Core/include/Acts/TrackFitting/detail/GsfActor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,9 @@ struct GsfActor {
old_bound.position(state.stepping.geoContext), state.options.direction,
MaterialUpdateStage::FullUpdate);

auto pathCorrection =
surface.pathCorrection(state.stepping.geoContext,
old_bound.position(state.stepping.geoContext),
old_bound.unitDirection());
auto pathCorrection = surface.pathCorrection(
state.stepping.geoContext,
old_bound.position(state.stepping.geoContext), old_bound.direction());
slab.scaleThickness(pathCorrection);

// Emit a warning if the approximation is not valid for this x/x0
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Utilities/UnitVectors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ inline Eigen::Matrix<T, 3, 1> makeDirectionUnitFromPhiEta(T phi, T eta) {
/// unexpected implicit type conversions and forces the user to
/// explicitly cast mismatched input types.
template <typename T>
inline Eigen::Matrix<T, 3, 1> makeDirectionUnitFromPhiTheta(T phi, T theta) {
inline Eigen::Matrix<T, 3, 1> makeDirectionFromPhiTheta(T phi, T theta) {
const auto cosTheta = std::cos(theta);
const auto sinTheta = std::sin(theta);
return {
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Acts::Result<Acts::LinearizedTrack> Acts::
// This allows us to determine whether we need to propagate the track
// forward or backward to arrive at the PCA.
auto intersection = perigeeSurface->intersect(gctx, params.position(gctx),
params.unitDirection(), false);
params.direction(), false);

// Create propagator options
propagator_options_t pOptions(gctx, mctx);
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Vertexing/NumericalTrackLinearizer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Acts::NumericalTrackLinearizer<propagator_t, propagator_options_t>::
// This allows us to determine whether we need to propagate the track
// forward or backward to arrive at the PCA.
auto intersection = perigeeSurface->intersect(gctx, params.position(gctx),
params.unitDirection(), false);
params.direction(), false);

// Setting the propagation direction using the intersection length from
// above.
Expand Down Expand Up @@ -108,8 +108,8 @@ Acts::NumericalTrackLinearizer<propagator_t, propagator_options_t>::
// Create curvilinear track object from our parameters. This is needed for
// the propagation. Note that we work without covariance since we don't need
// it to compute the derivative.
Vector3 wiggledDir = makeDirectionUnitFromPhiTheta(paramVecCopy(eLinPhi),
paramVecCopy(eLinTheta));
Vector3 wiggledDir = makeDirectionFromPhiTheta(paramVecCopy(eLinPhi),
paramVecCopy(eLinTheta));
// Since we work in 4D we have eLinPosSize = 4
CurvilinearTrackParameters wiggledCurvilinearParams(
paramVecCopy.head(eLinPosSize), wiggledDir, paramVecCopy(eLinQOverP));
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Visualization/EventDataView3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct EventDataView3D {

// Draw the parameter shaft and cone
auto position = parameters.position(gctx);
auto direction = parameters.unitDirection();
auto direction = parameters.direction();
double p = parameters.absoluteMomentum();

ViewConfig lparConfig = parConfig;
Expand Down
4 changes: 2 additions & 2 deletions Core/src/EventData/TransformationBoundToFree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Acts::FreeVector Acts::detail::transformBoundToFreeParameters(
const Acts::Surface& surface, const GeometryContext& geoCtx,
const Acts::BoundVector& boundParams) {
// convert angles to global unit direction vector
Vector3 direction = makeDirectionUnitFromPhiTheta(boundParams[eBoundPhi],
boundParams[eBoundTheta]);
Vector3 direction = makeDirectionFromPhiTheta(boundParams[eBoundPhi],
boundParams[eBoundTheta]);

// convert local position to global position vector
Vector2 local(boundParams[eBoundLoc0], boundParams[eBoundLoc1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ ActsExamples::DigitizationAlgorithm::channelizing(

auto driftedSegment =
m_surfaceDrift.toReadout(gctx, surface, geoCfg.thickness, hit.position(),
hit.unitDirection(), driftDir);
hit.direction(), driftDir);
auto maskedSegmentRes = m_surfaceMask.apply(surface, driftedSegment);
if (maskedSegmentRes.ok()) {
auto maskedSegment = maskedSegmentRes.value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ ActsExamples::ProcessCode ActsExamples::PlanarSteppingAlgorithm::execute(

Acts::Vector2 localIntersect =
(invTransfrom * simHit.position()).head<2>();
Acts::Vector3 localDirection =
invTransfrom.linear() * simHit.unitDirection();
Acts::Vector3 localDirection = invTransfrom.linear() * simHit.direction();

// compute digitization steps
const auto thickness = dg.detectorElement->thickness();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ActsExamples::ProcessCode ActsExamples::RefittingAlgorithm::execute(

ACTS_VERBOSE("Initial parameters: "
<< initialParams.fourPosition(ctx.geoContext).transpose()
<< " -> " << initialParams.unitDirection().transpose());
<< " -> " << initialParams.direction().transpose());

ACTS_DEBUG("Invoke direct fitter for track " << itrack);
auto result = (*m_cfg.fit)(trackSourceLinks, initialParams, options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ActsExamples::ProcessCode ActsExamples::TrackFittingAlgorithm::execute(

ACTS_VERBOSE("Initial parameters: "
<< initialParams.fourPosition(ctx.geoContext).transpose()
<< " -> " << initialParams.unitDirection().transpose());
<< " -> " << initialParams.direction().transpose());

// Clear & reserve the right size
trackSourceLinks.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ inline std::tuple<Acts::Vector2, Acts::Vector4, Acts::Vector3> averageSimHits(
// averaged position is still on the surface. the averaged global position
// might not be on the surface anymore.
auto result = surface.globalToLocal(gCtx, simHit.position(),
simHit.unitDirection(), 0.5_um);
simHit.direction(), 0.5_um);
if (result.ok()) {
avgLocal += result.value();
} else {
Expand All @@ -66,7 +66,7 @@ inline std::tuple<Acts::Vector2, Acts::Vector4, Acts::Vector3> averageSimHits(
// global position should already be at the intersection. no need to perform
// an additional intersection call.
avgPos4 += simHit.fourPosition();
avgDir += simHit.unitDirection();
avgDir += simHit.direction();
}

// only need to average if there are at least two inputs
Expand Down

0 comments on commit 62ec2e1

Please sign in to comment.