Back to home page

EIC code displayed by LXR

 
 

    


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

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/Units.hpp"
0012 #include "Acts/Geometry/CylinderVolumeBuilder.hpp"
0013 #include "Acts/Geometry/CylinderVolumeHelper.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/LayerArrayCreator.hpp"
0016 #include "Acts/Geometry/LayerCreator.hpp"
0017 #include "Acts/Geometry/PassiveLayerBuilder.hpp"
0018 #include "Acts/Geometry/SurfaceArrayCreator.hpp"
0019 #include "Acts/Geometry/TrackingGeometry.hpp"
0020 #include "Acts/Geometry/TrackingGeometryBuilder.hpp"
0021 #include "Acts/Geometry/TrackingVolumeArrayCreator.hpp"
0022 #include "Acts/Utilities/Logger.hpp"
0023 
0024 #include <functional>
0025 #include <memory>
0026 #include <string>
0027 #include <utility>
0028 #include <vector>
0029 
0030 using namespace Acts::UnitLiterals;
0031 
0032 namespace Acts::Test {
0033 
0034 // Create a test context
0035 GeometryContext tgContext = GeometryContext();
0036 
0037 /// @brief Unit test for a three layer detector parameters
0038 /// Testing the Tool chain in the geometry building process
0039 ///
0040 BOOST_AUTO_TEST_CASE(SimpleGeometryTest) {
0041   Logging::Level surfaceLLevel = Logging::INFO;
0042   Logging::Level layerLLevel = Logging::INFO;
0043   Logging::Level volumeLLevel = Logging::INFO;
0044 
0045   // configure surface array creator
0046   SurfaceArrayCreator::Config sacConfig;
0047   auto surfaceArrayCreator = std::make_shared<const SurfaceArrayCreator>(
0048       sacConfig, getDefaultLogger("SurfaceArrayCreator", surfaceLLevel));
0049   // configure the layer creator that uses the surface array creator
0050   LayerCreator::Config lcConfig;
0051   lcConfig.surfaceArrayCreator = surfaceArrayCreator;
0052   auto layerCreator = std::make_shared<const LayerCreator>(
0053       lcConfig, getDefaultLogger("LayerCreator", layerLLevel));
0054   // configure the layer array creator
0055   LayerArrayCreator::Config lacConfig;
0056   auto layerArrayCreator = std::make_shared<const LayerArrayCreator>(
0057       lacConfig, getDefaultLogger("LayerArrayCreator", layerLLevel));
0058 
0059   // tracking volume array creator
0060   TrackingVolumeArrayCreator::Config tvacConfig;
0061   auto tVolumeArrayCreator = std::make_shared<const TrackingVolumeArrayCreator>(
0062       tvacConfig, getDefaultLogger("TrackingVolumeArrayCreator", volumeLLevel));
0063   // configure the cylinder volume helper
0064   CylinderVolumeHelper::Config cvhConfig;
0065   cvhConfig.layerArrayCreator = layerArrayCreator;
0066   cvhConfig.trackingVolumeArrayCreator = tVolumeArrayCreator;
0067   auto cylinderVolumeHelper = std::make_shared<const CylinderVolumeHelper>(
0068       cvhConfig, getDefaultLogger("CylinderVolumeHelper", volumeLLevel));
0069 
0070   // ----------------- build a beam pipe -----------------------------------
0071   PassiveLayerBuilder::Config bplConfig;
0072   bplConfig.layerIdentification = "BeamPipe";
0073   bplConfig.centralLayerRadii = std::vector<double>(1, 3_mm);
0074   bplConfig.centralLayerHalflengthZ = std::vector<double>(1, 40_mm);
0075   bplConfig.centralLayerThickness = std::vector<double>(1, 0.8_mm);
0076   auto beamPipeBuilder = std::make_shared<const PassiveLayerBuilder>(
0077       bplConfig, getDefaultLogger("BeamPipeLayerBuilder", layerLLevel));
0078   // create the volume for the beam pipe
0079   CylinderVolumeBuilder::Config bpvConfig;
0080   bpvConfig.trackingVolumeHelper = cylinderVolumeHelper;
0081   bpvConfig.volumeName = "BeamPipe";
0082   bpvConfig.layerBuilder = beamPipeBuilder;
0083   bpvConfig.layerEnvelopeR = {1_mm, 1_mm};
0084   bpvConfig.buildToRadiusZero = true;
0085   auto beamPipeVolumeBuilder = std::make_shared<const CylinderVolumeBuilder>(
0086       bpvConfig, getDefaultLogger("BeamPipeVolumeBuilder", volumeLLevel));
0087 
0088   PassiveLayerBuilder::Config layerBuilderConfig;
0089   layerBuilderConfig.layerIdentification = "CentralBarrel";
0090   layerBuilderConfig.centralLayerRadii = {10_mm, 20_mm, 30_mm};
0091   layerBuilderConfig.centralLayerHalflengthZ = {40_mm, 40_mm, 40_mm};
0092   layerBuilderConfig.centralLayerThickness = {1_mm, 1_mm, 1_mm};
0093   auto layerBuilder = std::make_shared<const PassiveLayerBuilder>(
0094       layerBuilderConfig,
0095       getDefaultLogger("CentralBarrelBuilder", layerLLevel));
0096   // create the volume for the central barrel
0097   CylinderVolumeBuilder::Config cvbConfig;
0098   cvbConfig.trackingVolumeHelper = cylinderVolumeHelper;
0099   cvbConfig.volumeName = "CentralBarrel";
0100   cvbConfig.layerBuilder = layerBuilder;
0101   cvbConfig.layerEnvelopeR = {1_mm, 1_mm};
0102   cvbConfig.buildToRadiusZero = false;
0103   auto centralVolumeBuilder = std::make_shared<const CylinderVolumeBuilder>(
0104       cvbConfig, getDefaultLogger("CentralVolumeBuilder", volumeLLevel));
0105 
0106   // Make the TrackingGeometry Builder
0107   TrackingGeometryBuilder::Config tgbConfig;
0108   tgbConfig.trackingVolumeBuilders.push_back(
0109       [=](const auto& context, const auto& inner, const auto&) {
0110         return beamPipeVolumeBuilder->trackingVolume(context, inner);
0111       });
0112   tgbConfig.trackingVolumeBuilders.push_back(
0113       [=](const auto& context, const auto& inner, const auto&) {
0114         return centralVolumeBuilder->trackingVolume(context, inner);
0115       });
0116   tgbConfig.trackingVolumeHelper = cylinderVolumeHelper;
0117 
0118   TrackingGeometryBuilder tgBuilder(tgbConfig);
0119   auto tGeometry = tgBuilder.trackingGeometry(tgContext);
0120 
0121   BOOST_CHECK(tGeometry != nullptr);
0122 }
0123 }  // namespace Acts::Test