Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GeneralParticleSourceMessenger Class Reference

#include <G4GeneralParticleSourceMessenger.hh>

+ Inheritance diagram for G4GeneralParticleSourceMessenger:

Public Member Functions

void SetParticleGun (G4SingleParticleSource *fpg)
 
void SetNewValue (G4UIcommand *command, G4String newValues) override
 
G4String GetCurrentValue (G4UIcommand *command) override
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool CommandsShouldBeInMaster () const
 

Static Public Member Functions

static G4GeneralParticleSourceMessengerGetInstance (G4GeneralParticleSource *)
 
static void Destroy ()
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 74 of file G4GeneralParticleSourceMessenger.hh.

Member Function Documentation

◆ Destroy()

void G4GeneralParticleSourceMessenger::Destroy ( )
static

Definition at line 73 of file G4GeneralParticleSourceMessenger.cc.

74{
75 G4AutoLock l(&creationM);
76 if ( theInstance != nullptr )
77 {
78 delete theInstance;
79 theInstance = nullptr;
80 }
81}

Referenced by G4GeneralParticleSource::~G4GeneralParticleSource().

◆ GetCurrentValue()

G4String G4GeneralParticleSourceMessenger::GetCurrentValue ( G4UIcommand * command)
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 1486 of file G4GeneralParticleSourceMessenger.cc.

1487{
1488 G4String cv;
1489
1490 // if( command==directionCmd )
1491 // { cv = directionCmd->ConvertToString(fParticleGun->GetParticleMomentumDirection()); }
1492 // else if( command==energyCmd )
1493 // { cv = energyCmd->ConvertToString(fParticleGun->GetParticleEnergy(),"GeV"); }
1494 // else if( command==positionCmd )
1495 // { cv = positionCmd->ConvertToString(fParticleGun->GetParticlePosition(),"cm"); }
1496 // else if( command==timeCmd )
1497 // { cv = timeCmd->ConvertToString(fParticleGun->GetParticleTime(),"ns"); }
1498 // else if( command==polCmd )
1499 // { cv = polCmd->ConvertToString(fParticleGun->GetParticlePolarization()); }
1500 // else if( command==numberCmd )
1501 // { cv = numberCmd->ConvertToString(fParticleGun->GetNumberOfParticles()); }
1502
1503 cv = "Not implemented yet";
1504
1505 return cv;
1506}

◆ GetInstance()

G4GeneralParticleSourceMessenger * G4GeneralParticleSourceMessenger::GetInstance ( G4GeneralParticleSource * psc)
static

Definition at line 65 of file G4GeneralParticleSourceMessenger.cc.

66{
67 G4AutoLock l(&creationM);
68 if ( theInstance == nullptr )
69 theInstance = new G4GeneralParticleSourceMessenger(psc);
70 return theInstance;
71}

Referenced by G4GeneralParticleSource::G4GeneralParticleSource().

◆ SetNewValue()

void G4GeneralParticleSourceMessenger::SetNewValue ( G4UIcommand * command,
G4String newValues )
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 691 of file G4GeneralParticleSourceMessenger.cc.

692{
693// if(command == typeCmd)
694// {
695// CHECKPG(); fParticleGun->GetPosDist()->SetPosDisType(newValues);
696// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
697// << " The command is obsolete and will be removed soon." << G4endl
698// << " Please try to use the new structured commands!" << G4endl;
699// }
700// else if(command == shapeCmd)
701// {
702// CHECKPG(); fParticleGun->GetPosDist()->SetPosDisShape(newValues);
703// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
704// << " The command is obsolete and will be removed soon." << G4endl
705// << " Please try to use the new structured commands!" << G4endl;
706// }
707// else if(command == centreCmd)
708// {
709// CHECKPG(); fParticleGun->GetPosDist()->SetCentreCoords(centreCmd->GetNew3VectorValue(newValues));
710// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
711// << " The command is obsolete and will be removed soon." << G4endl
712// << " Please try to use the new structured commands!" << G4endl;
713// }
714// else if(command == posrot1Cmd)
715// {
716// CHECKPG(); fParticleGun->GetPosDist()->SetPosRot1(posrot1Cmd->GetNew3VectorValue(newValues));
717// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
718// << " The command is obsolete and will be removed soon." << G4endl
719// << " Please try to use the new structured commands!" << G4endl;
720// }
721// else if(command == posrot2Cmd)
722// {
723// CHECKPG(); fParticleGun->GetPosDist()->SetPosRot2(posrot2Cmd->GetNew3VectorValue(newValues));
724// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
725// << " The command is obsolete and will be removed soon." << G4endl
726// << " Please try to use the new structured commands!" << G4endl;
727// }
728// else if(command == halfxCmd)
729// {
730// CHECKPG(); fParticleGun->GetPosDist()->SetHalfX(halfxCmd->GetNewDoubleValue(newValues));
731// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
732// << " The command is obsolete and will be removed soon." << G4endl
733// << " Please try to use the new structured commands!" << G4endl;
734// }
735// else if(command == halfyCmd)
736// {
737// CHECKPG(); fParticleGun->GetPosDist()->SetHalfY(halfyCmd->GetNewDoubleValue(newValues));
738// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
739// << " The command is obsolete and will be removed soon." << G4endl
740// << " Please try to use the new structured commands!" << G4endl;
741// }
742// else if(command == halfzCmd)
743// {
744// CHECKPG(); fParticleGun->GetPosDist()->SetHalfZ(halfzCmd->GetNewDoubleValue(newValues));
745// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
746// << " The command is obsolete and will be removed soon." << G4endl
747// << " Please try to use the new structured commands!" << G4endl;
748// }
749// else if(command == radiusCmd)
750// {
751// CHECKPG(); fParticleGun->GetPosDist()->SetRadius(radiusCmd->GetNewDoubleValue(newValues));
752// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
753// << " The command is obsolete and will be removed soon." << G4endl
754// << " Please try to use the new structured commands!" << G4endl;
755// }
756// else if(command == radius0Cmd)
757// {
758// CHECKPG(); fParticleGun->GetPosDist()->SetRadius0(radius0Cmd->GetNewDoubleValue(newValues));
759// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
760// << " The command is obsolete and will be removed soon." << G4endl
761// << " Please try to use the new structured commands!" << G4endl;
762// }
763// else if(command == possigmarCmd)
764// {
765// CHECKPG(); fParticleGun->GetPosDist()->SetBeamSigmaInR(possigmarCmd->GetNewDoubleValue(newValues));
766// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
767// << " The command is obsolete and will be removed soon." << G4endl
768// << " Please try to use the new structured commands!" << G4endl;
769// }
770// else if(command == possigmaxCmd)
771// {
772// CHECKPG(); fParticleGun->GetPosDist()->SetBeamSigmaInX(possigmaxCmd->GetNewDoubleValue(newValues));
773// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
774// << " The command is obsolete and will be removed soon." << G4endl
775// << " Please try to use the new structured commands!" << G4endl;
776// }
777// else if(command == possigmayCmd)
778// {
779// CHECKPG(); fParticleGun->GetPosDist()->SetBeamSigmaInY(possigmayCmd->GetNewDoubleValue(newValues));
780// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
781// << " The command is obsolete and will be removed soon." << G4endl
782// << " Please try to use the new structured commands!" << G4endl;
783// }
784// else if(command == paralpCmd)
785// {
786// CHECKPG(); fParticleGun->GetPosDist()->SetParAlpha(paralpCmd->GetNewDoubleValue(newValues));
787// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
788// << " The command is obsolete and will be removed soon." << G4endl
789// << " Please try to use the new structured commands!" << G4endl;
790// }
791// else if(command == partheCmd)
792// {
793// CHECKPG(); fParticleGun->GetPosDist()->SetParTheta(partheCmd->GetNewDoubleValue(newValues));
794// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
795// << " The command is obsolete and will be removed soon." << G4endl
796// << " Please try to use the new structured commands!" << G4endl;
797// }
798// else if(command == parphiCmd)
799// {
800// CHECKPG(); fParticleGun->GetPosDist()->SetParPhi(parphiCmd->GetNewDoubleValue(newValues));
801// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
802// << " The command is obsolete and will be removed soon." << G4endl
803// << " Please try to use the new structured commands!" << G4endl;
804// }
805// else if(command == confineCmd)
806// {
807// CHECKPG(); fParticleGun->GetPosDist()->ConfineSourceToVolume(newValues);
808// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
809// << " The command is obsolete and will be removed soon." << G4endl
810// << " Please try to use the new structured commands!" << G4endl;
811// }
812// else if(command == angtypeCmd)
813// {
814// CHECKPG(); fParticleGun->GetAngDist()->SetAngDistType(newValues);
815// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
816// << " The command is obsolete and will be removed soon." << G4endl
817// << " Please try to use the new structured commands!" << G4endl;
818// }
819// else if(command == angrot1Cmd)
820// {
821// CHECKPG();
822// G4String a = "angref1";
823// fParticleGun->GetAngDist()->DefineAngRefAxes(a,angrot1Cmd->GetNew3VectorValue(newValues));
824// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
825// << " The command is obsolete and will be removed soon." << G4endl
826// << " Please try to use the new structured commands!" << G4endl;
827// }
828// else if(command == angrot2Cmd)
829// {
830// CHECKPG();
831// G4String a = "angref2";
832// fParticleGun->GetAngDist()->DefineAngRefAxes(a,angrot2Cmd->GetNew3VectorValue(newValues));
833// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
834// << " The command is obsolete and will be removed soon." << G4endl
835// << " Please try to use the new structured commands!" << G4endl;
836// }
837// else if(command == minthetaCmd)
838// {
839// CHECKPG(); fParticleGun->GetAngDist()->SetMinTheta(minthetaCmd->GetNewDoubleValue(newValues));
840// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
841// << " The command is obsolete and will be removed soon." << G4endl
842// << " Please try to use the new structured commands!" << G4endl;
843// }
844// else if(command == minphiCmd)
845// {
846// CHECKPG(); fParticleGun->GetAngDist()->SetMinPhi(minphiCmd->GetNewDoubleValue(newValues));
847// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
848// << " The command is obsolete and will be removed soon." << G4endl
849// << " Please try to use the new structured commands!" << G4endl;
850// }
851// else if(command == maxthetaCmd)
852// {
853// CHECKPG(); fParticleGun->GetAngDist()->SetMaxTheta(maxthetaCmd->GetNewDoubleValue(newValues));
854// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
855// << " The command is obsolete and will be removed soon." << G4endl
856// << " Please try to use the new structured commands!" << G4endl;
857// }
858// else if(command == maxphiCmd)
859// {
860// CHECKPG(); fParticleGun->GetAngDist()->SetMaxPhi(maxphiCmd->GetNewDoubleValue(newValues));
861// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
862// << " The command is obsolete and will be removed soon." << G4endl
863// << " Please try to use the new structured commands!" << G4endl;
864// }
865// else if(command == angsigmarCmd)
866// {
867// CHECKPG(); fParticleGun->GetAngDist()->SetBeamSigmaInAngR(angsigmarCmd->GetNewDoubleValue(newValues));
868// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
869// << " The command is obsolete and will be removed soon." << G4endl
870// << " Please try to use the new structured commands!" << G4endl;
871// }
872// else if(command == angsigmaxCmd)
873// {
874// CHECKPG(); fParticleGun->GetAngDist()->SetBeamSigmaInAngX(angsigmaxCmd->GetNewDoubleValue(newValues));
875// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
876// << " The command is obsolete and will be removed soon." << G4endl
877// << " Please try to use the new structured commands!" << G4endl;
878// }
879// else if(command == angsigmayCmd)
880// {
881// CHECKPG(); fParticleGun->GetAngDist()->SetBeamSigmaInAngY(angsigmayCmd->GetNewDoubleValue(newValues));
882// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
883// << " The command is obsolete and will be removed soon." << G4endl
884// << " Please try to use the new structured commands!" << G4endl;
885// }
886// else if(command == useuserangaxisCmd)
887// {
888// CHECKPG(); fParticleGun->GetAngDist()->SetUseUserAngAxis(useuserangaxisCmd->GetNewBoolValue(newValues));
889// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
890// << " The command is obsolete and will be removed soon." << G4endl
891// << " Please try to use the new structured commands!" << G4endl;
892// }
893// else if(command == surfnormCmd)
894// {
895// CHECKPG(); fParticleGun->GetAngDist()->SetUserWRTSurface(surfnormCmd->GetNewBoolValue(newValues));
896// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
897// << " The command is obsolete and will be removed soon." << G4endl
898// << " Please try to use the new structured commands!" << G4endl;
899// }
900// else if(command == energytypeCmd)
901// {
902// CHECKPG(); fParticleGun->GetEneDist()->SetEnergyDisType(newValues);
903// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
904// << " The command is obsolete and will be removed soon." << G4endl
905// << " Please try to use the new structured commands!" << G4endl;
906// }
907// else if(command == eminCmd)
908// {
909// CHECKPG(); fParticleGun->GetEneDist()->SetEmin(eminCmd->GetNewDoubleValue(newValues));
910// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
911// << " The command is obsolete and will be removed soon." << G4endl
912// << " Please try to use the new structured commands!" << G4endl;
913// }
914// else if(command == emaxCmd)
915// {
916// CHECKPG(); fParticleGun->GetEneDist()->SetEmax(emaxCmd->GetNewDoubleValue(newValues));
917// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
918// << " The command is obsolete and will be removed soon." << G4endl
919// << " Please try to use the new structured commands!" << G4endl;
920// }
921// else if(command == monoenergyCmd)
922// {
923// CHECKPG(); fParticleGun->GetEneDist()->SetMonoEnergy(monoenergyCmd->GetNewDoubleValue(newValues));
924// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
925// << " The command is obsolete and will be removed soon." << G4endl
926// << " Please try to use the new structured commands!" << G4endl;
927// }
928// else if(command == engsigmaCmd)
929// {
930// CHECKPG(); fParticleGun->GetEneDist()->SetBeamSigmaInE(engsigmaCmd->GetNewDoubleValue(newValues));
931// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
932// << " The command is obsolete and will be removed soon." << G4endl
933// << " Please try to use the new structured commands!" << G4endl;
934// }
935// else if(command == alphaCmd)
936// {
937// CHECKPG(); fParticleGun->GetEneDist()->SetAlpha(alphaCmd->GetNewDoubleValue(newValues));
938// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
939// << " The command is obsolete and will be removed soon." << G4endl
940// << " Please try to use the new structured commands!" << G4endl;
941// }
942// else if(command == tempCmd)
943// {
944// CHECKPG(); fParticleGun->GetEneDist()->SetTemp(tempCmd->GetNewDoubleValue(newValues));
945// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
946// << " The command is obsolete and will be removed soon." << G4endl
947// << " Please try to use the new structured commands!" << G4endl;
948// }
949// else if(command == ezeroCmd)
950// {
951// CHECKPG(); fParticleGun->GetEneDist()->SetEzero(ezeroCmd->GetNewDoubleValue(newValues));
952// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
953// << " The command is obsolete and will be removed soon." << G4endl
954// << " Please try to use the new structured commands!" << G4endl;
955// }
956// else if(command == gradientCmd)
957// {
958// CHECKPG(); fParticleGun->GetEneDist()->SetGradient(gradientCmd->GetNewDoubleValue(newValues));
959// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
960// << " The command is obsolete and will be removed soon." << G4endl
961// << " Please try to use the new structured commands!" << G4endl;
962// }
963// else if(command == interceptCmd)
964// {
965// CHECKPG(); fParticleGun->GetEneDist()->SetInterCept(interceptCmd->GetNewDoubleValue(newValues));
966// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
967// << " The command is obsolete and will be removed soon." << G4endl
968// << " Please try to use the new structured commands!" << G4endl;
969// }
970// else if(command == calculateCmd)
971// {
972// CHECKPG(); fParticleGun->GetEneDist()->Calculate();
973// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
974// << " The command is obsolete and will be removed soon." << G4endl
975// << " Please try to use the new structured commands!" << G4endl;
976// }
977// else if(command == energyspecCmd)
978// {
979// CHECKPG(); fParticleGun->GetEneDist()->InputEnergySpectra(energyspecCmd->GetNewBoolValue(newValues));
980// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
981// << " The command is obsolete and will be removed soon." << G4endl
982// << " Please try to use the new structured commands!" << G4endl;
983// }
984// else if(command == diffspecCmd)
985// {
986// CHECKPG(); fParticleGun->GetEneDist()->InputDifferentialSpectra(diffspecCmd->GetNewBoolValue(newValues));
987// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
988// << " The command is obsolete and will be removed soon." << G4endl
989// << " Please try to use the new structured commands!" << G4endl;
990// }
991// else if(command == histnameCmd)
992// {
993// histtype = newValues;
994// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
995// << " The command is obsolete and will be removed soon." << G4endl
996// << " Please try to use the new structured commands!" << G4endl;
997// }
998// else
999// if(command == histpointCmd)
1000// {
1001// CHECKPG();
1002// if(histtype == "biasx")
1003// fParticleGun->GetBiasRndm()->SetXBias(histpointCmd->GetNew3VectorValue(newValues));
1004// if(histtype == "biasy")
1005// fParticleGun->GetBiasRndm()->SetYBias(histpointCmd->GetNew3VectorValue(newValues));
1006// if(histtype == "biasz")
1007// fParticleGun->GetBiasRndm()->SetZBias(histpointCmd->GetNew3VectorValue(newValues));
1008// if(histtype == "biast")
1009// fParticleGun->GetBiasRndm()->SetThetaBias(histpointCmd->GetNew3VectorValue(newValues));
1010// if(histtype == "biasp")
1011// fParticleGun->GetBiasRndm()->SetPhiBias(histpointCmd->GetNew3VectorValue(newValues));
1012// if(histtype == "biase")
1013// fParticleGun->GetBiasRndm()->SetEnergyBias(histpointCmd->GetNew3VectorValue(newValues));
1014// if(histtype == "theta")
1015// fParticleGun->GetAngDist()->UserDefAngTheta(histpointCmd->GetNew3VectorValue(newValues));
1016// if(histtype == "phi")
1017// fParticleGun->GetAngDist()->UserDefAngPhi(histpointCmd->GetNew3VectorValue(newValues));
1018// if(histtype == "energy")
1019// fParticleGun->GetEneDist()->UserEnergyHisto(histpointCmd->GetNew3VectorValue(newValues));
1020// if(histtype == "arb")
1021// fParticleGun->GetEneDist()->ArbEnergyHisto(histpointCmd->GetNew3VectorValue(newValues));
1022// if(histtype == "epn")
1023// fParticleGun->GetEneDist()->EpnEnergyHisto(histpointCmd->GetNew3VectorValue(newValues));
1024// G4cout << " G4GeneralParticleSourceMessenger - Warning: The command is obsolete and will be removed soon. Please try to use the new structured commands!" << G4endl;
1025// }
1026// else if(command == resethistCmd)
1027// {
1028// CHECKPG();
1029// if(newValues == "theta" || newValues == "phi") {
1030// fParticleGun->GetAngDist()->ReSetHist(newValues);
1031// } else if (newValues == "energy" || newValues == "arb" || newValues == "epn") {
1032// fParticleGun->GetEneDist()->ReSetHist(newValues);
1033// } else {
1034// fParticleGun->GetBiasRndm()->ReSetHist(newValues);
1035// }
1036// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
1037// << " The command is obsolete and will be removed soon." << G4endl
1038// << " Please try to use the new structured commands!" << G4endl;
1039// }
1040// else if(command == arbintCmd)
1041// {
1042// CHECKPG();
1043// fParticleGun->GetEneDist()->ArbInterpolate(newValues);
1044// G4cout << " G4GeneralParticleSourceMessenger - Warning:" << G4endl
1045// << " The command is obsolete and will be removed soon." << G4endl
1046// << " Please try to use the new structured commands!" << G4endl;
1047// }
1048// else
1049 if( command==directionCmd )
1050 {
1051 CHECKPG();
1052 fParticleGun->GetAngDist()->SetAngDistType("planar");
1053 fParticleGun->GetAngDist()->SetParticleMomentumDirection(directionCmd->GetNew3VectorValue(newValues));
1054 }
1055 else if( command==energyCmd )
1056 {
1057 CHECKPG();
1058 fParticleGun->GetEneDist()->SetEnergyDisType("Mono");
1059 fParticleGun->GetEneDist()->SetMonoEnergy(energyCmd->GetNewDoubleValue(newValues));
1060 }
1061 else if( command==positionCmd )
1062 {
1063 CHECKPG();
1064 fParticleGun->GetPosDist()->SetPosDisType("Point");
1065 fParticleGun->GetPosDist()->SetCentreCoords(positionCmd->GetNew3VectorValue(newValues));
1066 }
1067 else if(command == verbosityCmd)
1068 {
1069 fGPS->SetVerbosity(verbosityCmd->GetNewIntValue(newValues));
1070 // CHECKPG();
1071 // fParticleGun->SetVerbosity(verbosityCmd->GetNewIntValue(newValues));
1072 }
1073 else if( command==particleCmd )
1074 {
1075 if (newValues =="ion")
1076 {
1077 fShootIon = true;
1078 }
1079 else
1080 {
1081 fShootIon = false;
1082 G4ParticleDefinition* pd = particleTable->FindParticle(newValues);
1083 if(pd != nullptr)
1084 {
1085 CHECKPG();
1086 fParticleGun->SetParticleDefinition( pd );
1087 }
1088 }
1089 }
1090 else if( command==timeCmd )
1091 {
1092 CHECKPG();
1093 fParticleGun->SetParticleTime(timeCmd->GetNewDoubleValue(newValues));
1094 }
1095 else if( command==polCmd )
1096 {
1097 CHECKPG();
1098 fParticleGun->SetParticlePolarization(polCmd->GetNew3VectorValue(newValues));
1099 }
1100 else if( command==numberCmd )
1101 {
1102 CHECKPG();
1103 fParticleGun->SetNumberOfParticles(numberCmd->GetNewIntValue(newValues));
1104 }
1105 else if( command==ionCmd )
1106 {
1107 IonCommand(newValues);
1108 }
1109 else if( command==ionLvlCmd )
1110 {
1111 IonLvlCommand(newValues);
1112 }
1113 else if( command==listCmd )
1114 {
1115 particleTable->DumpTable();
1116 }
1117 else if( command==addsourceCmd )
1118 {
1119 fGPS->AddaSource(addsourceCmd->GetNewDoubleValue(newValues));
1120 }
1121 else if( command==listsourceCmd )
1122 {
1123 fGPS->ListSource();
1124 }
1125 else if( command==clearsourceCmd )
1126 {
1127 fGPS->ClearAll();
1128 fParticleGun = nullptr;
1129 }
1130 else if( command==getsourceCmd )
1131 {
1132 G4cout << " Current source index:" << fGPS->GetCurrentSourceIndex()
1133 << " ; Intensity:" << fGPS->GetCurrentSourceIntensity() << G4endl;
1134 }
1135 else if( command==setsourceCmd )
1136 {
1137 // NOTE: This will also sets fParticleGun to the courrent source
1138 // Not very clean, the GPS::SetCurrentSourceto will call:
1139 // SetParticleSource( G4ParticleSource* )
1140 // The point is that GPS has no public API to get a source by index
1141 // TODO: Can we add this API?
1142 const G4int sn = setsourceCmd->GetNewIntValue(newValues);
1143 if ( sn >= fGPS->GetNumberofSource() )
1144 {
1146 msg << "Using command " << setsourceCmd->GetCommandPath() << "/"
1147 << setsourceCmd->GetCommandName() << " " << sn;
1148 msg << " is invalid " << fGPS->GetNumberofSource()
1149 << " source(s) are defined.";
1150 G4Exception("G4GeneralParticleSourceMessenger::SetNewValue",
1151 "G4GPS005", FatalException, msg);
1152 }
1153 fGPS->SetCurrentSourceto(setsourceCmd->GetNewIntValue(newValues));
1154 }
1155 else if( command==setintensityCmd )
1156 {
1157 fGPS->SetCurrentSourceIntensity(setintensityCmd->GetNewDoubleValue(newValues));
1158 }
1159 else if( command==deletesourceCmd )
1160 {
1161 fGPS->DeleteaSource(deletesourceCmd->GetNewIntValue(newValues));
1162 }
1163 else if(command == multiplevertexCmd)
1164 {
1165 fGPS->SetMultipleVertex(multiplevertexCmd->GetNewBoolValue(newValues));
1166 }
1167 else if(command == flatsamplingCmd)
1168 {
1169 fGPS->SetFlatSampling(flatsamplingCmd->GetNewBoolValue(newValues));
1170 }
1171 //
1172 // new implementations
1173 //
1174 else if(command == typeCmd1)
1175 {
1176 CHECKPG();
1177 fParticleGun->GetPosDist()->SetPosDisType(newValues);
1178 }
1179 else if(command == shapeCmd1)
1180 {
1181 CHECKPG();
1182 fParticleGun->GetPosDist()->SetPosDisShape(newValues);
1183 }
1184 else if(command == centreCmd1)
1185 {
1186 CHECKPG();
1187 fParticleGun->GetPosDist()->SetCentreCoords(centreCmd1->GetNew3VectorValue(newValues));
1188 }
1189 else if(command == posrot1Cmd1)
1190 {
1191 CHECKPG();
1192 fParticleGun->GetPosDist()->SetPosRot1(posrot1Cmd1->GetNew3VectorValue(newValues));
1193 }
1194 else if(command == posrot2Cmd1)
1195 {
1196 CHECKPG();
1197 fParticleGun->GetPosDist()->SetPosRot2(posrot2Cmd1->GetNew3VectorValue(newValues));
1198 }
1199 else if(command == halfxCmd1)
1200 {
1201 CHECKPG();
1202 fParticleGun->GetPosDist()->SetHalfX(halfxCmd1->GetNewDoubleValue(newValues));
1203 }
1204 else if(command == halfyCmd1)
1205 {
1206 CHECKPG();
1207 fParticleGun->GetPosDist()->SetHalfY(halfyCmd1->GetNewDoubleValue(newValues));
1208 }
1209 else if(command == halfzCmd1)
1210 {
1211 CHECKPG();
1212 fParticleGun->GetPosDist()->SetHalfZ(halfzCmd1->GetNewDoubleValue(newValues));
1213 }
1214 else if(command == radiusCmd1)
1215 {
1216 CHECKPG();
1217 fParticleGun->GetPosDist()->SetRadius(radiusCmd1->GetNewDoubleValue(newValues));
1218 }
1219 else if(command == radius0Cmd1)
1220 {
1221 CHECKPG();
1222 fParticleGun->GetPosDist()->SetRadius0(radius0Cmd1->GetNewDoubleValue(newValues));
1223 }
1224 else if(command == possigmarCmd1)
1225 {
1226 CHECKPG();
1227 fParticleGun->GetPosDist()->SetBeamSigmaInR(possigmarCmd1->GetNewDoubleValue(newValues));
1228 }
1229 else if(command == possigmaxCmd1)
1230 {
1231 CHECKPG();
1232 fParticleGun->GetPosDist()->SetBeamSigmaInX(possigmaxCmd1->GetNewDoubleValue(newValues));
1233 }
1234 else if(command == possigmayCmd1)
1235 {
1236 CHECKPG();
1237 fParticleGun->GetPosDist()->SetBeamSigmaInY(possigmayCmd1->GetNewDoubleValue(newValues));
1238 }
1239 else if(command == paralpCmd1)
1240 {
1241 CHECKPG();
1242 fParticleGun->GetPosDist()->SetParAlpha(paralpCmd1->GetNewDoubleValue(newValues));
1243 }
1244 else if(command == partheCmd1)
1245 {
1246 CHECKPG();
1247 fParticleGun->GetPosDist()->SetParTheta(partheCmd1->GetNewDoubleValue(newValues));
1248 }
1249 else if(command == parphiCmd1)
1250 {
1251 CHECKPG();
1252 fParticleGun->GetPosDist()->SetParPhi(parphiCmd1->GetNewDoubleValue(newValues));
1253 }
1254 else if(command == confineCmd1)
1255 {
1256 CHECKPG();
1257 fParticleGun->GetPosDist()->ConfineSourceToVolume(newValues);
1258 }
1259 else if(command == angtypeCmd1)
1260 {
1261 CHECKPG();
1262 fParticleGun->GetAngDist()->SetAngDistType(newValues);
1263 }
1264 else if(command == angrot1Cmd1)
1265 {
1266 CHECKPG();
1267 G4String a = "angref1";
1268 fParticleGun->GetAngDist()->DefineAngRefAxes(a,angrot1Cmd1->GetNew3VectorValue(newValues));
1269 }
1270 else if(command == angrot2Cmd1)
1271 {
1272 CHECKPG();
1273 G4String a = "angref2";
1274 fParticleGun->GetAngDist()->DefineAngRefAxes(a,angrot2Cmd1->GetNew3VectorValue(newValues));
1275 }
1276 else if(command == minthetaCmd1)
1277 {
1278 CHECKPG();
1279 fParticleGun->GetAngDist()->SetMinTheta(minthetaCmd1->GetNewDoubleValue(newValues));
1280 }
1281 else if(command == minphiCmd1)
1282 {
1283 CHECKPG();
1284 fParticleGun->GetAngDist()->SetMinPhi(minphiCmd1->GetNewDoubleValue(newValues));
1285 }
1286 else if(command == maxthetaCmd1)
1287 {
1288 CHECKPG();
1289 fParticleGun->GetAngDist()->SetMaxTheta(maxthetaCmd1->GetNewDoubleValue(newValues));
1290 }
1291 else if(command == maxphiCmd1)
1292 {
1293 CHECKPG();
1294 fParticleGun->GetAngDist()->SetMaxPhi(maxphiCmd1->GetNewDoubleValue(newValues));
1295 }
1296 else if(command == angsigmarCmd1)
1297 {
1298 CHECKPG();
1299 fParticleGun->GetAngDist()->SetBeamSigmaInAngR(angsigmarCmd1->GetNewDoubleValue(newValues));
1300 }
1301 else if(command == angsigmaxCmd1)
1302 {
1303 CHECKPG();
1304 fParticleGun->GetAngDist()->SetBeamSigmaInAngX(angsigmaxCmd1->GetNewDoubleValue(newValues));
1305 }
1306 else if(command == angsigmayCmd1)
1307 {
1308 CHECKPG();
1309 fParticleGun->GetAngDist()->SetBeamSigmaInAngY(angsigmayCmd1->GetNewDoubleValue(newValues));
1310 }
1311 else if(command == angfocusCmd)
1312 {
1313 CHECKPG();
1314 fParticleGun->GetAngDist()->SetFocusPoint(angfocusCmd->GetNew3VectorValue(newValues));
1315 }
1316 else if(command == useuserangaxisCmd1)
1317 {
1318 CHECKPG();
1319 fParticleGun->GetAngDist()->SetUseUserAngAxis(useuserangaxisCmd1->GetNewBoolValue(newValues));
1320 }
1321 else if(command == surfnormCmd1)
1322 {
1323 CHECKPG();
1324 fParticleGun->GetAngDist()->SetUserWRTSurface(surfnormCmd1->GetNewBoolValue(newValues));
1325 }
1326 else if(command == energytypeCmd1)
1327 {
1328 CHECKPG();
1329 if(newValues=="LW")
1330 {
1331 fParticleGun->GetEneDist()->SetEnergyDisType("Lin");
1332 fParticleGun->GetEneDist()->SetGradient(0.);
1333 fParticleGun->GetEneDist()->SetInterCept(1.);
1334 fParticleGun->GetEneDist()->ApplyEnergyWeight(true);
1335 }
1336 else
1337 {
1338 fParticleGun->GetEneDist()->SetEnergyDisType(newValues);
1339 fParticleGun->GetEneDist()->ApplyEnergyWeight(false);
1340 }
1341 }
1342 else if(command == eminCmd1)
1343 {
1344 CHECKPG();
1345 fParticleGun->GetEneDist()->SetEmin(eminCmd1->GetNewDoubleValue(newValues));
1346 }
1347 else if(command == emaxCmd1)
1348 {
1349 CHECKPG();
1350 fParticleGun->GetEneDist()->SetEmax(emaxCmd1->GetNewDoubleValue(newValues));
1351 }
1352 else if(command == monoenergyCmd1)
1353 {
1354 CHECKPG();
1355 fParticleGun->GetEneDist()->SetMonoEnergy(monoenergyCmd1->GetNewDoubleValue(newValues));
1356 }
1357 else if(command == engsigmaCmd1)
1358 {
1359 CHECKPG();
1360 fParticleGun->GetEneDist()->SetBeamSigmaInE(engsigmaCmd1->GetNewDoubleValue(newValues));
1361 }
1362 else if(command == alphaCmd1)
1363 {
1364 CHECKPG();
1365 fParticleGun->GetEneDist()->SetAlpha(alphaCmd1->GetNewDoubleValue(newValues));
1366 }
1367 else if(command == tempCmd1)
1368 {
1369 CHECKPG();
1370 fParticleGun->GetEneDist()->SetTemp(tempCmd1->GetNewDoubleValue(newValues));
1371 }
1372 else if(command == ezeroCmd1)
1373 {
1374 CHECKPG();
1375 fParticleGun->GetEneDist()->SetEzero(ezeroCmd1->GetNewDoubleValue(newValues));
1376 }
1377 else if(command == gradientCmd1)
1378 {
1379 CHECKPG();
1380 fParticleGun->GetEneDist()->SetGradient(gradientCmd1->GetNewDoubleValue(newValues));
1381 }
1382 else if(command == interceptCmd1)
1383 {
1384 CHECKPG();
1385 fParticleGun->GetEneDist()->SetInterCept(interceptCmd1->GetNewDoubleValue(newValues));
1386 }
1387 else if(command == arbeintCmd1)
1388 {
1389 CHECKPG();
1390 fParticleGun->GetEneDist()->SetBiasAlpha(arbeintCmd1->GetNewDoubleValue(newValues));
1391 }
1392 else if(command == calculateCmd1)
1393 {
1394 CHECKPG();
1395 fParticleGun->GetEneDist()->Calculate();
1396 }
1397 else if(command == energyspecCmd1)
1398 {
1399 CHECKPG();
1400 fParticleGun->GetEneDist()->InputEnergySpectra(energyspecCmd1->GetNewBoolValue(newValues));
1401 }
1402 else if(command == diffspecCmd1)
1403 {
1404 CHECKPG();
1405 fParticleGun->GetEneDist()->InputDifferentialSpectra(diffspecCmd1->GetNewBoolValue(newValues));
1406 }
1407 else if(command == applyEnergyWeightCmd1)
1408 {
1409 CHECKPG();
1410 auto eDisType = fParticleGun->GetEneDist()->GetEnergyDisType();
1411 if(eDisType != "Lin")
1412 {
1414 ed << "Energy distribution is defined as " << eDisType << ". /gps/ene/applyEneWeight is available only for Linear distribution.";
1415 command->CommandFailed(ed);
1416 return;
1417 }
1418 fParticleGun->GetEneDist()->ApplyEnergyWeight(applyEnergyWeightCmd1->GetNewBoolValue(newValues));
1419 }
1420 else if(command == histnameCmd1)
1421 {
1422 histtype = newValues;
1423 }
1424 else if(command == histfileCmd1)
1425 {
1426 histtype = "arb";
1427 CHECKPG();
1428 fParticleGun->GetEneDist()->ArbEnergyHistoFile(newValues);
1429 }
1430 else if(command == histpointCmd1)
1431 {
1432 CHECKPG();
1433 if(histtype == "biasx")
1434 fParticleGun->GetBiasRndm()->SetXBias(histpointCmd1->GetNew3VectorValue(newValues));
1435 if(histtype == "biasy")
1436 fParticleGun->GetBiasRndm()->SetYBias(histpointCmd1->GetNew3VectorValue(newValues));
1437 if(histtype == "biasz")
1438 fParticleGun->GetBiasRndm()->SetZBias(histpointCmd1->GetNew3VectorValue(newValues));
1439 if(histtype == "biast")
1440 fParticleGun->GetBiasRndm()->SetThetaBias(histpointCmd1->GetNew3VectorValue(newValues));
1441 if(histtype == "biasp")
1442 fParticleGun->GetBiasRndm()->SetPhiBias(histpointCmd1->GetNew3VectorValue(newValues));
1443 if(histtype == "biaspt")
1444 fParticleGun->GetBiasRndm()->SetPosThetaBias(histpointCmd1->GetNew3VectorValue(newValues));
1445 if(histtype == "biaspp")
1446 fParticleGun->GetBiasRndm()->SetPosPhiBias(histpointCmd1->GetNew3VectorValue(newValues));
1447 if(histtype == "biase")
1448 fParticleGun->GetBiasRndm()->SetEnergyBias(histpointCmd1->GetNew3VectorValue(newValues));
1449 if(histtype == "theta")
1450 fParticleGun->GetAngDist()->UserDefAngTheta(histpointCmd1->GetNew3VectorValue(newValues));
1451 if(histtype == "phi")
1452 fParticleGun->GetAngDist()->UserDefAngPhi(histpointCmd1->GetNew3VectorValue(newValues));
1453 if(histtype == "energy")
1454 fParticleGun->GetEneDist()->UserEnergyHisto(histpointCmd1->GetNew3VectorValue(newValues));
1455 if(histtype == "arb")
1456 fParticleGun->GetEneDist()->ArbEnergyHisto(histpointCmd1->GetNew3VectorValue(newValues));
1457 if(histtype == "epn")
1458 fParticleGun->GetEneDist()->EpnEnergyHisto(histpointCmd1->GetNew3VectorValue(newValues));
1459 }
1460 else if(command == resethistCmd1)
1461 {
1462 CHECKPG();
1463 if(newValues == "theta" || newValues == "phi")
1464 {
1465 fParticleGun->GetAngDist()->ReSetHist(newValues);
1466 }
1467 else if (newValues == "energy" || newValues == "arb" || newValues == "epn")
1468 {
1469 fParticleGun->GetEneDist()->ReSetHist(newValues);
1470 }
1471 else
1472 {
1473 fParticleGun->GetBiasRndm()->ReSetHist(newValues);
1474 }
1475 }
1476 else if(command == arbintCmd1)
1477 {
1478 CHECKPG(); fParticleGun->GetEneDist()->ArbInterpolate(newValues);
1479 }
1480 else
1481 {
1482 G4cout << "Error entering command" << G4endl;
1483 }
1484}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4double GetCurrentSourceIntensity() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void DumpTable(const G4String &particle_name="ALL")
void UserDefAngTheta(const G4ThreeVector &)
void SetFocusPoint(const G4ThreeVector &)
void SetAngDistType(const G4String &)
void UserDefAngPhi(const G4ThreeVector &)
void SetParticleMomentumDirection(const G4ParticleMomentum &aMomDirection)
void ReSetHist(const G4String &)
void DefineAngRefAxes(const G4String &, const G4ThreeVector &)
void ArbInterpolate(const G4String &)
const G4String & GetEnergyDisType()
void SetEnergyDisType(const G4String &)
void EpnEnergyHisto(const G4ThreeVector &)
void ArbEnergyHistoFile(const G4String &)
void ReSetHist(const G4String &)
void ApplyEnergyWeight(G4bool val)
void UserEnergyHisto(const G4ThreeVector &)
void ArbEnergyHisto(const G4ThreeVector &)
void SetPosRot2(const G4ThreeVector &)
void ConfineSourceToVolume(const G4String &)
void SetPosDisShape(const G4String &)
void SetCentreCoords(const G4ThreeVector &)
void SetPosRot1(const G4ThreeVector &)
void SetPosDisType(const G4String &)
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 SetParticleTime(G4double aTime)
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
G4SPSAngDistribution * GetAngDist() const
G4SPSRandomGenerator * GetBiasRndm() const
G4SPSEneDistribution * GetEneDist() const
void SetParticlePolarization(const G4ThreeVector &aVal)
G4SPSPosDistribution * GetPosDist() const
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static G4bool GetNewBoolValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)
const G4String & GetCommandPath() const
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
const G4String & GetCommandName() const

◆ SetParticleGun()

void G4GeneralParticleSourceMessenger::SetParticleGun ( G4SingleParticleSource * fpg)
inline

The documentation for this class was generated from the following files: