Warning, file /geant4/examples/extended/medical/GammaTherapy/src/PrimaryGeneratorMessenger.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 #include "PrimaryGeneratorMessenger.hh"
0044
0045 #include "PrimaryGeneratorAction.hh"
0046 #include "Run.hh"
0047
0048 #include "G4RunManager.hh"
0049 #include "G4UImanager.hh"
0050
0051
0052
0053 PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(PrimaryGeneratorAction* gen) : fGen(gen)
0054 {
0055 fVerbose = gen->GetVerbose();
0056 if (fVerbose) G4cout << "PrimaryGeneratorMessenger: Construct " << G4endl;
0057
0058 fBeamXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamX", this);
0059 fBeamXCmd->SetGuidance("Set X position of the center of the beam.");
0060 fBeamXCmd->SetParameterName("beamX", true);
0061 fBeamXCmd->SetUnitCategory("Length");
0062 fBeamXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0063
0064 fBeamYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamY", this);
0065 fBeamYCmd->SetGuidance("Set Y position of the center of the beam.");
0066 fBeamYCmd->SetParameterName("beamY", true);
0067 fBeamYCmd->SetUnitCategory("Length");
0068 fBeamYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0069
0070 fBeamZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamZ", this);
0071 fBeamZCmd->SetGuidance("Set Z of the entry point of the beam.");
0072 fBeamZCmd->SetParameterName("beamZ", true);
0073 fBeamZCmd->SetUnitCategory("Length");
0074 fBeamZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0075
0076 fBeamECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamE", this);
0077 fBeamECmd->SetGuidance("Set the beam kinetic energy");
0078 fBeamECmd->SetParameterName("beamE", false);
0079 fBeamECmd->SetUnitCategory("Energy");
0080 fBeamECmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0081
0082 fSigmaXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaX", this);
0083 fSigmaXCmd->SetGuidance("Set the beam Gussian width for X");
0084 fSigmaXCmd->SetParameterName("sigmaX", false);
0085 fSigmaXCmd->SetUnitCategory("Length");
0086 fSigmaXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0087
0088 fSigmaYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaY", this);
0089 fSigmaYCmd->SetGuidance("Set the beam Gussian width for Y");
0090 fSigmaYCmd->SetParameterName("sigmaY", false);
0091 fSigmaYCmd->SetUnitCategory("Length");
0092 fSigmaYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0093
0094 fSigmaZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaZ", this);
0095 fSigmaZCmd->SetGuidance("Set the beam Gussian width for Y");
0096 fSigmaZCmd->SetParameterName("sigmaZ", false);
0097 fSigmaZCmd->SetUnitCategory("Length");
0098 fSigmaZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0099
0100 fSigmaECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaE", this);
0101 fSigmaECmd->SetGuidance("Set the beam Gussian width for energy");
0102 fSigmaECmd->SetParameterName("sigmaE", false);
0103 fSigmaECmd->SetUnitCategory("Energy");
0104 fSigmaECmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0105
0106 fRandCmd = new G4UIcmdWithAString("/testem/gun", this);
0107 fRandCmd->SetGuidance("Set the name of the random distribution (gauss,flat)");
0108 fRandCmd->SetParameterName("rand", false);
0109 fRandCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0110
0111 fMaxThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/maxTheta", this);
0112 fMaxThetaCmd->SetGuidance("Set the beam maxTheta in degrees.");
0113 fMaxThetaCmd->SetParameterName("maxTheta", false);
0114 fMaxThetaCmd->SetUnitCategory("Angle");
0115 fMaxThetaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0116
0117 fThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaTheta", this);
0118 fThetaCmd->SetGuidance("Set the beam sigmaTheta in degrees.");
0119 fThetaCmd->SetParameterName("sigmaTheta", false);
0120 fThetaCmd->SetUnitCategory("Angle");
0121 fThetaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0122 }
0123
0124
0125
0126 PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
0127 {
0128 delete fBeamXCmd;
0129 delete fBeamYCmd;
0130 delete fBeamZCmd;
0131
0132 delete fSigmaXCmd;
0133 delete fSigmaYCmd;
0134 delete fSigmaZCmd;
0135 delete fSigmaECmd;
0136
0137 delete fBeamECmd;
0138 delete fRandCmd;
0139 delete fMaxThetaCmd;
0140 delete fThetaCmd;
0141 }
0142
0143
0144
0145 void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0146 {
0147 if (fVerbose) G4cout << "PrimaryGeneratorMessenger: Next command value = " << newValue << G4endl;
0148
0149 if (command == fBeamXCmd) {
0150 fGen->SetBeamX(fBeamXCmd->GetNewDoubleValue(newValue));
0151 }
0152 if (command == fBeamYCmd) {
0153 fGen->SetBeamY(fBeamYCmd->GetNewDoubleValue(newValue));
0154 }
0155 if (command == fBeamZCmd) {
0156 fGen->SetBeamZ(fBeamZCmd->GetNewDoubleValue(newValue));
0157 }
0158 if (command == fSigmaXCmd) {
0159 fGen->SetBeamSigmaX(fSigmaXCmd->GetNewDoubleValue(newValue));
0160 }
0161 if (command == fSigmaYCmd) {
0162 fGen->SetBeamSigmaY(fSigmaYCmd->GetNewDoubleValue(newValue));
0163 }
0164 if (command == fSigmaZCmd) {
0165 fGen->SetBeamSigmaZ(fSigmaZCmd->GetNewDoubleValue(newValue));
0166 }
0167 if (command == fSigmaECmd) {
0168 fGen->SetBeamSigmaE(fSigmaECmd->GetNewDoubleValue(newValue));
0169 }
0170 if (command == fBeamECmd) {
0171 G4double e = fBeamECmd->GetNewDoubleValue(newValue);
0172 fGen->SetBeamEnergy(e);
0173 }
0174 if (command == fMaxThetaCmd) {
0175 fGen->SetBeamMinCosTheta(std::cos(fMaxThetaCmd->GetNewDoubleValue(newValue)));
0176 }
0177 if (command == fThetaCmd) {
0178 fGen->SetSigmaTheta(fThetaCmd->GetNewDoubleValue(newValue));
0179 }
0180 if (command == fRandCmd) {
0181 fGen->SetRandom(newValue);
0182 }
0183
0184 if (fVerbose) G4cout << "PrimaryGeneratorMessenger: O'K " << G4endl;
0185 }
0186
0187