#include <G4ParticleGunMessenger.hh>
Inheritance diagram for G4ParticleGunMessenger:
Public Member Functions | |
G4ParticleGunMessenger (G4ParticleGun *fPtclGun) | |
~G4ParticleGunMessenger () | |
void | SetNewValue (G4UIcommand *command, G4String newValues) |
G4String | GetCurrentValue (G4UIcommand *command) |
Definition at line 54 of file G4ParticleGunMessenger.hh.
G4ParticleGunMessenger::G4ParticleGunMessenger | ( | G4ParticleGun * | fPtclGun | ) |
Definition at line 47 of file G4ParticleGunMessenger.cc.
References G4ParticleTable::entries(), G4Geantino::Geantino(), G4ParticleTable::GetParticle(), G4ParticleTable::GetParticleTable(), ns, G4UIcmdWithAString::SetCandidates(), G4UIcmdWith3VectorAndUnit::SetDefaultUnit(), G4UIcmdWithADoubleAndUnit::SetDefaultUnit(), G4UIparameter::SetDefaultValue(), G4UIcmdWithAString::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcommand::SetParameter(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcmdWith3VectorAndUnit::SetParameterName(), G4UIcmdWithADoubleAndUnit::SetParameterName(), G4UIcmdWith3Vector::SetParameterName(), G4UIcmdWithAString::SetParameterName(), G4ParticleGun::SetParticleDefinition(), G4ParticleGun::SetParticleEnergy(), G4ParticleGun::SetParticleMomentumDirection(), G4VPrimaryGenerator::SetParticlePosition(), G4VPrimaryGenerator::SetParticleTime(), and G4UIcommand::SetRange().
00048 :fParticleGun(fPtclGun),fShootIon(false) 00049 { 00050 particleTable = G4ParticleTable::GetParticleTable(); 00051 00052 gunDirectory = new G4UIdirectory("/gun/"); 00053 gunDirectory->SetGuidance("Particle Gun control commands."); 00054 00055 listCmd = new G4UIcmdWithoutParameter("/gun/List",this); 00056 listCmd->SetGuidance("List available particles."); 00057 listCmd->SetGuidance(" Invoke G4ParticleTable."); 00058 00059 particleCmd = new G4UIcmdWithAString("/gun/particle",this); 00060 particleCmd->SetGuidance("Set particle to be generated."); 00061 particleCmd->SetGuidance(" (geantino is default)"); 00062 particleCmd->SetGuidance(" (ion can be specified for shooting ions)"); 00063 particleCmd->SetParameterName("particleName",true); 00064 particleCmd->SetDefaultValue("geantino"); 00065 G4String candidateList; 00066 G4int nPtcl = particleTable->entries(); 00067 for(G4int i=0;i<nPtcl;i++) 00068 { 00069 G4ParticleDefinition* pd = particleTable->GetParticle(i); 00070 if( !(pd->IsShortLived()) || pd->GetDecayTable() ) 00071 { 00072 candidateList += pd->GetParticleName(); 00073 candidateList += " "; 00074 } 00075 } 00076 candidateList += "ion "; 00077 particleCmd->SetCandidates(candidateList); 00078 00079 directionCmd = new G4UIcmdWith3Vector("/gun/direction",this); 00080 directionCmd->SetGuidance("Set momentum direction."); 00081 directionCmd->SetGuidance("Direction needs not to be a unit vector."); 00082 directionCmd->SetParameterName("ex","ey","ez",true,true); 00083 directionCmd->SetRange("ex != 0 || ey != 0 || ez != 0"); 00084 00085 energyCmd = new G4UIcmdWithADoubleAndUnit("/gun/energy",this); 00086 energyCmd->SetGuidance("Set kinetic energy."); 00087 energyCmd->SetParameterName("Energy",true,true); 00088 energyCmd->SetDefaultUnit("GeV"); 00089 //energyCmd->SetUnitCategory("Energy"); 00090 //energyCmd->SetUnitCandidates("eV keV MeV GeV TeV"); 00091 00092 momCmd = new G4UIcmdWith3VectorAndUnit("/gun/momentum",this); 00093 momCmd->SetGuidance("Set momentum. This command is equivalent to two commands /gun/direction and /gun/momentumAmp"); 00094 momCmd->SetParameterName("px","py","pz",true,true); 00095 momCmd->SetRange("px != 0 || py != 0 || pz != 0"); 00096 momCmd->SetDefaultUnit("GeV"); 00097 00098 momAmpCmd = new G4UIcmdWithADoubleAndUnit("/gun/momentumAmp",this); 00099 momAmpCmd->SetGuidance("Set absolute value of momentum."); 00100 momAmpCmd->SetGuidance("Direction should be set by /gun/direction command."); 00101 momAmpCmd->SetGuidance("This command should be used alternatively with /gun/energy."); 00102 momAmpCmd->SetParameterName("Momentum",true,true); 00103 momAmpCmd->SetDefaultUnit("GeV"); 00104 00105 positionCmd = new G4UIcmdWith3VectorAndUnit("/gun/position",this); 00106 positionCmd->SetGuidance("Set starting position of the particle."); 00107 positionCmd->SetParameterName("X","Y","Z",true,true); 00108 positionCmd->SetDefaultUnit("cm"); 00109 //positionCmd->SetUnitCategory("Length"); 00110 //positionCmd->SetUnitCandidates("microm mm cm m km"); 00111 00112 timeCmd = new G4UIcmdWithADoubleAndUnit("/gun/time",this); 00113 timeCmd->SetGuidance("Set initial time of the particle."); 00114 timeCmd->SetParameterName("t0",true,true); 00115 timeCmd->SetDefaultUnit("ns"); 00116 //timeCmd->SetUnitCategory("Time"); 00117 //timeCmd->SetUnitCandidates("ns ms s"); 00118 00119 polCmd = new G4UIcmdWith3Vector("/gun/polarization",this); 00120 polCmd->SetGuidance("Set polarization."); 00121 polCmd->SetParameterName("Px","Py","Pz",true,true); 00122 polCmd->SetRange("Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1."); 00123 00124 numberCmd = new G4UIcmdWithAnInteger("/gun/number",this); 00125 numberCmd->SetGuidance("Set number of particles to be generated."); 00126 numberCmd->SetParameterName("N",true,true); 00127 numberCmd->SetRange("N>0"); 00128 00129 ionCmd = new G4UIcommand("/gun/ion",this); 00130 ionCmd->SetGuidance("Set properties of ion to be generated."); 00131 ionCmd->SetGuidance("[usage] /gun/ion Z A Q"); 00132 ionCmd->SetGuidance(" Z:(int) AtomicNumber"); 00133 ionCmd->SetGuidance(" A:(int) AtomicMass"); 00134 ionCmd->SetGuidance(" Q:(int) Charge of Ion (in unit of e)"); 00135 ionCmd->SetGuidance(" E:(double) Excitation energy (in keV)"); 00136 00137 G4UIparameter* param; 00138 param = new G4UIparameter("Z",'i',false); 00139 param->SetDefaultValue("1"); 00140 ionCmd->SetParameter(param); 00141 param = new G4UIparameter("A",'i',false); 00142 param->SetDefaultValue("1"); 00143 ionCmd->SetParameter(param); 00144 param = new G4UIparameter("Q",'i',true); 00145 param->SetDefaultValue("0"); 00146 ionCmd->SetParameter(param); 00147 param = new G4UIparameter("E",'d',true); 00148 param->SetDefaultValue("0.0"); 00149 ionCmd->SetParameter(param); 00150 00151 // set initial value to G4ParticleGun 00152 fParticleGun->SetParticleDefinition( G4Geantino::Geantino() ); 00153 fParticleGun->SetParticleMomentumDirection( G4ThreeVector(1.0,0.0,0.0) ); 00154 fParticleGun->SetParticleEnergy( 1.0*GeV ); 00155 fParticleGun->SetParticlePosition(G4ThreeVector(0.0*cm, 0.0*cm, 0.0*cm)); 00156 fParticleGun->SetParticleTime( 0.0*ns ); 00157 }
G4ParticleGunMessenger::~G4ParticleGunMessenger | ( | ) |
Definition at line 159 of file G4ParticleGunMessenger.cc.
00160 { 00161 delete listCmd; 00162 delete particleCmd; 00163 delete directionCmd; 00164 delete energyCmd; 00165 delete momCmd; 00166 delete momAmpCmd; 00167 delete positionCmd; 00168 delete timeCmd; 00169 delete polCmd; 00170 delete numberCmd; 00171 delete ionCmd; 00172 delete gunDirectory; 00173 }
G4String G4ParticleGunMessenger::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 210 of file G4ParticleGunMessenger.cc.
References G4UIcommand::ConvertToString(), G4cerr, G4endl, G4ParticleGun::GetNumberOfParticles(), G4ParticleGun::GetParticleDefinition(), G4ParticleGun::GetParticleEnergy(), G4ParticleGun::GetParticleMomentum(), G4ParticleGun::GetParticleMomentumDirection(), G4ParticleDefinition::GetParticleName(), G4ParticleGun::GetParticlePolarization(), G4VPrimaryGenerator::GetParticlePosition(), G4VPrimaryGenerator::GetParticleTime(), and G4UImessenger::ItoS().
00211 { 00212 G4String cv; 00213 00214 if( command==directionCmd ) 00215 { cv = directionCmd->ConvertToString(fParticleGun->GetParticleMomentumDirection()); } 00216 else if( command==particleCmd ) 00217 { cv = fParticleGun->GetParticleDefinition()->GetParticleName(); } 00218 else if( command==energyCmd ) 00219 { 00220 G4double ene = fParticleGun->GetParticleEnergy(); 00221 if(ene == 0.) 00222 { G4cerr << " G4ParticleGun: was defined in terms of momentum." << G4endl; } 00223 else 00224 { cv = energyCmd->ConvertToString(ene,"GeV"); } 00225 } 00226 else if( command==momCmd || command==momAmpCmd ) 00227 { 00228 G4double mom = fParticleGun->GetParticleMomentum(); 00229 if(mom == 0.) 00230 { G4cerr << " G4ParticleGun: was defined in terms of kinetic energy." << G4endl; } 00231 else 00232 { 00233 if( command==momCmd ) 00234 { cv = momCmd->ConvertToString(mom*(fParticleGun->GetParticleMomentumDirection()),"GeV"); } 00235 else 00236 { cv = momAmpCmd->ConvertToString(mom,"GeV"); } 00237 } 00238 } 00239 else if( command==positionCmd ) 00240 { cv = positionCmd->ConvertToString(fParticleGun->GetParticlePosition(),"cm"); } 00241 else if( command==timeCmd ) 00242 { cv = timeCmd->ConvertToString(fParticleGun->GetParticleTime(),"ns"); } 00243 else if( command==polCmd ) 00244 { cv = polCmd->ConvertToString(fParticleGun->GetParticlePolarization()); } 00245 else if( command==numberCmd ) 00246 { cv = numberCmd->ConvertToString(fParticleGun->GetNumberOfParticles()); } 00247 else if( command==ionCmd ) 00248 { 00249 if (fShootIon) { 00250 cv = ItoS(fAtomicNumber) + " " + ItoS(fAtomicMass) + " "; 00251 cv += ItoS(fIonCharge); 00252 } else { 00253 cv = ""; 00254 } 00255 } 00256 return cv; 00257 }
void G4ParticleGunMessenger::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValues | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 175 of file G4ParticleGunMessenger.cc.
References G4ParticleTable::DumpTable(), G4ParticleTable::FindParticle(), G4UIcmdWith3VectorAndUnit::GetNew3VectorValue(), G4UIcmdWith3Vector::GetNew3VectorValue(), G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(), G4UIcmdWithAnInteger::GetNewIntValue(), G4ParticleGun::SetNumberOfParticles(), G4ParticleGun::SetParticleDefinition(), G4ParticleGun::SetParticleEnergy(), G4ParticleGun::SetParticleMomentum(), G4ParticleGun::SetParticleMomentumDirection(), G4ParticleGun::SetParticlePolarization(), G4VPrimaryGenerator::SetParticlePosition(), and G4VPrimaryGenerator::SetParticleTime().
00176 { 00177 if( command==listCmd ) 00178 { particleTable->DumpTable(); } 00179 else if( command==particleCmd ) 00180 { 00181 if (newValues =="ion") { 00182 fShootIon = true; 00183 } else { 00184 fShootIon = false; 00185 G4ParticleDefinition* pd = particleTable->FindParticle(newValues); 00186 if(pd != 0) 00187 { fParticleGun->SetParticleDefinition( pd ); } 00188 } 00189 } 00190 else if( command==directionCmd ) 00191 { fParticleGun->SetParticleMomentumDirection(directionCmd->GetNew3VectorValue(newValues)); } 00192 else if( command==energyCmd ) 00193 { fParticleGun->SetParticleEnergy(energyCmd->GetNewDoubleValue(newValues)); } 00194 else if( command==momCmd ) 00195 { fParticleGun->SetParticleMomentum(momCmd->GetNew3VectorValue(newValues)); } 00196 else if( command==momAmpCmd ) 00197 { fParticleGun->SetParticleMomentum(momAmpCmd->GetNewDoubleValue(newValues)); } 00198 else if( command==positionCmd ) 00199 { fParticleGun->SetParticlePosition(positionCmd->GetNew3VectorValue(newValues)); } 00200 else if( command==timeCmd ) 00201 { fParticleGun->SetParticleTime(timeCmd->GetNewDoubleValue(newValues)); } 00202 else if( command==polCmd ) 00203 { fParticleGun->SetParticlePolarization(polCmd->GetNew3VectorValue(newValues)); } 00204 else if( command==numberCmd ) 00205 { fParticleGun->SetNumberOfParticles(numberCmd->GetNewIntValue(newValues)); } 00206 else if( command==ionCmd ) 00207 { IonCommand(newValues); } 00208 }