Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resurrect ActsScalar with float #3754

Closed
wants to merge 15 commits into from
55 changes: 55 additions & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,61 @@ jobs:
- name: Downstream run
run: ./build-downstream/bin/ShowActsVersion

linux_acts_scalar:
runs-on: ubuntu-latest
container: ghcr.io/acts-project/ubuntu2404:58
env:
INSTALL_DIR: ${{ github.workspace }}/install
ACTS_LOG_FAILURE_THRESHOLD: WARNING
steps:
- name: Install git lfs
run: apt-get update && apt-get install -y git-lfs

- uses: actions/checkout@v4
with:
submodules: true
lfs: true

- name: Restore ccache
uses: actions/cache/restore@v4
id: ccache-restore
with:
path: ${{ github.workspace }}/ccache
key: ${{ runner.os }}-ccache-linux_ubuntu_${{ env.CCACHE_KEY_SUFFIX }}_${{ github.sha }}
AJPfleger marked this conversation as resolved.
Show resolved Hide resolved
restore-keys: |
${{ runner.os }}-ccache-linux_ubuntu_${{ env.CCACHE_KEY_SUFFIX }}_

- name: Configure
# setting CMAKE_CXX_STANDARD=20 is a workaround for a bug in the
# dd4hep CMake configuration that gets triggered on recent CMake
# versions
# Need to set git user & email for patching to work (GeoModel plugin)
run: >
git config --global user.name 'CI' &&
git config --global user.email '<>' &&
ccache -z &&
cmake -B build -S .
-DCMAKE_CXX_FLAGS="-Wno-narrowing"
-DACTS_CUSTOM_SCALARTYPE=float

- name: Build
run: cmake --build build

- name: ccache stats
run: ccache -s

- name: Save ccache
uses: actions/cache/save@v4
if: always()
with:
path: ${{ github.workspace }}/ccache
key: ${{ steps.ccache-restore.outputs.cache-primary-key }}

- uses: actions/upload-artifact@v4
with:
name: acts-linux-ubuntu
path: build.tar.gz

macos:
runs-on: macos-14
env:
Expand Down
8 changes: 4 additions & 4 deletions Core/include/Acts/EventData/ChargeConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
namespace Acts {

template <typename C>
concept ChargeConcept = requires(C c, C c2, float f, double d) {
concept ChargeConcept = requires(C c, C c2, float f, ActsScalar a) {
{ C{f} };

{ c == c2 } -> std::same_as<bool>;
{ c != c2 } -> std::same_as<bool>;

{ c.absQ() } -> std::same_as<float>;
{ c.extractCharge(d) } -> std::same_as<float>;
{ c.extractMomentum(d) } -> std::same_as<double>;
{ c.qOverP(d, d) } -> std::same_as<double>;
{ c.extractCharge(a) } -> std::same_as<float>;
{ c.extractMomentum(a) } -> std::same_as<ActsScalar>;
{ c.qOverP(a, f) } -> std::same_as<ActsScalar>;
};

} // namespace Acts
18 changes: 9 additions & 9 deletions Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class CutoutCylinderVolumeBounds : public VolumeBounds {
/// @param rmax The outer radius of the overall shape
/// @param hlZ The longer halflength of the shape
/// @param hlZc The cutout halflength of the shape
CutoutCylinderVolumeBounds(double rmin, double rmed, double rmax, double hlZ,
double hlZc) noexcept(false)
CutoutCylinderVolumeBounds(ActsScalar rmin, ActsScalar rmed, ActsScalar rmax,
ActsScalar hlZ, ActsScalar hlZc) noexcept(false)
: m_values({rmin, rmed, rmax, hlZ, hlZc}) {
checkConsistency();
buildSurfaceBounds();
Expand All @@ -66,8 +66,8 @@ class CutoutCylinderVolumeBounds : public VolumeBounds {
/// Constructor - from a fixed size array
///
/// @param values The bound values
CutoutCylinderVolumeBounds(const std::array<double, eSize>& values) noexcept(
false)
CutoutCylinderVolumeBounds(
const std::array<ActsScalar, eSize>& values) noexcept(false)
: m_values(values) {
checkConsistency();
buildSurfaceBounds();
Expand All @@ -82,14 +82,14 @@ class CutoutCylinderVolumeBounds : public VolumeBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

/// Inside method to test whether a point is inside the shape
///
/// @param gpos The point to test
/// @param tol The tolerance to test with
/// @return Whether the point is inside or not.
bool inside(const Vector3& gpos, double tol = 0) const override;
bool inside(const Vector3& gpos, ActsScalar tol = 0) const override;

/// Oriented surfaces, i.e. the decomposed boundary surfaces and the
/// according navigation direction into the volume given the normal
Expand Down Expand Up @@ -134,7 +134,7 @@ class CutoutCylinderVolumeBounds : public VolumeBounds {
double get(BoundValues bValue) const { return m_values[bValue]; }

private:
std::array<double, eSize> m_values;
std::array<ActsScalar, eSize> m_values;

// The surface bound objects
std::shared_ptr<const CylinderBounds> m_innerCylinderBounds{nullptr};
Expand All @@ -151,8 +151,8 @@ class CutoutCylinderVolumeBounds : public VolumeBounds {
void checkConsistency() noexcept(false);
};

inline std::vector<double> CutoutCylinderVolumeBounds::values() const {
std::vector<double> valvector;
inline std::vector<ActsScalar> CutoutCylinderVolumeBounds::values() const {
std::vector<ActsScalar> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Geometry/GenericCuboidVolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GenericCuboidVolumeBounds : public VolumeBounds {
///
/// @param values The input values
GenericCuboidVolumeBounds(
const std::array<double, BoundValues::eSize>& values) noexcept(false);
const std::array<ActsScalar, BoundValues::eSize>& values) noexcept(false);

~GenericCuboidVolumeBounds() override = default;

Expand All @@ -57,15 +57,15 @@ class GenericCuboidVolumeBounds : public VolumeBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

/// Checking if position given in volume frame is inside
///
/// @param gpos is the global position to be checked
/// @param tol is the tolerance applied for the inside check
///
/// @return boolean indicating if the position is inside
bool inside(const Vector3& gpos, double tol = 0.) const override;
bool inside(const Vector3& gpos, ActsScalar tol = 0.) const override;

/// Oriented surfaces, i.e. the decomposed boundary surfaces and the
/// according navigation direction into the volume given the normal
Expand Down
10 changes: 5 additions & 5 deletions Core/include/Acts/Geometry/VolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ class VolumeBounds {
/// vector containing the parameters needed to describe these bounds
///
/// @return of the stored values for this SurfaceBounds object
virtual std::vector<double> values() const = 0;
virtual std::vector<ActsScalar> values() const = 0;

/// Checking if position given in volume frame is inside
///
/// @param gpos is the global position to be checked
/// @param tol is the tolerance applied for the inside check
///
/// @return boolean indicating if the position is inside
virtual bool inside(const Vector3& gpos, double tol = 0.) const = 0;
virtual bool inside(const Vector3& gpos, ActsScalar tol = 0.) const = 0;

/// Oriented surfaces, i.e. the decomposed boundary surfaces and the
/// according navigation direction into the volume given the normal
Expand Down Expand Up @@ -143,7 +143,7 @@ class VolumeBounds {
/// @param bValue is the binning schema used
///
/// @return float offset to be used for the binning
virtual double binningBorder(BinningValue bValue) const;
virtual ActsScalar binningBorder(BinningValue bValue) const;

/// Output Method for std::ostream, to be overloaded by child classes
///
Expand All @@ -157,8 +157,8 @@ inline Vector3 VolumeBounds::binningOffset(
return Vector3(0., 0., 0.);
}

inline double VolumeBounds::binningBorder(BinningValue /*bValue*/) const {
return 0.;
inline ActsScalar VolumeBounds::binningBorder(BinningValue /*bValue*/) const {
return ActsScalar{0.};
AJPfleger marked this conversation as resolved.
Show resolved Hide resolved
}

/// Overload of << operator for std::ostream for debug output
Expand Down
21 changes: 20 additions & 1 deletion Core/include/Acts/MagneticField/InterpolatedBFieldMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,26 @@ class InterpolatedBFieldMap : public InterpolatedMagneticField {

assert(i == nCorners);

return FieldCell(lowerLeft, upperRight, std::move(neighbors));
AJPfleger marked this conversation as resolved.
Show resolved Hide resolved
// This possible conversion is necessary, in case we want to use custom
// general scalar type ActsScalar != double
auto convertArray = [](const auto& inputArray) {
using T = typename std::decay_t<decltype(inputArray)>::value_type;

std::array<double, DIM_POS> outputArray;

if constexpr (!std::is_same_v<T, double>) {
std::transform(inputArray.begin(), inputArray.end(),
outputArray.begin(),
[](T val) { return static_cast<double>(val); });
} else {
std::copy(inputArray.begin(), inputArray.end(), outputArray.begin());
}

return outputArray;
};

return FieldCell(convertArray(lowerLeft), convertArray(upperRight),
std::move(neighbors));
}

/// @brief get the number of bins for all axes of the field map
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Surfaces/AnnulusBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class AnnulusBounds : public DiscBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

/// Inside check for the bounds object driven by the boundary check directive
/// Each Bounds has a method inside, which checks if a LocalPosition is inside
Expand Down Expand Up @@ -248,8 +248,8 @@ inline double AnnulusBounds::binningValuePhi() const {
return get(eAveragePhi);
}

inline std::vector<double> AnnulusBounds::values() const {
std::vector<double> valvector;
inline std::vector<ActsScalar> AnnulusBounds::values() const {
std::vector<ActsScalar> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Surfaces/ConeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ConeBounds : public SurfaceBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

/// inside method for local position
///
Expand Down Expand Up @@ -134,8 +134,8 @@ inline double ConeBounds::tanAlpha() const {
return m_tanAlpha;
}

inline std::vector<double> ConeBounds::values() const {
std::vector<double> valvector;
inline std::vector<ActsScalar> ConeBounds::values() const {
std::vector<ActsScalar> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/ConeSurface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class ConeSurface : public RegularSurface {
const Vector3& direction,
const BoundaryTolerance& boundaryTolerance =
BoundaryTolerance::Infinite(),
double tolerance = s_onSurfaceTolerance) const final;
ActsScalar tolerance = s_onSurfaceTolerance) const final;

/// The pathCorrection for derived classes with thickness
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ConvexPolygonBoundsBase : public PlanarBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

protected:
/// Return a rectangle bounds instance that encloses a set of vertices.
Expand Down
18 changes: 9 additions & 9 deletions Core/include/Acts/Surfaces/CylinderBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class CylinderBounds : public SurfaceBounds {
/// @param avgPhi (optional) The phi value from which the opening angle spans
/// @param bevelMinZ (optional) The bevel on the negative z side
/// @param bevelMaxZ (optional) The bevel on the positive z sid The bevel on the positive z side
CylinderBounds(double r, double halfZ, double halfPhi = M_PI,
double avgPhi = 0., double bevelMinZ = 0.,
double bevelMaxZ = 0.) noexcept(false)
CylinderBounds(ActsScalar r, ActsScalar halfZ, ActsScalar halfPhi = M_PI,
ActsScalar avgPhi = 0., ActsScalar bevelMinZ = 0.,
ActsScalar bevelMaxZ = 0.) noexcept(false)
: m_values({r, halfZ, halfPhi, avgPhi, bevelMinZ, bevelMaxZ}),
m_closed(std::abs(halfPhi - M_PI) < s_epsilon) {
checkConsistency();
Expand All @@ -80,7 +80,7 @@ class CylinderBounds : public SurfaceBounds {
/// Constructor - from fixed size array
///
/// @param values The parameter values
CylinderBounds(const std::array<double, eSize>& values) noexcept(false)
CylinderBounds(const std::array<ActsScalar, eSize>& values) noexcept(false)
: m_values(values),
m_closed(std::abs(values[eHalfPhiSector] - M_PI) < s_epsilon) {
checkConsistency();
Expand All @@ -93,7 +93,7 @@ class CylinderBounds : public SurfaceBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

/// Inside check for the bounds object driven by the boundary check directive
/// Each Bounds has a method inside, which checks if a LocalPosition is inside
Expand All @@ -107,7 +107,7 @@ class CylinderBounds : public SurfaceBounds {

/// Access to the bound values
/// @param bValue the class nested enum for the array access
double get(BoundValues bValue) const { return m_values[bValue]; }
ActsScalar get(BoundValues bValue) const { return m_values[bValue]; }

/// Returns true for full phi coverage
bool coversFullAzimuth() const;
Expand All @@ -130,7 +130,7 @@ class CylinderBounds : public SurfaceBounds {

private:
/// The bound radius, half Z, half phi and average phi
std::array<double, eSize> m_values;
std::array<ActsScalar, eSize> m_values;
/// Indicator if the bounds are closed
bool m_closed{false};

Expand All @@ -146,8 +146,8 @@ class CylinderBounds : public SurfaceBounds {
ActsMatrix<2, 2> jacobian() const;
};

inline std::vector<double> CylinderBounds::values() const {
std::vector<double> valvector;
inline std::vector<ActsScalar> CylinderBounds::values() const {
std::vector<ActsScalar> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Surfaces/DiamondBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class DiamondBounds : public PlanarBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

/// Inside check for the bounds object driven by the boundary check directive
/// Each Bounds has a method inside, which checks if a LocalPosition is inside
Expand Down Expand Up @@ -119,8 +119,8 @@ class DiamondBounds : public PlanarBounds {
void checkConsistency() noexcept(false);
};

inline std::vector<double> DiamondBounds::values() const {
std::vector<double> valvector;
inline std::vector<ActsScalar> DiamondBounds::values() const {
std::vector<ActsScalar> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DiscTrapezoidBounds : public DiscBounds {
/// Return the bound values as dynamically sized vector
///
/// @return this returns a copy of the internal values
std::vector<double> values() const final;
std::vector<ActsScalar> values() const final;

/// This method checks if the radius given in the LocalPosition is inside
/// [rMin,rMax]
Expand Down Expand Up @@ -207,8 +207,8 @@ inline double DiscTrapezoidBounds::binningValuePhi() const {
return get(eAveragePhi);
}

inline std::vector<double> DiscTrapezoidBounds::values() const {
std::vector<double> valvector;
inline std::vector<ActsScalar> DiscTrapezoidBounds::values() const {
std::vector<ActsScalar> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}
Expand Down
Loading
Loading