Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EigenStepperBenchmark.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EigenStepperBenchmark.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 
18 
19 #include <iostream>
20 
21 #include <boost/program_options.hpp>
22 
23 namespace po = boost::program_options;
24 using namespace Acts;
25 using namespace Acts::UnitLiterals;
26 
27 int main(int argc, char* argv[]) {
28  unsigned int toys = 1;
29  double ptInGeV = 1;
30  double BzInT = 1;
31  double maxPathInM = 1;
32  unsigned int lvl = Acts::Logging::INFO;
33  bool withCov = true;
34 
35  // Create a test context
38 
39  try {
40  po::options_description desc("Allowed options");
41  // clang-format off
42  desc.add_options()
43  ("help", "produce help message")
44  ("toys",po::value<unsigned int>(&toys)->default_value(20000),"number of tracks to propagate")
45  ("pT",po::value<double>(&ptInGeV)->default_value(1),"transverse momentum in GeV")
46  ("B",po::value<double>(&BzInT)->default_value(2),"z-component of B-field in T")
47  ("path",po::value<double>(&maxPathInM)->default_value(5),"maximum path length in m")
48  ("cov",po::value<bool>(&withCov)->default_value(true),"propagation with covariance matrix")
49  ("verbose",po::value<unsigned int>(&lvl)->default_value(Acts::Logging::INFO),"logging level");
50  // clang-format on
51  po::variables_map vm;
52  po::store(po::parse_command_line(argc, argv, desc), vm);
53  po::notify(vm);
54 
55  if (vm.count("help") != 0u) {
56  std::cout << desc << std::endl;
57  return 0;
58  }
59  } catch (std::exception& e) {
60  std::cerr << "error: " << e.what() << std::endl;
61  return 1;
62  }
63 
65  getDefaultLogger("Eigen_Stepper", Acts::Logging::Level(lvl)));
66 
67  // print information about profiling setup
68  ACTS_INFO("propagating " << toys << " tracks with pT = " << ptInGeV
69  << "GeV in a " << BzInT << "T B-field");
70 
71  using BField_type = ConstantBField;
72  using Stepper_type = EigenStepper<>;
73  using Propagator_type = Propagator<Stepper_type>;
75 
76  auto bField =
77  std::make_shared<BField_type>(Vector3{0, 0, BzInT * UnitConstants::T});
78  Stepper_type atlas_stepper(std::move(bField));
79  Propagator_type propagator(std::move(atlas_stepper));
80 
81  PropagatorOptions<> options(tgContext, mfContext);
82  options.pathLimit = maxPathInM * UnitConstants::m;
83 
84  Vector4 pos4(0, 0, 0, 0);
85  Vector3 dir(1, 0, 0);
87  // clang-format off
88  cov << 10_mm, 0, 0, 0, 0, 0,
89  0, 10_mm, 0, 0, 0, 0,
90  0, 0, 1, 0, 0, 0,
91  0, 0, 0, 1, 0, 0,
92  0, 0, 0, 0, 1_e / 10_GeV, 0,
93  0, 0, 0, 0, 0, 0;
94  // clang-format on
95 
96  std::optional<Covariance> covOpt = std::nullopt;
97  if (withCov) {
98  covOpt = cov;
99  }
100  CurvilinearTrackParameters pars(pos4, dir, +1 / ptInGeV, covOpt,
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 
123  return 0;
124 }