EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4Options.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Geant4Options.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 
12 
13 #include <string>
14 
15 #include <boost/program_options.hpp>
16 
19  using boost::program_options::bool_switch;
21 
22  auto opt = desc.add_options();
23  opt("g4-rnd-seed1", value<unsigned int>()->default_value(287362910),
24  "The first seed of the G4 random number generation");
25  opt("g4-rnd-seed2", value<unsigned int>()->default_value(730284537),
26  "The second seed of the G4 random number generation");
27  opt("g4-pg-nparticles", value<unsigned int>()->default_value(100),
28  "The number of particles produced by the g4 particle gun");
29  opt("g4-material-tracks",
30  value<std::string>()->default_value("geant4-material-tracks"),
31  "The output collection for material tracks");
32  opt("g4-vertex-posX", value<double>()->default_value(0.0),
33  "The X position of the geantino vertex");
34  opt("g4-vertex-posY", value<double>()->default_value(0.0),
35  "The Y position of the geantino vertex");
36  opt("g4-vertex-posZ", value<double>()->default_value(0.0),
37  "The Z position of the geantino vertex");
38  opt("g4-vertex-sigmaX", value<double>()->default_value(0.0),
39  "The X spread of the geantino vertex");
40  opt("g4-vertex-sigmaY", value<double>()->default_value(0.0),
41  "The Y spread of the geantino vertex");
42  opt("g4-vertex-sigmaZ", value<double>()->default_value(0.0),
43  "The Z spread of the geantino vertex");
44  opt("g4-phi-range",
45  value<read_range>()->multitoken()->default_value({-M_PI, M_PI}),
46  "Azimutal angle phi range for the geantino");
47  opt("g4-eta-range",
48  value<read_range>()->multitoken()->default_value({-5., 5.}),
49  "Pseudorapidity eta range for the geantino");
50  opt("g4-sampling-variable", value<std::string>()->default_value("theta"),
51  "Variable from which the particle generation is uniform. Can be theta "
52  "or eta");
53 }
54 
57  const ActsExamples::Options::Variables& variables) {
59 
60  gRecConfig.tracksPerEvent = variables["g4-pg-nparticles"].as<unsigned int>();
61  gRecConfig.generationConfig.randomSeed1 =
62  variables["g4-rnd-seed1"].as<unsigned int>();
63  gRecConfig.generationConfig.randomSeed2 =
64  variables["g4-rnd-seed2"].as<unsigned int>();
65  gRecConfig.outputMaterialTracks =
66  variables["g4-material-tracks"].as<std::string>();
67 
68  gRecConfig.generationConfig.vertexPosX =
69  variables["g4-vertex-posX"].as<double>();
70  gRecConfig.generationConfig.vertexPosY =
71  variables["g4-vertex-posY"].as<double>();
72  gRecConfig.generationConfig.vertexPosZ =
73  variables["g4-vertex-posZ"].as<double>();
74  gRecConfig.generationConfig.vertexSigmaX =
75  variables["g4-vertex-sigmaX"].as<double>();
76  gRecConfig.generationConfig.vertexSigmaY =
77  variables["g4-vertex-sigmaY"].as<double>();
78  gRecConfig.generationConfig.vertexSigmaZ =
79  variables["g4-vertex-sigmaZ"].as<double>();
80 
81  read_range iphir = variables["g4-phi-range"].template as<read_range>();
82  read_range ietar = variables["g4-eta-range"].template as<read_range>();
83 
84  gRecConfig.generationConfig.phiRange = {iphir[0], iphir[1]};
85  gRecConfig.generationConfig.etaRange = {ietar[0], ietar[1]};
86 
88  variables["g4-sampling-variable"].as<std::string>();
89 
90  return gRecConfig;
91 }