14 #include <G4ParticleDefinition.hh>
15 #include <G4ParticleGun.hh>
16 #include <G4ParticleTable.hh>
17 #include <G4RandomDirection.hh>
18 #include <G4UnitsTable.hh>
19 #include <Randomize.hh>
21 using namespace ActsExamples;
30 : G4VUserPrimaryGeneratorAction(),
32 m_particleGun(std::make_unique<G4ParticleGun>(1)) {
34 throw std::logic_error(
35 "Attempted to duplicate the PrimaryGeneratorAction singleton");
41 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
46 G4UnitDefinition::PrintUnitsTable();
66 theta = thetaMin + G4UniformRand() * (thetaMax - thetaMin);
71 theta = 2 * atan(exp(-eta));
73 throw std::invalid_argument(
"Unknow sampling variable");
77 G4ThreeVector(
cos(phi) * sin(theta), sin(phi) * sin(theta),
cos(theta));