ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParticleGunOptions.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ParticleGunOptions.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 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 
10 
15 #include "Acts/Utilities/Units.hpp"
16 
18  boost::program_options::options_description& opt) {
19  using namespace boost::program_options;
20 
21  opt.add_options()("pg-nparticles", value<size_t>()->default_value(1.),
22  "number of particles.")(
23  "pg-d0-range", value<read_range>()->multitoken()->default_value({0., 0.}),
24  "range in which the d0 parameter is simulated in [mm]. Please hand"
25  "over by simply seperating the values by space")(
26  "pg-z0-range", value<read_range>()->multitoken()->default_value({0., 0.}),
27  "range in which the z0 parameter is simulated in [mm]. Please hand"
28  "over by simply seperating the values by space")(
29  "pg-t0-range", value<read_range>()->multitoken()->default_value({0., 0.}),
30  "range in which the t0 parameter is simulated in [ns]. Please hand"
31  "over by simply seperating the values by space")(
32  "pg-phi-range",
33  value<read_range>()->multitoken()->default_value({-M_PI, M_PI}),
34  "range in which the phi0 parameter is simulated. Please hand over by "
35  "simply seperating the values by space")(
36  "pg-eta-range",
37  value<read_range>()->multitoken()->default_value({-4., 4.}),
38  "range in which the eta parameter is simulated. Please hand over by "
39  "simply seperating the values by space")(
40  "pg-pt-range", value<read_range>()->multitoken()->default_value({1, 100}),
41  "range in which the pt in [GeV] parameter is simulated. Please hand "
42  "over by simply seperating the values by space")(
43  "pg-pdg", value<int32_t>()->default_value(Acts::PdgParticle::eMuon),
44  "PDG number of the particle, will be adjusted for charge flip.")(
45  "pg-randomize-charge", bool_switch(),
46  "flip the charge (and change PDG accordingly).");
47 }
48 
50  const boost::program_options::variables_map& vm) {
51  using namespace Acts::UnitLiterals;
52 
53  // read the range as vector (missing istream for std::array)
54  auto d0 = vm["pg-d0-range"].template as<read_range>();
55  auto z0 = vm["pg-z0-range"].template as<read_range>();
56  auto t0 = vm["pg-t0-range"].template as<read_range>();
57  auto phi = vm["pg-phi-range"].template as<read_range>();
58  auto eta = vm["pg-eta-range"].template as<read_range>();
59  auto pt = vm["pg-pt-range"].template as<read_range>();
60 
62  pgCfg.numParticles = vm["pg-nparticles"].template as<size_t>();
63  pgCfg.d0Range = {{d0[0] * 1_mm, d0[1] * 1_mm}};
64  pgCfg.z0Range = {{z0[0] * 1_mm, z0[1] * 1_mm}};
65  pgCfg.t0Range = {{t0[0] * 1_ns, t0[1] * 1_ns}};
66  pgCfg.phiRange = {{phi[0], phi[1]}};
67  pgCfg.etaRange = {{eta[0], eta[1]}};
68  pgCfg.ptRange = {{pt[0] * 1_GeV, pt[1] * 1_GeV}};
69  pgCfg.pdg =
70  static_cast<Acts::PdgParticle>(vm["pg-pdg"].template as<int32_t>());
71  pgCfg.randomizeCharge = vm["pg-randomize-charge"].template as<bool>();
72 
74  cfg.generators = {
76  FixedVertexGenerator{{0.0, 0.0, 0.0, 0.0}},
78  };
79 
80  return cfg;
81 }