Skip to content

Commit

Permalink
refactor!: Rename Single*TrackParameters to `Generic*TrackParameter…
Browse files Browse the repository at this point in the history
…s` (#2269)

I am unhappy with the name `Single*TrackParameters` as it could refer to singly charged or single track. The track actually supports different kinds of charge hypothesis so I thought `Generic*TrackParameter` might fit better.

I also merged `NeutralTrackParameters` into `TrackParameters` and removed the external template instantiation as it could be a performance hit because it disables inlining.

Pulled these changes out of #2181
  • Loading branch information
andiwand authored Jul 27, 2023
1 parent 1e2eb5d commit aa860d7
Show file tree
Hide file tree
Showing 69 changed files with 192 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Acts {
///
/// @note This class holds shared ownership on its reference surface.
template <class charge_t>
class SingleBoundTrackParameters {
class GenericBoundTrackParameters {
public:
using Scalar = ActsScalar;
using ParametersVector = BoundVector;
Expand All @@ -51,9 +51,9 @@ class SingleBoundTrackParameters {
/// an input here to be consistent with the other constructors below that
/// that also take the charge as an input. The charge sign is only used in
/// debug builds to check for consistency with the q/p parameter.
SingleBoundTrackParameters(std::shared_ptr<const Surface> surface,
const ParametersVector& params, Scalar q,
std::optional<CovarianceMatrix> cov = std::nullopt)
GenericBoundTrackParameters(
std::shared_ptr<const Surface> surface, const ParametersVector& params,
Scalar q, std::optional<CovarianceMatrix> cov = std::nullopt)
: m_params(params),
m_cov(std::move(cov)),
m_surface(std::move(surface)),
Expand All @@ -74,9 +74,9 @@ class SingleBoundTrackParameters {
/// ambiguities, i.e. the charge type is default-constructible.
template <typename T = charge_t,
std::enable_if_t<std::is_default_constructible_v<T>, int> = 0>
SingleBoundTrackParameters(std::shared_ptr<const Surface> surface,
const ParametersVector& params,
std::optional<CovarianceMatrix> cov = std::nullopt)
GenericBoundTrackParameters(
std::shared_ptr<const Surface> surface, const ParametersVector& params,
std::optional<CovarianceMatrix> cov = std::nullopt)
: m_params(params), m_cov(std::move(cov)), m_surface(std::move(surface)) {
assert(m_surface);
normalizePhiTheta();
Expand All @@ -95,7 +95,7 @@ class SingleBoundTrackParameters {
///
/// @note The returned result indicates whether the free parameters could
/// successfully be converted to on-surface parameters.
static Result<SingleBoundTrackParameters<charge_t>> create(
static Result<GenericBoundTrackParameters<charge_t>> create(
std::shared_ptr<const Surface> surface, const GeometryContext& geoCtx,
const Vector4& pos4, const Vector3& dir, Scalar p, Scalar q,
std::optional<CovarianceMatrix> cov = std::nullopt) {
Expand All @@ -107,8 +107,8 @@ class SingleBoundTrackParameters {
return bound.error();
}

return SingleBoundTrackParameters<charge_t>{std::move(surface), *bound, q,
std::move(cov)};
return GenericBoundTrackParameters<charge_t>{std::move(surface), *bound, q,
std::move(cov)};
}

/// Factory to construct from four-position, direction, and
Expand All @@ -128,7 +128,7 @@ class SingleBoundTrackParameters {
/// successfully be converted to on-surface parameters.
template <typename T = charge_t,
std::enable_if_t<std::is_default_constructible_v<T>, int> = 0>
static Result<SingleBoundTrackParameters<charge_t>> create(
static Result<GenericBoundTrackParameters<charge_t>> create(
std::shared_ptr<const Surface> surface, const GeometryContext& geoCtx,
const Vector4& pos4, const Vector3& dir, Scalar qOverP,
std::optional<CovarianceMatrix> cov = std::nullopt) {
Expand All @@ -138,18 +138,19 @@ class SingleBoundTrackParameters {
return bound.error();
}

return SingleBoundTrackParameters<charge_t>{std::move(surface), *bound,
std::move(cov)};
return GenericBoundTrackParameters<charge_t>{std::move(surface), *bound,
std::move(cov)};
}

/// Parameters are not default constructible due to the charge type.
SingleBoundTrackParameters() = delete;
SingleBoundTrackParameters(const SingleBoundTrackParameters&) = default;
SingleBoundTrackParameters(SingleBoundTrackParameters&&) = default;
~SingleBoundTrackParameters() = default;
SingleBoundTrackParameters& operator=(const SingleBoundTrackParameters&) =
GenericBoundTrackParameters() = delete;
GenericBoundTrackParameters(const GenericBoundTrackParameters&) = default;
GenericBoundTrackParameters(GenericBoundTrackParameters&&) = default;
~GenericBoundTrackParameters() = default;
GenericBoundTrackParameters& operator=(const GenericBoundTrackParameters&) =
default;
GenericBoundTrackParameters& operator=(GenericBoundTrackParameters&&) =
default;
SingleBoundTrackParameters& operator=(SingleBoundTrackParameters&&) = default;

/// Parameters vector.
ParametersVector& parameters() { return m_params; }
Expand Down Expand Up @@ -263,20 +264,20 @@ class SingleBoundTrackParameters {
/// of equality in different contexts. None of that can be handled by
/// this operator. Users should think really hard if this is what they
/// want and we might decided that we will remove this in the future.
friend bool operator==(const SingleBoundTrackParameters<charge_t>& lhs,
const SingleBoundTrackParameters<charge_t>& rhs) {
friend bool operator==(const GenericBoundTrackParameters<charge_t>& lhs,
const GenericBoundTrackParameters<charge_t>& rhs) {
return (lhs.m_params == rhs.m_params) and (lhs.m_cov == rhs.m_cov) and
(lhs.m_surface == rhs.m_surface) and
(lhs.m_chargeInterpreter == rhs.m_chargeInterpreter);
}
/// Compare two bound track parameters for bitwise in-equality.
friend bool operator!=(const SingleBoundTrackParameters<charge_t>& lhs,
const SingleBoundTrackParameters<charge_t>& rhs) {
friend bool operator!=(const GenericBoundTrackParameters<charge_t>& lhs,
const GenericBoundTrackParameters<charge_t>& rhs) {
return not(lhs == rhs);
}
/// Print information to the output stream.
friend std::ostream& operator<<(std::ostream& os,
const SingleBoundTrackParameters& tp) {
const GenericBoundTrackParameters& tp) {
detail::printBoundParameters(
os, tp.referenceSurface(), tp.parameters(),
tp.covariance().has_value() ? &tp.covariance().value() : nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include "Acts/EventData/SingleBoundTrackParameters.hpp"
#include "Acts/EventData/GenericBoundTrackParameters.hpp"
#include "Acts/Surfaces/PlaneSurface.hpp"

namespace Acts {
Expand All @@ -22,11 +22,11 @@ namespace Acts {
/// parameters and their corresponding covariance matrix are stored in
/// curvilinear parametrization.
///
/// @see SingleBoundTrackParameters
/// @see GenericBoundTrackParameters
template <typename charge_t>
class SingleCurvilinearTrackParameters
: public SingleBoundTrackParameters<charge_t> {
using Base = SingleBoundTrackParameters<charge_t>;
class GenericCurvilinearTrackParameters
: public GenericBoundTrackParameters<charge_t> {
using Base = GenericBoundTrackParameters<charge_t>;

public:
using Scalar = ActsScalar;
Expand All @@ -40,7 +40,7 @@ class SingleCurvilinearTrackParameters
/// @param p Absolute momentum
/// @param q Particle charge
/// @param cov Curvilinear bound parameters covariance matrix
SingleCurvilinearTrackParameters(
GenericCurvilinearTrackParameters(
const Vector4& pos4, const Vector3& dir, Scalar p, Scalar q,
std::optional<CovarianceMatrix> cov = std::nullopt)
: Base(Surface::makeShared<PlaneSurface>(pos4.segment<3>(ePos0), dir),
Expand All @@ -61,7 +61,7 @@ class SingleCurvilinearTrackParameters
/// ambiguities, i.e. the charge interpretation type is default-constructible.
template <typename T = charge_t,
std::enable_if_t<std::is_default_constructible_v<T>, int> = 0>
SingleCurvilinearTrackParameters(
GenericCurvilinearTrackParameters(
const Vector4& pos4, const Vector3& dir, Scalar qOverP,
std::optional<CovarianceMatrix> cov = std::nullopt)
: Base(Surface::makeShared<PlaneSurface>(pos4.segment<3>(ePos0), dir),
Expand All @@ -77,7 +77,7 @@ class SingleCurvilinearTrackParameters
/// @param p Absolute momentum
/// @param q Particle charge
/// @param cov Curvilinear bound parameters covariance matrix
SingleCurvilinearTrackParameters(
GenericCurvilinearTrackParameters(
const Vector4& pos4, Scalar phi, Scalar theta, Scalar p, Scalar q,
std::optional<CovarianceMatrix> cov = std::nullopt)
: Base(Surface::makeShared<PlaneSurface>(
Expand All @@ -101,7 +101,7 @@ class SingleCurvilinearTrackParameters
/// ambiguities, i.e. the charge interpretation type is default-constructible.
template <typename T = charge_t,
std::enable_if_t<std::is_default_constructible_v<T>, int> = 0>
SingleCurvilinearTrackParameters(
GenericCurvilinearTrackParameters(
const Vector4& pos4, Scalar phi, Scalar theta, Scalar qOverP,
std::optional<CovarianceMatrix> cov = std::nullopt)
: Base(Surface::makeShared<PlaneSurface>(
Expand All @@ -112,16 +112,16 @@ class SingleCurvilinearTrackParameters
std::move(cov)) {}

/// Parameters are not default constructible due to the charge type.
SingleCurvilinearTrackParameters() = delete;
SingleCurvilinearTrackParameters(const SingleCurvilinearTrackParameters&) =
GenericCurvilinearTrackParameters() = delete;
GenericCurvilinearTrackParameters(const GenericCurvilinearTrackParameters&) =
default;
SingleCurvilinearTrackParameters(SingleCurvilinearTrackParameters&&) =
GenericCurvilinearTrackParameters(GenericCurvilinearTrackParameters&&) =
default;
~SingleCurvilinearTrackParameters() = default;
SingleCurvilinearTrackParameters& operator=(
const SingleCurvilinearTrackParameters&) = default;
SingleCurvilinearTrackParameters& operator=(
SingleCurvilinearTrackParameters&&) = default;
~GenericCurvilinearTrackParameters() = default;
GenericCurvilinearTrackParameters& operator=(
const GenericCurvilinearTrackParameters&) = default;
GenericCurvilinearTrackParameters& operator=(
GenericCurvilinearTrackParameters&&) = default;
};

} // namespace Acts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Acts {
/// Parameters and covariance matrix are stored using the free parametrization
/// defined in `enum FreeIndices`.
template <class charge_t>
class SingleFreeTrackParameters {
class GenericFreeTrackParameters {
public:
using Scalar = ActsScalar;
using ParametersVector = FreeVector;
Expand All @@ -45,8 +45,8 @@ class SingleFreeTrackParameters {
/// an input here to be consistent with the other constructors below that
/// that also take the charge as an input. The charge sign is only used in
/// debug builds to check for consistency with the q/p parameter.
SingleFreeTrackParameters(const ParametersVector& params, Scalar q,
std::optional<CovarianceMatrix> cov = std::nullopt)
GenericFreeTrackParameters(const ParametersVector& params, Scalar q,
std::optional<CovarianceMatrix> cov = std::nullopt)
: m_params(params),
m_cov(std::move(cov)),
m_chargeInterpreter(std::abs(q)) {
Expand All @@ -63,8 +63,8 @@ class SingleFreeTrackParameters {
/// ambiguities, i.e. the charge interpretation type is default-constructible.
template <typename T = charge_t,
std::enable_if_t<std::is_default_constructible_v<T>, int> = 0>
SingleFreeTrackParameters(const ParametersVector& params,
std::optional<CovarianceMatrix> cov = std::nullopt)
GenericFreeTrackParameters(const ParametersVector& params,
std::optional<CovarianceMatrix> cov = std::nullopt)
: m_params(params), m_cov(std::move(cov)) {}

/// Construct from four-position, angles, absolute momentum, and charge.
Expand All @@ -75,9 +75,9 @@ class SingleFreeTrackParameters {
/// @param p Absolute momentum
/// @param q Particle charge
/// @param cov Free parameters covariance matrix
SingleFreeTrackParameters(const Vector4& pos4, Scalar phi, Scalar theta,
Scalar p, Scalar q,
std::optional<CovarianceMatrix> cov = std::nullopt)
GenericFreeTrackParameters(const Vector4& pos4, Scalar phi, Scalar theta,
Scalar p, Scalar q,
std::optional<CovarianceMatrix> cov = std::nullopt)
: m_params(FreeVector::Zero()),
m_cov(std::move(cov)),
m_chargeInterpreter(std::abs(q)) {
Expand Down Expand Up @@ -106,9 +106,9 @@ class SingleFreeTrackParameters {
/// ambiguities, i.e. the charge interpretation type is default-constructible.
template <typename T = charge_t,
std::enable_if_t<std::is_default_constructible_v<T>, int> = 0>
SingleFreeTrackParameters(const Vector4& pos4, Scalar phi, Scalar theta,
Scalar qOverP,
std::optional<CovarianceMatrix> cov = std::nullopt)
GenericFreeTrackParameters(const Vector4& pos4, Scalar phi, Scalar theta,
Scalar qOverP,
std::optional<CovarianceMatrix> cov = std::nullopt)
: m_params(FreeVector::Zero()), m_cov(std::move(cov)) {
auto dir = makeDirectionUnitFromPhiTheta(phi, theta);
m_params[eFreePos0] = pos4[ePos0];
Expand All @@ -122,13 +122,13 @@ class SingleFreeTrackParameters {
}

/// Parameters are not default constructible due to the charge type.
SingleFreeTrackParameters() = delete;
SingleFreeTrackParameters(const SingleFreeTrackParameters&) = default;
SingleFreeTrackParameters(SingleFreeTrackParameters&&) = default;
~SingleFreeTrackParameters() = default;
SingleFreeTrackParameters& operator=(const SingleFreeTrackParameters&) =
GenericFreeTrackParameters() = delete;
GenericFreeTrackParameters(const GenericFreeTrackParameters&) = default;
GenericFreeTrackParameters(GenericFreeTrackParameters&&) = default;
~GenericFreeTrackParameters() = default;
GenericFreeTrackParameters& operator=(const GenericFreeTrackParameters&) =
default;
SingleFreeTrackParameters& operator=(SingleFreeTrackParameters&&) = default;
GenericFreeTrackParameters& operator=(GenericFreeTrackParameters&&) = default;

/// Parameters vector.
const ParametersVector& parameters() const { return m_params; }
Expand Down Expand Up @@ -194,7 +194,7 @@ class SingleFreeTrackParameters {

/// Print information to the output stream.
friend std::ostream& operator<<(std::ostream& os,
const SingleFreeTrackParameters& tp) {
const GenericFreeTrackParameters& tp) {
detail::printFreeParameters(
os, tp.parameters(),
tp.covariance().has_value() ? &tp.covariance().value() : nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include "Acts/EventData/SingleBoundTrackParameters.hpp"
#include "Acts/EventData/GenericBoundTrackParameters.hpp"
#include "Acts/Surfaces/Surface.hpp"

#include <cmath>
Expand All @@ -21,7 +21,7 @@ namespace Acts {
/// This class is only a light wrapper around a surface and a vector of
/// parameters. Its main purpose is to provide many constructors for the
/// underlying vector. Most accessors are generated from the
/// SingleBoundTrackParameters equivalent and thus may be expensive
/// GenericBoundTrackParameters equivalent and thus may be expensive
/// @tparam charge_t Helper type to interpret the particle charge/momentum
/// @note This class holds shared ownership on its reference surface.
/// @note The accessors for parameters, covariance, position, etc.
Expand All @@ -31,7 +31,7 @@ namespace Acts {
/// TODO Add constructor from range and projector maybe?
template <typename charge_t>
class MultiComponentBoundTrackParameters {
using SingleParameters = SingleBoundTrackParameters<charge_t>;
using SingleParameters = GenericBoundTrackParameters<charge_t>;

std::vector<std::tuple<double, BoundVector, std::optional<BoundSymMatrix>>>
m_components;
Expand Down Expand Up @@ -157,7 +157,7 @@ class MultiComponentBoundTrackParameters {
/// Reference surface onto which the parameters are bound.
const Surface& referenceSurface() const { return *m_surface; }

/// Get the weight and a SingleBoundTrackParameters object for one component
/// Get the weight and a GenericBoundTrackParameters object for one component
std::pair<double, SingleParameters> operator[](std::size_t i) const {
return std::make_pair(
std::get<double>(m_components[i]),
Expand Down
27 changes: 0 additions & 27 deletions Core/include/Acts/EventData/NeutralTrackParameters.hpp

This file was deleted.

21 changes: 11 additions & 10 deletions Core/include/Acts/EventData/TrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
#pragma once

#include "Acts/EventData/Charge.hpp"
#include "Acts/EventData/SingleBoundTrackParameters.hpp"
#include "Acts/EventData/SingleCurvilinearTrackParameters.hpp"
#include "Acts/EventData/SingleFreeTrackParameters.hpp"
#include "Acts/EventData/GenericBoundTrackParameters.hpp"
#include "Acts/EventData/GenericCurvilinearTrackParameters.hpp"
#include "Acts/EventData/GenericFreeTrackParameters.hpp"

namespace Acts {

extern template class SingleBoundTrackParameters<SinglyCharged>;
extern template class SingleCurvilinearTrackParameters<SinglyCharged>;
extern template class SingleFreeTrackParameters<SinglyCharged>;

using BoundTrackParameters = SingleBoundTrackParameters<SinglyCharged>;
using BoundTrackParameters = GenericBoundTrackParameters<SinglyCharged>;
using CurvilinearTrackParameters =
SingleCurvilinearTrackParameters<SinglyCharged>;
using FreeTrackParameters = SingleFreeTrackParameters<SinglyCharged>;
GenericCurvilinearTrackParameters<SinglyCharged>;
using FreeTrackParameters = GenericFreeTrackParameters<SinglyCharged>;

using NeutralBoundTrackParameters = GenericBoundTrackParameters<Neutral>;
using NeutralCurvilinearTrackParameters =
GenericCurvilinearTrackParameters<Neutral>;
using NeutralFreeTrackParameters = GenericFreeTrackParameters<Neutral>;

} // namespace Acts
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/AtlasStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class AtlasStepper {
template <typename charge_t>
State makeState(std::reference_wrapper<const GeometryContext> gctx,
std::reference_wrapper<const MagneticFieldContext> mctx,
const SingleBoundTrackParameters<charge_t>& par,
const GenericBoundTrackParameters<charge_t>& par,
Direction navDir = Direction::Forward,
double ssize = std::numeric_limits<double>::max(),
double stolerance = s_onSurfaceTolerance) const {
Expand Down
Loading

0 comments on commit aa860d7

Please sign in to comment.