File indexing completed on 2025-08-06 08:11:21
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/Detector/ProtoDetector.hpp"
0015 #include "Acts/Geometry/CylinderVolumeHelper.hpp"
0016 #include "Acts/Geometry/Extent.hpp"
0017 #include "Acts/Geometry/GeometryContext.hpp"
0018 #include "Acts/Geometry/KDTreeTrackingGeometryBuilder.hpp"
0019 #include "Acts/Geometry/LayerArrayCreator.hpp"
0020 #include "Acts/Geometry/LayerCreator.hpp"
0021 #include "Acts/Geometry/SurfaceArrayCreator.hpp"
0022 #include "Acts/Geometry/TrackingVolumeArrayCreator.hpp"
0023 #include "Acts/Surfaces/CylinderSurface.hpp"
0024 #include "Acts/Surfaces/Surface.hpp"
0025 #include "Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp"
0026 #include "Acts/Utilities/BinningData.hpp"
0027 #include "Acts/Utilities/BinningType.hpp"
0028 #include "Acts/Utilities/Logger.hpp"
0029
0030 #include <cstddef>
0031 #include <memory>
0032 #include <optional>
0033 #include <string>
0034 #include <utility>
0035 #include <vector>
0036
0037 namespace Acts {
0038
0039 using namespace UnitLiterals;
0040
0041 namespace Test {
0042
0043 BOOST_AUTO_TEST_SUITE(Geometry)
0044
0045 BOOST_AUTO_TEST_CASE(KDTreeTrackingGeometryBuilder_simple) {
0046 GeometryContext tContext;
0047 CylindricalTrackingGeometry ctGeometry(tContext);
0048 CylindricalTrackingGeometry::DetectorStore detectorStore;
0049
0050
0051 std::vector<std::shared_ptr<Surface>> layerSurfacePtrs;
0052
0053
0054 auto hTransform = Transform3::Identity();
0055 layerSurfacePtrs.push_back(
0056 Surface::makeShared<CylinderSurface>(hTransform, 15., 800.));
0057
0058
0059 std::vector<ActsScalar> pLayerRadii = {32., 72., 116., 172.};
0060 std::vector<std::pair<int, int>> pLayerBinning = {
0061 {16, 14}, {32, 14}, {52, 14}, {78, 14}};
0062 std::vector<ActsScalar> pModuleTiltPhi = {0.145, 0.145, 0.145, 0.145};
0063 std::vector<ActsScalar> pModuleHalfX = {8.4, 8.4, 8.4, 8.4};
0064 std::vector<ActsScalar> pModuleHalfY = {36., 36., 36., 36.};
0065 std::vector<ActsScalar> pModuleThickness = {0.15, 0.15, 0.15, 0.15};
0066
0067
0068 for (std::size_t ilp = 0; ilp < pLayerRadii.size(); ++ilp) {
0069 std::vector<const Surface*> layerSurfaces = ctGeometry.surfacesCylinder(
0070 detectorStore, pModuleHalfX[ilp], pModuleHalfY[ilp],
0071 pModuleThickness[ilp], pModuleTiltPhi[ilp], pLayerRadii[ilp], 2_mm,
0072 5_mm, pLayerBinning[ilp]);
0073
0074
0075 for (auto& sf : layerSurfaces) {
0076 Surface* mutableSf = const_cast<Surface*>(sf);
0077 layerSurfacePtrs.push_back(mutableSf->getSharedPtr());
0078 }
0079 }
0080
0081
0082 std::vector<ActsScalar> discZ = {-700., -600., 600., 700.};
0083 std::vector<ActsScalar> discRadii = {60., 60., 60., 60.};
0084 std::vector<int> discModules = {22, 22, 22, 22};
0085
0086 std::vector<ActsScalar> dModuleHalfXMinY = {6.4, 6.4, 6.4, 6.4};
0087 std::vector<ActsScalar> dModuleHalfXMaxY = {12.4, 12.4, 12.4, 12.4};
0088 std::vector<ActsScalar> dModuleHalfY = {36., 36., 36., 36.};
0089 std::vector<ActsScalar> dModuleTilt = {0.075, 0.075, 0.075, 0.075};
0090 std::vector<ActsScalar> dModuleThickness = {0.15, 0.15, 0.15, 0.15};
0091
0092 for (std::size_t ilp = 0; ilp < discZ.size(); ++ilp) {
0093 std::vector<const Surface*> layerSurfaces = ctGeometry.surfacesRing(
0094 detectorStore, dModuleHalfXMinY[ilp], dModuleHalfXMaxY[ilp],
0095 dModuleHalfY[ilp], dModuleThickness[ilp], dModuleTilt[ilp],
0096 discRadii[ilp], discZ[ilp], 2., discModules[ilp]);
0097 for (auto& sf : layerSurfaces) {
0098 Surface* mutableSf = const_cast<Surface*>(sf);
0099 layerSurfacePtrs.push_back(mutableSf->getSharedPtr());
0100 }
0101 }
0102
0103
0104 Acts::ProtoVolume beamPipeContainer;
0105 beamPipeContainer.name = "odd-beam-pipe";
0106 beamPipeContainer.extent.set(Acts::binR, 0., 17);
0107 Acts::ProtoVolume beamPipe;
0108 beamPipe.name = "odd-beam-pipe-l";
0109 beamPipe.extent.set(Acts::binR, 2., 16.);
0110 beamPipe.internal = Acts::ProtoVolume::InternalStructure{
0111 Acts::Surface::SurfaceType::Cylinder};
0112 beamPipeContainer.container = Acts::ProtoVolume::ContainerStructure{
0113 {beamPipe}, {Acts::BinningData(Acts::open, Acts::binR, {0., 1.})}, true};
0114
0115
0116 Acts::ProtoVolume pixelContainer;
0117 pixelContainer.name = "odd-pixel";
0118 pixelContainer.extent.set(Acts::binR, 18., 200);
0119
0120 Acts::ProtoVolume pixelNec;
0121 pixelNec.name = "odd-pixel-nec";
0122 pixelNec.extent.set(Acts::binZ, -1000., -580);
0123
0124 Acts::ProtoVolume pixNecD1;
0125 pixNecD1.name = "odd-pixel-nec-d1";
0126 pixNecD1.extent.set(Acts::binZ, -720., -680);
0127 Acts::ProtoVolume pixNecD0;
0128 pixNecD0.name = "odd-pixel-nec-d0";
0129 pixNecD0.extent.set(Acts::binZ, -620., -580);
0130 pixelNec.container = Acts::ProtoVolume::ContainerStructure{
0131 {pixNecD1, pixNecD0},
0132 {Acts::BinningData(Acts::open, Acts::binZ, {0., 1.})},
0133 true};
0134 for (auto& cv : pixelNec.container.value().constituentVolumes) {
0135 cv.internal =
0136 Acts::ProtoVolume::InternalStructure{Acts::Surface::SurfaceType::Disc};
0137 }
0138
0139 Acts::ProtoVolume pixelBarrel;
0140 pixelBarrel.name = "odd-pixel-barrel";
0141 pixelBarrel.extent.set(Acts::binZ, -580., 580);
0142
0143 Acts::ProtoVolume pixBarrelL0;
0144 pixBarrelL0.name = "odd-pixel-barrel-l0";
0145 pixBarrelL0.extent.set(Acts::binR, 28., 48.);
0146 pixBarrelL0.extent.set(Acts::binZ, -580., 580);
0147 pixBarrelL0.internal = Acts::ProtoVolume::InternalStructure{
0148 Acts::Surface::SurfaceType::Cylinder};
0149 Acts::ProtoVolume pixBarrelL1;
0150 pixBarrelL1.name = "odd-pixel-barrel-l1";
0151 pixBarrelL1.extent.set(Acts::binR, 62., 76);
0152 pixBarrelL1.extent.set(Acts::binZ, -580., 580);
0153 pixBarrelL1.internal = Acts::ProtoVolume::InternalStructure{
0154 Acts::Surface::SurfaceType::Cylinder};
0155 Acts::ProtoVolume pixBarrelL2;
0156 pixBarrelL2.name = "odd-pixel-barrel-l2";
0157 pixBarrelL2.extent.set(Acts::binR, 100., 120.);
0158 pixBarrelL2.extent.set(Acts::binZ, -580., 580);
0159 pixBarrelL2.internal = Acts::ProtoVolume::InternalStructure{
0160 Acts::Surface::SurfaceType::Cylinder};
0161 Acts::ProtoVolume pixBarrelL3;
0162 pixBarrelL3.name = "odd-pixel-barrel-l3";
0163 pixBarrelL3.extent.set(Acts::binR, 160., 180.);
0164 pixBarrelL3.extent.set(Acts::binZ, -580., 580);
0165 pixBarrelL3.internal = Acts::ProtoVolume::InternalStructure{
0166 Acts::Surface::SurfaceType::Cylinder};
0167
0168 pixelBarrel.container = Acts::ProtoVolume::ContainerStructure{
0169 {pixBarrelL0, pixBarrelL1, pixBarrelL2, pixBarrelL3},
0170 {Acts::BinningData(Acts::open, Acts::binR, {0., 1})},
0171 true};
0172
0173 Acts::ProtoVolume pixelPec;
0174 pixelPec.name = "odd-pixel-pec";
0175 pixelPec.extent.set(Acts::binZ, 580., 1000.);
0176
0177 Acts::ProtoVolume pixPecD0;
0178 pixPecD0.name = "odd-pixel-pec-d0";
0179 pixPecD0.extent.set(Acts::binZ, 580., 620);
0180 Acts::ProtoVolume pixPecD1;
0181 pixPecD1.name = "odd-pixel-pec-d1";
0182 pixPecD1.extent.set(Acts::binZ, 680., 720);
0183
0184 pixelPec.container = Acts::ProtoVolume::ContainerStructure{
0185 {pixPecD0, pixPecD1},
0186 {Acts::BinningData(Acts::open, Acts::binZ, {0., 1})},
0187 true};
0188 for (auto& cv : pixelPec.container.value().constituentVolumes) {
0189 cv.internal =
0190 Acts::ProtoVolume::InternalStructure{Acts::Surface::SurfaceType::Disc};
0191 }
0192
0193 pixelContainer.container = Acts::ProtoVolume::ContainerStructure{
0194 {pixelNec, pixelBarrel, pixelPec},
0195 {Acts::BinningData(Acts::open, Acts::binZ,
0196 {-1000., -580., 580., 1000.})}};
0197
0198 Acts::ProtoVolume detectorContainer;
0199 detectorContainer.name = "odd-detector";
0200 detectorContainer.extent.set(Acts::binR, 0., 200);
0201 detectorContainer.container = Acts::ProtoVolume::ContainerStructure{
0202 {beamPipeContainer, pixelContainer},
0203 {Acts::BinningData(Acts::open, Acts::binR, {0., 17.5, 200.})}};
0204
0205 Acts::ProtoDetector detector;
0206 detector.name = "odd";
0207 detector.worldVolume = detectorContainer;
0208
0209 auto logLevel = Acts::Logging::VERBOSE;
0210
0211
0212 auto surfaceArrayCreator = std::make_shared<const Acts::SurfaceArrayCreator>(
0213 Acts::SurfaceArrayCreator::Config(),
0214 Acts::getDefaultLogger("SurfaceArrayCreator", logLevel));
0215
0216 Acts::LayerCreator::Config lcConfig;
0217 lcConfig.surfaceArrayCreator = surfaceArrayCreator;
0218 auto layerCreator = std::make_shared<Acts::LayerCreator>(
0219 lcConfig, Acts::getDefaultLogger("LayerCreator", logLevel));
0220
0221 Acts::LayerArrayCreator::Config lacConfig;
0222 auto layerArrayCreator = std::make_shared<const Acts::LayerArrayCreator>(
0223 lacConfig, Acts::getDefaultLogger("LayerArrayCreator", logLevel));
0224
0225 Acts::TrackingVolumeArrayCreator::Config tvacConfig;
0226 auto tVolumeArrayCreator =
0227 std::make_shared<const Acts::TrackingVolumeArrayCreator>(
0228 tvacConfig,
0229 Acts::getDefaultLogger("TrackingVolumeArrayCreator", logLevel));
0230
0231 Acts::CylinderVolumeHelper::Config cvhConfig;
0232 cvhConfig.layerArrayCreator = layerArrayCreator;
0233 cvhConfig.trackingVolumeArrayCreator = tVolumeArrayCreator;
0234 auto cylinderVolumeHelper =
0235 std::make_shared<const Acts::CylinderVolumeHelper>(
0236 cvhConfig, Acts::getDefaultLogger("CylinderVolumeHelper", logLevel));
0237
0238
0239 Acts::KDTreeTrackingGeometryBuilder::Config kdtgConfig;
0240 kdtgConfig.layerCreator = layerCreator;
0241 kdtgConfig.trackingVolumeHelper = cylinderVolumeHelper;
0242
0243 kdtgConfig.surfaces = layerSurfacePtrs;
0244
0245
0246 kdtgConfig.protoDetector = detector;
0247
0248
0249 auto kdtTrackingGeometryBuilder = Acts::KDTreeTrackingGeometryBuilder(
0250 kdtgConfig,
0251 Acts::getDefaultLogger("KDTreeTrackingGeometryBuilder", logLevel));
0252
0253 auto trackingGeometry = kdtTrackingGeometryBuilder.trackingGeometry(tContext);
0254 BOOST_CHECK(trackingGeometry != nullptr);
0255 }
0256
0257 BOOST_AUTO_TEST_SUITE_END()
0258
0259 }
0260 }