source: trunk/source/event/include/G4ParticleGun.hh @ 964

Last change on this file since 964 was 964, checked in by garnier, 15 years ago

update event

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