Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleGun.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id$
28//
29
30#ifndef G4ParticleGun_h
31#define G4ParticleGun_h 1
32
33
34#include "globals.hh"
36#include "G4ThreeVector.hh"
38#include "G4PrimaryVertex.hh"
39#include "G4ParticleMomentum.hh"
40
41class G4Event;
43
44// class description:
45//
46// This is a concrete class of G4VPrimaryGenerator. It shoots a particle of given type
47// into a given direction with either a given kinetic energy or momentum.
48// The position and time of the primary particle must be set by the corresponding
49// set methods of G4VPrimaryGenerator base class, otherwise zero will be set.
50//
51// The FAQ to this class is for randomizing position/direction/kinetic energy of primary
52// particle. But, G4ParticleGun does NOT have any way of randomization. Instead, the user's
53// concrete implementation of G4VUserPrimaryGeneratorAction which transmits G4Event object
54// to this particle gun can randomize these quantities and set to this particle gun before
55// invoking GeneratePrimaryVertex() method.
56// Note that, even if the particle gun shoots more than one particles at one invokation of
57// GeneratePrimaryVertex() method, all particles have the same physical quantities. If the
58// user wants to shoot two particles with different momentum, position, etc., invoke
59// GeneratePrimaryVertex() method twice and set quantities on demand to the particle gun.
60//
61
63{
64 public: // with description
66 G4ParticleGun(G4int numberofparticles);
68 G4int numberofparticles = 1);
69 // costructors. "numberofparticles" is number of particles to be shoot at one invokation
70 // of GeneratePrimaryVertex() method. All paricles are shot with the same physical
71 // quantities.
72
73 public:
74 virtual ~G4ParticleGun();
75
76 private:
78 const G4ParticleGun & operator=(const G4ParticleGun&);
79 G4int operator==(const G4ParticleGun&) const;
80 G4int operator!=(const G4ParticleGun&) const;
81
82 public: // with description
83 virtual void GeneratePrimaryVertex(G4Event* evt);
84 // Creates a primary vertex at the given point and put primary particles to it.
85 // Followings are set methods for the particle properties.
86 // SetParticleDefinition should be called first.
87 // By using SetParticleMomentum(), both particle_momentum_direction and
88 // particle_energy(Kinetic Energy) are set.
89 //
91 (G4ParticleDefinition * aParticleDefinition);
92 void SetParticleEnergy(G4double aKineticEnergy);
93 void SetParticleMomentum(G4double aMomentum);
96 (G4ParticleMomentum aMomentumDirection)
97 { particle_momentum_direction = aMomentumDirection.unit(); }
99 { particle_charge = aCharge; }
101 { particle_polarization = aVal; }
104
105 public:
107 { return particle_definition; }
111 { return particle_energy; }
113 { return particle_momentum; }
115 { return particle_charge; }
117 { return particle_polarization; }
120
121 protected:
122 virtual void SetInitialValues();
123
131
132 private:
133 G4ParticleGunMessenger* theMessenger;
134};
135
136#endif
137
138
139
140
141
142
143
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
Hep3Vector unit() const
G4double particle_momentum
virtual void SetInitialValues()
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
G4ThreeVector GetParticlePolarization() const
G4ParticleMomentum GetParticleMomentumDirection() const
G4double particle_energy
virtual ~G4ParticleGun()
G4double GetParticleMomentum() const
void SetNumberOfParticles(G4int i)
void SetParticlePolarization(G4ThreeVector aVal)
G4ParticleDefinition * GetParticleDefinition() const
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
G4ThreeVector particle_polarization
G4ParticleMomentum particle_momentum_direction
G4int NumberOfParticlesToBeGenerated
G4double particle_charge
G4int GetNumberOfParticles() const
void SetParticleEnergy(G4double aKineticEnergy)
G4double GetParticleCharge() const
G4ParticleDefinition * particle_definition
virtual void GeneratePrimaryVertex(G4Event *evt)
void SetParticleMomentum(G4double aMomentum)
G4double GetParticleEnergy() const
void SetParticleCharge(G4double aCharge)