Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:14:33

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/Detector/DetectorVolume.hpp"
0013 #include "Acts/Detector/PortalGenerators.hpp"
0014 #include "Acts/Detector/detail/CylindricalDetectorHelper.hpp"
0015 #include "Acts/Geometry/CylinderLayer.hpp"
0016 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0017 #include "Acts/Geometry/GeometryContext.hpp"
0018 #include "Acts/Geometry/GeometryIdentifier.hpp"
0019 #include "Acts/Geometry/LayerArrayCreator.hpp"
0020 #include "Acts/Geometry/TrackingGeometry.hpp"
0021 #include "Acts/Geometry/TrackingVolume.hpp"
0022 #include "Acts/Geometry/TrackingVolumeArrayCreator.hpp"
0023 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0024 #include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
0025 #include "Acts/Material/HomogeneousVolumeMaterial.hpp"
0026 #include "Acts/Material/Material.hpp"
0027 #include "Acts/Material/PropagatorMaterialAssigner.hpp"
0028 #include "Acts/Navigation/DetectorNavigator.hpp"
0029 #include "Acts/Navigation/DetectorVolumeFinders.hpp"
0030 #include "Acts/Navigation/InternalNavigation.hpp"
0031 #include "Acts/Propagator/Navigator.hpp"
0032 #include "Acts/Propagator/StraightLineStepper.hpp"
0033 #include "Acts/Surfaces/CylinderSurface.hpp"
0034 #include "Acts/Surfaces/SurfaceArray.hpp"
0035 
0036 namespace Acts::Test {
0037 
0038 auto tContext = GeometryContext();
0039 auto mContext = MagneticFieldContext();
0040 
0041 double rMin = 0.;
0042 double rMid = 25.;
0043 double rMax = 110.;
0044 
0045 auto vCylinderOuter = std::make_shared<CylinderVolumeBounds>(rMid, rMax, 110.);
0046 
0047 auto pCylinder = std::make_shared<const CylinderBounds>(20., 100.);
0048 
0049 auto surfaceMaterial = std::make_shared<HomogeneousSurfaceMaterial>();
0050 
0051 Material mat = Material::fromMolarDensity(1., 2., 3., 4., 5.);
0052 auto volumeMaterial = std::make_shared<HomogeneousVolumeMaterial>(mat);
0053 
0054 BOOST_AUTO_TEST_SUITE(PropagatorMaterialAssignerTestSuite)
0055 
0056 /// Test with TrackingGeometry
0057 BOOST_AUTO_TEST_CASE(FindSurfaceIntersectionsTrackingGeometry) {
0058   auto vCylinderInner =
0059       std::make_shared<CylinderVolumeBounds>(rMin, rMid, 110.);
0060 
0061   // Create a tracking geometry with  one material layer and one material volume
0062   auto pCylinderLayer =
0063       CylinderLayer::create(Transform3::Identity(), pCylinder, nullptr, 1.);
0064   pCylinderLayer->surfaceRepresentation().assignSurfaceMaterial(
0065       surfaceMaterial);
0066 
0067   LayerArrayCreator::Config lacConfig;
0068   LayerArrayCreator lac = LayerArrayCreator(lacConfig);
0069   auto layers = lac.layerArray(tContext, {pCylinderLayer}, rMin, rMid,
0070                                arbitrary, AxisDirection::AxisR);
0071 
0072   auto innerVolume = std::make_shared<TrackingVolume>(
0073       Transform3::Identity(), vCylinderInner, nullptr, std::move(layers),
0074       nullptr, MutableTrackingVolumeVector{}, "InnerVolumeWithLayers");
0075 
0076   auto outerVolume = std::make_shared<TrackingVolume>(
0077       Transform3::Identity(), vCylinderOuter, volumeMaterial, nullptr, nullptr,
0078       MutableTrackingVolumeVector{}, "OuterVolume");
0079   innerVolume->glueTrackingVolume(tContext, tubeOuterCover, outerVolume.get(),
0080                                   tubeInnerCover);
0081 
0082   TrackingVolumeArrayCreator::Config tvacConfig;
0083   TrackingVolumeArrayCreator tvac = TrackingVolumeArrayCreator(tvacConfig);
0084 
0085   auto volumes = tvac.trackingVolumeArray(tContext, {innerVolume, outerVolume},
0086                                           AxisDirection::AxisR);
0087 
0088   auto vCylinderTop = std::make_shared<CylinderVolumeBounds>(rMin, rMax, 110.);
0089 
0090   auto topVolume = std::make_shared<TrackingVolume>(
0091       Transform3::Identity(), vCylinderTop, nullptr, nullptr, volumes,
0092       MutableTrackingVolumeVector{}, "TopVolume");
0093 
0094   auto tGeometry = std::make_shared<TrackingGeometry>(topVolume);
0095 
0096   // Create a navigator and a propagator
0097   Navigator::Config navConfig{tGeometry};
0098   Navigator navigator(navConfig);
0099 
0100   using StraightLinePropagator = Propagator<StraightLineStepper, Navigator>;
0101 
0102   StraightLineStepper stepper;
0103   StraightLinePropagator propagator(stepper, navigator);
0104 
0105   using PropagationMaterialAssigner =
0106       PropagatorMaterialAssigner<StraightLinePropagator>;
0107 
0108   PropagationMaterialAssigner pmAssigner(propagator);
0109   auto [surfaceCandides, volumeCandidates] = pmAssigner.assignmentCandidates(
0110       tContext, mContext, Vector3(0, 0, 0), Vector3(1, 1, 0).normalized());
0111 
0112   BOOST_CHECK_EQUAL(surfaceCandides.size(), 1u);
0113   BOOST_CHECK_EQUAL(volumeCandidates.size(), 1u);
0114 }
0115 
0116 // Test with Detector
0117 BOOST_AUTO_TEST_CASE(FindSurfaceIntersectionsTrackingVolume) {
0118   unsigned int volID = 1;
0119   auto assignGeoIds = [&volID](Experimental::DetectorVolume& dVol) -> void {
0120     dVol.assignGeometryId(GeometryIdentifier().withVolume(volID));
0121     unsigned int pID = 1;
0122     for (auto& p : dVol.portalPtrs()) {
0123       p->surface().assignGeometryId(
0124           GeometryIdentifier().withVolume(volID).withBoundary(pID));
0125     }
0126     volID++;
0127   };
0128 
0129   auto portalGenerator = Experimental::defaultPortalGenerator();
0130 
0131   double rInnerL0 = 19;
0132   double rOuterL0 = 21;
0133 
0134   Transform3 nominal = Transform3::Identity();
0135 
0136   auto vCylinderGap0 =
0137       std::make_shared<CylinderVolumeBounds>(rMin, rInnerL0, 110.);
0138 
0139   auto vCylinderL0 =
0140       std::make_shared<CylinderVolumeBounds>(rInnerL0, rOuterL0, 110.);
0141 
0142   auto vCylinderGap1 =
0143       std::make_shared<CylinderVolumeBounds>(rOuterL0, rMid, 110.);
0144 
0145   auto gap0 = Experimental::DetectorVolumeFactory::construct(
0146       portalGenerator, tContext, "Gap0", nominal, std::move(vCylinderGap0),
0147       Experimental::tryAllPortals());
0148   assignGeoIds(*gap0);
0149 
0150   auto pCylinderSurface =
0151       Surface::makeShared<CylinderSurface>(Transform3::Identity(), pCylinder);
0152   pCylinderSurface->assignSurfaceMaterial(surfaceMaterial);
0153   pCylinderSurface->assignGeometryId(GeometryIdentifier().withSensitive(1));
0154 
0155   auto layer0 = Experimental::DetectorVolumeFactory::construct(
0156       portalGenerator, tContext, "Layer0", nominal, std::move(vCylinderL0),
0157       {pCylinderSurface}, {}, Experimental::tryNoVolumes(),
0158       Experimental::tryAllPortalsAndSurfaces());
0159   assignGeoIds(*layer0);
0160 
0161   auto gap1 = Experimental::DetectorVolumeFactory::construct(
0162       portalGenerator, tContext, "Gap1", nominal, std::move(vCylinderGap1),
0163       Experimental::tryAllPortals());
0164   assignGeoIds(*gap1);
0165 
0166   auto outerVolume = Experimental::DetectorVolumeFactory::construct(
0167       portalGenerator, tContext, "OuterVolume", nominal, vCylinderOuter,
0168       Experimental::tryAllPortals());
0169   outerVolume->assignVolumeMaterial(volumeMaterial);
0170   assignGeoIds(*outerVolume);
0171 
0172   std::vector<std::shared_ptr<Experimental::DetectorVolume>> volumes = {
0173       gap0, layer0, gap1, outerVolume};
0174 
0175   auto pc = Experimental::detail::CylindricalDetectorHelper::connectInR(
0176       tContext, volumes);
0177 
0178   auto detector = Acts::Experimental::Detector::makeShared(
0179       "Detector", volumes, Acts::Experimental::tryRootVolumes());
0180 
0181   // Create a navigator and a propagator
0182   Experimental::DetectorNavigator::Config navConfig{detector.get()};
0183   Experimental::DetectorNavigator navigator(navConfig);
0184 
0185   using StraightLinePropagator =
0186       Propagator<StraightLineStepper, Experimental::DetectorNavigator>;
0187 
0188   StraightLineStepper stepper;
0189   StraightLinePropagator propagator(stepper, navigator);
0190 
0191   using PropagationMaterialAssigner =
0192       PropagatorMaterialAssigner<StraightLinePropagator>;
0193 
0194   PropagationMaterialAssigner pmAssigner(propagator);
0195   auto [surfaceCandides, volumeCandidates] = pmAssigner.assignmentCandidates(
0196       tContext, mContext, Vector3(0, 0, 0), Vector3(1, 1, 0).normalized());
0197 
0198   BOOST_CHECK_EQUAL(surfaceCandides.size(), 1u);
0199   BOOST_CHECK_EQUAL(volumeCandidates.size(), 1u);
0200 }
0201 
0202 BOOST_AUTO_TEST_SUITE_END()
0203 
0204 }  // namespace Acts::Test