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5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 // G4ParticleGum
 27 //
 28 // Class description:
 29 //
 30 // This is a concrete class of G4VPrimaryGenerator. It shoots a particle of
 31 // given type into a given direction with either a given kinetic energy or
 32 // momentum.
 33 // The position and time of the primary particle must be set by the
 34 // corresponding set methods of the G4VPrimaryGenerator base class, otherwise
 35 // zero will be set.
 36 //
 37 // The FAQ to this class is for randomizing position/direction/kinetic energy
 38 // of the primary particle. But, G4ParticleGun does NOT have any way of
 39 // randomization. Instead, the user's concrete implementation of
 40 // G4VUserPrimaryGeneratorAction which transfer the G4Event object
 41 // to this particle gun can randomize these quantities and set to this
 42 // particle gun before invoking GeneratePrimaryVertex() method.
 43 // Note that, even if the particle gun shoots more than one particles at one
 44 // invokation of the GeneratePrimaryVertex() method, all particles have the
 45 // same physical quantities. If the user wants to shoot two particles with
 46 // different momentum, position, etc., should invoke GeneratePrimaryVertex()
 47 // method twice and set quantities on demand to the particle gun.
 48 
 49 // Author: Makoto Asai, 1997
 50 // --------------------------------------------------------------------
 51 #ifndef G4ParticleGun_hh
 52 #define G4ParticleGun_hh 1
 53 
 54 #include "globals.hh"
 55 #include "G4VPrimaryGenerator.hh"
 56 #include "G4ThreeVector.hh"
 57 #include "G4ParticleDefinition.hh"
 58 #include "G4PrimaryVertex.hh"
 59 #include "G4ParticleMomentum.hh"
 60 
 61 class G4Event;
 62 class G4ParticleGunMessenger;
 63 
 64 class G4ParticleGun : public G4VPrimaryGenerator
 65 {
 66   public:
 67 
 68     G4ParticleGun();
 69     explicit G4ParticleGun(G4int numberofparticles);
 70     explicit G4ParticleGun(G4ParticleDefinition* particleDef, 
 71                   G4int numberofparticles = 1);
 72       // Costructors. "numberofparticles" is the number of particles to be
 73       // shot at one invokation of GeneratePrimaryVertex() method.
 74       // All particles are shot with the same physical quantities.
 75 
 76     ~G4ParticleGun() override;
 77 
 78     G4ParticleGun(const G4ParticleGun&) = delete;
 79     const G4ParticleGun& operator=(const G4ParticleGun&) = delete;
 80     G4bool operator==(const G4ParticleGun&) const = delete;
 81     G4bool operator!=(const G4ParticleGun&) const = delete;
 82 
 83     void GeneratePrimaryVertex(G4Event* evt) override;
 84       // Creates a primary vertex at the given point
 85       // and put primary particles to it.
 86 
 87     // Followings are the Set methods for the particle properties.
 88     // SetParticleDefinition() should be called first.  
 89     // By using SetParticleMomentum(), both particle_momentum_direction and
 90     // particle_energy(Kinetic Energy) are set.
 91     //
 92     void SetParticleDefinition(G4ParticleDefinition* aParticleDefinition);
 93     void SetParticleEnergy(G4double aKineticEnergy);
 94     void SetParticleMomentum(G4double aMomentum);
 95     void SetParticleMomentum(G4ParticleMomentum aMomentum);
 96     inline void SetParticleMomentumDirection(G4ParticleMomentum aMomDirection)
 97       { particle_momentum_direction =  aMomDirection.unit(); }
 98     inline void SetParticleCharge(G4double aCharge)
 99       { particle_charge = aCharge; }
100     inline void SetParticlePolarization(G4ThreeVector aVal)
101       { particle_polarization = aVal; }
102     inline void SetNumberOfParticles(G4int i)
103       { NumberOfParticlesToBeGenerated = i; }
104     inline void SetParticleWeight(G4double w)
105       { particle_weight = w; }
106 
107     inline G4ParticleDefinition* GetParticleDefinition() const
108       { return particle_definition; }
109     inline G4ParticleMomentum GetParticleMomentumDirection() const
110       { return particle_momentum_direction; }
111     inline G4double GetParticleEnergy() const
112       { return particle_energy; }
113     inline G4double GetParticleMomentum() const
114       { return particle_momentum; }
115     inline G4double GetParticleCharge() const
116       { return particle_charge; }
117     inline G4ThreeVector GetParticlePolarization() const
118       { return particle_polarization; }
119     inline G4int GetNumberOfParticles() const
120       { return NumberOfParticlesToBeGenerated; }
121     inline G4double GetParticleWeight() const
122       { return particle_weight; }
123 
124   protected:  
125 
126      virtual void SetInitialValues();
127 
128      G4int                 NumberOfParticlesToBeGenerated = 0;
129      G4ParticleDefinition* particle_definition = nullptr;
130      G4ParticleMomentum    particle_momentum_direction;
131      G4double              particle_energy = 0.0;
132      G4double              particle_momentum = 0.0;
133      G4double              particle_charge = 0.0;
134      G4ThreeVector         particle_polarization;
135      G4double              particle_weight = 1.0;
136 
137   private:
138 
139      G4ParticleGunMessenger* theMessenger = nullptr;
140 };
141 
142 #endif
143 
144 
145