Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-04 09:23:52

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/CylinderVolumeBounds.hpp"
0013 #include "Acts/Geometry/CylinderVolumeBuilder.hpp"
0014 #include "Acts/Geometry/CylinderVolumeHelper.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Geometry/LayerArrayCreator.hpp"
0017 #include "Acts/Geometry/LayerCreator.hpp"
0018 #include "Acts/Geometry/PassiveLayerBuilder.hpp"
0019 #include "Acts/Geometry/SurfaceArrayCreator.hpp"
0020 #include "Acts/Geometry/TrackingGeometry.hpp"
0021 #include "Acts/Geometry/TrackingVolumeArrayCreator.hpp"
0022 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0023 #include "Acts/Material/ProtoSurfaceMaterial.hpp"
0024 #include "Acts/Material/SurfaceMaterialMapper.hpp"
0025 #include "Acts/Propagator/Navigator.hpp"
0026 #include "Acts/Propagator/StraightLineStepper.hpp"
0027 #include "Acts/Utilities/BinUtility.hpp"
0028 #include "Acts/Utilities/BinningType.hpp"
0029 #include "Acts/Utilities/Logger.hpp"
0030 
0031 #include <map>
0032 #include <memory>
0033 #include <string>
0034 #include <utility>
0035 #include <vector>
0036 
0037 using namespace Acts;
0038 using namespace Acts::UnitLiterals;
0039 
0040 namespace ActsTests {
0041 
0042 /// @brief create a small tracking geometry to map some dummy material on
0043 std::shared_ptr<const TrackingGeometry> trackingGeometry() {
0044   BinUtility zbinned(8, -40, 40, open, AxisDirection::AxisZ);
0045   auto matProxy = std::make_shared<const ProtoSurfaceMaterial>(zbinned);
0046 
0047   Logging::Level surfaceLLevel = Logging::INFO;
0048   Logging::Level layerLLevel = Logging::INFO;
0049   Logging::Level volumeLLevel = Logging::INFO;
0050 
0051   // configure surface array creator
0052   auto surfaceArrayCreator = std::make_shared<const SurfaceArrayCreator>(
0053       getDefaultLogger("SurfaceArrayCreator", surfaceLLevel));
0054   // configure the layer creator that uses the surface array creator
0055   LayerCreator::Config lcConfig;
0056   lcConfig.surfaceArrayCreator = surfaceArrayCreator;
0057   auto layerCreator = std::make_shared<const LayerCreator>(
0058       lcConfig, getDefaultLogger("LayerCreator", layerLLevel));
0059   // configure the layer array creator
0060   LayerArrayCreator::Config lacConfig;
0061   auto layerArrayCreator = std::make_shared<const LayerArrayCreator>(
0062       lacConfig, getDefaultLogger("LayerArrayCreator", layerLLevel));
0063 
0064   // tracking volume array creator
0065   TrackingVolumeArrayCreator::Config tvacConfig;
0066   auto tVolumeArrayCreator = std::make_shared<const TrackingVolumeArrayCreator>(
0067       tvacConfig, getDefaultLogger("TrackingVolumeArrayCreator", volumeLLevel));
0068   // configure the cylinder volume helper
0069   CylinderVolumeHelper::Config cvhConfig;
0070   cvhConfig.layerArrayCreator = layerArrayCreator;
0071   cvhConfig.trackingVolumeArrayCreator = tVolumeArrayCreator;
0072   auto cylinderVolumeHelper = std::make_shared<const CylinderVolumeHelper>(
0073       cvhConfig, getDefaultLogger("CylinderVolumeHelper", volumeLLevel));
0074 
0075   PassiveLayerBuilder::Config layerBuilderConfig;
0076   layerBuilderConfig.layerIdentification = "CentralBarrel";
0077   layerBuilderConfig.centralLayerRadii = {10., 20., 30.};
0078   layerBuilderConfig.centralLayerHalflengthZ = {40., 40., 40.};
0079   layerBuilderConfig.centralLayerThickness = {1., 1., 1.};
0080   layerBuilderConfig.centralLayerMaterial = {matProxy, matProxy, matProxy};
0081   auto layerBuilder = std::make_shared<const PassiveLayerBuilder>(
0082       layerBuilderConfig,
0083       getDefaultLogger("CentralBarrelBuilder", layerLLevel));
0084   // create the volume for the beam pipe
0085   CylinderVolumeBuilder::Config cvbConfig;
0086   cvbConfig.trackingVolumeHelper = cylinderVolumeHelper;
0087   cvbConfig.volumeName = "BeamPipe";
0088   cvbConfig.layerBuilder = layerBuilder;
0089   cvbConfig.layerEnvelopeR = {1_mm, 1_mm};
0090   cvbConfig.buildToRadiusZero = true;
0091   auto centralVolumeBuilder = std::make_shared<const CylinderVolumeBuilder>(
0092       cvbConfig, getDefaultLogger("CentralVolumeBuilder", volumeLLevel));
0093 
0094   // create the bounds and the volume
0095   auto centralVolumeBounds =
0096       std::make_shared<const CylinderVolumeBounds>(0., 40., 110.);
0097 
0098   GeometryContext gCtx;
0099   auto centralVolume =
0100       centralVolumeBuilder->trackingVolume(gCtx, nullptr, centralVolumeBounds);
0101 
0102   return std::make_shared<const TrackingGeometry>(centralVolume);
0103 }
0104 
0105 std::shared_ptr<const TrackingGeometry> tGeometry = trackingGeometry();
0106 
0107 BOOST_AUTO_TEST_SUITE(MaterialSuite)
0108 
0109 /// Test the filling and conversion
0110 BOOST_AUTO_TEST_CASE(SurfaceMaterialMapper_tests) {
0111   /// We need a Navigator, Stepper to build a Propagator
0112   Navigator navigator({tGeometry});
0113   StraightLineStepper stepper;
0114   SurfaceMaterialMapper::StraightLinePropagator propagator(
0115       stepper, std::move(navigator));
0116 
0117   /// The config object
0118   SurfaceMaterialMapper::Config smmConfig;
0119   SurfaceMaterialMapper smMapper(smmConfig, std::move(propagator));
0120 
0121   /// Create some contexts
0122   GeometryContext gCtx;
0123   MagneticFieldContext mfCtx;
0124 
0125   /// Now create the mapper state
0126   auto mState = smMapper.createState(gCtx, mfCtx, *tGeometry);
0127 
0128   /// Test if this is not null
0129   BOOST_CHECK_EQUAL(mState.accumulatedMaterial.size(), 3u);
0130 }
0131 
0132 BOOST_AUTO_TEST_SUITE_END()
0133 
0134 }  // namespace ActsTests