File indexing completed on 2026-11-12 09:43:39
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Surfaces/LineBounds.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Surfaces/StrawSurface.hpp"
0017 #include "Acts/Surfaces/Surface.hpp"
0018 #include "Acts/Utilities/Diagnostics.hpp"
0019 #include "ActsTests/CommonHelpers/DetectorElementStub.hpp"
0020
0021 #include <memory>
0022 #include <string>
0023
0024 using namespace Acts;
0025
0026 namespace ActsTests {
0027
0028
0029 GeometryContext tgContext = GeometryContext::dangerouslyDefaultConstruct();
0030
0031 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0032
0033 const double radius = 1.;
0034 const double halfZ = 10.;
0035 Translation3 translation{0., 1., 2.};
0036
0037
0038 BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) {
0039
0040
0041
0042
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., 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 auto pTransform = Transform3(translation);
0084 auto strawSurfaceObject =
0085 Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
0086
0087
0088 BOOST_CHECK_EQUAL(strawSurfaceObject->type(), Surface::Straw);
0089
0090
0091 BOOST_CHECK_EQUAL(strawSurfaceObject->name(),
0092 std::string("Acts::StrawSurface"));
0093
0094
0095 boost::test_tools::output_test_stream dumpOutput;
0096 dumpOutput << strawSurfaceObject->toStream(tgContext);
0097 BOOST_CHECK(
0098 dumpOutput.is_equal("Acts::StrawSurface\n\
0099 Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n\
0100 Rotation: colX = (1.000000, 0.000000, 0.000000)\n\
0101 colY = (0.000000, 1.000000, 0.000000)\n\
0102 colZ = (0.000000, 0.000000, 1.000000)\n\
0103 Bounds : Acts::LineBounds: (radius, halflengthInZ) = (1.0000000, 10.0000000)"));
0104 }
0105
0106 BOOST_AUTO_TEST_CASE(EqualityOperators) {
0107 auto pTransform = Transform3(translation);
0108 auto strawSurfaceObject =
0109 Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
0110
0111 auto strawSurfaceObject2 =
0112 Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
0113
0114
0115 BOOST_CHECK(*strawSurfaceObject == *strawSurfaceObject2);
0116
0117 BOOST_TEST_CHECKPOINT(
0118 "Create and then assign a StrawSurface object to the existing one");
0119
0120
0121 auto assignedStrawSurface =
0122 Surface::makeShared<StrawSurface>(Transform3::Identity(), 6.6, 33.33);
0123
0124
0125 ACTS_PUSH_IGNORE_DEPRECATED()
0126 *assignedStrawSurface = *strawSurfaceObject;
0127 ACTS_POP_IGNORE_DEPRECATED()
0128
0129
0130 BOOST_CHECK(*assignedStrawSurface == *strawSurfaceObject);
0131 }
0132
0133 BOOST_AUTO_TEST_SUITE_END()
0134
0135 }