File indexing completed on 2025-08-05 08:10:22
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Definitions/Units.hpp"
0010 #include "Acts/EventData/ParticleHypothesis.hpp"
0011 #include "Acts/EventData/TrackParameters.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/MagneticField/ConstantBField.hpp"
0014 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0015 #include "Acts/Propagator/AtlasStepper.hpp"
0016 #include "Acts/Propagator/Propagator.hpp"
0017 #include "Acts/Tests/CommonHelpers/BenchmarkTools.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019
0020 #include <iostream>
0021
0022 #include <boost/program_options.hpp>
0023
0024 namespace po = boost::program_options;
0025 using namespace Acts;
0026 using namespace Acts::UnitLiterals;
0027
0028 int main(int argc, char* argv[]) {
0029 unsigned int toys = 1;
0030 double ptInGeV = 1;
0031 double BzInT = 1;
0032 double maxPathInM = 1;
0033 unsigned int lvl = Acts::Logging::INFO;
0034 bool withCov = true;
0035
0036
0037 GeometryContext tgContext = GeometryContext();
0038 MagneticFieldContext mfContext = MagneticFieldContext();
0039
0040 try {
0041 po::options_description desc("Allowed options");
0042
0043 desc.add_options()
0044 ("help", "produce help message")
0045 ("toys",po::value<unsigned int>(&toys)->default_value(20000),"number of tracks to propagate")
0046 ("pT",po::value<double>(&ptInGeV)->default_value(1),"transverse momentum in GeV")
0047 ("B",po::value<double>(&BzInT)->default_value(2),"z-component of B-field in T")
0048 ("path",po::value<double>(&maxPathInM)->default_value(5),"maximum path length in m")
0049 ("cov",po::value<bool>(&withCov)->default_value(true),"propagation with covariance matrix")
0050 ("verbose",po::value<unsigned int>(&lvl)->default_value(Acts::Logging::INFO),"logging level");
0051
0052 po::variables_map vm;
0053 po::store(po::parse_command_line(argc, argv, desc), vm);
0054 po::notify(vm);
0055
0056 if (vm.count("help") != 0u) {
0057 std::cout << desc << std::endl;
0058 return 0;
0059 }
0060 } catch (std::exception& e) {
0061 std::cerr << "error: " << e.what() << std::endl;
0062 return 1;
0063 }
0064
0065 ACTS_LOCAL_LOGGER(
0066 getDefaultLogger("ATLAS_Stepper", Acts::Logging::Level(lvl)));
0067
0068
0069 ACTS_INFO("propagating " << toys << " tracks with pT = " << ptInGeV
0070 << "GeV in a " << BzInT << "T B-field");
0071
0072 using BField = ConstantBField;
0073 using Stepper = AtlasStepper;
0074 using Propagator = Propagator<Stepper>;
0075 using Covariance = BoundSquareMatrix;
0076
0077 auto bField =
0078 std::make_shared<BField>(Vector3{0, 0, BzInT * UnitConstants::T});
0079 Stepper stepper(std::move(bField));
0080 Propagator propagator(std::move(stepper));
0081
0082 PropagatorOptions<> options(tgContext, mfContext);
0083 options.pathLimit = maxPathInM * UnitConstants::m;
0084
0085 Vector4 pos4(0, 0, 0, 0);
0086 Vector3 dir(1, 0, 0);
0087 Covariance cov;
0088
0089 cov << 10_mm, 0, 0, 0, 0, 0,
0090 0, 10_mm, 0, 0, 0, 0,
0091 0, 0, 1, 0, 0, 0,
0092 0, 0, 0, 1, 0, 0,
0093 0, 0, 0, 0, 1_e / 10_GeV, 0,
0094 0, 0, 0, 0, 0, 0;
0095
0096
0097 std::optional<Covariance> covOpt = std::nullopt;
0098 if (withCov) {
0099 covOpt = cov;
0100 }
0101 CurvilinearTrackParameters pars(pos4, dir, +1 / ptInGeV, covOpt,
0102 ParticleHypothesis::pion());
0103
0104 double totalPathLength = 0;
0105 std::size_t numSteps = 0;
0106 std::size_t numIters = 0;
0107 const auto propagationBenchResult = Acts::Test::microBenchmark(
0108 [&] {
0109 auto r = propagator.propagate(pars, options).value();
0110 if (totalPathLength == 0.) {
0111 ACTS_DEBUG("reached position "
0112 << r.endParameters->position(tgContext).transpose()
0113 << " in " << r.steps << " steps");
0114 }
0115 totalPathLength += r.pathLength;
0116 numSteps += r.steps;
0117 ++numIters;
0118 return r;
0119 },
0120 1, toys);
0121
0122 ACTS_INFO("Execution stats: " << propagationBenchResult);
0123 ACTS_INFO("average path length = " << totalPathLength / numIters / 1_mm
0124 << "mm");
0125 ACTS_INFO("average number of steps = " << 1.0 * numSteps / numIters);
0126
0127 return 0;
0128 }