Analysis Software
Documentation for sPHENIX simulation 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 
19 
20 #include <iostream>
21 
22 #include <boost/program_options.hpp>
23 
24 namespace po = boost::program_options;
25 using namespace Acts;
26 using namespace Acts::UnitLiterals;
27 
28 int main(int argc, char* argv[]) {
29  unsigned int toys = 1;
30  double ptInGeV = 1;
31  double BzInT = 1;
32  double maxPathInM = 1;
33  unsigned int lvl = Acts::Logging::INFO;
34  bool withCov = true;
35 
36  // Create a test context
39 
40  try {
41  po::options_description desc("Allowed options");
42  // clang-format off
43  desc.add_options()
44  ("help", "produce help message")
45  ("toys",po::value<unsigned int>(&toys)->default_value(20000),"number of tracks to propagate")
46  ("pT",po::value<double>(&ptInGeV)->default_value(1),"transverse momentum in GeV")
47  ("B",po::value<double>(&BzInT)->default_value(2),"z-component of B-field in T")
48  ("path",po::value<double>(&maxPathInM)->default_value(5),"maximum path length in m")
49  ("cov",po::value<bool>(&withCov)->default_value(true),"propagation with covariance matrix")
50  ("verbose",po::value<unsigned int>(&lvl)->default_value(Acts::Logging::INFO),"logging level");
51  // clang-format on
52  po::variables_map vm;
53  po::store(po::parse_command_line(argc, argv, desc), vm);
54  po::notify(vm);
55 
56  if (vm.count("help") != 0u) {
57  std::cout << desc << std::endl;
58  return 0;
59  }
60  } catch (std::exception& e) {
61  std::cerr << "error: " << e.what() << std::endl;
62  return 1;
63  }
64 
66  getDefaultLogger("ATLAS_Stepper", Acts::Logging::Level(lvl)));
67 
68  // print information about profiling setup
69  ACTS_INFO("propagating " << toys << " tracks with pT = " << ptInGeV
70  << "GeV in a " << BzInT << "T B-field");
71 
72  using BField_type = ConstantBField;
73  using Stepper_type = AtlasStepper;
74  using Propagator_type = Propagator<Stepper_type>;
76 
77  auto bField =
78  std::make_shared<BField_type>(Vector3{0, 0, BzInT * UnitConstants::T});
79  Stepper_type atlas_stepper(std::move(bField));
80  Propagator_type propagator(std::move(atlas_stepper));
81 
82  PropagatorOptions<> options(tgContext, mfContext);
83  options.pathLimit = maxPathInM * UnitConstants::m;
84 
86  // clang-format off
87  cov << 10_mm, 0, 0, 0, 0, 0,
88  0, 10_mm, 0, 0, 0, 0,
89  0, 0, 1, 0, 0, 0,
90  0, 0, 0, 1, 0, 0,
91  0, 0, 0, 0, 1_e / 10_GeV, 0,
92  0, 0, 0, 0, 0, 0;
93  // clang-format on
94 
95  std::optional<Covariance> optCov = std::nullopt;
96  if (withCov) {
97  optCov = cov;
98  }
99  CurvilinearTrackParameters pars(Vector4::Zero(), 0_degree, 90_degree,
100  1_e / ptInGeV * UnitConstants::GeV, optCov,
102 
103  double totalPathLength = 0;
104  size_t num_iters = 0;
105  const auto propagation_bench_result = Acts::Test::microBenchmark(
106  [&] {
107  auto r = propagator.propagate(pars, options).value();
108  if (totalPathLength == 0.) {
109  ACTS_DEBUG("reached position "
110  << r.endParameters->position(tgContext).transpose()
111  << " in " << r.steps << " steps");
112  }
113  totalPathLength += r.pathLength;
114  ++num_iters;
115  return r;
116  },
117  1, toys);
118 
119  ACTS_INFO("Execution stats: " << propagation_bench_result);
120  ACTS_INFO("average path length = " << totalPathLength / num_iters / 1_mm
121  << "mm");
122  return 0;
123 }