Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:51

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4ParticleGum
0027 //
0028 // Class description:
0029 //
0030 // This is a concrete class of G4VPrimaryGenerator. It shoots a particle of
0031 // given type into a given direction with either a given kinetic energy or
0032 // momentum.
0033 // The position and time of the primary particle must be set by the
0034 // corresponding set methods of the G4VPrimaryGenerator base class, otherwise
0035 // zero will be set.
0036 //
0037 // The FAQ to this class is for randomizing position/direction/kinetic energy
0038 // of the primary particle. But, G4ParticleGun does NOT have any way of
0039 // randomization. Instead, the user's concrete implementation of
0040 // G4VUserPrimaryGeneratorAction which transfer the G4Event object
0041 // to this particle gun can randomize these quantities and set to this
0042 // particle gun before invoking GeneratePrimaryVertex() method.
0043 // Note that, even if the particle gun shoots more than one particles at one
0044 // invokation of the GeneratePrimaryVertex() method, all particles have the
0045 // same physical quantities. If the user wants to shoot two particles with
0046 // different momentum, position, etc., should invoke GeneratePrimaryVertex()
0047 // method twice and set quantities on demand to the particle gun.
0048 
0049 // Author: Makoto Asai, 1997
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       // Costructors. "numberofparticles" is the number of particles to be
0073       // shot at one invokation of GeneratePrimaryVertex() method.
0074       // All particles are shot with the same physical quantities.
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       // Creates a primary vertex at the given point
0085       // and put primary particles to it.
0086 
0087     // Followings are the Set methods for the particle properties.
0088     // SetParticleDefinition() should be called first.  
0089     // By using SetParticleMomentum(), both particle_momentum_direction and
0090     // particle_energy(Kinetic Energy) are set.
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