Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Jan 15, 2025
1 parent 41f3cf7 commit 941c8f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
17 changes: 6 additions & 11 deletions Core/include/Acts/Definitions/Direction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Direction final {
/// @return a direction enum
static constexpr Direction fromScalar(double scalar) {
assert(scalar != 0);
return Direction{scalar >= 0 ? Value::Positive : Value::Negative};
return scalar >= 0 ? Positive() : Negative();
}

/// This turns a signed value into a direction and 0 will be handled as a
Expand All @@ -58,18 +58,15 @@ class Direction final {
///
/// @return a direction enum
static constexpr Direction fromScalarZeroAsPositive(double scalar) {
return Direction{scalar >= 0 ? Value::Positive : Value::Negative};
return scalar >= 0 ? Positive() : Negative();
}

/// Convert and index [0,1] to a direction e.g. for sorting in
/// std::array<T, 2u>
///
/// @param index is the direction at input
static constexpr Direction fromIndex(std::size_t index) {
if (index == 0u) {
return Direction{Value::Negative};
}
return Direction{Value::Positive};
return index == 0u ? Negative() : Positive();
}

/// Convert dir to index [0,1] which allows to store direction dependent
Expand All @@ -92,20 +89,18 @@ class Direction final {
///
/// @return an opposite direction
constexpr Direction invert() const {
return Direction{m_value == Value::Positive ? Value::Negative
: Value::Positive};
return *this == Positive() ? Negative() : Positive();
}

std::string toString() const;

constexpr Direction() = default;
explicit constexpr Direction(Value value) : m_value(value) {}

friend constexpr bool operator==(Direction lhs, Direction rhs) {
return lhs.m_value == rhs.m_value;
}

private:
explicit constexpr Direction(Value value) : m_value(value) {}

Value m_value = Value::Positive;
};

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/VolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Direction;

struct OrientedSurface {
std::shared_ptr<RegularSurface> surface;
Direction direction;
Direction direction = Direction::AlongNormal();
};

// Planar definitions to help construct the boundary surfaces
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/detail/SteppingLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace detail {
/// later stage, the surface is referenced counted here.
struct Step {
ConstrainedStep stepSize;
Direction navDir;
Direction navDir = Direction::Forward();
Vector3 position = Vector3(0., 0., 0.);
Vector3 momentum = Vector3(0., 0., 0.);
std::shared_ptr<const Surface> surface = nullptr;
Expand Down

0 comments on commit 941c8f9

Please sign in to comment.