File indexing completed on 2025-01-18 09:58:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 #ifndef G4ParticleGun_hh
0052 #define G4ParticleGun_hh 1
0053
0054 #include "globals.hh"
0055 #include "G4VPrimaryGenerator.hh"
0056 #include "G4ThreeVector.hh"
0057 #include "G4ParticleDefinition.hh"
0058 #include "G4PrimaryVertex.hh"
0059 #include "G4ParticleMomentum.hh"
0060
0061 class G4Event;
0062 class G4ParticleGunMessenger;
0063
0064 class G4ParticleGun : public G4VPrimaryGenerator
0065 {
0066 public:
0067
0068 G4ParticleGun();
0069 explicit G4ParticleGun(G4int numberofparticles);
0070 explicit G4ParticleGun(G4ParticleDefinition* particleDef,
0071 G4int numberofparticles = 1);
0072
0073
0074
0075
0076 ~G4ParticleGun() override;
0077
0078 G4ParticleGun(const G4ParticleGun&) = delete;
0079 const G4ParticleGun& operator=(const G4ParticleGun&) = delete;
0080 G4bool operator==(const G4ParticleGun&) const = delete;
0081 G4bool operator!=(const G4ParticleGun&) const = delete;
0082
0083 void GeneratePrimaryVertex(G4Event* evt) override;
0084
0085
0086
0087
0088
0089
0090
0091
0092 void SetParticleDefinition(G4ParticleDefinition* aParticleDefinition);
0093 void SetParticleEnergy(G4double aKineticEnergy);
0094 void SetParticleMomentum(G4double aMomentum);
0095 void SetParticleMomentum(G4ParticleMomentum aMomentum);
0096 inline void SetParticleMomentumDirection(G4ParticleMomentum aMomDirection)
0097 { particle_momentum_direction = aMomDirection.unit(); }
0098 inline void SetParticleCharge(G4double aCharge)
0099 { particle_charge = aCharge; }
0100 inline void SetParticlePolarization(G4ThreeVector aVal)
0101 { particle_polarization = aVal; }
0102 inline void SetNumberOfParticles(G4int i)
0103 { NumberOfParticlesToBeGenerated = i; }
0104 inline void SetParticleWeight(G4double w)
0105 { particle_weight = w; }
0106
0107 inline G4ParticleDefinition* GetParticleDefinition() const
0108 { return particle_definition; }
0109 inline G4ParticleMomentum GetParticleMomentumDirection() const
0110 { return particle_momentum_direction; }
0111 inline G4double GetParticleEnergy() const
0112 { return particle_energy; }
0113 inline G4double GetParticleMomentum() const
0114 { return particle_momentum; }
0115 inline G4double GetParticleCharge() const
0116 { return particle_charge; }
0117 inline G4ThreeVector GetParticlePolarization() const
0118 { return particle_polarization; }
0119 inline G4int GetNumberOfParticles() const
0120 { return NumberOfParticlesToBeGenerated; }
0121 inline G4double GetParticleWeight() const
0122 { return particle_weight; }
0123
0124 protected:
0125
0126 virtual void SetInitialValues();
0127
0128 G4int NumberOfParticlesToBeGenerated = 0;
0129 G4ParticleDefinition* particle_definition = nullptr;
0130 G4ParticleMomentum particle_momentum_direction;
0131 G4double particle_energy = 0.0;
0132 G4double particle_momentum = 0.0;
0133 G4double particle_charge = 0.0;
0134 G4ThreeVector particle_polarization;
0135 G4double particle_weight = 1.0;
0136
0137 private:
0138
0139 G4ParticleGunMessenger* theMessenger = nullptr;
0140 };
0141
0142 #endif
0143
0144