Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GeneralParticleSource.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 //
27 //
28 // MODULE: G4GeneralParticleSource.hh
29 //
30 // Version: 2.0
31 // Date: 5/02/04
32 // Author: Fan Lei
33 // Organisation: QinetiQ ltd.
34 // Customer: ESA/ESTEC
35 //
36 // Documentation avaialable at http://reat.space.qinetiq.com/gps
37 // These include:
38 // User Requirement Document (URD)
39 // Software Specification Documents (SSD)
40 // Software User Manual (SUM): on-line version available
41 // Technical Note (TN) on the physics and algorithms
42 //
44 //
45 // CHANGE HISTORY
46 // --------------
47 // 26/10/2004, F Lei
48 // Added the Multiple_vertex capability.
49 // Removed "inline" from all Set/Get methods.
50 //
51 // Version 2.0, 05/02/2004, Fan Lei, Created.
52 // based on version 1.1 in Geant4 v6.0
53 // - Mutilple particle source definition
54 // - Re-structured commands
55 // - Split the task into smaller classes
56 //
57 // - old commonds have been retained for backward compatibility, but will
58 // be removed in the future.
59 //
61 //
62 // Class Description:
63 //
64 // The General Particle Source is designed to replace the G4ParticleGun class.
65 // It is designed to allow specification of mutiple particle sources, each with
66 // independent definitions of particle type, position, direction (or angular)
67 // and energy distributions.
68 //
70 //
71 // MEMBER FUNCTIONS
72 // ----------------
73 //
74 // G4GeneralParticleSource()
75 // Constructor: Initializes variables and instantiates the
76 // Messenger and generator classes
77 //
78 // ~G4GeneralParticleSourceMessenger()
79 // Destructor: deletes Messenger and others
80 //
81 // G4int GetNumberofSource()
82 // Return the number of particle gun defined
83 //
84 // void ListSource()
85 // List the particle guns defined
86 //
87 // void SetCurrentSourceto(G4int)
88 // set the current gun to the specified one so its definition can be changed
89 //
90 // void SetCurrentSourceIntensity(G4double)
91 // change the current particle gun strength
92 //
93 // void SetMultipleVertex(G4bool )
94 // Set if multiple vertex per event.
95 
96 // G4SingleParticleSource* GetCurrentSource()
97 // return the pointer to current particle gun
98 //
99 // G4int GetCurrentSourceIndex()
100 // return the index of the current particle gun
101 //
102 // G4double GetCurrentSourceIntensity()
103 // return the strength of the current gun
104 //
105 // void ClearAll()
106 // remove all defined aprticle gun
107 //
108 // void AddaSource (G4double)
109 // add a new particle gun with the specified strength
110 //
111 // void DeleteaSource(G4int);
112 // delete the specified particle gun
113 //
114 // void SetParticleDefinition ();
115 // G4ParticleDefinition * GetParticleDefinition ()
116 // Get/Set the particle definition of the primary track
117 //
118 // void SetParticleCharge(G4double aCharge)
119 // set the charge state of the primary track
120 //
121 // void SetParticlePolarization (G4ThreeVector aVal)
122 // G4ThreeVector GetParticlePolarization ()
123 // Set/Get the polarization state of the primary track
124 //
125 // void SetParticleTime(G4double aTime) { particle_time = aTime; };
126 // G4double GetParticleTime() { return particle_time; };
127 // Set/Get the Time.
128 //
129 // void SetNumberOfParticles(G4int i)
130 // G4int GetNumberOfParticles()
131 // set/get the number of particles to be generated in the primary track
132 //
133 // G4ThreeVector GetParticlePosition()
134 // G4ThreeVector GetParticleMomentumDirection()
135 // G4double GetParticleEnergy()
136 // get the position, direction, and energy of the current particle
137 //
139 //
140 #ifndef G4GeneralParticleSource_H
141 #define G4GeneralParticleSource_H 1
142 
143 #include "globals.hh"
144 #include <vector>
145 
146 #include "G4Event.hh"
147 #include "G4SingleParticleSource.hh"
148 //
150 
152 {
153  //
154 public:
155 
158 
160 
161  G4int GetNumberofSource() { return G4int(sourceVector.size()); };
162  void ListSource();
163  void SetCurrentSourceto(G4int) ;
165  G4SingleParticleSource* GetCurrentSource() {return currentSource;};
166  G4int GetCurrentSourceIndex() { return currentSourceIdx; };
167  G4double GetCurrentSourceIntensity() { return sourceIntensity[currentSourceIdx]; };
168  void ClearAll();
169  void AddaSource (G4double);
170  void DeleteaSource(G4int);
171 
172  // Set the verbosity level.
173  void SetVerbosity(G4int i) {currentSource->SetVerbosity(i);} ;
174 
175  // Set if multiple vertex per event.
176  void SetMultipleVertex(G4bool av) {multiple_vertex = av;} ;
177 
178  // set if flat_sampling is applied in multiple source case
179 
180  void SetFlatSampling(G4bool av) {flat_sampling = av; normalised = false;} ;
181 
182  // Set the particle species
183  void SetParticleDefinition (G4ParticleDefinition * aParticleDefinition)
184  {currentSource->SetParticleDefinition(aParticleDefinition); } ;
185 
187 
188  void SetParticleCharge(G4double aCharge) { currentSource->SetParticleCharge(aCharge); } ;
189 
190  // Set polarization
191  void SetParticlePolarization (G4ThreeVector aVal) {currentSource->SetParticlePolarization(aVal);};
193 
194  // Set Time.
195  void SetParticleTime(G4double aTime) { currentSource->SetParticleTime(aTime); };
196  G4double GetParticleTime() { return currentSource->GetParticleTime(); };
197 
198  void SetNumberOfParticles(G4int i) { currentSource->SetNumberOfParticles(i); };
199  //
200  G4int GetNumberOfParticles() { return currentSource->GetNumberOfParticles(); };
203  G4double GetParticleEnergy() {return currentSource->GetParticleEnergy();};
204 
205 private:
206 
207  void IntensityNormalization();
208 
209 private:
210  G4bool multiple_vertex;
211  G4bool flat_sampling;
212  G4bool normalised;
213  G4int currentSourceIdx;
214  G4SingleParticleSource* currentSource;
215  std::vector <G4SingleParticleSource*> sourceVector;
216  std::vector <G4double> sourceIntensity;
217  std::vector <G4double>sourceProbability;
218 
219  G4GeneralParticleSourceMessenger* theMessenger;
220 
221 };
222 
223 #endif