Back to home page

EIC code displayed by LXR

 
 

    


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

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