ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AtlasStepperBenchmark.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AtlasStepperBenchmark.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/program_options.hpp>
10 #include <iostream>
11 
20 #include "Acts/Utilities/Units.hpp"
21 
22 namespace po = boost::program_options;
23 using namespace Acts;
24 using namespace Acts::UnitLiterals;
25 
26 int main(int argc, char* argv[]) {
27  unsigned int toys = 1;
28  double ptInGeV = 1;
29  double BzInT = 1;
30  double maxPathInM = 1;
31  unsigned int lvl = Acts::Logging::INFO;
32  bool withCov = true;
33 
34  // Create a test context
37 
38  try {
39  po::options_description desc("Allowed options");
40  // clang-format off
41  desc.add_options()
42  ("help", "produce help message")
43  ("toys",po::value<unsigned int>(&toys)->default_value(20000),"number of tracks to propagate")
44  ("pT",po::value<double>(&ptInGeV)->default_value(1),"transverse momentum in GeV")
45  ("B",po::value<double>(&BzInT)->default_value(2),"z-component of B-field in T")
46  ("path",po::value<double>(&maxPathInM)->default_value(5),"maximum path length in m")
47  ("cov",po::value<bool>(&withCov)->default_value(true),"propagation with covariance matrix")
48  ("verbose",po::value<unsigned int>(&lvl)->default_value(Acts::Logging::INFO),"logging level");
49  // clang-format on
50  po::variables_map vm;
51  po::store(po::parse_command_line(argc, argv, desc), vm);
52  po::notify(vm);
53 
54  if (vm.count("help") != 0u) {
55  std::cout << desc << std::endl;
56  return 0;
57  }
58  } catch (std::exception& e) {
59  std::cerr << "error: " << e.what() << std::endl;
60  return 1;
61  }
62 
64  getDefaultLogger("ATLAS_Stepper", Acts::Logging::Level(lvl)));
65 
66  // print information about profiling setup
67  ACTS_INFO("propagating " << toys << " tracks with pT = " << ptInGeV
68  << "GeV in a " << BzInT << "T B-field");
69 
70  using BField_type = ConstantBField;
71  using Stepper_type = AtlasStepper<BField_type>;
72  using Propagator_type = Propagator<Stepper_type>;
73  using Covariance = BoundSymMatrix;
74 
75  BField_type bField(0, 0, BzInT * UnitConstants::T);
76  Stepper_type atlas_stepper(std::move(bField));
77  Propagator_type propagator(std::move(atlas_stepper));
78 
79  PropagatorOptions<> options(tgContext, mfContext);
80  options.pathLimit = maxPathInM * UnitConstants::m;
81 
82  Vector3D pos(0, 0, 0);
83  Vector3D mom(ptInGeV * UnitConstants::GeV, 0, 0);
84  Covariance cov;
85  // clang-format off
86  cov << 10_mm, 0, 0, 0, 0, 0,
87  0, 10_mm, 0, 0, 0, 0,
88  0, 0, 1, 0, 0, 0,
89  0, 0, 0, 1, 0, 0,
90  0, 0, 0, 0, 1_e / 10_GeV, 0,
91  0, 0, 0, 0, 0, 0;
92  // clang-format on
93 
94  std::optional<Covariance> optCov = std::nullopt;
95  if (withCov) {
96  optCov = cov;
97  }
98  CurvilinearParameters pars(optCov, pos, mom, +1, 0.);
99 
100  double totalPathLength = 0;
101  size_t num_iters = 0;
102  const auto propagation_bench_result = Acts::Test::microBenchmark(
103  [&] {
104  auto r = propagator.propagate(pars, options).value();
105  if (totalPathLength == 0.) {
106  ACTS_DEBUG("reached position ("
107  << r.endParameters->position().x() << ", "
108  << r.endParameters->position().y() << ", "
109  << r.endParameters->position().z() << ") in " << r.steps
110  << " steps");
111  }
112  totalPathLength += r.pathLength;
113  ++num_iters;
114  return r;
115  },
116  1, toys);
117 
118  ACTS_INFO("Execution stats: " << propagation_bench_result);
119  ACTS_INFO("average path length = " << totalPathLength / num_iters / 1_mm
120  << "mm");
121  return 0;
122 }