68 if ( theInstance ==
nullptr )
76 if ( theInstance !=
nullptr )
79 theInstance =
nullptr;
85G4GeneralParticleSourceMessenger::
112 gpsDirectory->
SetGuidance(
"General Particle Source control commands.");
117 sourceDirectory->
SetGuidance(
"Multiple source control sub-directory");
120 addsourceCmd->
SetGuidance(
"Add a new source definition to the particle gun");
121 addsourceCmd->
SetGuidance(
" with the specified intensity");
123 addsourceCmd->
SetRange(
"addsource > 0.");
126 listsourceCmd->
SetGuidance(
"List the defined particle sources");
129 clearsourceCmd->
SetGuidance(
"Remove all the defined particle sources");
132 getsourceCmd->
SetGuidance(
"Show the current source index and intensity");
135 setsourceCmd->
SetGuidance(
"Set the indexed source as the current one");
136 setsourceCmd->
SetGuidance(
" so one can change its source definition");
138 setsourceCmd->
SetRange(
"setsource >= 0");
141 deletesourceCmd->
SetGuidance(
"Delete the indexed source from the list");
143 deletesourceCmd->
SetRange(
"deletesource > 0");
146 setintensityCmd->
SetGuidance(
"Reset the current source to the specified intensity");
148 setintensityCmd->
SetRange(
"setintensity > 0.");
150 multiplevertexCmd =
new G4UIcmdWithABool(
"/gps/source/multiplevertex",
this);
151 multiplevertexCmd->
SetGuidance(
"True for simultaneous generation multiple vertex");
152 multiplevertexCmd->
SetGuidance(
" Default is false");
157 flatsamplingCmd->
SetGuidance(
"True for applying flat (biased) sampling among the sources");
169 particleCmd->
SetGuidance(
"Set particle to be generated.");
170 particleCmd->
SetGuidance(
" (geantino is default)");
171 particleCmd->
SetGuidance(
" (ion can be specified for shooting ions)");
176 for(
G4int i=0; i<nPtcl; ++i)
179 candidateList +=
" ";
181 candidateList +=
"ion ";
185 directionCmd->
SetGuidance(
"Set momentum direction.");
186 directionCmd->
SetGuidance(
" Direction needs not to be a unit vector.");
187 directionCmd->
SetGuidance(
" Angular distribution type is set to planar.");
189 directionCmd->
SetRange(
"Px != 0 || Py != 0 || Pz != 0");
199 positionCmd->
SetGuidance(
"Set starting position of the particle for a Point like source.");
200 positionCmd->
SetGuidance(
" Same effect as the two /gps/pos/type Point /gps/pos/centre commands.");
207 ionCmd->
SetGuidance(
"Set properties of ion to be generated.");
211 ionCmd->
SetGuidance(
" Q:(int) Charge of Ion (in unit of e)");
212 ionCmd->
SetGuidance(
" E:(double) Excitation energy (in keV)");
229 ionLvlCmd->
SetGuidance(
"Set properties of ion to be generated.");
230 ionLvlCmd->
SetGuidance(
"[usage] /gps/ion Z A Q Lvl");
233 ionLvlCmd->
SetGuidance(
" Q:(int) Charge of Ion (in unit of e)");
234 ionLvlCmd->
SetGuidance(
" Lvl:(int) Number of metastable state excitation level (0-9)");
251 timeCmd->
SetGuidance(
"Set initial time of the particle.");
260 polCmd->
SetRange(
"Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1.");
263 numberCmd->
SetGuidance(
"Set number of particles to be generated per vertex.");
270 verbosityCmd->
SetGuidance(
"Set Verbose level for GPS");
272 verbosityCmd->
SetGuidance(
" 1 : Limited information");
273 verbosityCmd->
SetGuidance(
" 2 : Detailed information");
275 verbosityCmd->
SetRange(
"level>=0 && level <=2");
281 positionDirectory->
SetGuidance(
"Positional commands sub-directory");
284 typeCmd1->
SetGuidance(
"Sets source distribution type.");
285 typeCmd1->
SetGuidance(
"Either Point, Beam, Plane, Surface or Volume");
291 shapeCmd1->
SetGuidance(
"Sets source shape for Plan, Surface or Volume type source.");
294 shapeCmd1->
SetCandidates(
"Circle Annulus Ellipse Square Rectangle Sphere Ellipsoid Cylinder EllipticCylinder Para");
297 centreCmd1->
SetGuidance(
"Set centre coordinates of source.");
303 posrot1Cmd1->
SetGuidance(
"Set the 1st vector defining the rotation matrix'.");
304 posrot1Cmd1->
SetGuidance(
"It does not need to be a unit vector.");
306 posrot1Cmd1->
SetRange(
"R1x != 0 || R1y != 0 || R1z != 0");
309 posrot2Cmd1->
SetGuidance(
"Set the 2nd vector defining the rotation matrix'.");
310 posrot2Cmd1->
SetGuidance(
"It does not need to be a unit vector.");
312 posrot2Cmd1->
SetRange(
"R2x != 0 || R2y != 0 || R2z != 0");
315 halfxCmd1->
SetGuidance(
"Set x half length of source.");
321 halfyCmd1->
SetGuidance(
"Set y half length of source.");
327 halfzCmd1->
SetGuidance(
"Set z half length of source.");
339 radius0Cmd1->
SetGuidance(
"Set inner radius of source when required.");
345 possigmarCmd1->
SetGuidance(
"Set standard deviation in radial of the beam positional profile");
346 possigmarCmd1->
SetGuidance(
" applicable to Beam type source only");
352 possigmaxCmd1->
SetGuidance(
"Set standard deviation of beam positional profile in x-dir");
353 possigmaxCmd1->
SetGuidance(
" applicable to Beam type source only");
359 possigmayCmd1->
SetGuidance(
"Set standard deviation of beam positional profile in y-dir");
360 possigmayCmd1->
SetGuidance(
" applicable to Beam type source only");
366 paralpCmd1->
SetGuidance(
"Angle from y-axis of y' in Para");
372 partheCmd1->
SetGuidance(
"Polar angle through centres of z faces");
378 parphiCmd1->
SetGuidance(
"Azimuth angle through centres of z faces");
384 confineCmd1->
SetGuidance(
"Confine source to volume (NULL to unset).");
385 confineCmd1->
SetGuidance(
" Usage: confine VolName");
392 angularDirectory->
SetGuidance(
"Angular commands sub-directory");
395 angtypeCmd1->
SetGuidance(
"Sets angular source distribution type");
396 angtypeCmd1->
SetGuidance(
" Possible variables are: iso, cos, planar, beam1d, beam2d, focused or user");
399 angtypeCmd1->
SetCandidates(
"iso cos planar beam1d beam2d focused user");
402 angrot1Cmd1->
SetGuidance(
"Sets the 1st vector for angular distribution rotation matrix");
403 angrot1Cmd1->
SetGuidance(
" Need not be a unit vector");
405 angrot1Cmd1->
SetRange(
"AR1x != 0 || AR1y != 0 || AR1z != 0");
408 angrot2Cmd1->
SetGuidance(
"Sets the 2nd vector for angular distribution rotation matrix");
409 angrot2Cmd1->
SetGuidance(
" Need not be a unit vector");
411 angrot2Cmd1->
SetRange(
"AR2x != 0 || AR2y != 0 || AR2z != 0");
441 angsigmarCmd1->
SetGuidance(
"Set standard deviation in direction for 1D beam.");
447 angsigmaxCmd1->
SetGuidance(
"Set standard deviation in direction in x-direc. for 2D beam");
453 angsigmayCmd1->
SetGuidance(
"Set standard deviation in direction in y-direc. for 2D beam");
459 angfocusCmd->
SetGuidance(
"Set the focusing point for the beam");
465 useuserangaxisCmd1->
SetGuidance(
"True for using user defined angular co-ordinates");
466 useuserangaxisCmd1->
SetGuidance(
" Default is false");
471 surfnormCmd1->
SetGuidance(
"Makes a user-defined distribution with respect to surface normals rather than x,y,z axes.");
479 energyDirectory->
SetGuidance(
"Spectral commands sub-directory");
482 energytypeCmd1->
SetGuidance(
"Sets energy distribution type");
485 energytypeCmd1->
SetCandidates(
"Mono Lin Pow Exp CPow Gauss Brem Bbody Cdg User Arb Epn LW");
500 monoenergyCmd1->
SetGuidance(
"Sets a monocromatic energy (same as gps/energy)");
506 engsigmaCmd1->
SetGuidance(
"Sets the standard deviation for Gaussian energy dist.");
512 alphaCmd1->
SetGuidance(
"Sets Alpha (index) for power-law energy dist.");
516 tempCmd1->
SetGuidance(
"Sets the temperature for Brem and BBody distributions (in Kelvin)");
520 ezeroCmd1->
SetGuidance(
"Sets E_0 for exponential distribution (in MeV)");
524 gradientCmd1->
SetGuidance(
"Sets the gradient for Lin distribution (in 1/MeV)");
528 interceptCmd1->
SetGuidance(
"Sets the intercept for Lin distributions (in MeV)");
532 arbeintCmd1->
SetGuidance(
"Sets the power-law index for the energy sampling distri. )");
536 calculateCmd1->
SetGuidance(
"Calculates the distributions for Cdg and BBody");
539 energyspecCmd1->
SetGuidance(
"True for energy and false for momentum spectra");
544 diffspecCmd1->
SetGuidance(
"True for differential and flase for integral spectra");
548 applyEnergyWeightCmd1 =
new G4UIcmdWithABool(
"/gps/ene/applyEneWeight",
this);
549 applyEnergyWeightCmd1->
SetGuidance(
"Apply energy weight.");
550 applyEnergyWeightCmd1->
SetGuidance(
"- Instead of using the Arb type histogram for sampling the energy spectrum,");
551 applyEnergyWeightCmd1->
SetGuidance(
" energy is sampled by Linear distribution, and the Arb type histogram is");
552 applyEnergyWeightCmd1->
SetGuidance(
" used for the weight of the generated particle.");
553 applyEnergyWeightCmd1->
SetGuidance(
"- \"/gps/ene/type LW\" automatically applies this command.");
554 applyEnergyWeightCmd1->
SetGuidance(
"- If this command has to be explicitly used, \"/gps/ene/type\" distribution mush be Lin.");
561 histDirectory->
SetGuidance(
"Histogram, biasing commands sub-directory");
567 histnameCmd1->
SetCandidates(
"biasx biasy biasz biast biasp biase biaspt biaspp theta phi energy arb epn");
570 resethistCmd1->
SetGuidance(
"Reset (clean) the histogram ");
573 resethistCmd1->
SetCandidates(
"biasx biasy biasz biast biasp biase biaspt biaspp theta phi energy arb epn");
576 histpointCmd1->
SetGuidance(
"Allows user to define a histogram");
579 histpointCmd1->
SetRange(
"Ehi >= 0. && Weight >= 0.");
582 histfileCmd1->
SetGuidance(
"Imports the arb energy hist in an ASCII file");
586 arbintCmd1->
SetGuidance(
"Sets the interpolation method for arbitrary distribution.");
587 arbintCmd1->
SetGuidance(
"Spline interpolation may not be applicable for some distributions.");
593G4GeneralParticleSourceMessenger::~G4GeneralParticleSourceMessenger()
595 delete positionDirectory;
606 delete possigmarCmd1;
607 delete possigmaxCmd1;
608 delete possigmayCmd1;
614 delete angularDirectory;
622 delete angsigmarCmd1;
623 delete angsigmaxCmd1;
624 delete angsigmayCmd1;
626 delete useuserangaxisCmd1;
629 delete energyDirectory;
630 delete energytypeCmd1;
633 delete monoenergyCmd1;
639 delete interceptCmd1;
641 delete calculateCmd1;
642 delete energyspecCmd1;
644 delete applyEnergyWeightCmd1;
646 delete histDirectory;
648 delete resethistCmd1;
649 delete histpointCmd1;
665 delete sourceDirectory;
667 delete listsourceCmd;
668 delete clearsourceCmd;
671 delete setintensityCmd;
672 delete deletesourceCmd;
673 delete multiplevertexCmd;
674 delete flatsamplingCmd;
677 theInstance =
nullptr;
680#define CHECKPG() { if (fParticleGun==nullptr) { \
681 G4ExceptionDescription msg; \
682 msg << "Command "<< command->GetCommandPath()<<"/";\
683 msg << command->GetCommandName(); \
684 msg << " used but no particle sources are set.";\
685 msg <<" Add at least a source with: /gps/source/add.";\
686 G4Exception("G4GeneralParticleSourceMessenger::SetNewValue","G4GPS003",\
687 FatalException,msg); return;\
1048 if( command==directionCmd )
1054 else if( command==energyCmd )
1060 else if( command==positionCmd )
1066 else if(command == verbosityCmd)
1072 else if( command==particleCmd )
1074 if (newValues ==
"ion")
1089 else if( command==timeCmd )
1094 else if( command==polCmd )
1099 else if( command==numberCmd )
1104 else if( command==ionCmd )
1106 IonCommand(newValues);
1108 else if( command==ionLvlCmd )
1110 IonLvlCommand(newValues);
1112 else if( command==listCmd )
1116 else if( command==addsourceCmd )
1120 else if( command==listsourceCmd )
1124 else if( command==clearsourceCmd )
1127 fParticleGun =
nullptr;
1129 else if( command==getsourceCmd )
1134 else if( command==setsourceCmd )
1148 <<
" source(s) are defined.";
1149 G4Exception(
"G4GeneralParticleSourceMessenger::SetNewValue",
1154 else if( command==setintensityCmd )
1158 else if( command==deletesourceCmd )
1162 else if(command == multiplevertexCmd)
1166 else if(command == flatsamplingCmd)
1173 else if(command == typeCmd1)
1178 else if(command == shapeCmd1)
1183 else if(command == centreCmd1)
1188 else if(command == posrot1Cmd1)
1193 else if(command == posrot2Cmd1)
1198 else if(command == halfxCmd1)
1203 else if(command == halfyCmd1)
1208 else if(command == halfzCmd1)
1213 else if(command == radiusCmd1)
1218 else if(command == radius0Cmd1)
1223 else if(command == possigmarCmd1)
1228 else if(command == possigmaxCmd1)
1233 else if(command == possigmayCmd1)
1238 else if(command == paralpCmd1)
1243 else if(command == partheCmd1)
1248 else if(command == parphiCmd1)
1253 else if(command == confineCmd1)
1258 else if(command == angtypeCmd1)
1263 else if(command == angrot1Cmd1)
1269 else if(command == angrot2Cmd1)
1275 else if(command == minthetaCmd1)
1280 else if(command == minphiCmd1)
1285 else if(command == maxthetaCmd1)
1290 else if(command == maxphiCmd1)
1295 else if(command == angsigmarCmd1)
1300 else if(command == angsigmaxCmd1)
1305 else if(command == angsigmayCmd1)
1310 else if(command == angfocusCmd)
1315 else if(command == useuserangaxisCmd1)
1320 else if(command == surfnormCmd1)
1325 else if(command == energytypeCmd1)
1341 else if(command == eminCmd1)
1346 else if(command == emaxCmd1)
1351 else if(command == monoenergyCmd1)
1356 else if(command == engsigmaCmd1)
1361 else if(command == alphaCmd1)
1366 else if(command == tempCmd1)
1371 else if(command == ezeroCmd1)
1376 else if(command == gradientCmd1)
1381 else if(command == interceptCmd1)
1386 else if(command == arbeintCmd1)
1391 else if(command == calculateCmd1)
1396 else if(command == energyspecCmd1)
1401 else if(command == diffspecCmd1)
1406 else if(command == applyEnergyWeightCmd1)
1410 if(eDisType !=
"Lin")
1413 ed <<
"Energy distribution is defined as " << eDisType <<
". /gps/ene/applyEneWeight is available only for Linear distribution.";
1419 else if(command == histnameCmd1)
1421 histtype = newValues;
1423 else if(command == histfileCmd1)
1429 else if(command == histpointCmd1)
1432 if(histtype ==
"biasx")
1434 if(histtype ==
"biasy")
1436 if(histtype ==
"biasz")
1438 if(histtype ==
"biast")
1440 if(histtype ==
"biasp")
1442 if(histtype ==
"biaspt")
1444 if(histtype ==
"biaspp")
1446 if(histtype ==
"biase")
1448 if(histtype ==
"theta")
1450 if(histtype ==
"phi")
1452 if(histtype ==
"energy")
1454 if(histtype ==
"arb")
1456 if(histtype ==
"epn")
1459 else if(command == resethistCmd1)
1462 if(newValues ==
"theta" || newValues ==
"phi")
1466 else if (newValues ==
"energy" || newValues ==
"arb" || newValues ==
"epn")
1475 else if(command == arbintCmd1)
1502 cv =
"Not implemented yet";
1507void G4GeneralParticleSourceMessenger::IonCommand(
G4String newValues)
1513 fAtomicNumber =
StoI(next());
1514 fAtomicMass =
StoI(next());
1518 fIonCharge = fAtomicNumber;
1522 fIonCharge =
StoI(sQ);
1526 fIonExciteEnergy = 0.0;
1530 fIonExciteEnergy =
StoD(sQ) * keV;
1534 ->
GetIon(fAtomicNumber, fAtomicMass, fIonExciteEnergy);
1538 ed <<
"Ion with Z=" << fAtomicNumber;
1539 ed <<
" A=" << fAtomicMass <<
" is not defined";
1551 ed <<
"Set /gps/particle to ion before using /gps/ion command";
1556void G4GeneralParticleSourceMessenger::IonLvlCommand(
G4String newValues)
1562 fAtomicNumberL =
StoI(next());
1563 fAtomicMassL =
StoI(next());
1567 fIonChargeL = fAtomicNumberL;
1571 fIonChargeL =
StoI(sQ);
1575 fIonEnergyLevel = 0;
1579 fIonEnergyLevel =
StoI(sQ);
1584 ->
GetIon(fAtomicNumberL, fAtomicMassL, fIonEnergyLevel);
1588 ed <<
"Ion with Z=" << fAtomicNumberL;
1589 ed <<
" A=" << fAtomicMassL <<
" is not defined";
1602 ed <<
"Set /gps/particle to ion before using /gps/ionLvl command";
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
static G4GeneralParticleSourceMessenger * GetInstance(G4GeneralParticleSource *)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValues)
void SetFlatSampling(G4bool av)
void AddaSource(G4double)
G4int GetCurrentSourceIndex() const
G4double GetCurrentSourceIntensity() const
void SetCurrentSourceIntensity(G4double)
void SetVerbosity(G4int i)
void SetCurrentSourceto(G4int)
void DeleteaSource(G4int)
G4int GetNumberofSource()
void SetMultipleVertex(G4bool av)
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
static G4IonTable * GetIonTable()
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
const G4String & GetParticleName(G4int index) const
void DumpTable(const G4String &particle_name="ALL")
void SetBeamSigmaInAngX(G4double)
void SetBeamSigmaInAngR(G4double)
void UserDefAngTheta(const G4ThreeVector &)
void SetFocusPoint(const G4ThreeVector &)
void SetAngDistType(const G4String &)
void UserDefAngPhi(const G4ThreeVector &)
void SetMaxTheta(G4double)
void SetUseUserAngAxis(G4bool)
void SetMinTheta(G4double)
void SetParticleMomentumDirection(const G4ParticleMomentum &aMomDirection)
void SetBeamSigmaInAngY(G4double)
void ReSetHist(const G4String &)
void DefineAngRefAxes(const G4String &, const G4ThreeVector &)
void SetUserWRTSurface(G4bool)
void InputEnergySpectra(G4bool)
void ArbInterpolate(const G4String &)
const G4String & GetEnergyDisType()
void SetBeamSigmaInE(G4double)
void SetBiasAlpha(G4double)
void SetEnergyDisType(const G4String &)
void EpnEnergyHisto(const G4ThreeVector &)
void ArbEnergyHistoFile(const G4String &)
void SetGradient(G4double)
void ReSetHist(const G4String &)
void InputDifferentialSpectra(G4bool)
void SetMonoEnergy(G4double)
void ApplyEnergyWeight(G4bool val)
void UserEnergyHisto(const G4ThreeVector &)
void SetInterCept(G4double)
void ArbEnergyHisto(const G4ThreeVector &)
void SetParAlpha(G4double)
void SetPosRot2(const G4ThreeVector &)
void SetBeamSigmaInX(G4double)
void ConfineSourceToVolume(const G4String &)
void SetPosDisShape(const G4String &)
void SetCentreCoords(const G4ThreeVector &)
void SetBeamSigmaInR(G4double)
void SetRadius0(G4double)
void SetParTheta(G4double)
void SetPosRot1(const G4ThreeVector &)
void SetPosDisType(const G4String &)
void SetBeamSigmaInY(G4double)
void SetXBias(const G4ThreeVector &)
void SetEnergyBias(const G4ThreeVector &)
void SetPosPhiBias(const G4ThreeVector &)
void SetThetaBias(const G4ThreeVector &)
void SetYBias(const G4ThreeVector &)
void SetPosThetaBias(const G4ThreeVector &)
void SetPhiBias(const G4ThreeVector &)
void SetZBias(const G4ThreeVector &)
void ReSetHist(const G4String &)
void SetNumberOfParticles(G4int i)
void SetParticleTime(G4double aTime)
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
G4SPSAngDistribution * GetAngDist() const
G4SPSRandomGenerator * GetBiasRndm() const
G4SPSEneDistribution * GetEneDist() const
void SetParticlePolarization(const G4ThreeVector &aVal)
void SetParticleCharge(G4double aCharge)
G4SPSPosDistribution * GetPosDist() const
void SetDefaultUnit(const char *defUnit)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetDefaultValue(G4double defVal)
void SetDefaultUnit(const char *defUnit)
static G4double GetNewDoubleValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4double GetNewDoubleValue(const char *paramString)
void SetCandidates(const char *candidateList)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
const G4String & GetCommandPath() const
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
void SetRange(const char *rs)
const G4String & GetCommandName() const
G4bool commandsShouldBeInMaster
G4double StoD(G4String s)
void SetDefaultValue(const char *theDefaultValue)