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