File indexing completed on 2025-12-17 09:11:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "Acts/Digitization/PlanarModuleStepper.hpp"
0014
0015 #include "Acts/Definitions/Algebra.hpp"
0016 #include "Acts/Digitization/DigitizationCell.hpp"
0017 #include "Acts/Digitization/DigitizationModule.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include "Acts/Utilities/Intersection.hpp"
0020
0021 #include <algorithm>
0022 #include <cstddef>
0023 #include <ostream>
0024
0025 Acts::PlanarModuleStepper::PlanarModuleStepper(
0026 std::unique_ptr<const Logger> mlogger)
0027 : m_logger(std::move(mlogger)) {}
0028
0029 std::vector<Acts::DigitizationStep> Acts::PlanarModuleStepper::cellSteps(
0030 const GeometryContext& gctx, const DigitizationModule& dmodule,
0031 const Vector3& startPoint, const Vector3& endPoint) const {
0032
0033 std::vector<DigitizationStep> cSteps;
0034
0035
0036 auto stepSurfaces = dmodule.stepSurfaces(startPoint, endPoint);
0037
0038
0039 Vector3 trackDirection((endPoint - startPoint).normalized());
0040
0041
0042 std::vector<Acts::Intersection3D> stepIntersections;
0043 stepIntersections.reserve(stepSurfaces.size() + 1);
0044
0045
0046 for (auto& sSurface : stepSurfaces) {
0047
0048 auto sIntersection =
0049 sSurface
0050 ->intersect(gctx, startPoint, trackDirection, BoundaryCheck(true))
0051 .closest();
0052 if (sIntersection) {
0053
0054 stepIntersections.push_back(sIntersection.intersection());
0055 ACTS_VERBOSE("Boundary Surface intersected with = "
0056 << sIntersection.position().x() << ", "
0057 << sIntersection.position().y() << ", "
0058 << sIntersection.position().z());
0059 }
0060 }
0061
0062 stepIntersections.push_back(
0063 Intersection3D(endPoint, (startPoint - endPoint).norm(),
0064 Intersection3D::Status::reachable));
0065 std::sort(stepIntersections.begin(), stepIntersections.end(),
0066 Intersection3D::pathLengthOrder);
0067
0068 Vector3 lastPosition = startPoint;
0069
0070 cSteps.reserve(stepIntersections.size());
0071 for (auto& sIntersection : stepIntersections) {
0072
0073 cSteps.push_back(
0074 dmodule.digitizationStep(lastPosition, sIntersection.position()));
0075 lastPosition = sIntersection.position();
0076 }
0077
0078 return cSteps;
0079 }
0080
0081
0082 std::vector<Acts::DigitizationStep> Acts::PlanarModuleStepper::cellSteps(
0083 const GeometryContext& gctx, const Acts::DigitizationModule& dmodule,
0084 const Vector2& moduleIntersection, const Vector3& trackDirection) const {
0085
0086 auto boundarySurfaces = dmodule.boundarySurfaces();
0087
0088
0089 Vector3 intersection3D(moduleIntersection.x(), moduleIntersection.y(), 0.);
0090 std::size_t attempts = 0;
0091
0092 std::vector<Acts::Intersection3D> boundaryIntersections;
0093
0094 for (auto& bSurface : boundarySurfaces) {
0095
0096 ++attempts;
0097
0098 auto bIntersection = bSurface
0099 ->intersect(gctx, intersection3D, trackDirection,
0100 BoundaryCheck(true))
0101 .closest();
0102 if (bIntersection) {
0103
0104 boundaryIntersections.push_back(bIntersection.intersection());
0105 ACTS_VERBOSE("Boundary Surface intersected with = "
0106 << bIntersection.position().x() << ", "
0107 << bIntersection.position().y() << ", "
0108 << bIntersection.position().z());
0109 }
0110
0111
0112
0113 if (attempts == 2 && boundaryIntersections.size() == attempts) {
0114 break;
0115 }
0116 }
0117
0118
0119 if (boundaryIntersections.size() > 2) {
0120 ACTS_VERBOSE(
0121 "More than 2 Boundary Surfaces intersected, this is an edge "
0122 "case, resolving ... ");
0123 std::sort(boundaryIntersections.begin(), boundaryIntersections.end(),
0124 Intersection3D::pathLengthOrder);
0125 }
0126
0127 if (boundaryIntersections.empty()) {
0128 return std::vector<Acts::DigitizationStep>();
0129 }
0130
0131 return cellSteps(gctx, dmodule, boundaryIntersections[0].position(),
0132 boundaryIntersections[1].position());
0133 }