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 // 00027 // 00028 // MODULE: G4GeneralParticleSource.hh 00029 // 00030 // Version: 2.0 00031 // Date: 5/02/04 00032 // Author: Fan Lei 00033 // Organisation: QinetiQ ltd. 00034 // Customer: ESA/ESTEC 00035 // 00036 // Documentation avaialable at http://reat.space.qinetiq.com/gps 00037 // These include: 00038 // User Requirement Document (URD) 00039 // Software Specification Documents (SSD) 00040 // Software User Manual (SUM): on-line version available 00041 // Technical Note (TN) on the physics and algorithms 00042 // 00044 // 00045 // CHANGE HISTORY 00046 // -------------- 00047 // 26/10/2004, F Lei 00048 // Added the Multiple_vertex capability. 00049 // Removed "inline" from all Set/Get methods. 00050 // 00051 // Version 2.0, 05/02/2004, Fan Lei, Created. 00052 // based on version 1.1 in Geant4 v6.0 00053 // - Mutilple particle source definition 00054 // - Re-structured commands 00055 // - Split the task into smaller classes 00056 // 00057 // - old commonds have been retained for backward compatibility, but will 00058 // be removed in the future. 00059 // 00061 // 00062 // Class Description: 00063 // 00064 // The General Particle Source is designed to replace the G4ParticleGun class. 00065 // It is designed to allow specification of mutiple particle sources, each with 00066 // independent definitions of particle type, position, direction (or angular) 00067 // and energy distributions. 00068 // 00070 // 00071 // MEMBER FUNCTIONS 00072 // ---------------- 00073 // 00074 // G4GeneralParticleSource() 00075 // Constructor: Initializes variables and instantiates the 00076 // Messenger and generator classes 00077 // 00078 // ~G4GeneralParticleSourceMessenger() 00079 // Destructor: deletes Messenger and others 00080 // 00081 // G4int GetNumberofSource() 00082 // Return the number of particle gun defined 00083 // 00084 // void ListSource() 00085 // List the particle guns defined 00086 // 00087 // void SetCurrentSourceto(G4int) 00088 // set the current gun to the specified one so its definition can be changed 00089 // 00090 // void SetCurrentSourceIntensity(G4double) 00091 // change the current particle gun strength 00092 // 00093 // void SetMultipleVertex(G4bool ) 00094 // Set if multiple vertex per event. 00095 00096 // G4SingleParticleSource* GetCurrentSource() 00097 // return the pointer to current particle gun 00098 // 00099 // G4int GetCurrentSourceIndex() 00100 // return the index of the current particle gun 00101 // 00102 // G4double GetCurrentSourceIntensity() 00103 // return the strength of the current gun 00104 // 00105 // void ClearAll() 00106 // remove all defined aprticle gun 00107 // 00108 // void AddaSource (G4double) 00109 // add a new particle gun with the specified strength 00110 // 00111 // void DeleteaSource(G4int); 00112 // delete the specified particle gun 00113 // 00114 // void SetParticleDefinition (); 00115 // G4ParticleDefinition * GetParticleDefinition () 00116 // Get/Set the particle definition of the primary track 00117 // 00118 // void SetParticleCharge(G4double aCharge) 00119 // set the charge state of the primary track 00120 // 00121 // void SetParticlePolarization (G4ThreeVector aVal) 00122 // G4ThreeVector GetParticlePolarization () 00123 // Set/Get the polarization state of the primary track 00124 // 00125 // void SetParticleTime(G4double aTime) { particle_time = aTime; }; 00126 // G4double GetParticleTime() { return particle_time; }; 00127 // Set/Get the Time. 00128 // 00129 // void SetNumberOfParticles(G4int i) 00130 // G4int GetNumberOfParticles() 00131 // set/get the number of particles to be generated in the primary track 00132 // 00133 // G4ThreeVector GetParticlePosition() 00134 // G4ThreeVector GetParticleMomentumDirection() 00135 // G4double GetParticleEnergy() 00136 // get the position, direction, and energy of the current particle 00137 // 00139 // 00140 #ifndef G4GeneralParticleSource_H 00141 #define G4GeneralParticleSource_H 1 00142 00143 #include "globals.hh" 00144 #include <vector> 00145 00146 #include "G4Event.hh" 00147 #include "G4SingleParticleSource.hh" 00148 // 00149 #include "G4GeneralParticleSourceMessenger.hh" 00150 00151 class G4GeneralParticleSource : public G4VPrimaryGenerator 00152 { 00153 // 00154 public: 00155 00156 G4GeneralParticleSource(); 00157 ~G4GeneralParticleSource(); 00158 00159 void GeneratePrimaryVertex(G4Event*); 00160 00161 G4int GetNumberofSource() { return G4int(sourceVector.size()); }; 00162 void ListSource(); 00163 void SetCurrentSourceto(G4int) ; 00164 void SetCurrentSourceIntensity(G4double); 00165 G4SingleParticleSource* GetCurrentSource() {return currentSource;}; 00166 G4int GetCurrentSourceIndex() { return currentSourceIdx; }; 00167 G4double GetCurrentSourceIntensity() { return sourceIntensity[currentSourceIdx]; }; 00168 void ClearAll(); 00169 void AddaSource (G4double); 00170 void DeleteaSource(G4int); 00171 00172 // Set the verbosity level. 00173 void SetVerbosity(G4int i) {currentSource->SetVerbosity(i);} ; 00174 00175 // Set if multiple vertex per event. 00176 void SetMultipleVertex(G4bool av) {multiple_vertex = av;} ; 00177 00178 // set if flat_sampling is applied in multiple source case 00179 00180 void SetFlatSampling(G4bool av) {flat_sampling = av; normalised = false;} ; 00181 00182 // Set the particle species 00183 void SetParticleDefinition (G4ParticleDefinition * aParticleDefinition) 00184 {currentSource->SetParticleDefinition(aParticleDefinition); } ; 00185 00186 G4ParticleDefinition * GetParticleDefinition () { return currentSource->GetParticleDefinition();} ; 00187 00188 void SetParticleCharge(G4double aCharge) { currentSource->SetParticleCharge(aCharge); } ; 00189 00190 // Set polarization 00191 void SetParticlePolarization (G4ThreeVector aVal) {currentSource->SetParticlePolarization(aVal);}; 00192 G4ThreeVector GetParticlePolarization () {return currentSource->GetParticlePolarization();}; 00193 00194 // Set Time. 00195 void SetParticleTime(G4double aTime) { currentSource->SetParticleTime(aTime); }; 00196 G4double GetParticleTime() { return currentSource->GetParticleTime(); }; 00197 00198 void SetNumberOfParticles(G4int i) { currentSource->SetNumberOfParticles(i); }; 00199 // 00200 G4int GetNumberOfParticles() { return currentSource->GetNumberOfParticles(); }; 00201 G4ThreeVector GetParticlePosition() { return currentSource->GetParticlePosition();}; 00202 G4ThreeVector GetParticleMomentumDirection() { return currentSource->GetParticleMomentumDirection();}; 00203 G4double GetParticleEnergy() {return currentSource->GetParticleEnergy();}; 00204 00205 private: 00206 00207 void IntensityNormalization(); 00208 00209 private: 00210 G4bool multiple_vertex; 00211 G4bool flat_sampling; 00212 G4bool normalised; 00213 G4int currentSourceIdx; 00214 G4SingleParticleSource* currentSource; 00215 std::vector <G4SingleParticleSource*> sourceVector; 00216 std::vector <G4double> sourceIntensity; 00217 std::vector <G4double>sourceProbability; 00218 00219 G4GeneralParticleSourceMessenger* theMessenger; 00220 00221 }; 00222 00223 #endif