95 if ( theInstance != 0 ) {
102 G4GeneralParticleSourceMessenger::G4GeneralParticleSourceMessenger
104 : fGPS(fPtclGun),fParticleGun(0),fShootIon(false),
105 fAtomicNumber(0),fAtomicMass(0),fIonCharge(0),fIonExciteEnergy(0.),
106 fShootIonL(0),fAtomicNumberL(0),fAtomicMassL(0),fIonChargeL(0),fIonEnergyLevel(0)
131 gpsDirectory->
SetGuidance(
"General Paricle Source control commands.");
136 sourceDirectory->
SetGuidance(
"Multiple source control sub-directory");
139 addsourceCmd->
SetGuidance(
"add a new source defintion to the particle gun with the specified intensity");
141 addsourceCmd->
SetRange(
"addsource > 0.");
144 listsourceCmd->
SetGuidance(
"List the defined particle sources");
147 clearsourceCmd->
SetGuidance(
"Remove all the defined particle sources");
150 getsourceCmd->
SetGuidance(
"Show the current source index and intensity");
153 setsourceCmd->
SetGuidance(
"set the indexed source as the current one");
154 setsourceCmd->
SetGuidance(
" so one can change its source definition");
156 setsourceCmd->
SetRange(
"setsource >= 0");
159 deletesourceCmd->
SetGuidance(
"delete the indexed source from the list");
161 deletesourceCmd->
SetRange(
"deletesource > 0");
164 setintensityCmd->
SetGuidance(
"reset the current source to the specified intensity");
166 setintensityCmd->
SetRange(
"setintensity > 0.");
168 multiplevertexCmd =
new G4UIcmdWithABool(
"/gps/source/multiplevertex",
this);
169 multiplevertexCmd->
SetGuidance(
"true for simulaneous generation mutiple vertex");
170 multiplevertexCmd->
SetGuidance(
"Default is false");
175 flatsamplingCmd->
SetGuidance(
"true for applying flat (biased) sampling among the sources");
187 particleCmd->
SetGuidance(
"Set particle to be generated.");
188 particleCmd->
SetGuidance(
" (geantino is default)");
189 particleCmd->
SetGuidance(
" (ion can be specified for shooting ions)");
194 for(
G4int i=0;i<nPtcl;i++)
197 candidateList +=
" ";
199 candidateList +=
"ion ";
203 directionCmd->
SetGuidance(
"Set momentum direction.");
204 directionCmd->
SetGuidance(
"Direction needs not to be a unit vector.");
205 directionCmd->
SetGuidance(
"Angular distribution type is set to planar.");
207 directionCmd->
SetRange(
"Px != 0 || Py != 0 || Pz != 0");
217 positionCmd->
SetGuidance(
"Set starting position of the particle for a Point like source.");
218 positionCmd->
SetGuidance(
"Same effect as the two /gps/pos/type Point /gps/pos/centre commands.");
225 ionCmd->
SetGuidance(
"Set properties of ion to be generated.");
229 ionCmd->
SetGuidance(
" Q:(int) Charge of Ion (in unit of e)");
230 ionCmd->
SetGuidance(
" E:(double) Excitation energy (in keV)");
247 ionLvlCmd->
SetGuidance(
"Set properties of ion to be generated.");
248 ionLvlCmd->
SetGuidance(
"[usage] /gps/ion Z A Q Lvl");
251 ionLvlCmd->
SetGuidance(
" Q:(int) Charge of Ion (in unit of e)");
252 ionLvlCmd->
SetGuidance(
" Lvl:(int) Number of metastable state excitation level (0-9)");
269 timeCmd->
SetGuidance(
"Set initial time of the particle.");
278 polCmd->
SetRange(
"Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1.");
281 numberCmd->
SetGuidance(
"Set number of particles to be generated per vertex.");
287 verbosityCmd->
SetGuidance(
"Set Verbose level for GPS");
289 verbosityCmd->
SetGuidance(
" 1 : Limited information");
290 verbosityCmd->
SetGuidance(
" 2 : Detailed information");
292 verbosityCmd->
SetRange(
"level>=0 && level <=2");
297 positionDirectory->
SetGuidance(
"Positional commands sub-directory");
300 typeCmd1->
SetGuidance(
"Sets source distribution type.");
301 typeCmd1->
SetGuidance(
"Either Point, Beam, Plane, Surface or Volume");
307 shapeCmd1->
SetGuidance(
"Sets source shape for Plan, Surface or Volume type source.");
310 shapeCmd1->
SetCandidates(
"Circle Annulus Ellipse Square Rectangle Sphere Ellipsoid Cylinder Para");
313 centreCmd1->
SetGuidance(
"Set centre coordinates of source.");
320 posrot1Cmd1->
SetGuidance(
"Set the 1st vector defining the rotation matrix'.");
321 posrot1Cmd1->
SetGuidance(
"It does not need to be a unit vector.");
323 posrot1Cmd1->
SetRange(
"R1x != 0 || R1y != 0 || R1z != 0");
326 posrot2Cmd1->
SetGuidance(
"Set the 2nd vector defining the rotation matrix'.");
327 posrot2Cmd1->
SetGuidance(
"It does not need to be a unit vector.");
329 posrot2Cmd1->
SetRange(
"R2x != 0 || R2y != 0 || R2z != 0");
332 halfxCmd1->
SetGuidance(
"Set x half length of source.");
338 halfyCmd1->
SetGuidance(
"Set y half length of source.");
344 halfzCmd1->
SetGuidance(
"Set z half length of source.");
356 radius0Cmd1->
SetGuidance(
"Set inner radius of source when required.");
362 possigmarCmd1->
SetGuidance(
"Set standard deviation in radial of the beam positional profile");
363 possigmarCmd1->
SetGuidance(
" applicable to Beam type source only");
369 possigmaxCmd1->
SetGuidance(
"Set standard deviation of beam positional profile in x-dir");
370 possigmaxCmd1->
SetGuidance(
" applicable to Beam type source only");
376 possigmayCmd1->
SetGuidance(
"Set standard deviation of beam positional profile in y-dir");
377 possigmayCmd1->
SetGuidance(
" applicable to Beam type source only");
383 paralpCmd1->
SetGuidance(
"Angle from y-axis of y' in Para");
389 partheCmd1->
SetGuidance(
"Polar angle through centres of z faces");
395 parphiCmd1->
SetGuidance(
"Azimuth angle through centres of z faces");
401 confineCmd1->
SetGuidance(
"Confine source to volume (NULL to unset).");
402 confineCmd1->
SetGuidance(
"usage: confine VolName");
512 angularDirectory->
SetGuidance(
"Angular commands sub-directory");
515 angtypeCmd1->
SetGuidance(
"Sets angular source distribution type");
516 angtypeCmd1->
SetGuidance(
"Possible variables are: iso, cos, planar, beam1d, beam2d, focused or user");
519 angtypeCmd1->
SetCandidates(
"iso cos planar beam1d beam2d focused user");
522 angrot1Cmd1->
SetGuidance(
"Sets the 1st vector for angular distribution rotation matrix");
523 angrot1Cmd1->
SetGuidance(
"Need not be a unit vector");
525 angrot1Cmd1->
SetRange(
"AR1x != 0 || AR1y != 0 || AR1z != 0");
528 angrot2Cmd1->
SetGuidance(
"Sets the 2nd vector for angular distribution rotation matrix");
529 angrot2Cmd1->
SetGuidance(
"Need not be a unit vector");
531 angrot2Cmd1->
SetRange(
"AR2x != 0 || AR2y != 0 || AR2z != 0");
561 angsigmarCmd1->
SetGuidance(
"Set standard deviation in direction for 1D beam.");
567 angsigmaxCmd1->
SetGuidance(
"Set standard deviation in direction in x-direc. for 2D beam");
573 angsigmayCmd1->
SetGuidance(
"Set standard deviation in direction in y-direc. for 2D beam");
579 angfocusCmd->
SetGuidance(
"Set the focusing point for the beam");
585 useuserangaxisCmd1->
SetGuidance(
"true for using user defined angular co-ordinates");
586 useuserangaxisCmd1->
SetGuidance(
"Default is false");
591 surfnormCmd1->
SetGuidance(
"Makes a user-defined distribution with respect to surface normals rather than x,y,z axes.");
674 energyDirectory->
SetGuidance(
"Spectral commands sub-directory");
677 energytypeCmd1->
SetGuidance(
"Sets energy distribution type");
680 energytypeCmd1->
SetCandidates(
"Mono Lin Pow Exp Gauss Brem Bbody Cdg User Arb Epn");
695 monoenergyCmd1->
SetGuidance(
"Sets a monocromatic energy (same as gps/energy)");
701 engsigmaCmd1->
SetGuidance(
"Sets the standard deviation for Gaussian energy dist.");
707 alphaCmd1->
SetGuidance(
"Sets Alpha (index) for power-law energy dist.");
711 tempCmd1->
SetGuidance(
"Sets the temperature for Brem and BBody distributions (in Kelvin)");
715 ezeroCmd1->
SetGuidance(
"Sets E_0 for exponential distribution (in MeV)");
719 gradientCmd1->
SetGuidance(
"Sets the gradient for Lin distribution (in 1/MeV)");
723 interceptCmd1->
SetGuidance(
"Sets the intercept for Lin distributions (in MeV)");
727 arbeintCmd1->
SetGuidance(
"Set the power-law index for the energy sampling distri. )");
731 calculateCmd1->
SetGuidance(
"Calculates the distributions for Cdg and BBody");
734 energyspecCmd1->
SetGuidance(
"True for energy and false for momentum spectra");
739 diffspecCmd1->
SetGuidance(
"True for differential and flase for integral spectra");
809 histDirectory->
SetGuidance(
"Histogram, biasing commands sub-directory");
815 histnameCmd1->
SetCandidates(
"biasx biasy biasz biast biasp biase biaspt biaspp theta phi energy arb epn");
818 resethistCmd1->
SetGuidance(
"Reset (clean) the histogram ");
821 resethistCmd1->
SetCandidates(
"biasx biasy biasz biast biasp biase biaspt biaspp theta phi energy arb epn");
824 histpointCmd1->
SetGuidance(
"Allows user to define a histogram");
827 histpointCmd1->
SetRange(
"Ehi >= 0. && Weight >= 0.");
830 histfileCmd1->
SetGuidance(
"import the arb energy hist in an ASCII file");
834 arbintCmd1->
SetGuidance(
"Sets the interpolation method for arbitrary distribution.");
867 G4GeneralParticleSourceMessenger::~G4GeneralParticleSourceMessenger()
869 delete positionDirectory;
897 delete possigmarCmd1;
898 delete possigmaxCmd1;
899 delete possigmayCmd1;
905 delete angularDirectory;
925 delete angsigmarCmd1;
926 delete angsigmaxCmd1;
927 delete angsigmayCmd1;
929 delete useuserangaxisCmd1;
932 delete energyDirectory;
946 delete energytypeCmd1;
949 delete monoenergyCmd1;
955 delete interceptCmd1;
957 delete calculateCmd1;
958 delete energyspecCmd1;
961 delete histDirectory;
967 delete resethistCmd1;
968 delete histpointCmd1;
984 delete sourceDirectory;
986 delete listsourceCmd;
987 delete clearsourceCmd;
990 delete setintensityCmd;
991 delete deletesourceCmd;
992 delete multiplevertexCmd;
993 delete flatsamplingCmd;
999 #define CHECKPG() { if (fParticleGun==NULL) { \
1000 G4ExceptionDescription msg; \
1001 msg << "Command "<< command->GetCommandPath()<<"/";\
1002 msg<<command->GetCommandName() << " used but no particle sources are set.";\
1003 msg <<" Add at least a source with: /gps/source/add.";\
1004 G4Exception("G4GeneralParticleSourceMessenger::SetNewValue","G4GPS003",\
1005 FatalException,msg); return;\
1366 if( command==directionCmd )
1372 else if( command==energyCmd )
1378 else if( command==positionCmd )
1384 else if(command == verbosityCmd)
1390 else if( command==particleCmd )
1392 if (newValues ==
"ion") {
1401 else if( command==timeCmd )
1403 else if( command==polCmd )
1405 else if( command==numberCmd )
1407 else if( command==ionCmd )
1408 { IonCommand(newValues); }
1409 else if( command==ionLvlCmd )
1410 { IonLvlCommand(newValues); }
1411 else if( command==listCmd ){
1414 else if( command==addsourceCmd )
1418 else if( command==listsourceCmd )
1422 else if( command==clearsourceCmd )
1427 else if( command==getsourceCmd )
1432 else if( command==setsourceCmd )
1451 else if( command==setintensityCmd )
1455 else if( command==deletesourceCmd )
1459 else if(command == multiplevertexCmd)
1463 else if(command == flatsamplingCmd)
1471 else if(command == typeCmd1)
1476 else if(command == shapeCmd1)
1481 else if(command == centreCmd1)
1486 else if(command == posrot1Cmd1)
1491 else if(command == posrot2Cmd1)
1496 else if(command == halfxCmd1)
1501 else if(command == halfyCmd1)
1506 else if(command == halfzCmd1)
1511 else if(command == radiusCmd1)
1516 else if(command == radius0Cmd1)
1521 else if(command == possigmarCmd1)
1526 else if(command == possigmaxCmd1)
1530 else if(command == possigmayCmd1)
1534 else if(command == paralpCmd1)
1538 else if(command == partheCmd1)
1542 else if(command == parphiCmd1)
1546 else if(command == confineCmd1)
1550 else if(command == angtypeCmd1)
1554 else if(command == angrot1Cmd1)
1560 else if(command == angrot2Cmd1)
1566 else if(command == minthetaCmd1)
1571 else if(command == minphiCmd1)
1575 else if(command == maxthetaCmd1)
1579 else if(command == maxphiCmd1)
1583 else if(command == angsigmarCmd1)
1587 else if(command == angsigmaxCmd1)
1591 else if(command == angsigmayCmd1)
1595 else if(command == angfocusCmd)
1599 else if(command == useuserangaxisCmd1)
1603 else if(command == surfnormCmd1)
1607 else if(command == energytypeCmd1)
1611 else if(command == eminCmd1)
1615 else if(command == emaxCmd1)
1619 else if(command == monoenergyCmd1)
1623 else if(command == engsigmaCmd1)
1627 else if(command == alphaCmd1)
1631 else if(command == tempCmd1)
1635 else if(command == ezeroCmd1)
1639 else if(command == gradientCmd1)
1643 else if(command == interceptCmd1)
1647 else if(command == arbeintCmd1)
1651 else if(command == calculateCmd1)
1655 else if(command == energyspecCmd1)
1659 else if(command == diffspecCmd1)
1663 else if(command == histnameCmd1)
1665 histtype = newValues;
1667 else if(command == histfileCmd1)
1672 else if(command == histpointCmd1)
1675 if(histtype ==
"biasx")
1677 if(histtype ==
"biasy")
1679 if(histtype ==
"biasz")
1681 if(histtype ==
"biast")
1683 if(histtype ==
"biasp")
1685 if(histtype ==
"biaspt")
1687 if(histtype ==
"biaspp")
1689 if(histtype ==
"biase")
1691 if(histtype ==
"theta")
1693 if(histtype ==
"phi")
1695 if(histtype ==
"energy")
1697 if(histtype ==
"arb")
1699 if(histtype ==
"epn")
1702 else if(command == resethistCmd1)
1705 if(newValues ==
"theta" || newValues ==
"phi") {
1707 }
else if (newValues ==
"energy" || newValues ==
"arb" || newValues ==
"epn") {
1713 else if(command == arbintCmd1)
1740 cv =
"Not implemented yet";
1745 void G4GeneralParticleSourceMessenger::IonCommand(
G4String newValues)
1753 fAtomicNumber =
StoI(next());
1754 fAtomicMass =
StoI(next());
1758 fIonCharge = fAtomicNumber;
1762 fIonCharge =
StoI(sQ);
1766 fIonExciteEnergy = 0.0;
1770 fIonExciteEnergy =
StoD(sQ) *
keV;
1777 G4cout <<
"Ion with Z=" << fAtomicNumber;
1778 G4cout <<
" A=" << fAtomicMass <<
" is not defined" <<
G4endl;
1788 G4cout <<
"Set /gps/particle to ion before using /gps/ion command";
1793 void G4GeneralParticleSourceMessenger::IonLvlCommand(
G4String newValues)
1800 fAtomicNumberL =
StoI(next());
1801 fAtomicMassL =
StoI(next());
1804 fIonChargeL = fAtomicNumberL;
1806 fIonChargeL =
StoI(sQ);
1809 fIonEnergyLevel = 0;
1811 fIonEnergyLevel =
StoI(sQ);
1818 G4cout <<
"Ion with Z=" << fAtomicNumberL;
1819 G4cout <<
" A=" << fAtomicMassL <<
" is not defined" <<
G4endl;
1826 G4cout <<
"Set /gps/particle to ion before using /gps/ionLvl command";
static G4GeneralParticleSourceMessenger * GetInstance(G4GeneralParticleSource *)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetBeamSigmaInE(G4double)
G4SPSAngDistribution * GetAngDist() const
void SetParameter(G4UIparameter *const newParameter)
G4SPSEneDistribution * GetEneDist() const
void SetParticleTime(G4double aTime)
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetDefaultValue(G4double defVal)
void AddaSource(G4double)
G4SPSPosDistribution * GetPosDist() const
void DumpTable(const G4String &particle_name="ALL")
void SetPosDisType(G4String)
void SetParTheta(G4double)
std::ostringstream G4ExceptionDescription
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetBeamSigmaInX(G4double)
void ArbEnergyHisto(G4ThreeVector)
static G4int GetNewIntValue(const char *paramString)
void SetBeamSigmaInAngR(G4double)
std::vector< ExP01TrackerHit * > a
const G4String & GetParticleName(G4int index) const
G4int GetCurrentSourceIndex() const
void SetDefaultUnit(const char *defUnit)
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetMultipleVertex(G4bool av)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetDefaultValue(const char *theDefaultValue)
void SetParAlpha(G4double)
void SetBeamSigmaInAngY(G4double)
void SetMinTheta(G4double)
void SetEnergyBias(G4ThreeVector)
void SetNewValue(G4UIcommand *command, G4String newValues)
void SetUseUserAngAxis(G4bool)
void SetYBias(G4ThreeVector)
static G4double GetNewDoubleValue(const char *paramString)
void SetCurrentSourceIntensity(G4double)
void SetPosThetaBias(G4ThreeVector)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
static G4bool GetNewBoolValue(const char *paramString)
#define G4MUTEX_INITIALIZER
void SetVerbosity(G4int i)
void SetThetaBias(G4ThreeVector)
void SetZBias(G4ThreeVector)
void SetXBias(G4ThreeVector)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void UserDefAngPhi(G4ThreeVector)
void UserDefAngTheta(G4ThreeVector)
G4GLOB_DLL std::ostream G4cout
void SetCentreCoords(G4ThreeVector)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetEnergyDisType(G4String)
void SetBeamSigmaInR(G4double)
G4SPSRandomGenerator * GetBiasRndm() const
static G4double GetNewDoubleValue(const char *paramString)
void SetRange(const char *rs)
void SetGuidance(const char *aGuidance)
static constexpr double eplus
void DefineAngRefAxes(G4String, G4ThreeVector)
void SetParticlePolarization(G4ThreeVector aVal)
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
void SetPosRot1(G4ThreeVector)
const G4String & GetCommandPath() const
G4double GetCurrentSourceIntensity() const
void SetPosDisShape(G4String)
static G4IonTable * GetIonTable()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void ArbInterpolate(G4String)
void EpnEnergyHisto(G4ThreeVector)
G4String GetCurrentValue(G4UIcommand *command)
const G4String & GetCommandName() const
void SetPhiBias(G4ThreeVector)
void InputEnergySpectra(G4bool)
void SetAngDistType(G4String)
static G4ParticleTable * GetParticleTable()
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetGradient(G4double)
void UserEnergyHisto(G4ThreeVector)
G4double StoD(G4String s)
void SetPosRot2(G4ThreeVector)
void SetInterCept(G4double)
void SetDefaultUnit(const char *defUnit)
void InputDifferentialSpectra(G4bool)
void SetFocusPoint(G4ThreeVector)
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
void SetBiasAlpha(G4double)
void SetCandidates(const char *candidateList)
void DeleteaSource(G4int)
static constexpr double pi
G4bool commandsShouldBeInMaster
void SetCurrentSourceto(G4int)
void ArbEnergyHistoFile(G4String)
void SetUserWRTSurface(G4bool)
void SetParticleCharge(G4double aCharge)
void ConfineSourceToVolume(G4String)
void SetFlatSampling(G4bool av)
void SetMaxTheta(G4double)
static constexpr double keV
void SetRadius0(G4double)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4int GetNumberofSource()
void SetBeamSigmaInY(G4double)
void SetNumberOfParticles(G4int i)
void SetMonoEnergy(G4double)
void SetPosPhiBias(G4ThreeVector)
void SetBeamSigmaInAngX(G4double)