EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrimaryGeneratorAction.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PrimaryGeneratorAction.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-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 
9 #pragma once
10 
11 #include <memory>
12 
13 #include <G4SystemOfUnits.hh>
14 #include <G4ThreeVector.hh>
15 #include <G4VUserPrimaryGeneratorAction.hh>
16 #include <globals.hh>
17 
18 class G4ParticleGun;
19 class G4Event;
20 
21 namespace ActsExamples {
22 
32 class PrimaryGeneratorAction final : public G4VUserPrimaryGeneratorAction {
33  public:
34  struct Config {
36  G4String particleName = "geantino";
38  G4double energy = 1000.0;
40  G4int randomSeed1 = 12345;
42  G4int randomSeed2 = 45678;
44  G4double vertexPosX = 0.0;
46  G4double vertexPosY = 0.0;
48  G4double vertexPosZ = 0.0;
50  G4double vertexSigmaX = 0.0;
52  G4double vertexSigmaY = 0.0;
54  G4double vertexSigmaZ = 0.0;
56  std::pair<G4double, G4double> phiRange = {-M_PI, M_PI};
58  std::pair<G4double, G4double> etaRange = {-4., 4.};
60  G4String samplingVariable = "theta";
61  };
62 
65 
67  PrimaryGeneratorAction(const Config& cfg);
68  ~PrimaryGeneratorAction() final override;
69 
71  void GeneratePrimaries(G4Event*) final override;
72 
74  const G4ThreeVector& direction() const { return m_direction; }
75 
77  const G4ThreeVector& position() const { return m_position; }
78 
79  private:
82 
85 
87  std::unique_ptr<G4ParticleGun> m_particleGun;
89  G4ThreeVector m_position;
91  G4ThreeVector m_direction;
92 };
93 
94 } // namespace ActsExamples