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