File indexing completed on 2025-02-23 09:22:18
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
0044
0045 #include "PrimaryGeneratorMessenger.hh"
0046
0047 #include "PrimaryGeneratorAction.hh"
0048 #include "Run.hh"
0049
0050 #include "G4RunManager.hh"
0051 #include "G4UImanager.hh"
0052
0053
0054
0055 PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(PrimaryGeneratorAction* gen) : fGen(gen)
0056 {
0057 fVerbose = gen->GetVerbose();
0058 if (fVerbose) G4cout << "PrimaryGeneratorMessenger: Construct " << G4endl;
0059
0060 fBeamXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamX", this);
0061 fBeamXCmd->SetGuidance("Set X position of the center of the beam.");
0062 fBeamXCmd->SetParameterName("beamX", true);
0063 fBeamXCmd->SetUnitCategory("Length");
0064 fBeamXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0065
0066 fBeamYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamY", this);
0067 fBeamYCmd->SetGuidance("Set Y position of the center of the beam.");
0068 fBeamYCmd->SetParameterName("beamY", true);
0069 fBeamYCmd->SetUnitCategory("Length");
0070 fBeamYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0071
0072 fBeamZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamZ", this);
0073 fBeamZCmd->SetGuidance("Set Z of the entry point of the beam.");
0074 fBeamZCmd->SetParameterName("beamZ", true);
0075 fBeamZCmd->SetUnitCategory("Length");
0076 fBeamZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0077
0078 fBeamECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamE", this);
0079 fBeamECmd->SetGuidance("Set the beam kinetic energy");
0080 fBeamECmd->SetParameterName("beamE", false);
0081 fBeamECmd->SetUnitCategory("Energy");
0082 fBeamECmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0083
0084 fSigmaXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaX", this);
0085 fSigmaXCmd->SetGuidance("Set the beam Gussian width for X");
0086 fSigmaXCmd->SetParameterName("sigmaX", false);
0087 fSigmaXCmd->SetUnitCategory("Length");
0088 fSigmaXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0089
0090 fSigmaYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaY", this);
0091 fSigmaYCmd->SetGuidance("Set the beam Gussian width for Y");
0092 fSigmaYCmd->SetParameterName("sigmaY", false);
0093 fSigmaYCmd->SetUnitCategory("Length");
0094 fSigmaYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0095
0096 fSigmaZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaZ", this);
0097 fSigmaZCmd->SetGuidance("Set the beam Gussian width for Y");
0098 fSigmaZCmd->SetParameterName("sigmaZ", false);
0099 fSigmaZCmd->SetUnitCategory("Length");
0100 fSigmaZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0101
0102 fSigmaECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaE", this);
0103 fSigmaECmd->SetGuidance("Set the beam Gussian width for energy");
0104 fSigmaECmd->SetParameterName("sigmaE", false);
0105 fSigmaECmd->SetUnitCategory("Energy");
0106 fSigmaECmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0107
0108 fRandCmd = new G4UIcmdWithAString("/testem/gun", this);
0109 fRandCmd->SetGuidance("Set the name of the random distribution (gauss,flat)");
0110 fRandCmd->SetParameterName("rand", false);
0111 fRandCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0112
0113 fMaxThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/maxTheta", this);
0114 fMaxThetaCmd->SetGuidance("Set the beam maxTheta in degrees.");
0115 fMaxThetaCmd->SetParameterName("maxTheta", false);
0116 fMaxThetaCmd->SetUnitCategory("Angle");
0117 fMaxThetaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0118
0119 fThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaTheta", this);
0120 fThetaCmd->SetGuidance("Set the beam sigmaTheta in degrees.");
0121 fThetaCmd->SetParameterName("sigmaTheta", false);
0122 fThetaCmd->SetUnitCategory("Angle");
0123 fThetaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0124 }
0125
0126
0127
0128 PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
0129 {
0130 delete fBeamXCmd;
0131 delete fBeamYCmd;
0132 delete fBeamZCmd;
0133
0134 delete fSigmaXCmd;
0135 delete fSigmaYCmd;
0136 delete fSigmaZCmd;
0137 delete fSigmaECmd;
0138
0139 delete fBeamECmd;
0140 delete fRandCmd;
0141 delete fMaxThetaCmd;
0142 delete fThetaCmd;
0143 }
0144
0145
0146
0147 void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0148 {
0149 if (fVerbose) G4cout << "PrimaryGeneratorMessenger: Next command value = " << newValue << G4endl;
0150
0151 if (command == fBeamXCmd) {
0152 fGen->SetBeamX(fBeamXCmd->GetNewDoubleValue(newValue));
0153 }
0154 if (command == fBeamYCmd) {
0155 fGen->SetBeamY(fBeamYCmd->GetNewDoubleValue(newValue));
0156 }
0157 if (command == fBeamZCmd) {
0158 fGen->SetBeamZ(fBeamZCmd->GetNewDoubleValue(newValue));
0159 }
0160 if (command == fSigmaXCmd) {
0161 fGen->SetBeamSigmaX(fSigmaXCmd->GetNewDoubleValue(newValue));
0162 }
0163 if (command == fSigmaYCmd) {
0164 fGen->SetBeamSigmaY(fSigmaYCmd->GetNewDoubleValue(newValue));
0165 }
0166 if (command == fSigmaZCmd) {
0167 fGen->SetBeamSigmaZ(fSigmaZCmd->GetNewDoubleValue(newValue));
0168 }
0169 if (command == fSigmaECmd) {
0170 fGen->SetBeamSigmaE(fSigmaECmd->GetNewDoubleValue(newValue));
0171 }
0172 if (command == fBeamECmd) {
0173 G4double e = fBeamECmd->GetNewDoubleValue(newValue);
0174 fGen->SetBeamEnergy(e);
0175 }
0176 if (command == fMaxThetaCmd) {
0177 fGen->SetBeamMinCosTheta(std::cos(fMaxThetaCmd->GetNewDoubleValue(newValue)));
0178 }
0179 if (command == fThetaCmd) {
0180 fGen->SetSigmaTheta(fThetaCmd->GetNewDoubleValue(newValue));
0181 }
0182 if (command == fRandCmd) {
0183 fGen->SetRandom(newValue);
0184 }
0185
0186 if (fVerbose) G4cout << "PrimaryGeneratorMessenger: O'K " << G4endl;
0187 }
0188
0189