File indexing completed on 2025-08-06 08:11:18
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "Acts/Digitization/CartesianSegmentation.hpp"
0015 #include "Acts/Digitization/Segmentation.hpp"
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/Surfaces/PlaneSurface.hpp"
0018 #include "Acts/Surfaces/RectangleBounds.hpp"
0019 #include "Acts/Surfaces/Surface.hpp"
0020 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0021
0022 #include <cmath>
0023 #include <cstdlib>
0024 #include <memory>
0025
0026 using namespace Acts::UnitLiterals;
0027
0028 namespace Acts::Test {
0029
0030 std::size_t nbinsx = 100;
0031 std::size_t nbinsy = 200;
0032 double hThickness = 75_um;
0033 double lAngle = 0.1;
0034
0035
0036 auto moduleBounds = std::make_shared<const RectangleBounds>(5_mm, 10_mm);
0037 CartesianSegmentation cSegmentation(moduleBounds, nbinsx, nbinsy);
0038
0039
0040 GeometryContext tgContext = GeometryContext();
0041
0042
0043
0044 BOOST_AUTO_TEST_CASE(cartesian_segmentation) {
0045
0046
0047 SurfacePtrVector boundariesPZL;
0048 SurfacePtrVector segSurfacesXPZL;
0049 SurfacePtrVector segSurfacesYPZL;
0050
0051 cSegmentation.createSegmentationSurfaces(boundariesPZL, segSurfacesXPZL,
0052 segSurfacesYPZL, hThickness, 1, 0.);
0053
0054 BOOST_CHECK_EQUAL(boundariesPZL.size(), 6u);
0055
0056
0057 BOOST_CHECK_EQUAL(segSurfacesXPZL.size(), std::size_t(nbinsx - 1));
0058 BOOST_CHECK_EQUAL(segSurfacesYPZL.size(), std::size_t(nbinsy - 1));
0059
0060
0061 auto centerReadoutPZL = boundariesPZL[0]->center(tgContext);
0062 auto centerCounterPZL = boundariesPZL[1]->center(tgContext);
0063 auto centerDiffPZL = centerReadoutPZL - centerCounterPZL;
0064 double thicknessPZL = centerDiffPZL.norm();
0065
0066 CHECK_CLOSE_REL(thicknessPZL, 2 * hThickness, 10e-6);
0067
0068
0069
0070 SurfacePtrVector boundariesNZL;
0071 SurfacePtrVector segSurfacesXNZL;
0072 SurfacePtrVector segSurfacesYNZL;
0073
0074 cSegmentation.createSegmentationSurfaces(boundariesNZL, segSurfacesXNZL,
0075 segSurfacesYNZL, hThickness, -1, 0.);
0076
0077 BOOST_CHECK_EQUAL(boundariesNZL.size(), 6u);
0078
0079
0080 BOOST_CHECK_EQUAL(segSurfacesXNZL.size(), std::size_t(nbinsx - 1));
0081 BOOST_CHECK_EQUAL(segSurfacesYNZL.size(), std::size_t(nbinsy - 1));
0082
0083
0084 auto centerReadoutNZL = boundariesNZL[0]->center(tgContext);
0085 auto centerCounterNZL = boundariesNZL[1]->center(tgContext);
0086 auto centerDiffNZL = centerReadoutNZL - centerCounterNZL;
0087 double thicknessNZL = centerDiffNZL.norm();
0088
0089 CHECK_CLOSE_REL(thicknessNZL, 2 * hThickness, 10e-6);
0090
0091
0092 CHECK_CLOSE_OR_SMALL(centerReadoutPZL, centerCounterNZL, 10e-6, 10e-9);
0093 CHECK_CLOSE_OR_SMALL(centerReadoutNZL, centerCounterPZL, 10e-6, 10e-9);
0094
0095
0096
0097 SurfacePtrVector boundariesPL;
0098 SurfacePtrVector segSurfacesXPL;
0099 SurfacePtrVector segSurfacesYPL;
0100
0101 cSegmentation.createSegmentationSurfaces(
0102 boundariesPL, segSurfacesXPL, segSurfacesYPL, hThickness, 1, lAngle);
0103
0104 BOOST_CHECK_EQUAL(boundariesPL.size(), 6u);
0105
0106
0107 BOOST_CHECK_EQUAL(segSurfacesXPL.size(), std::size_t(nbinsx - 1));
0108 BOOST_CHECK_EQUAL(segSurfacesYPL.size(), std::size_t(nbinsy - 1));
0109
0110
0111 auto centerReadoutPL = boundariesPL[0]->center(tgContext);
0112 auto centerCounterPL = boundariesPL[1]->center(tgContext);
0113 double thicknessPL = abs((centerReadoutPL - centerCounterPL).z());
0114
0115 CHECK_CLOSE_REL(thicknessPL, 2 * hThickness, 10e-6);
0116
0117
0118 const auto* pSurface =
0119 dynamic_cast<const Acts::PlaneSurface*>(segSurfacesXPL[2].get());
0120 BOOST_REQUIRE(pSurface != nullptr);
0121 auto nLorentzPlane = pSurface->normal(tgContext);
0122
0123 Vector3 nNominal(1., 0., 0.);
0124 double tAngle = acos(nLorentzPlane.dot(nNominal));
0125
0126 CHECK_CLOSE_REL(tAngle, lAngle, 0.001);
0127 }
0128
0129 }