Skip to content

Commit

Permalink
refactor: remove custom scalar in classes (#3894)
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger authored Nov 25, 2024
1 parent 0e64ff5 commit d6b1ee3
Show file tree
Hide file tree
Showing 45 changed files with 499 additions and 584 deletions.
21 changes: 10 additions & 11 deletions Core/include/Acts/EventData/GenericBoundTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace Acts {
template <class particle_hypothesis_t>
class GenericBoundTrackParameters {
public:
using Scalar = ActsScalar;
using ParametersVector = BoundVector;
using CovarianceMatrix = BoundSquareMatrix;
using ParticleHypothesis = particle_hypothesis_t;
Expand Down Expand Up @@ -92,10 +91,10 @@ class GenericBoundTrackParameters {
/// successfully be converted to on-surface parameters.
static Result<GenericBoundTrackParameters> create(
std::shared_ptr<const Surface> surface, const GeometryContext& geoCtx,
const Vector4& pos4, const Vector3& dir, Scalar qOverP,
const Vector4& pos4, const Vector3& dir, double qOverP,
std::optional<CovarianceMatrix> cov,
ParticleHypothesis particleHypothesis,
ActsScalar tolerance = s_onSurfaceTolerance) {
double tolerance = s_onSurfaceTolerance) {
Result<BoundVector> bound =
transformFreeToBoundParameters(pos4.segment<3>(ePos0), pos4[eTime], dir,
qOverP, *surface, geoCtx, tolerance);
Expand Down Expand Up @@ -168,7 +167,7 @@ class GenericBoundTrackParameters {
///
/// @tparam kIndex Track parameter index
template <BoundIndices kIndex>
Scalar get() const {
double get() const {
return m_params[kIndex];
}

Expand Down Expand Up @@ -203,14 +202,14 @@ class GenericBoundTrackParameters {
return m_surface->localToGlobal(geoCtx, localPosition(), direction());
}
/// Time coordinate.
Scalar time() const { return m_params[eBoundTime]; }
double time() const { return m_params[eBoundTime]; }

/// Phi direction.
Scalar phi() const { return m_params[eBoundPhi]; }
double phi() const { return m_params[eBoundPhi]; }
/// Theta direction.
Scalar theta() const { return m_params[eBoundTheta]; }
double theta() const { return m_params[eBoundTheta]; }
/// Charge over momentum.
Scalar qOverP() const { return m_params[eBoundQOverP]; }
double qOverP() const { return m_params[eBoundQOverP]; }

/// Unit direction three-vector, i.e. the normalized momentum
/// three-vector.
Expand All @@ -219,18 +218,18 @@ class GenericBoundTrackParameters {
m_params[eBoundTheta]);
}
/// Absolute momentum.
Scalar absoluteMomentum() const {
double absoluteMomentum() const {
return m_particleHypothesis.extractMomentum(m_params[eBoundQOverP]);
}
/// Transverse momentum.
Scalar transverseMomentum() const {
double transverseMomentum() const {
return std::sin(m_params[eBoundTheta]) * absoluteMomentum();
}
/// Momentum three-vector.
Vector3 momentum() const { return absoluteMomentum() * direction(); }

/// Particle electric charge.
Scalar charge() const {
double charge() const {
return m_particleHypothesis.extractCharge(get<eBoundQOverP>());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class GenericCurvilinearTrackParameters
using Base = GenericBoundTrackParameters<particle_hypothesis_t>;

public:
using Scalar = ActsScalar;
using ParametersVector = BoundVector;
using CovarianceMatrix = BoundSquareMatrix;
using ParticleHypothesis = particle_hypothesis_t;
Expand All @@ -43,7 +42,7 @@ class GenericCurvilinearTrackParameters
/// @param cov Curvilinear bound parameters covariance matrix
/// @param particleHypothesis Particle hypothesis
GenericCurvilinearTrackParameters(const Vector4& pos4, const Vector3& dir,
Scalar qOverP,
double qOverP,
std::optional<CovarianceMatrix> cov,
ParticleHypothesis particleHypothesis)
: Base(CurvilinearSurface(pos4.segment<3>(ePos0), dir).surface(),
Expand All @@ -58,8 +57,8 @@ class GenericCurvilinearTrackParameters
/// @param qOverP Charge over momentum
/// @param cov Curvilinear bound parameters covariance matrix
/// @param particleHypothesis Particle hypothesis
GenericCurvilinearTrackParameters(const Vector4& pos4, Scalar phi,
Scalar theta, Scalar qOverP,
GenericCurvilinearTrackParameters(const Vector4& pos4, double phi,
double theta, double qOverP,
std::optional<CovarianceMatrix> cov,
ParticleHypothesis particleHypothesis)
: Base(CurvilinearSurface(pos4.segment<3>(ePos0),
Expand Down
27 changes: 13 additions & 14 deletions Core/include/Acts/EventData/GenericFreeTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace Acts {
template <class particle_hypothesis_t>
class GenericFreeTrackParameters {
public:
using Scalar = ActsScalar;
using ParametersVector = FreeVector;
using CovarianceMatrix = FreeSquareMatrix;
using ParticleHypothesis = particle_hypothesis_t;
Expand Down Expand Up @@ -66,7 +65,7 @@ class GenericFreeTrackParameters {
/// @param cov Free parameters covariance matrix
/// @param particleHypothesis Particle hypothesis
GenericFreeTrackParameters(const Vector4& pos4, const Vector3& dir,
Scalar qOverP, std::optional<CovarianceMatrix> cov,
double qOverP, std::optional<CovarianceMatrix> cov,
ParticleHypothesis particleHypothesis)
: m_params(FreeVector::Zero()),
m_cov(std::move(cov)),
Expand All @@ -91,8 +90,8 @@ class GenericFreeTrackParameters {
/// @param qOverP Charge over momentum
/// @param cov Free parameters covariance matrix
/// @param particleHypothesis Particle hypothesis
GenericFreeTrackParameters(const Vector4& pos4, Scalar phi, Scalar theta,
Scalar qOverP, std::optional<CovarianceMatrix> cov,
GenericFreeTrackParameters(const Vector4& pos4, double phi, double theta,
double qOverP, std::optional<CovarianceMatrix> cov,
ParticleHypothesis particleHypothesis)
: m_params(FreeVector::Zero()),
m_cov(std::move(cov)),
Expand Down Expand Up @@ -146,7 +145,7 @@ class GenericFreeTrackParameters {
///
/// @tparam kIndex Track parameter index
template <FreeIndices kIndex>
Scalar get() const {
double get() const {
return m_params[kIndex];
}

Expand All @@ -162,41 +161,41 @@ class GenericFreeTrackParameters {
/// Spatial position three-vector.
Vector3 position() const { return m_params.segment<3>(eFreePos0); }
/// Time coordinate.
Scalar time() const { return m_params[eFreeTime]; }
double time() const { return m_params[eFreeTime]; }

/// Phi direction.
Scalar phi() const { return VectorHelpers::phi(direction()); }
double phi() const { return VectorHelpers::phi(direction()); }
/// Theta direction.
Scalar theta() const { return VectorHelpers::theta(direction()); }
double theta() const { return VectorHelpers::theta(direction()); }
/// Charge over momentum.
Scalar qOverP() const { return m_params[eFreeQOverP]; }
double qOverP() const { return m_params[eFreeQOverP]; }

/// Unit direction three-vector, i.e. the normalized momentum three-vector.
Vector3 direction() const {
return m_params.segment<3>(eFreeDir0).normalized();
}
/// Absolute momentum.
Scalar absoluteMomentum() const {
double absoluteMomentum() const {
return m_particleHypothesis.extractMomentum(m_params[eFreeQOverP]);
}
/// Transverse momentum.
Scalar transverseMomentum() const {
double transverseMomentum() const {
// direction vector w/ arbitrary normalization can be parametrized as
// [f*sin(theta)*cos(phi), f*sin(theta)*sin(phi), f*cos(theta)]
// w/ f,sin(theta) positive, the transverse magnitude is then
// sqrt(f^2*sin^2(theta)) = f*sin(theta)
Scalar transverseMagnitude2 =
double transverseMagnitude2 =
square(m_params[eFreeDir0]) + square(m_params[eFreeDir1]);
// absolute magnitude is f by construction
Scalar magnitude2 = transverseMagnitude2 + square(m_params[eFreeDir2]);
double magnitude2 = transverseMagnitude2 + square(m_params[eFreeDir2]);
// such that we can extract sin(theta) = f*sin(theta) / f
return std::sqrt(transverseMagnitude2 / magnitude2) * absoluteMomentum();
}
/// Momentum three-vector.
Vector3 momentum() const { return absoluteMomentum() * direction(); }

/// Particle electric charge.
Scalar charge() const {
double charge() const {
return m_particleHypothesis.extractCharge(get<eFreeQOverP>());
}

Expand Down
21 changes: 10 additions & 11 deletions Core/include/Acts/EventData/MultiComponentTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class MultiComponentBoundTrackParameters {
public:
using Parameters = BoundTrackParameters;
using ParticleHypothesis = Parameters::ParticleHypothesis;
using Scalar = typename Parameters::Scalar;
using ParametersVector = typename Parameters::ParametersVector;
using CovarianceMatrix = typename Parameters::CovarianceMatrix;

Expand Down Expand Up @@ -159,7 +158,7 @@ class MultiComponentBoundTrackParameters {
///
/// @tparam kIndex Track parameter index
template <BoundIndices kIndex>
Scalar get() const {
double get() const {
return reduce([&](const Parameters& p) { return p.get<kIndex>(); });
}

Expand All @@ -180,7 +179,7 @@ class MultiComponentBoundTrackParameters {
}

/// Time coordinate.
Scalar time() const {
double time() const {
return reduce([](const Parameters& p) { return p.time(); });
}

Expand All @@ -192,21 +191,21 @@ class MultiComponentBoundTrackParameters {
}

/// Phi direction.
Scalar phi() const { return VectorHelpers::phi(direction()); }
double phi() const { return VectorHelpers::phi(direction()); }

/// Theta direction.
Scalar theta() const { return VectorHelpers::theta(direction()); }
double theta() const { return VectorHelpers::theta(direction()); }

/// Charge over momentum.
Scalar qOverP() const { return get<eBoundQOverP>(); }
double qOverP() const { return get<eBoundQOverP>(); }

/// Absolute momentum.
Scalar absoluteMomentum() const {
double absoluteMomentum() const {
return reduce([](const Parameters& p) { return p.absoluteMomentum(); });
}

/// Transverse momentum.
Scalar transverseMomentum() const {
double transverseMomentum() const {
return reduce([](const Parameters& p) { return p.transverseMomentum(); });
}

Expand All @@ -216,7 +215,7 @@ class MultiComponentBoundTrackParameters {
}

/// Particle electric charge.
Scalar charge() const {
double charge() const {
return reduce([](const Parameters& p) { return p.charge(); });
}

Expand All @@ -238,8 +237,8 @@ class MultiComponentCurvilinearTrackParameters
using covariance_t = BoundSquareMatrix;

public:
using ConstructionTuple = std::tuple<double, Acts::Vector4, Acts::Vector3,
ActsScalar, covariance_t>;
using ConstructionTuple =
std::tuple<double, Acts::Vector4, Acts::Vector3, double, covariance_t>;

private:
using Base = MultiComponentBoundTrackParameters;
Expand Down
1 change: 0 additions & 1 deletion Core/include/Acts/EventData/TrackParametersConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Surface;
namespace Concepts {
template <typename Parameters>
concept BasicTrackParameters = requires {
typename Parameters::Scalar;
typename Parameters::ParametersVector;
typename Parameters::CovarianceMatrix;

Expand Down
22 changes: 8 additions & 14 deletions Core/include/Acts/EventData/TrackStateProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,15 @@ template <std::size_t Size, bool ReadOnlyMaps = true>
struct FixedSizeTypes {
constexpr static auto Flags = Eigen::ColMajor | Eigen::AutoAlign;

using Scalar = ActsScalar;

// single items
using Coefficients = Eigen::Matrix<Scalar, Size, 1, Flags>;
using Covariance = Eigen::Matrix<Scalar, Size, Size, Flags>;
using Coefficients = Eigen::Matrix<double, Size, 1, Flags>;
using Covariance = Eigen::Matrix<double, Size, Size, Flags>;
using CoefficientsMap = Eigen::Map<ConstIf<Coefficients, ReadOnlyMaps>>;
using CovarianceMap = Eigen::Map<ConstIf<Covariance, ReadOnlyMaps>>;

using DynamicCoefficients = Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Flags>;
using DynamicCoefficients = Eigen::Matrix<double, Eigen::Dynamic, 1, Flags>;
using DynamicCovariance =
Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Flags>;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Flags>;
using DynamicCoefficientsMap =
Eigen::Map<ConstIf<DynamicCoefficients, ReadOnlyMaps>>;
using DynamicCovarianceMap =
Expand All @@ -105,11 +103,9 @@ template <bool ReadOnlyMaps = true>
struct DynamicSizeTypes {
constexpr static auto Flags = Eigen::ColMajor | Eigen::AutoAlign;

using Scalar = ActsScalar;

using Coefficients = Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Flags>;
using Coefficients = Eigen::Matrix<double, Eigen::Dynamic, 1, Flags>;
using Covariance =
Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Flags>;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Flags>;
using CoefficientsMap = Eigen::Map<ConstIf<Coefficients, ReadOnlyMaps>>;
using CovarianceMap = Eigen::Map<ConstIf<Covariance, ReadOnlyMaps>>;
};
Expand All @@ -119,8 +115,6 @@ struct DynamicSizeTypes {
// This is public
template <std::size_t M, bool ReadOnly = true>
struct TrackStateTraits {
using Scalar = ActsScalar;

using Parameters =
typename detail_lt::FixedSizeTypes<eBoundSize, ReadOnly>::CoefficientsMap;
using Covariance =
Expand All @@ -135,8 +129,8 @@ struct TrackStateTraits {
typename detail_lt::DynamicSizeTypes<ReadOnly>::CovarianceMap;

constexpr static auto ProjectorFlags = Eigen::RowMajor | Eigen::AutoAlign;
using Projector = Eigen::Matrix<Scalar, M, eBoundSize, ProjectorFlags>;
using EffectiveProjector = Eigen::Matrix<Scalar, Eigen::Dynamic, eBoundSize,
using Projector = Eigen::Matrix<double, M, eBoundSize, ProjectorFlags>;
using EffectiveProjector = Eigen::Matrix<double, Eigen::Dynamic, eBoundSize,
ProjectorFlags, M, eBoundSize>;
};

Expand Down
Loading

0 comments on commit d6b1ee3

Please sign in to comment.