Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:38

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Detector/ProtoDetector.hpp"
0014 #include "Acts/Geometry/CylinderVolumeHelper.hpp"
0015 #include "Acts/Geometry/Extent.hpp"
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/Geometry/KDTreeTrackingGeometryBuilder.hpp"
0018 #include "Acts/Geometry/LayerArrayCreator.hpp"
0019 #include "Acts/Geometry/LayerCreator.hpp"
0020 #include "Acts/Geometry/SurfaceArrayCreator.hpp"
0021 #include "Acts/Geometry/TrackingVolumeArrayCreator.hpp"
0022 #include "Acts/Surfaces/CylinderSurface.hpp"
0023 #include "Acts/Surfaces/Surface.hpp"
0024 #include "Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp"
0025 #include "Acts/Utilities/BinningData.hpp"
0026 #include "Acts/Utilities/BinningType.hpp"
0027 #include "Acts/Utilities/Logger.hpp"
0028 
0029 #include <cstddef>
0030 #include <memory>
0031 #include <optional>
0032 #include <string>
0033 #include <utility>
0034 #include <vector>
0035 
0036 using namespace Acts::UnitLiterals;
0037 
0038 namespace Acts::Test {
0039 
0040 BOOST_AUTO_TEST_SUITE(Geometry)
0041 
0042 BOOST_AUTO_TEST_CASE(KDTreeTrackingGeometryBuilder_simple) {
0043   GeometryContext tContext;
0044   CylindricalTrackingGeometry ctGeometry(tContext);
0045   CylindricalTrackingGeometry::DetectorStore detectorStore;
0046 
0047   // The collected surfaces
0048   std::vector<std::shared_ptr<Surface>> layerSurfacePtrs;
0049 
0050   // Add a beam pipe
0051   auto hTransform = Transform3::Identity();
0052   layerSurfacePtrs.push_back(
0053       Surface::makeShared<CylinderSurface>(hTransform, 15., 800.));
0054 
0055   // Pixel Surfaces
0056   std::vector<double> pLayerRadii = {32., 72., 116., 172.};
0057   std::vector<std::pair<int, int>> pLayerBinning = {
0058       {16, 14}, {32, 14}, {52, 14}, {78, 14}};
0059   std::vector<double> pModuleTiltPhi = {0.145, 0.145, 0.145, 0.145};
0060   std::vector<double> pModuleHalfX = {8.4, 8.4, 8.4, 8.4};
0061   std::vector<double> pModuleHalfY = {36., 36., 36., 36.};
0062   std::vector<double> pModuleThickness = {0.15, 0.15, 0.15, 0.15};
0063 
0064   // Fill surfaces from cylinder layers
0065   for (std::size_t ilp = 0; ilp < pLayerRadii.size(); ++ilp) {
0066     std::vector<const Surface*> layerSurfaces = ctGeometry.surfacesCylinder(
0067         detectorStore, pModuleHalfX[ilp], pModuleHalfY[ilp],
0068         pModuleThickness[ilp], pModuleTiltPhi[ilp], pLayerRadii[ilp], 2_mm,
0069         5_mm, pLayerBinning[ilp]);
0070 
0071     // Make a shared version out of it
0072     for (auto& sf : layerSurfaces) {
0073       Surface* mutableSf = const_cast<Surface*>(sf);
0074       layerSurfacePtrs.push_back(mutableSf->getSharedPtr());
0075     }
0076   }
0077 
0078   // Fill surfaces for disc layers
0079   std::vector<double> discZ = {-700., -600., 600., 700.};
0080   std::vector<double> discRadii = {60., 60., 60., 60.};
0081   std::vector<int> discModules = {22, 22, 22, 22};
0082 
0083   std::vector<double> dModuleHalfXMinY = {6.4, 6.4, 6.4, 6.4};
0084   std::vector<double> dModuleHalfXMaxY = {12.4, 12.4, 12.4, 12.4};
0085   std::vector<double> dModuleHalfY = {36., 36., 36., 36.};
0086   std::vector<double> dModuleTilt = {0.075, 0.075, 0.075, 0.075};
0087   std::vector<double> dModuleThickness = {0.15, 0.15, 0.15, 0.15};
0088 
0089   for (std::size_t ilp = 0; ilp < discZ.size(); ++ilp) {
0090     std::vector<const Surface*> layerSurfaces = ctGeometry.surfacesRing(
0091         detectorStore, dModuleHalfXMinY[ilp], dModuleHalfXMaxY[ilp],
0092         dModuleHalfY[ilp], dModuleThickness[ilp], dModuleTilt[ilp],
0093         discRadii[ilp], discZ[ilp], 2., discModules[ilp]);
0094     for (auto& sf : layerSurfaces) {
0095       Surface* mutableSf = const_cast<Surface*>(sf);
0096       layerSurfacePtrs.push_back(mutableSf->getSharedPtr());
0097     }
0098   }
0099 
0100   // Make a proto detectpr description
0101   Acts::ProtoVolume beamPipeContainer;
0102   beamPipeContainer.name = "odd-beam-pipe";
0103   beamPipeContainer.extent.set(Acts::AxisDirection::AxisR, 0., 17);
0104   Acts::ProtoVolume beamPipe;
0105   beamPipe.name = "odd-beam-pipe-l";
0106   beamPipe.extent.set(Acts::AxisDirection::AxisR, 2., 16.);
0107   beamPipe.internal = Acts::ProtoVolume::InternalStructure{
0108       Acts::Surface::SurfaceType::Cylinder};
0109   beamPipeContainer.container = Acts::ProtoVolume::ContainerStructure{
0110       {beamPipe},
0111       {Acts::BinningData(Acts::open, Acts::AxisDirection::AxisR, {0., 1.})},
0112       true};
0113 
0114   // Pixel section
0115   Acts::ProtoVolume pixelContainer;
0116   pixelContainer.name = "odd-pixel";
0117   pixelContainer.extent.set(Acts::AxisDirection::AxisR, 18., 200);
0118 
0119   Acts::ProtoVolume pixelNec;
0120   pixelNec.name = "odd-pixel-nec";
0121   pixelNec.extent.set(Acts::AxisDirection::AxisZ, -1000., -580);
0122 
0123   Acts::ProtoVolume pixNecD1;
0124   pixNecD1.name = "odd-pixel-nec-d1";
0125   pixNecD1.extent.set(Acts::AxisDirection::AxisZ, -720., -680);
0126   Acts::ProtoVolume pixNecD0;
0127   pixNecD0.name = "odd-pixel-nec-d0";
0128   pixNecD0.extent.set(Acts::AxisDirection::AxisZ, -620., -580);
0129   pixelNec.container = Acts::ProtoVolume::ContainerStructure{
0130       {pixNecD1, pixNecD0},
0131       {Acts::BinningData(Acts::open, Acts::AxisDirection::AxisZ, {0., 1.})},
0132       true};
0133   for (auto& cv : pixelNec.container.value().constituentVolumes) {
0134     cv.internal =
0135         Acts::ProtoVolume::InternalStructure{Acts::Surface::SurfaceType::Disc};
0136   }
0137 
0138   Acts::ProtoVolume pixelBarrel;
0139   pixelBarrel.name = "odd-pixel-barrel";
0140   pixelBarrel.extent.set(Acts::AxisDirection::AxisZ, -580., 580);
0141 
0142   Acts::ProtoVolume pixBarrelL0;
0143   pixBarrelL0.name = "odd-pixel-barrel-l0";
0144   pixBarrelL0.extent.set(Acts::AxisDirection::AxisR, 28., 48.);
0145   pixBarrelL0.extent.set(Acts::AxisDirection::AxisZ, -580., 580);
0146   pixBarrelL0.internal = Acts::ProtoVolume::InternalStructure{
0147       Acts::Surface::SurfaceType::Cylinder};
0148   Acts::ProtoVolume pixBarrelL1;
0149   pixBarrelL1.name = "odd-pixel-barrel-l1";
0150   pixBarrelL1.extent.set(Acts::AxisDirection::AxisR, 62., 76);
0151   pixBarrelL1.extent.set(Acts::AxisDirection::AxisZ, -580., 580);
0152   pixBarrelL1.internal = Acts::ProtoVolume::InternalStructure{
0153       Acts::Surface::SurfaceType::Cylinder};
0154   Acts::ProtoVolume pixBarrelL2;
0155   pixBarrelL2.name = "odd-pixel-barrel-l2";
0156   pixBarrelL2.extent.set(Acts::AxisDirection::AxisR, 100., 120.);
0157   pixBarrelL2.extent.set(Acts::AxisDirection::AxisZ, -580., 580);
0158   pixBarrelL2.internal = Acts::ProtoVolume::InternalStructure{
0159       Acts::Surface::SurfaceType::Cylinder};
0160   Acts::ProtoVolume pixBarrelL3;
0161   pixBarrelL3.name = "odd-pixel-barrel-l3";
0162   pixBarrelL3.extent.set(Acts::AxisDirection::AxisR, 160., 180.);
0163   pixBarrelL3.extent.set(Acts::AxisDirection::AxisZ, -580., 580);
0164   pixBarrelL3.internal = Acts::ProtoVolume::InternalStructure{
0165       Acts::Surface::SurfaceType::Cylinder};
0166 
0167   pixelBarrel.container = Acts::ProtoVolume::ContainerStructure{
0168       {pixBarrelL0, pixBarrelL1, pixBarrelL2, pixBarrelL3},
0169       {Acts::BinningData(Acts::open, Acts::AxisDirection::AxisR, {0., 1})},
0170       true};
0171 
0172   Acts::ProtoVolume pixelPec;
0173   pixelPec.name = "odd-pixel-pec";
0174   pixelPec.extent.set(Acts::AxisDirection::AxisZ, 580., 1000.);
0175 
0176   Acts::ProtoVolume pixPecD0;
0177   pixPecD0.name = "odd-pixel-pec-d0";
0178   pixPecD0.extent.set(Acts::AxisDirection::AxisZ, 580., 620);
0179   Acts::ProtoVolume pixPecD1;
0180   pixPecD1.name = "odd-pixel-pec-d1";
0181   pixPecD1.extent.set(Acts::AxisDirection::AxisZ, 680., 720);
0182 
0183   pixelPec.container = Acts::ProtoVolume::ContainerStructure{
0184       {pixPecD0, pixPecD1},
0185       {Acts::BinningData(Acts::open, Acts::AxisDirection::AxisZ, {0., 1})},
0186       true};
0187   for (auto& cv : pixelPec.container.value().constituentVolumes) {
0188     cv.internal =
0189         Acts::ProtoVolume::InternalStructure{Acts::Surface::SurfaceType::Disc};
0190   }
0191 
0192   pixelContainer.container = Acts::ProtoVolume::ContainerStructure{
0193       {pixelNec, pixelBarrel, pixelPec},
0194       {Acts::BinningData(Acts::open, Acts::AxisDirection::AxisZ,
0195                          {-1000., -580., 580., 1000.})}};
0196 
0197   Acts::ProtoVolume detectorContainer;
0198   detectorContainer.name = "odd-detector";
0199   detectorContainer.extent.set(Acts::AxisDirection::AxisR, 0., 200);
0200   detectorContainer.container = Acts::ProtoVolume::ContainerStructure{
0201       {beamPipeContainer, pixelContainer},
0202       {Acts::BinningData(Acts::open, Acts::AxisDirection::AxisR,
0203                          {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   // Surface array creator
0212   auto surfaceArrayCreator = std::make_shared<const Acts::SurfaceArrayCreator>(
0213       Acts::SurfaceArrayCreator::Config(),
0214       Acts::getDefaultLogger("SurfaceArrayCreator", logLevel));
0215   // Layer Creator
0216   Acts::LayerCreator::Config lcConfig;
0217   lcConfig.surfaceArrayCreator = surfaceArrayCreator;
0218   auto layerCreator = std::make_shared<Acts::LayerCreator>(
0219       lcConfig, Acts::getDefaultLogger("LayerCreator", logLevel));
0220   // Layer array creator
0221   Acts::LayerArrayCreator::Config lacConfig;
0222   auto layerArrayCreator = std::make_shared<const Acts::LayerArrayCreator>(
0223       lacConfig, Acts::getDefaultLogger("LayerArrayCreator", logLevel));
0224   // Tracking volume array creator
0225   Acts::TrackingVolumeArrayCreator::Config tvacConfig;
0226   auto tVolumeArrayCreator =
0227       std::make_shared<const Acts::TrackingVolumeArrayCreator>(
0228           tvacConfig,
0229           Acts::getDefaultLogger("TrackingVolumeArrayCreator", logLevel));
0230   // configure the cylinder volume helper
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   // The KDT tracking geometry builder
0239   Acts::KDTreeTrackingGeometryBuilder::Config kdtgConfig;
0240   kdtgConfig.layerCreator = layerCreator;
0241   kdtgConfig.trackingVolumeHelper = cylinderVolumeHelper;
0242   // Reserve the right amount of surfaces
0243   kdtgConfig.surfaces = layerSurfacePtrs;
0244 
0245   // Assign the proto detector
0246   kdtgConfig.protoDetector = detector;
0247 
0248   // Make the builder
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 }  // namespace Acts::Test