G4ParticleGun.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 
00030 #ifndef G4ParticleGun_h
00031 #define G4ParticleGun_h 1
00032 
00033 
00034 #include "globals.hh"
00035 #include "G4VPrimaryGenerator.hh"
00036 #include "G4ThreeVector.hh"
00037 #include "G4ParticleDefinition.hh"
00038 #include "G4PrimaryVertex.hh"
00039 #include "G4ParticleMomentum.hh"
00040 
00041 class G4Event;
00042 class G4ParticleGunMessenger;
00043 
00044 // class description:
00045 //
00046 //  This is a concrete class of G4VPrimaryGenerator. It shoots a particle of given type
00047 // into a given direction with either a given kinetic energy or momentum.
00048 //  The position and time of the primary particle must be set by the corresponding
00049 // set methods of G4VPrimaryGenerator base class, otherwise zero will be set.
00050 //
00051 //  The FAQ to this class is for randomizing position/direction/kinetic energy of primary
00052 // particle. But, G4ParticleGun does NOT have any way of randomization. Instead, the user's
00053 // concrete implementation of G4VUserPrimaryGeneratorAction which transmits G4Event object
00054 // to this particle gun can randomize these quantities and set to this particle gun before
00055 // invoking GeneratePrimaryVertex() method.
00056 //  Note that, even if the particle gun shoots more than one particles at one invokation of
00057 // GeneratePrimaryVertex() method, all particles have the same physical quantities. If the
00058 // user wants to shoot two particles with different momentum, position, etc., invoke
00059 // GeneratePrimaryVertex() method twice and set quantities on demand to the particle gun.
00060 //
00061 
00062 class G4ParticleGun:public G4VPrimaryGenerator
00063 {
00064   public: // with description
00065      G4ParticleGun();
00066      G4ParticleGun(G4int numberofparticles);
00067      G4ParticleGun(G4ParticleDefinition * particleDef, 
00068                    G4int numberofparticles = 1);
00069      // costructors. "numberofparticles" is number of particles to be shoot at one invokation
00070      // of GeneratePrimaryVertex() method. All paricles are shot with the same physical
00071      // quantities.
00072 
00073   public:
00074      virtual ~G4ParticleGun();
00075 
00076   private:
00077      G4ParticleGun(const G4ParticleGun&);
00078      const G4ParticleGun & operator=(const G4ParticleGun&);
00079      G4int operator==(const G4ParticleGun&) const;
00080      G4int operator!=(const G4ParticleGun&) const;
00081 
00082   public: // with description
00083      virtual void GeneratePrimaryVertex(G4Event* evt);
00084      // Creates a primary vertex at the given point and put primary particles to it.
00085      // Followings are set methods for the particle properties.
00086      //   SetParticleDefinition should be called first.  
00087      //   By using SetParticleMomentum(), both particle_momentum_direction and
00088      //   particle_energy(Kinetic Energy) are set.
00089      //   
00090      void SetParticleDefinition
00091        (G4ParticleDefinition * aParticleDefinition);
00092      void SetParticleEnergy(G4double aKineticEnergy);
00093      void SetParticleMomentum(G4double aMomentum);
00094      void SetParticleMomentum(G4ParticleMomentum aMomentum);
00095      void SetParticleMomentumDirection
00096                  (G4ParticleMomentum aMomentumDirection)
00097      { particle_momentum_direction =  aMomentumDirection.unit(); }
00098      void SetParticleCharge(G4double aCharge)
00099      { particle_charge = aCharge; }
00100      void SetParticlePolarization(G4ThreeVector aVal)
00101      { particle_polarization = aVal; }
00102      void SetNumberOfParticles(G4int i)
00103      { NumberOfParticlesToBeGenerated = i; }
00104 
00105   public:
00106      G4ParticleDefinition* GetParticleDefinition() const
00107      { return particle_definition; }
00108      G4ParticleMomentum GetParticleMomentumDirection() const
00109      { return particle_momentum_direction; }
00110      G4double GetParticleEnergy() const
00111      { return particle_energy; }
00112      G4double GetParticleMomentum() const
00113      { return particle_momentum; }
00114      G4double GetParticleCharge() const
00115      { return particle_charge; }
00116      G4ThreeVector GetParticlePolarization() const
00117      { return particle_polarization; }
00118      G4int GetNumberOfParticles() const
00119      { return NumberOfParticlesToBeGenerated; }
00120 
00121   protected:  
00122      virtual void SetInitialValues();
00123 
00124      G4int                 NumberOfParticlesToBeGenerated;
00125      G4ParticleDefinition* particle_definition;
00126      G4ParticleMomentum    particle_momentum_direction;
00127      G4double              particle_energy;
00128      G4double              particle_momentum;
00129      G4double              particle_charge;
00130      G4ThreeVector         particle_polarization;
00131 
00132   private:
00133      G4ParticleGunMessenger* theMessenger;
00134 };
00135 
00136 #endif
00137 
00138 
00139 
00140 
00141 
00142 
00143 

Generated on Mon May 27 17:49:16 2013 for Geant4 by  doxygen 1.4.7