Skip to content

Commit

Permalink
revert angle helper changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Oct 28, 2024
1 parent 625a14f commit 94ddba5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 89 deletions.
42 changes: 0 additions & 42 deletions Core/include/Acts/Utilities/AngleHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,16 @@
#pragma once

#include <cmath>
#include <numbers>

namespace Acts::AngleHelpers {

template <typename Scalar>
struct EtaThetaConversionTraits {
static constexpr Scalar minTheta = 0;
static constexpr Scalar maxTheta = std::numbers::pi_v<Scalar>;

static constexpr Scalar minEta = -std::numeric_limits<Scalar>::infinity();
static constexpr Scalar maxEta = std::numeric_limits<Scalar>::infinity();
};

template <>
struct EtaThetaConversionTraits<float> {
static constexpr float minTheta = 0;
static constexpr float maxTheta = std::numbers::pi_v<float> - 1e-6f;

static constexpr float minEta = -std::numeric_limits<float>::infinity();
static constexpr float maxEta = std::numeric_limits<float>::infinity();
};

template <>
struct EtaThetaConversionTraits<double> {
static constexpr double minTheta = 0;
static constexpr double maxTheta = std::numbers::pi;

static constexpr double minEta = -std::numeric_limits<double>::infinity();
static constexpr double maxEta = std::numeric_limits<double>::infinity();
};

/// Calculate the pseudorapidity from the polar angle theta.
///
/// @param theta is the polar angle in radian towards the z-axis.
///
/// @return the pseudorapidity towards the z-axis.
template <typename Scalar>
Scalar etaFromTheta(Scalar theta) {
if (theta < EtaThetaConversionTraits<Scalar>::minTheta) {
return std::numeric_limits<Scalar>::infinity();
}
if (theta > EtaThetaConversionTraits<Scalar>::maxTheta) {
return -std::numeric_limits<Scalar>::infinity();
}

return -std::log(std::tan(0.5 * theta));
}

Expand All @@ -64,13 +29,6 @@ Scalar etaFromTheta(Scalar theta) {
/// @return the polar angle in radian towards the z-axis.
template <typename Scalar>
Scalar thetaFromEta(Scalar eta) {
if (eta < EtaThetaConversionTraits<Scalar>::minEta) {
return std::numbers::pi_v<Scalar>;
}
if (eta > EtaThetaConversionTraits<Scalar>::maxEta) {
return 0;
}

return 2 * std::atan(std::exp(-eta));
}

Expand Down
47 changes: 0 additions & 47 deletions Tests/UnitTests/Core/Utilities/AngleHelpersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#include <boost/test/data/test_case.hpp>
#include <boost/test/unit_test.hpp>

#include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
#include "Acts/Utilities/AngleHelpers.hpp"

#include <cmath>
#include <numbers>

namespace bd = boost::unit_test::data;

using Acts::AngleHelpers::etaFromTheta;
using Acts::AngleHelpers::thetaFromEta;

Expand All @@ -30,47 +26,4 @@ BOOST_AUTO_TEST_CASE(EtaThetaConversion) {
CHECK_CLOSE_ABS(1.0, thetaFromEta(etaFromTheta(1.0)), 1e-6);
}

BOOST_DATA_TEST_CASE(EtaFromThetaRobustness, bd::xrange(1, 100, 1), exponent) {
{
float thetaRight = std::pow(10.0f, -exponent);
float etaRight = etaFromTheta(thetaRight);
BOOST_CHECK(!std::isnan(etaRight));

float thetaLeft = std::numbers::pi_v<float> - thetaRight;
float etaLeft = etaFromTheta(thetaLeft);
BOOST_CHECK(!std::isnan(etaLeft));
}

{
double thetaRight = std::pow(10.0, -exponent);
double etaRight = etaFromTheta(thetaRight);
BOOST_CHECK(!std::isnan(etaRight));

double thetaLeft = std::numbers::pi - thetaRight;
double etaLeft = etaFromTheta(thetaLeft);
BOOST_CHECK(!std::isnan(etaLeft));
}
}

BOOST_DATA_TEST_CASE(ThetaFromEtaRobustness, bd::xrange(1.0, 100.0, 1.0),
etaRight) {
{
float thetaRight = thetaFromEta(etaRight);
BOOST_CHECK(!std::isnan(thetaRight));

float etaLeft = -etaRight;
float thetaLeft = thetaFromEta(etaLeft);
BOOST_CHECK(!std::isnan(thetaLeft));
}

{
double thetaRight = thetaFromEta(etaRight);
BOOST_CHECK(!std::isnan(thetaRight));

double etaLeft = -etaRight;
double thetaLeft = thetaFromEta(etaLeft);
BOOST_CHECK(!std::isnan(thetaLeft));
}
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 94ddba5

Please sign in to comment.