File indexing completed on 2025-08-06 08:11:19
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/DigitizationCell.hpp"
0016 #include "Acts/Digitization/DigitizationModule.hpp"
0017 #include "Acts/Digitization/PlanarModuleStepper.hpp"
0018 #include "Acts/Geometry/GeometryContext.hpp"
0019 #include "Acts/Surfaces/RectangleBounds.hpp"
0020 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0021
0022 #include <cmath>
0023 #include <cstdlib>
0024 #include <memory>
0025 #include <random>
0026 #include <utility>
0027 #include <vector>
0028
0029 namespace bdata = boost::unit_test::data;
0030 using namespace Acts::UnitLiterals;
0031
0032 namespace Acts::Test {
0033
0034 double halfX = 5_mm;
0035 double halfY = 10_mm;
0036 std::size_t ntests = 100;
0037 std::size_t nbinsx = 100;
0038 std::size_t nbinsy = 200;
0039 double hThickness = 75_um;
0040 double lAngle = 0.1;
0041 double tanAlpha = tan(lAngle);
0042 double sguardX = 2 * hThickness * abs(tanAlpha);
0043
0044
0045 auto moduleBounds = std::make_shared<const RectangleBounds>(halfX, halfY);
0046 auto cSegmentation =
0047 std::make_shared<const CartesianSegmentation>(moduleBounds, nbinsx, nbinsy);
0048
0049
0050
0051 DigitizationModule pdModule(cSegmentation, hThickness, 1, lAngle, 0., true);
0052
0053 DigitizationModule ndModule(cSegmentation, hThickness, -1, lAngle, 0., true);
0054 std::vector<DigitizationModule> testModules = {pdModule, ndModule};
0055
0056
0057 PlanarModuleStepper pmStepper;
0058
0059
0060 GeometryContext tgContext = GeometryContext();
0061
0062
0063
0064 BOOST_DATA_TEST_CASE(
0065 readout_counter_test,
0066 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 0,
0067 bdata::distribution = std::uniform_real_distribution<double>(
0068 -halfX + sguardX, halfX - sguardX))) ^
0069 bdata::random(
0070 (bdata::engine = std::mt19937(), bdata::seed = 1,
0071 bdata::distribution = std::uniform_real_distribution<double>(
0072 -halfX + sguardX, halfX - sguardX))) ^
0073 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
0074 bdata::distribution =
0075 std::uniform_real_distribution<double>(-halfY,
0076 halfY))) ^
0077 bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3,
0078 bdata::distribution =
0079 std::uniform_real_distribution<double>(-halfY,
0080 halfY))) ^
0081 bdata::xrange(ntests),
0082 entryX, entryY, exitX, exitY, index) {
0083
0084 (void)index;
0085
0086
0087 Vector3 entry(entryX, entryY, -hThickness);
0088 Vector3 exit(exitX, exitY, hThickness);
0089
0090
0091 for (auto& dm : testModules) {
0092
0093 auto cSteps = pmStepper.cellSteps(tgContext, dm, entry, exit);
0094 BOOST_CHECK_NE(cSteps.size(), 0);
0095
0096
0097
0098 auto fPosition = cSteps.begin()->stepEntry;
0099 auto lPosition = cSteps.rbegin()->stepExit;
0100 double zDiff = (lPosition - fPosition).z();
0101
0102 CHECK_CLOSE_REL(zDiff, 2 * hThickness, 10e-6);
0103 }
0104 }
0105
0106 }