#include <G4ParticleGun.hh>
Inheritance diagram for G4ParticleGun:
Definition at line 62 of file G4ParticleGun.hh.
G4ParticleGun::G4ParticleGun | ( | ) |
Definition at line 38 of file G4ParticleGun.cc.
References SetInitialValues().
00039 { 00040 SetInitialValues(); 00041 }
G4ParticleGun::G4ParticleGun | ( | G4int | numberofparticles | ) |
Definition at line 43 of file G4ParticleGun.cc.
References NumberOfParticlesToBeGenerated, and SetInitialValues().
00044 { 00045 SetInitialValues(); 00046 NumberOfParticlesToBeGenerated = numberofparticles; 00047 }
G4ParticleGun::G4ParticleGun | ( | G4ParticleDefinition * | particleDef, | |
G4int | numberofparticles = 1 | |||
) |
Definition at line 50 of file G4ParticleGun.cc.
00051 { 00052 SetInitialValues(); 00053 NumberOfParticlesToBeGenerated = numberofparticles; 00054 SetParticleDefinition( particleDef ); 00055 }
G4ParticleGun::~G4ParticleGun | ( | ) | [virtual] |
void G4ParticleGun::GeneratePrimaryVertex | ( | G4Event * | evt | ) | [virtual] |
Implements G4VPrimaryGenerator.
Definition at line 212 of file G4ParticleGun.cc.
References G4Event::AddPrimaryVertex(), G4ParticleDefinition::GetPDGMass(), NumberOfParticlesToBeGenerated, particle_charge, particle_definition, particle_energy, particle_momentum_direction, particle_polarization, G4VPrimaryGenerator::particle_position, G4VPrimaryGenerator::particle_time, and G4PrimaryVertex::SetPrimary().
00213 { 00214 if(particle_definition==0) return; 00215 00216 // create a new vertex 00217 G4PrimaryVertex* vertex = 00218 new G4PrimaryVertex(particle_position,particle_time); 00219 00220 // create new primaries and set them to the vertex 00221 G4double mass = particle_definition->GetPDGMass(); 00222 for( G4int i=0; i<NumberOfParticlesToBeGenerated; i++ ){ 00223 G4PrimaryParticle* particle = 00224 new G4PrimaryParticle(particle_definition); 00225 particle->SetKineticEnergy( particle_energy ); 00226 particle->SetMass( mass ); 00227 particle->SetMomentumDirection( particle_momentum_direction ); 00228 particle->SetCharge( particle_charge ); 00229 particle->SetPolarization(particle_polarization.x(), 00230 particle_polarization.y(), 00231 particle_polarization.z()); 00232 vertex->SetPrimary( particle ); 00233 } 00234 00235 evt->AddPrimaryVertex( vertex ); 00236 }
G4int G4ParticleGun::GetNumberOfParticles | ( | ) | const [inline] |
Definition at line 118 of file G4ParticleGun.hh.
References NumberOfParticlesToBeGenerated.
Referenced by G4ParticleGunMessenger::GetCurrentValue().
00119 { return NumberOfParticlesToBeGenerated; }
G4double G4ParticleGun::GetParticleCharge | ( | ) | const [inline] |
Definition at line 114 of file G4ParticleGun.hh.
References particle_charge.
00115 { return particle_charge; }
G4ParticleDefinition* G4ParticleGun::GetParticleDefinition | ( | ) | const [inline] |
Definition at line 106 of file G4ParticleGun.hh.
References particle_definition.
Referenced by G4ParticleGunMessenger::GetCurrentValue().
00107 { return particle_definition; }
G4double G4ParticleGun::GetParticleEnergy | ( | ) | const [inline] |
Definition at line 110 of file G4ParticleGun.hh.
References particle_energy.
Referenced by G4ParticleGunMessenger::GetCurrentValue().
00111 { return particle_energy; }
G4double G4ParticleGun::GetParticleMomentum | ( | ) | const [inline] |
Definition at line 112 of file G4ParticleGun.hh.
References particle_momentum.
Referenced by G4ParticleGunMessenger::GetCurrentValue().
00113 { return particle_momentum; }
G4ParticleMomentum G4ParticleGun::GetParticleMomentumDirection | ( | ) | const [inline] |
Definition at line 108 of file G4ParticleGun.hh.
References particle_momentum_direction.
Referenced by G4ParticleGunMessenger::GetCurrentValue().
00109 { return particle_momentum_direction; }
G4ThreeVector G4ParticleGun::GetParticlePolarization | ( | ) | const [inline] |
Definition at line 116 of file G4ParticleGun.hh.
References particle_polarization.
Referenced by G4ParticleGunMessenger::GetCurrentValue().
00117 { return particle_polarization; }
void G4ParticleGun::SetInitialValues | ( | ) | [protected, virtual] |
Definition at line 57 of file G4ParticleGun.cc.
References NumberOfParticlesToBeGenerated, particle_charge, particle_definition, particle_energy, particle_momentum, particle_momentum_direction, particle_polarization, G4VPrimaryGenerator::particle_position, and G4VPrimaryGenerator::particle_time.
Referenced by G4ParticleGun().
00058 { 00059 NumberOfParticlesToBeGenerated = 1; 00060 particle_definition = 0; 00061 G4ThreeVector zero; 00062 particle_momentum_direction = (G4ParticleMomentum)zero; 00063 particle_energy = 0.0; 00064 particle_momentum = 0.0; 00065 particle_position = zero; 00066 particle_time = 0.0; 00067 particle_polarization = zero; 00068 particle_charge = 0.0; 00069 theMessenger = new G4ParticleGunMessenger(this); 00070 }
void G4ParticleGun::SetNumberOfParticles | ( | G4int | i | ) | [inline] |
Definition at line 102 of file G4ParticleGun.hh.
References NumberOfParticlesToBeGenerated.
Referenced by G4ParticleGunMessenger::SetNewValue().
00103 { NumberOfParticlesToBeGenerated = i; }
void G4ParticleGun::SetParticleCharge | ( | G4double | aCharge | ) | [inline] |
Definition at line 98 of file G4ParticleGun.hh.
References particle_charge.
00099 { particle_charge = aCharge; }
void G4ParticleGun::SetParticleDefinition | ( | G4ParticleDefinition * | aParticleDefinition | ) |
Definition at line 102 of file G4ParticleGun.cc.
References FatalException, G4endl, G4Exception(), G4ParticleDefinition::GetDecayTable(), G4ParticleDefinition::GetParticleName(), G4ParticleDefinition::GetPDGCharge(), G4ParticleDefinition::IsShortLived(), and JustWarning.
Referenced by G4ParticleGunMessenger::G4ParticleGunMessenger(), and G4ParticleGunMessenger::SetNewValue().
00103 { 00104 if(!aParticleDefinition) 00105 { 00106 G4Exception("G4ParticleGun::SetParticleDefinition()","Event0101", 00107 FatalException,"Null pointer is given."); 00108 } 00109 if(aParticleDefinition->IsShortLived()) 00110 { 00111 if(!(aParticleDefinition->GetDecayTable())) 00112 { 00113 G4ExceptionDescription ED; 00114 ED << "G4ParticleGun does not support shooting a short-lived particle without a valid decay table." << G4endl; 00115 ED << "G4ParticleGun::SetParticleDefinition for " 00116 << aParticleDefinition->GetParticleName() << " is ignored." << G4endl; 00117 G4Exception("G4ParticleGun::SetParticleDefinition()","Event0102", 00118 JustWarning,ED); 00119 return; 00120 } 00121 } 00122 particle_definition = aParticleDefinition; 00123 particle_charge = particle_definition->GetPDGCharge(); 00124 if(particle_momentum>0.0) 00125 { 00126 G4double mass = particle_definition->GetPDGMass(); 00127 particle_energy = 00128 std::sqrt(particle_momentum*particle_momentum+mass*mass)-mass; 00129 } 00130 }
void G4ParticleGun::SetParticleEnergy | ( | G4double | aKineticEnergy | ) |
Definition at line 132 of file G4ParticleGun.cc.
References G4cout, G4endl, G4ParticleDefinition::GetParticleName(), particle_definition, particle_energy, and particle_momentum.
Referenced by G4ParticleGunMessenger::G4ParticleGunMessenger(), and G4ParticleGunMessenger::SetNewValue().
00133 { 00134 particle_energy = aKineticEnergy; 00135 if(particle_momentum>0.0){ 00136 if(particle_definition){ 00137 G4cout << "G4ParticleGun::" << particle_definition->GetParticleName() 00138 << G4endl; 00139 }else{ 00140 G4cout << "G4ParticleGun::" << " " << G4endl; 00141 } 00142 G4cout << " was defined in terms of Momentum: " 00143 << particle_momentum/GeV << "GeV/c" << G4endl; 00144 G4cout << " is now defined in terms of KineticEnergy: " 00145 << particle_energy/GeV << "GeV" << G4endl; 00146 particle_momentum = 0.0; 00147 } 00148 }
void G4ParticleGun::SetParticleMomentum | ( | G4ParticleMomentum | aMomentum | ) |
Definition at line 180 of file G4ParticleGun.cc.
References G4cout, G4endl, G4ParticleDefinition::GetParticleName(), G4ParticleDefinition::GetPDGMass(), particle_definition, particle_energy, particle_momentum, and particle_momentum_direction.
00181 { 00182 if(particle_energy>0.0){ 00183 if(particle_definition){ 00184 G4cout << "G4ParticleGun::" << particle_definition->GetParticleName() 00185 << G4endl; 00186 }else{ 00187 G4cout << "G4ParticleGun::" << " " << G4endl; 00188 } 00189 G4cout << " was defined in terms of KineticEnergy: " 00190 << particle_energy/GeV << "GeV" << G4endl; 00191 G4cout << " is now defined in terms Momentum: " 00192 << aMomentum.mag()/GeV << "GeV/c" << G4endl; 00193 } 00194 if(particle_definition==0) 00195 { 00196 G4cout <<"Particle Definition not defined yet for G4ParticleGun"<< G4endl; 00197 G4cout <<"Zero Mass is assumed"<<G4endl; 00198 particle_momentum_direction = aMomentum.unit(); 00199 particle_momentum = aMomentum.mag(); 00200 particle_energy = aMomentum.mag(); 00201 } 00202 else 00203 { 00204 G4double mass = particle_definition->GetPDGMass(); 00205 particle_momentum = aMomentum.mag(); 00206 particle_momentum_direction = aMomentum.unit(); 00207 particle_energy = 00208 std::sqrt(particle_momentum*particle_momentum+mass*mass)-mass; 00209 } 00210 }
void G4ParticleGun::SetParticleMomentum | ( | G4double | aMomentum | ) |
Definition at line 150 of file G4ParticleGun.cc.
References G4cout, G4endl, G4ParticleDefinition::GetParticleName(), G4ParticleDefinition::GetPDGMass(), particle_definition, particle_energy, and particle_momentum.
Referenced by G4ParticleGunMessenger::SetNewValue().
00151 { 00152 if(particle_energy>0.0){ 00153 if(particle_definition){ 00154 G4cout << "G4ParticleGun::" << particle_definition->GetParticleName() 00155 << G4endl; 00156 }else{ 00157 G4cout << "G4ParticleGun::" << " " << G4endl; 00158 } 00159 G4cout << " was defined in terms of KineticEnergy: " 00160 << particle_energy/GeV << "GeV" << G4endl; 00161 G4cout << " is now defined in terms Momentum: " 00162 << aMomentum/GeV << "GeV/c" << G4endl; 00163 } 00164 if(particle_definition==0) 00165 { 00166 G4cout <<"Particle Definition not defined yet for G4ParticleGun"<< G4endl; 00167 G4cout <<"Zero Mass is assumed"<<G4endl; 00168 particle_momentum = aMomentum; 00169 particle_energy = aMomentum; 00170 } 00171 else 00172 { 00173 G4double mass = particle_definition->GetPDGMass(); 00174 particle_momentum = aMomentum; 00175 particle_energy = 00176 std::sqrt(particle_momentum*particle_momentum+mass*mass)-mass; 00177 } 00178 }
void G4ParticleGun::SetParticleMomentumDirection | ( | G4ParticleMomentum | aMomentumDirection | ) | [inline] |
Definition at line 96 of file G4ParticleGun.hh.
References particle_momentum_direction.
Referenced by G4ParticleGunMessenger::G4ParticleGunMessenger(), and G4ParticleGunMessenger::SetNewValue().
00097 { particle_momentum_direction = aMomentumDirection.unit(); }
void G4ParticleGun::SetParticlePolarization | ( | G4ThreeVector | aVal | ) | [inline] |
Definition at line 100 of file G4ParticleGun.hh.
References particle_polarization.
Referenced by G4ParticleGunMessenger::SetNewValue().
00101 { particle_polarization = aVal; }
G4int G4ParticleGun::NumberOfParticlesToBeGenerated [protected] |
Definition at line 124 of file G4ParticleGun.hh.
Referenced by G4ParticleGun(), GeneratePrimaryVertex(), GetNumberOfParticles(), SetInitialValues(), and SetNumberOfParticles().
G4double G4ParticleGun::particle_charge [protected] |
Definition at line 129 of file G4ParticleGun.hh.
Referenced by GeneratePrimaryVertex(), GetParticleCharge(), SetInitialValues(), and SetParticleCharge().
G4ParticleDefinition* G4ParticleGun::particle_definition [protected] |
Definition at line 125 of file G4ParticleGun.hh.
Referenced by GeneratePrimaryVertex(), GetParticleDefinition(), SetInitialValues(), SetParticleEnergy(), and SetParticleMomentum().
G4double G4ParticleGun::particle_energy [protected] |
Definition at line 127 of file G4ParticleGun.hh.
Referenced by GeneratePrimaryVertex(), GetParticleEnergy(), SetInitialValues(), SetParticleEnergy(), and SetParticleMomentum().
G4double G4ParticleGun::particle_momentum [protected] |
Definition at line 128 of file G4ParticleGun.hh.
Referenced by GetParticleMomentum(), SetInitialValues(), SetParticleEnergy(), and SetParticleMomentum().
Definition at line 126 of file G4ParticleGun.hh.
Referenced by GeneratePrimaryVertex(), GetParticleMomentumDirection(), SetInitialValues(), SetParticleMomentum(), and SetParticleMomentumDirection().
G4ThreeVector G4ParticleGun::particle_polarization [protected] |
Definition at line 130 of file G4ParticleGun.hh.
Referenced by GeneratePrimaryVertex(), GetParticlePolarization(), SetInitialValues(), and SetParticlePolarization().