Skip to content

Commit

Permalink
tests 4
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger committed Oct 24, 2024
1 parent bde6cc4 commit c1004ba
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 273 deletions.
5 changes: 3 additions & 2 deletions Tests/UnitTests/Core/Seeding/BinnedGroupTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <array>
#include <memory>
#include <numbers>
#include <vector>

namespace Acts::Test {
Expand Down Expand Up @@ -156,7 +157,7 @@ BOOST_AUTO_TEST_CASE(binned_group_fill_2d) {
using value_t = std::size_t;
using binfinder_t = Acts::GridBinFinder<2ul>;

Axis phiAxis(AxisClosed, -M_PI, M_PI, 40);
Axis phiAxis(AxisClosed, -std::numbers::pi, std::numbers::pi, 40);
Axis zAxis(AxisBound, 0, 100, 10);

Grid grid(Type<std::vector<value_t>>, std::move(phiAxis), std::move(zAxis));
Expand Down Expand Up @@ -192,7 +193,7 @@ BOOST_AUTO_TEST_CASE(binned_group_fill_3d) {
using grid_t = Acts::Grid<std::vector<value_t>, phiAxis_t, zAxis_t, rAxis_t>;
using binfinder_t = Acts::GridBinFinder<3ul>;

phiAxis_t phiAxis(-M_PI, M_PI, 40);
phiAxis_t phiAxis(-std::numbers::pi, std::numbers::pi, 40);
zAxis_t zAxis(0, 100, 10);
rAxis_t rAxis(0, 11000, 1);

Expand Down
4 changes: 3 additions & 1 deletion Tests/UnitTests/Core/Seeding/PathSeederTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "Acts/Tests/CommonHelpers/MeasurementsCreator.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <numbers>

BOOST_AUTO_TEST_SUITE(PathSeeder)

using namespace Acts;
Expand All @@ -51,7 +53,7 @@ const ActsScalar deltaYZ = 1.;
const Vector4 trueVertex(-5., 0., 0., 0);
const std::vector<ActsScalar> truePhis = {-0.15, -0.1, -0.05, 0,
0.05, 0.1, 0.15};
const ActsScalar trueTheta = M_PI_2;
const ActsScalar trueTheta = std::numbers::pi / 2.;
const ActsScalar trueQOverP = 1. / 1._GeV;

// Intersection finding to get the
Expand Down
7 changes: 4 additions & 3 deletions Tests/UnitTests/Core/Surfaces/AlignmentHelperTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <algorithm>
#include <cmath>
#include <numbers>
#include <utility>

namespace Acts::Test {
Expand All @@ -23,9 +24,9 @@ namespace Acts::Test {
BOOST_AUTO_TEST_CASE(alignment_helper_test) {
// (a) Test with non-identity rotation matrix
// Rotation angle parameters
const double alpha = M_PI;
const double beta = 0;
const double gamma = M_PI / 2;
const double alpha = std::numbers::pi;
const double beta = 0.;
const double gamma = std::numbers::pi / 2.;
// rotation around x axis
AngleAxis3 rotX(alpha, Vector3(1., 0., 0.));
// rotation around y axis
Expand Down
103 changes: 55 additions & 48 deletions Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,117 +17,126 @@
#include <algorithm>
#include <array>
#include <cmath>
#include <numbers>
#include <stdexcept>
#include <vector>

/* Note on nomenclature:
alpha = cone opening half angle
z is the axis of symmetry
zmin, zmax define limits for truncated cone
phi is clock angle around cone, with x axis corresponding to phi=0
Cone segments may be defined with the avphi (central position of segment) and
halfphi (extent in phi of cone segment either side of the avphi)
Local coords are z, rphi
*/
// Note on nomenclature:
// - alpha = cone opening half angle
// - z is the axis of symmetry
// - zmin, zmax define limits for truncated cone
// - phi is clock angle around cone, with x axis corresponding to phi=0
// - Cone segments may be defined with the avphi (central position of segment)
// and halfphi (extent in phi of cone segment either side of the avphi)
// - Local coords are z, rphi

namespace Acts::Test {

BOOST_AUTO_TEST_SUITE(Surfaces)

/// Unit test for creating compliant/non-compliant ConeBounds object
const double alpha = std::numbers::pi / 8.;
const double zMin = 3.;
const double zMax = 6.;
const double halfPhi = std::numbers::pi / 4.;
const double averagePhi = 0.;
const bool symmetric = false;

// Unit test for creating compliant/non-compliant ConeBounds object
BOOST_AUTO_TEST_CASE(ConeBoundsConstruction) {
// test default construction
// ConeBounds defaultConstructedConeBounds; // deleted
double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0),
averagePhi(0.);
const bool symmetric(false);

BOOST_TEST_CHECKPOINT("Four parameter constructor (last two at default)");
ConeBounds defaultConeBounds(alpha, symmetric);
BOOST_CHECK_EQUAL(defaultConeBounds.type(), SurfaceBounds::eCone);

BOOST_TEST_CHECKPOINT("Four parameter constructor");
ConeBounds fourParameterConstructed(alpha, symmetric, halfPhi, averagePhi);
BOOST_CHECK_EQUAL(fourParameterConstructed.type(), SurfaceBounds::eCone);

BOOST_TEST_CHECKPOINT("Five parameter constructor (last two at default)");
ConeBounds defaulted5ParamConeBounds(alpha, zMin, zMax);
BOOST_CHECK_EQUAL(defaulted5ParamConeBounds.type(), SurfaceBounds::eCone);

BOOST_TEST_CHECKPOINT("Five parameter constructor)");
ConeBounds fiveParamConstructedConeBounds(alpha, zMin, zMax, halfPhi,
averagePhi);
BOOST_CHECK_EQUAL(fiveParamConstructedConeBounds.type(),
SurfaceBounds::eCone);

BOOST_TEST_CHECKPOINT("Copy constructor");
ConeBounds copyConstructedConeBounds(fiveParamConstructedConeBounds);
BOOST_CHECK_EQUAL(copyConstructedConeBounds, fiveParamConstructedConeBounds);
}

// Streaning and recreation test
BOOST_AUTO_TEST_CASE(ConeBoundsRecreation) {
double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0),
averagePhi(0.);
// const bool symmetric(false);
ConeBounds original(alpha, zMin, zMax, halfPhi, averagePhi);
auto valvector = original.values();
std::array<double, ConeBounds::eSize> values{};
std::copy_n(valvector.begin(), ConeBounds::eSize, values.begin());
ConeBounds recreated(values);

BOOST_CHECK_EQUAL(recreated, original);
}

// Unit tests for AnnulusBounds exception throwing
BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) {
double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0),
averagePhi(0.);

// Exception for opening angle smaller 0
BOOST_CHECK_THROW(ConeBounds(-alpha, zMin, zMax, halfPhi, averagePhi),
std::logic_error);
// Exception for opening angle bigger M_PI
BOOST_CHECK_THROW(ConeBounds(M_PI, zMin, zMax, halfPhi, averagePhi),
std::logic_error);

// Exception for opening angle bigger std::numbers::pi
BOOST_CHECK_THROW(
ConeBounds(std::numbers::pi, zMin, zMax, halfPhi, averagePhi),
std::logic_error);

// Exception for swapped zMin and zMax
BOOST_CHECK_THROW(ConeBounds(alpha, zMax, zMin, halfPhi, averagePhi),
std::logic_error);

// Exception for negative half sector phi
BOOST_CHECK_THROW(ConeBounds(alpha, zMin, zMax, -halfPhi, averagePhi),
std::logic_error);

// Exception for out of range phi positioning
BOOST_CHECK_THROW(ConeBounds(alpha, zMin, zMax, halfPhi, 2 * M_PI),
std::logic_error);
BOOST_CHECK_THROW(
ConeBounds(alpha, zMin, zMax, halfPhi, 2 * std::numbers::pi),
std::logic_error);
}

/// Unit tests for properties of ConeBounds object
// Unit tests for properties of ConeBounds object
BOOST_AUTO_TEST_CASE(ConeBoundsProperties) {
double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0),
averagePhi(0.);
// const bool symmetric(false);
const Vector2 origin(0, 0);
const Vector2 somewhere(4., 4.);
ConeBounds coneBoundsObject(alpha, zMin, zMax, halfPhi, averagePhi);
//
/// test for type (redundant)

// test for type (redundant)
BOOST_CHECK_EQUAL(coneBoundsObject.type(), SurfaceBounds::eCone);
//
/// test for inside

// test for inside
BOOST_CHECK(!coneBoundsObject.inside(origin));
//
/// test for r

// test for r
CHECK_CLOSE_REL(coneBoundsObject.r(zMin), zMin * std::tan(alpha), 1e-6);
//
/// test for tanAlpha

// test for tanAlpha
CHECK_CLOSE_REL(coneBoundsObject.tanAlpha(), std::tan(alpha), 1e-6);
//
/// test for alpha

// test for alpha
CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eAlpha), alpha, 1e-6);
//
/// test for minZ

// test for minZ
CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMinZ), zMin, 1e-6);
//
/// test for maxZ

// test for maxZ
CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMaxZ), zMax, 1e-6);
//
/// test for averagePhi

// test for averagePhi
CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eHalfPhiSector), halfPhi,
1e-6);
/// test for dump

// test for dump
boost::test_tools::output_test_stream dumpOuput;
coneBoundsObject.toStream(dumpOuput);
BOOST_CHECK(dumpOuput.is_equal(
Expand All @@ -137,12 +146,10 @@ BOOST_AUTO_TEST_CASE(ConeBoundsProperties) {

// Unit test for testing ConeBounds assignment
BOOST_AUTO_TEST_CASE(ConeBoundsAssignment) {
double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0),
averagePhi(0.);
// const bool symmetric(false);
ConeBounds originalConeBounds(alpha, zMin, zMax, halfPhi, averagePhi);
ConeBounds assignedConeBounds(0.1, 2.3, 4.5, 1.2, 2.1);
assignedConeBounds = originalConeBounds;

BOOST_CHECK_EQUAL(assignedConeBounds, originalConeBounds);
}

Expand Down
Loading

0 comments on commit c1004ba

Please sign in to comment.