File indexing completed on 2025-08-06 08:11:29
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/tools/output_test_stream.hpp>
0011 #include <boost/test/unit_test.hpp>
0012
0013 #include "Acts/Definitions/Algebra.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Surfaces/LineBounds.hpp"
0016 #include "Acts/Surfaces/RectangleBounds.hpp"
0017 #include "Acts/Surfaces/StrawSurface.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp"
0020
0021 #include <memory>
0022 #include <string>
0023
0024 namespace Acts {
0025 class PlanarBounds;
0026 }
0027
0028 namespace utf = boost::unit_test;
0029
0030 namespace Acts::Test {
0031
0032
0033 GeometryContext tgContext = GeometryContext();
0034
0035 BOOST_AUTO_TEST_SUITE(StrawSurfaces)
0036
0037 BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) {
0038
0039
0040
0041 double radius(1.0), halfZ(10.);
0042 Translation3 translation{0., 1., 2.};
0043 auto pTransform = Transform3(translation);
0044 BOOST_CHECK_EQUAL(
0045 Surface::makeShared<StrawSurface>(Transform3::Identity(), radius, halfZ)
0046 ->type(),
0047 Surface::Straw);
0048 BOOST_CHECK_EQUAL(
0049 Surface::makeShared<StrawSurface>(pTransform, radius, halfZ)->type(),
0050 Surface::Straw);
0051
0052
0053 auto pLineBounds = std::make_shared<const LineBounds>(radius, halfZ);
0054 BOOST_CHECK_EQUAL(
0055 Surface::makeShared<StrawSurface>(pTransform, pLineBounds)->type(),
0056 Surface::Straw);
0057
0058
0059 std::shared_ptr<const Acts::PlanarBounds> p =
0060 std::make_shared<const RectangleBounds>(1., 10.);
0061 DetectorElementStub detElement{pTransform, p, 1.0, nullptr};
0062 BOOST_CHECK_EQUAL(
0063 Surface::makeShared<StrawSurface>(pLineBounds, detElement)->type(),
0064 Surface::Straw);
0065
0066
0067 auto strawSurfaceObject =
0068 Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
0069 auto copiedStrawSurface =
0070 Surface::makeShared<StrawSurface>(*strawSurfaceObject);
0071 BOOST_CHECK_EQUAL(copiedStrawSurface->type(), Surface::Straw);
0072 BOOST_CHECK(*copiedStrawSurface == *strawSurfaceObject);
0073
0074
0075 auto copiedTransformedStrawSurface = Surface::makeShared<StrawSurface>(
0076 tgContext, *strawSurfaceObject, pTransform);
0077 BOOST_CHECK_EQUAL(copiedTransformedStrawSurface->type(), Surface::Straw);
0078 }
0079
0080
0081 BOOST_AUTO_TEST_CASE(StrawSurfaceProperties) {
0082
0083 double radius(1.0), halfZ(10.);
0084 Translation3 translation{0., 1., 2.};
0085 auto pTransform = Transform3(translation);
0086 auto strawSurfaceObject =
0087 Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
0088
0089
0090 BOOST_CHECK_EQUAL(strawSurfaceObject->type(), Surface::Straw);
0091
0092
0093 BOOST_CHECK_EQUAL(strawSurfaceObject->name(),
0094 std::string("Acts::StrawSurface"));
0095
0096
0097 boost::test_tools::output_test_stream dumpOuput;
0098 strawSurfaceObject->toStream(tgContext, dumpOuput);
0099 BOOST_CHECK(
0100 dumpOuput.is_equal("Acts::StrawSurface\n\
0101 Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n\
0102 Rotation: colX = (1.000000, 0.000000, 0.000000)\n\
0103 colY = (0.000000, 1.000000, 0.000000)\n\
0104 colZ = (0.000000, 0.000000, 1.000000)\n\
0105 Bounds : Acts::LineBounds: (radius, halflengthInZ) = (1.0000000, 10.0000000)"));
0106 }
0107
0108 BOOST_AUTO_TEST_CASE(EqualityOperators) {
0109 double radius(1.0), halfZ(10.);
0110 Translation3 translation{0., 1., 2.};
0111 auto pTransform = Transform3(translation);
0112 auto strawSurfaceObject =
0113 Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
0114
0115 auto strawSurfaceObject2 =
0116 Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
0117
0118
0119 BOOST_CHECK(*strawSurfaceObject == *strawSurfaceObject2);
0120
0121 BOOST_TEST_CHECKPOINT(
0122 "Create and then assign a StrawSurface object to the existing one");
0123
0124 auto assignedStrawSurface =
0125 Surface::makeShared<StrawSurface>(Transform3::Identity(), 6.6, 33.33);
0126 *assignedStrawSurface = *strawSurfaceObject;
0127
0128 BOOST_CHECK(*assignedStrawSurface == *strawSurfaceObject);
0129 }
0130
0131 BOOST_AUTO_TEST_SUITE_END()
0132
0133 }