Skip to content

Commit

Permalink
refactor!: finalize consistent renaming of direction (#2388)
Browse files Browse the repository at this point in the history
Following #2343
  • Loading branch information
felix-russo committed Aug 24, 2023
1 parent f90906c commit 27cd1e3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Core/include/Acts/Utilities/UnitVectors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Acts {
/// unexpected implicit type conversions and forces the user to
/// explicitly cast mismatched input types.
template <typename T>
inline Eigen::Matrix<T, 3, 1> makeDirectionUnitFromPhiEta(T phi, T eta) {
inline Eigen::Matrix<T, 3, 1> makeDirectionFromPhiEta(T phi, T eta) {
const auto coshEtaInv = 1 / std::cosh(eta);
return {
std::cos(phi) * coshEtaInv,
Expand Down Expand Up @@ -60,7 +60,7 @@ inline Eigen::Matrix<T, 3, 1> makeDirectionFromPhiTheta(T phi, T theta) {
/// @param unitDir 3D vector indicating a direction
///
template <typename T>
inline Eigen::Matrix<T, 2, 1> makePhiThetaFromDirectionUnit(
inline Eigen::Matrix<T, 2, 1> makePhiThetaFromDirection(
Eigen::Matrix<T, 3, 1> unitDir) {
unitDir.normalize();
T phi = std::atan2(unitDir[1], unitDir[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,7 @@ ActsExamples::ProcessCode ActsExamples::VertexPerformanceWriter::writeT(
if (trk.originalParams->parameters() == params) {
const auto& trueUnitDir = particle.direction();
Acts::ActsVector<3> trueMom;
trueMom.head(2) =
Acts::makePhiThetaFromDirectionUnit(trueUnitDir);
trueMom.head(2) = Acts::makePhiThetaFromDirection(trueUnitDir);
trueMom[2] = particle.qOverP();
innerTruthPhi.push_back(trueMom[0]);
innerTruthTheta.push_back(trueMom[1]);
Expand Down
2 changes: 1 addition & 1 deletion Tests/IntegrationTests/Fatras/FatrasSimulationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ BOOST_DATA_TEST_CASE(FatrasSimulation, dataset, pdg, phi, eta, p,
const auto pid = ActsFatras::Barcode().setVertexPrimary(42).setParticle(i);
const auto particle =
ActsFatras::Particle(pid, pdg)
.setDirection(Acts::makeDirectionUnitFromPhiEta(phi, eta))
.setDirection(Acts::makeDirectionFromPhiEta(phi, eta))
.setAbsoluteMomentum(p);
input.push_back(std::move(particle));
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(LineSurfaceTransformRoundTripEtaStability) {

for (double eta : etas) {
Vector3 pca = {5, 0, 0};
Vector3 dir = makeDirectionUnitFromPhiEta(M_PI_2, eta);
Vector3 dir = makeDirectionFromPhiEta(M_PI_2, eta);
Vector3 pos = pca + dir;

auto intersection = surface.intersect(tgContext, pos, dir);
Expand Down
32 changes: 16 additions & 16 deletions Tests/UnitTests/Core/Utilities/UnitVectorsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,64 @@ constexpr auto eps = std::numeric_limits<double>::epsilon();
BOOST_AUTO_TEST_SUITE(UnitVectors)

BOOST_AUTO_TEST_CASE(DirectionPhiEta) {
using Acts::makeDirectionUnitFromPhiEta;
using Acts::makeDirectionFromPhiEta;

// along positive x
const auto xPos1 = makeDirectionUnitFromPhiEta(0.0, 0.0);
const auto xPos1 = makeDirectionFromPhiEta(0.0, 0.0);
CHECK_CLOSE_REL(xPos1.norm(), 1, eps);
CHECK_CLOSE_REL(xPos1.dot(Vector3(1, 0, 0)), 1, eps);
const auto xPos2 = makeDirectionUnitFromPhiEta(2 * M_PI, 0.0);
const auto xPos2 = makeDirectionFromPhiEta(2 * M_PI, 0.0);
CHECK_CLOSE_REL(xPos2.norm(), 1, eps);
CHECK_CLOSE_REL(xPos2.dot(Vector3(1, 0, 0)), 1, eps);
// along negative x
const auto xNeg1 = makeDirectionUnitFromPhiEta(M_PI, 0.0);
const auto xNeg1 = makeDirectionFromPhiEta(M_PI, 0.0);
CHECK_CLOSE_REL(xNeg1.norm(), 1, eps);
CHECK_CLOSE_REL(xNeg1.dot(Vector3(-1, 0, 0)), 1, eps);
const auto xNeg2 = makeDirectionUnitFromPhiEta(-M_PI, 0.0);
const auto xNeg2 = makeDirectionFromPhiEta(-M_PI, 0.0);
CHECK_CLOSE_REL(xNeg2.norm(), 1, eps);
CHECK_CLOSE_REL(xNeg2.dot(Vector3(-1, 0, 0)), 1, eps);
// along positive y
const auto yPos1 = makeDirectionUnitFromPhiEta(M_PI_2, 0.0);
const auto yPos1 = makeDirectionFromPhiEta(M_PI_2, 0.0);
CHECK_CLOSE_REL(yPos1.norm(), 1, eps);
CHECK_CLOSE_REL(yPos1.dot(Vector3(0, 1, 0)), 1, eps);
const auto yPos2 = makeDirectionUnitFromPhiEta(-3 * M_PI_2, 0.0);
const auto yPos2 = makeDirectionFromPhiEta(-3 * M_PI_2, 0.0);
CHECK_CLOSE_REL(yPos2.norm(), 1, eps);
CHECK_CLOSE_REL(yPos2.dot(Vector3(0, 1, 0)), 1, eps);
// along negative y
const auto yNeg1 = makeDirectionUnitFromPhiEta(-M_PI_2, 0.0);
const auto yNeg1 = makeDirectionFromPhiEta(-M_PI_2, 0.0);
CHECK_CLOSE_REL(yNeg1.norm(), 1, eps);
CHECK_CLOSE_REL(yNeg1.dot(Vector3(0, -1, 0)), 1, eps);
const auto yNeg2 = makeDirectionUnitFromPhiEta(3 * M_PI_2, 0.0);
const auto yNeg2 = makeDirectionFromPhiEta(3 * M_PI_2, 0.0);
CHECK_CLOSE_REL(yNeg2.norm(), 1, eps);
CHECK_CLOSE_REL(yNeg2.dot(Vector3(0, -1, 0)), 1, eps);

const auto inf = std::numeric_limits<double>::infinity();
// along positive z
const auto zPos1 = makeDirectionUnitFromPhiEta(0.0, inf);
const auto zPos1 = makeDirectionFromPhiEta(0.0, inf);
CHECK_CLOSE_REL(zPos1.norm(), 1, eps);
CHECK_CLOSE_REL(zPos1.dot(Vector3(0, 0, 1)), 1, eps);
const auto zPos2 = makeDirectionUnitFromPhiEta(M_PI_2, inf);
const auto zPos2 = makeDirectionFromPhiEta(M_PI_2, inf);
CHECK_CLOSE_REL(zPos2.norm(), 1, eps);
CHECK_CLOSE_REL(zPos2.dot(Vector3(0, 0, 1)), 1, eps);
// along negative z
const auto zNeg1 = makeDirectionUnitFromPhiEta(0.0, -inf);
const auto zNeg1 = makeDirectionFromPhiEta(0.0, -inf);
CHECK_CLOSE_REL(zNeg1.norm(), 1, eps);
CHECK_CLOSE_REL(zNeg1.dot(Vector3(0, 0, -1)), 1, eps);
const auto zNeg2 = makeDirectionUnitFromPhiEta(M_PI_2, -inf);
const auto zNeg2 = makeDirectionFromPhiEta(M_PI_2, -inf);
CHECK_CLOSE_REL(zNeg2.norm(), 1, eps);
CHECK_CLOSE_REL(zNeg2.dot(Vector3(0, 0, -1)), 1, eps);

// mixed direction
const auto mixed1 = makeDirectionUnitFromPhiEta(M_PI_4, 1.0);
const auto mixed1 = makeDirectionFromPhiEta(M_PI_4, 1.0);
CHECK_CLOSE_REL(mixed1.norm(), 1, eps);
CHECK_CLOSE_REL(
mixed1.dot(Vector3(1, 1, M_SQRT2 * std::sinh(1.0)).normalized()), 1, eps);
const auto mixed2 = makeDirectionUnitFromPhiEta(M_PI_4, -1.0);
const auto mixed2 = makeDirectionFromPhiEta(M_PI_4, -1.0);
CHECK_CLOSE_REL(mixed2.norm(), 1, eps);
CHECK_CLOSE_REL(
mixed2.dot(Vector3(1, 1, M_SQRT2 * std::sinh(-1.0)).normalized()), 1,
eps);
const auto mixed3 = makeDirectionUnitFromPhiEta(-M_PI_4, -1.0);
const auto mixed3 = makeDirectionFromPhiEta(-M_PI_4, -1.0);
CHECK_CLOSE_REL(mixed3.norm(), 1, eps);
CHECK_CLOSE_REL(
mixed3.dot(Vector3(1, -1, M_SQRT2 * std::sinh(-1.0)).normalized()), 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(grid_density_vertex_finder_test) {
double charge = etaDist(gen) > 0 ? 1 : -1;

// project the position on the surface
Vector3 direction = makeDirectionUnitFromPhiEta(phi, eta);
Vector3 direction = makeDirectionFromPhiEta(phi, eta);
auto intersection = perigeeSurface->intersect(geoContext, pos, direction);
pos = intersection.intersection.position;

Expand Down Expand Up @@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE(grid_density_vertex_finder_track_caching_test) {
double charge = etaDist(gen) > 0 ? 1 : -1;

// project the position on the surface
Vector3 direction = makeDirectionUnitFromPhiEta(phi, eta);
Vector3 direction = makeDirectionFromPhiEta(phi, eta);
auto intersection = perigeeSurface->intersect(geoContext, pos, direction);
pos = intersection.intersection.position;

Expand Down Expand Up @@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(grid_density_vertex_finder_seed_width_test) {
double charge = etaDist(gen) > 0 ? 1 : -1;

// project the position on the surface
Vector3 direction = makeDirectionUnitFromPhiEta(phi, eta);
Vector3 direction = makeDirectionFromPhiEta(phi, eta);
auto intersection = perigeeSurface->intersect(geoContext, pos, direction);
pos = intersection.intersection.position;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_random_test) {
double charge = etaDist(gen) > 0 ? 1 : -1;

// project the position on the surface
Vector3 direction = makeDirectionUnitFromPhiEta(phi, eta);
Vector3 direction = makeDirectionFromPhiEta(phi, eta);
auto intersection = perigeeSurface->intersect(geoContext, pos, direction);
pos = intersection.intersection.position;

Expand Down

0 comments on commit 27cd1e3

Please sign in to comment.