File indexing completed on 2025-08-06 08:10:41
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/DD4hepDetector/DD4hepDetectorHelper.hpp"
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Digitization/CartesianSegmentation.hpp"
0013 #include "Acts/Digitization/DigitizationModule.hpp"
0014 #include "Acts/Surfaces/RectangleBounds.hpp"
0015 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0016
0017 #include <cstddef>
0018
0019 #include "DD4hep/CartesianGridXY.h"
0020 #include "DD4hep/Segmentations.h"
0021
0022 using namespace ActsExamples::DD4hep;
0023
0024 std::shared_ptr<const Acts::DigitizationModule>
0025 DD4hepDetectorHelper::rectangleDigiModule(
0026 double halflengthX, double halflengthY, double thickness,
0027 const dd4hep::Segmentation& segmentation) {
0028
0029 double scalor = Acts::UnitConstants::cm;
0030 halflengthX *= scalor;
0031 halflengthY *= scalor;
0032 thickness *= scalor;
0033
0034 auto bounds =
0035 std::make_shared<const Acts::RectangleBounds>(halflengthX, halflengthY);
0036 dd4hep::CartesianGridXY cartesianGrid = segmentation;
0037 if (cartesianGrid.isValid()) {
0038
0039 double gridSizeX = cartesianGrid.gridSizeX() * scalor;
0040 double gridSizeY = cartesianGrid.gridSizeY() * scalor;
0041 std::size_t bins0 =
0042 (cartesianGrid.gridSizeX() != 0)
0043 ? static_cast<std::size_t>((2 * halflengthX) / gridSizeX)
0044 : 0;
0045 std::size_t bins1 =
0046 (cartesianGrid.gridSizeY() != 0)
0047 ? static_cast<std::size_t>((2 * halflengthY) / gridSizeY)
0048 : 0;
0049
0050 std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
0051 std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0,
0052 bins1);
0053
0054
0055 return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation,
0056 thickness, 1, 0));
0057 }
0058 return nullptr;
0059 }
0060
0061 std::shared_ptr<const Acts::DigitizationModule>
0062 DD4hepDetectorHelper::trapezoidalDigiModule(
0063 double minHalflengthX, double maxHalflengthX, double halflengthY,
0064 double thickness, const dd4hep::Segmentation& segmentation) {
0065
0066 double scalor = Acts::UnitConstants::cm;
0067 minHalflengthX *= scalor;
0068 maxHalflengthX *= scalor;
0069 halflengthY *= scalor;
0070 thickness *= scalor;
0071
0072 auto bounds = std::make_shared<const Acts::TrapezoidBounds>(
0073 minHalflengthX, maxHalflengthX, halflengthY);
0074 ;
0075 dd4hep::CartesianGridXY cartesianGrid = segmentation;
0076 if (cartesianGrid.isValid()) {
0077
0078 double gridSizeX = cartesianGrid.gridSizeX() * scalor;
0079 double gridSizeY = cartesianGrid.gridSizeY() * scalor;
0080 std::size_t bins0 =
0081 (cartesianGrid.gridSizeX() != 0)
0082 ? static_cast<std::size_t>((2 * maxHalflengthX) / gridSizeX)
0083 : 0;
0084 std::size_t bins1 =
0085 (cartesianGrid.gridSizeY() != 0)
0086 ? static_cast<std::size_t>((2 * halflengthY) / gridSizeY)
0087 : 0;
0088
0089 std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
0090 std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0,
0091 bins1);
0092
0093
0094 return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation,
0095 thickness, 1, 0));
0096 }
0097 return nullptr;
0098 }