File indexing completed on 2026-04-09 07:51:48
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 #include "DetectorMessenger.hh"
0043
0044 #include "DetectorConstruction.hh"
0045
0046 #include "G4UIcmdWithADoubleAndUnit.hh"
0047 #include "G4UIcmdWithAString.hh"
0048 #include "G4UIcmdWithoutParameter.hh"
0049 #include "G4UIdirectory.hh"
0050
0051
0052
0053 DetectorMessenger::DetectorMessenger(DetectorConstruction* det) : fDetector(det)
0054 {
0055 fDetDir = new G4UIdirectory("/testem/");
0056 fDetDir->SetGuidance("Detector control.");
0057
0058 fGasMaterCmd = new G4UIcmdWithAString("/testem/setGasMat", this);
0059 fGasMaterCmd->SetGuidance("Select material of the detector.");
0060 fGasMaterCmd->SetParameterName("gmat", true);
0061 fGasMaterCmd->SetDefaultValue("Argon");
0062 fGasMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0063
0064 fWindowMaterCmd = new G4UIcmdWithAString("/testem/setWindowMat", this);
0065 fWindowMaterCmd->SetGuidance("Select material of the window.");
0066 fWindowMaterCmd->SetParameterName("wmat", true);
0067 fWindowMaterCmd->SetDefaultValue("Mylar");
0068 fWindowMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0069
0070 fWorldMaterCmd = new G4UIcmdWithAString("/testem/setWorldMat", this);
0071 fWorldMaterCmd->SetGuidance("Select material of the world.");
0072 fWorldMaterCmd->SetParameterName("worldmat", true);
0073 fWorldMaterCmd->SetDefaultValue("empty");
0074 fWorldMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0075
0076 fGasThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/setGasThick", this);
0077 fGasThickCmd->SetGuidance("Set thickness of the detector");
0078 fGasThickCmd->SetParameterName("SizeZ", false, false);
0079 fGasThickCmd->SetUnitCategory("Length");
0080 fGasThickCmd->SetDefaultUnit("mm");
0081 fGasThickCmd->SetRange("SizeZ>0.");
0082 fGasThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0083
0084 fGasRadCmd = new G4UIcmdWithADoubleAndUnit("/testem/setGasRad", this);
0085 fGasRadCmd->SetGuidance("Set radius of the detector");
0086 fGasRadCmd->SetParameterName("SizeR", false, false);
0087 fGasRadCmd->SetUnitCategory("Length");
0088 fGasRadCmd->SetDefaultUnit("mm");
0089 fGasRadCmd->SetRange("SizeR>0.");
0090 fGasRadCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0091
0092 fWinThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/setWindowThick", this);
0093 fWinThickCmd->SetGuidance("Set thickness of the window");
0094 fWinThickCmd->SetParameterName("delta", false, false);
0095 fWinThickCmd->SetUnitCategory("Length");
0096 fWinThickCmd->SetDefaultUnit("mm");
0097 fWinThickCmd->SetRange("delta>0.");
0098 fWinThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0099
0100 fIonCmd = new G4UIcmdWithADoubleAndUnit("/testem/setPairEnergy", this);
0101 fIonCmd->SetGuidance("Set energy per electron-ion pair for detector");
0102 fIonCmd->SetParameterName("en", false, false);
0103 fIonCmd->SetUnitCategory("Energy");
0104 fIonCmd->SetDefaultUnit("MeV");
0105 fIonCmd->SetRange("en>0.");
0106 fIonCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0107
0108 fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/testem/stepMax", this);
0109 fStepMaxCmd->SetGuidance("Set max allowed step length for charged particles");
0110 fStepMaxCmd->SetParameterName("mxStep", false);
0111 fStepMaxCmd->SetRange("mxStep>0.");
0112 fStepMaxCmd->SetUnitCategory("Length");
0113 fStepMaxCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0114 }
0115
0116
0117
0118 DetectorMessenger::~DetectorMessenger()
0119 {
0120 delete fGasMaterCmd;
0121 delete fGasThickCmd;
0122 delete fGasRadCmd;
0123 delete fWinThickCmd;
0124 delete fWindowMaterCmd;
0125 delete fWorldMaterCmd;
0126 delete fIonCmd;
0127 delete fStepMaxCmd;
0128 delete fDetDir;
0129 }
0130
0131
0132
0133 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0134 {
0135 if (command == fGasMaterCmd) {
0136 fDetector->SetGasMaterial(newValue);
0137 }
0138 else if (command == fWindowMaterCmd) {
0139 fDetector->SetContainerMaterial(newValue);
0140 }
0141 else if (command == fWorldMaterCmd) {
0142 fDetector->SetWorldMaterial(newValue);
0143 }
0144 else if (command == fGasThickCmd) {
0145 fDetector->SetGasThickness(fGasThickCmd->GetNewDoubleValue(newValue));
0146 }
0147 else if (command == fGasRadCmd) {
0148 fDetector->SetGasRadius(fGasRadCmd->GetNewDoubleValue(newValue));
0149 }
0150 else if (command == fWinThickCmd) {
0151 fDetector->SetContainerThickness(fWinThickCmd->GetNewDoubleValue(newValue));
0152 }
0153 else if (command == fStepMaxCmd) {
0154 fDetector->SetMaxChargedStep(fStepMaxCmd->GetNewDoubleValue(newValue));
0155 }
0156 else if (command == fIonCmd) {
0157 fDetector->SetPairEnergy(fIonCmd->GetNewDoubleValue(newValue));
0158 }
0159 }
0160
0161