Back to home page

EIC code displayed by LXR

 
 

    


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

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/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Geometry/CuboidVolumeBuilder.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Geometry/TrackingGeometryBuilder.hpp"
0015 #include "Acts/MagneticField/ConstantBField.hpp"
0016 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0017 #include "Acts/Material/HomogeneousVolumeMaterial.hpp"
0018 #include "Acts/Propagator/EigenStepper.hpp"
0019 #include "Acts/Propagator/EigenStepperDenseExtension.hpp"
0020 #include "Acts/Propagator/Navigator.hpp"
0021 #include "Acts/Propagator/Propagator.hpp"
0022 #include "Acts/Propagator/RiddersPropagator.hpp"
0023 #include "Acts/Tests/CommonHelpers/PredefinedMaterials.hpp"
0024 #include "Acts/Utilities/Logger.hpp"
0025 
0026 #include <limits>
0027 
0028 #include "PropagationDatasets.hpp"
0029 #include "PropagationTests.hpp"
0030 
0031 namespace {
0032 
0033 namespace ds = ActsTests::PropagationDatasets;
0034 using namespace Acts::UnitLiterals;
0035 
0036 using MagneticField = Acts::ConstantBField;
0037 using Stepper = Acts::EigenStepper<Acts::EigenStepperDenseExtension>;
0038 using Propagator = Acts::Propagator<Stepper, Acts::Navigator>;
0039 using RiddersPropagator = Acts::RiddersPropagator<Propagator>;
0040 
0041 // absolute parameter tolerances for position, direction, and absolute momentum
0042 constexpr auto epsPos = 10_um;
0043 constexpr auto epsDir = 1_mrad;
0044 constexpr auto epsMom = 5_MeV;
0045 // relative covariance tolerance
0046 constexpr auto epsCov = 0.07;
0047 
0048 const Acts::GeometryContext geoCtx;
0049 const Acts::MagneticFieldContext magCtx;
0050 
0051 inline std::shared_ptr<const Acts::TrackingGeometry> makeDetector() {
0052   using namespace Acts;
0053 
0054   // avoid rebuilding the tracking geometry for every propagator
0055   static std::shared_ptr<const Acts::TrackingGeometry> detector;
0056   if (!detector) {
0057     CuboidVolumeBuilder::VolumeConfig vConf;
0058     vConf.position = {0., 0., 0.};
0059     vConf.length = {4_m, 4_m, 4_m};
0060     vConf.volumeMaterial = std::make_shared<const HomogeneousVolumeMaterial>(
0061         Acts::Test::makeBeryllium());
0062     CuboidVolumeBuilder::Config conf;
0063     conf.volumeCfg.push_back(vConf);
0064     conf.position = {0., 0., 0.};
0065     conf.length = {4_m, 4_m, 4_m};
0066     CuboidVolumeBuilder cvb(conf);
0067     TrackingGeometryBuilder::Config tgbCfg;
0068     tgbCfg.trackingVolumeBuilders.push_back(
0069         [=](const auto& context, const auto& inner, const auto&) {
0070           return cvb.trackingVolume(context, inner, nullptr);
0071         });
0072     detector = TrackingGeometryBuilder(tgbCfg).trackingGeometry(geoCtx);
0073   }
0074 
0075   return detector;
0076 }
0077 
0078 inline Propagator makePropagator(double bz) {
0079   using namespace Acts;
0080 
0081   auto magField = std::make_shared<MagneticField>(Acts::Vector3(0.0, 0.0, bz));
0082   Stepper stepper(std::move(magField));
0083   auto logger = getDefaultLogger("Nominal", Logging::INFO);
0084   return Propagator(
0085       std::move(stepper),
0086       Acts::Navigator{{makeDetector()}, logger->cloneWithSuffix("Nav")},
0087       logger->cloneWithSuffix("Prop"));
0088 }
0089 
0090 inline RiddersPropagator makeRiddersPropagator(double bz) {
0091   using namespace Acts;
0092 
0093   auto magField = std::make_shared<MagneticField>(Acts::Vector3(0.0, 0.0, bz));
0094   Stepper stepper(std::move(magField));
0095   auto logger = getDefaultLogger("Ridder", Logging::INFO);
0096   auto propagator = Propagator(
0097       std::move(stepper),
0098       Acts::Navigator{{makeDetector()}, logger->cloneWithSuffix("Nav")},
0099       logger->cloneWithSuffix("Prop"));
0100   return RiddersPropagator(std::move(propagator));
0101 }
0102 
0103 }  // namespace
0104 
0105 BOOST_AUTO_TEST_SUITE(PropagationDenseConstant)
0106 
0107 // check that the propagation is reversible and self-consistent
0108 
0109 // TODO does not seem to work as-is
0110 BOOST_DATA_TEST_CASE(ForwardBackward,
0111                      ds::phi* ds::theta* ds::absMomentum* ds::chargeNonZero*
0112                          ds::pathLength* ds::magneticField,
0113                      phi, theta, p, q, s, bz) {
0114   runForwardBackwardTest<Propagator>(
0115       makePropagator(bz), geoCtx, magCtx,
0116       makeParametersCurvilinear(phi, theta, p, q), s, epsPos, epsDir, epsMom);
0117 }
0118 
0119 // check that reachable surfaces are correctly reached
0120 
0121 // True forward/backward tracks do not work with z cylinders
0122 BOOST_DATA_TEST_CASE(ToCylinderAlongZ,
0123                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0124                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0125                      phi, theta, p, q, s, bz) {
0126   runToSurfaceTest<Propagator, ZCylinderSurfaceBuilder>(
0127       makePropagator(bz), geoCtx, magCtx,
0128       makeParametersCurvilinear(phi, theta, p, q), s, ZCylinderSurfaceBuilder(),
0129       epsPos, epsDir, epsMom);
0130 }
0131 
0132 BOOST_DATA_TEST_CASE(ToDisc,
0133                      ds::phi* ds::theta* ds::absMomentum* ds::chargeNonZero*
0134                          ds::pathLength* ds::magneticField,
0135                      phi, theta, p, q, s, bz) {
0136   runToSurfaceTest<Propagator, DiscSurfaceBuilder>(
0137       makePropagator(bz), geoCtx, magCtx,
0138       makeParametersCurvilinear(phi, theta, p, q), s, DiscSurfaceBuilder(),
0139       epsPos, epsDir, epsMom);
0140 }
0141 
0142 BOOST_DATA_TEST_CASE(ToPlane,
0143                      ds::phi* ds::theta* ds::absMomentum* ds::chargeNonZero*
0144                          ds::pathLength* ds::magneticField,
0145                      phi, theta, p, q, s, bz) {
0146   runToSurfaceTest<Propagator, PlaneSurfaceBuilder>(
0147       makePropagator(bz), geoCtx, magCtx,
0148       makeParametersCurvilinear(phi, theta, p, q), s, PlaneSurfaceBuilder(),
0149       epsPos, epsDir, epsMom);
0150 }
0151 
0152 // True forward/backward tracks do not work with z straws
0153 BOOST_DATA_TEST_CASE(ToStrawAlongZ,
0154                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0155                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0156                      phi, theta, p, q, s, bz) {
0157   runToSurfaceTest<Propagator, ZStrawSurfaceBuilder>(
0158       makePropagator(bz), geoCtx, magCtx,
0159       makeParametersCurvilinear(phi, theta, p, q), s, ZStrawSurfaceBuilder(),
0160       epsPos, epsDir, epsMom);
0161 }
0162 
0163 // check covariance transport using the ridders propagator for comparison
0164 // Covariance transport does not work for theta close to poles
0165 BOOST_DATA_TEST_CASE(CovarianceCurvilinear,
0166                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0167                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0168                      phi, theta, p, q, s, bz) {
0169   runForwardComparisonTest<Propagator, RiddersPropagator>(
0170       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0171       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s, epsPos,
0172       epsDir, epsMom, epsCov);
0173 }
0174 
0175 // limit theta to ignore the covariance mismatches at high theta for now
0176 BOOST_DATA_TEST_CASE(CovarianceToCylinderAlongZ,
0177                      ds::phiWithoutAmbiguity* ds::thetaCentral* ds::absMomentum*
0178                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0179                      phi, theta, p, q, s, bz) {
0180   runToSurfaceComparisonTest<Propagator, RiddersPropagator,
0181                              ZCylinderSurfaceBuilder>(
0182       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0183       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0184       ZCylinderSurfaceBuilder(), epsPos, epsDir, epsMom, epsCov);
0185 }
0186 
0187 BOOST_DATA_TEST_CASE(CovarianceToDisc,
0188                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0189                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0190                      phi, theta, p, q, s, bz) {
0191   runToSurfaceComparisonTest<Propagator, RiddersPropagator, DiscSurfaceBuilder>(
0192       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0193       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0194       DiscSurfaceBuilder(), epsPos, epsDir, epsMom, epsCov);
0195 }
0196 
0197 // Covariance transport does not work for theta close to poles
0198 BOOST_DATA_TEST_CASE(CovarianceToPlane,
0199                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0200                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0201                      phi, theta, p, q, s, bz) {
0202   runToSurfaceComparisonTest<Propagator, RiddersPropagator,
0203                              PlaneSurfaceBuilder>(
0204       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0205       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0206       PlaneSurfaceBuilder(), epsPos, epsDir, epsMom, epsCov);
0207 }
0208 
0209 // limit theta to ignore the covariance mismatches at high theta for now
0210 BOOST_DATA_TEST_CASE(CovarianceToStrawAlongZ,
0211                      ds::phiWithoutAmbiguity* ds::thetaCentral* ds::absMomentum*
0212                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0213                      phi, theta, p, q, s, bz) {
0214   runToSurfaceComparisonTest<Propagator, RiddersPropagator,
0215                              ZStrawSurfaceBuilder>(
0216       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0217       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0218       ZStrawSurfaceBuilder(), epsPos, epsDir, epsMom, epsCov);
0219 }
0220 
0221 BOOST_AUTO_TEST_SUITE_END()