File indexing completed on 2025-01-18 09:17:05
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 #include "DetectorMessenger.hh"
0032
0033 #include "G4UIcmdWithADoubleAndUnit.hh"
0034 #include "G4UIcmdWithAString.hh"
0035 #include "G4UIcmdWithAnInteger.hh"
0036 #include "G4UIdirectory.hh"
0037
0038 #include "DetectorConstruction.hh"
0039
0040
0041
0042 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det)
0043 : G4UImessenger(),
0044 fDetector(Det),
0045 fTomoDir(nullptr),
0046 fDetDir(nullptr),
0047 fAbsMaterCmd(nullptr),
0048 fAbsThickCmd(nullptr),
0049 fAbsSizYZCmd(nullptr),
0050 fAbsXposCmd(nullptr),
0051 fWorldMaterCmd(nullptr),
0052 fWorldXCmd(nullptr),
0053 fWorldYZCmd(nullptr),
0054 fPhantomType(nullptr)
0055 {
0056 fTomoDir = new G4UIdirectory("/tomography/");
0057 fTomoDir->SetGuidance("UI commands specific to this example.");
0058
0059 fDetDir = new G4UIdirectory("/tomography/det/");
0060 fDetDir->SetGuidance("detector construction commands");
0061
0062 fAbsMaterCmd = new G4UIcmdWithAString("/tomography/det/setAbsMat", this);
0063 fAbsMaterCmd->SetGuidance("Select Material of the Absorber.");
0064 fAbsMaterCmd->SetParameterName("choice", false);
0065 fAbsMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0066 fAbsMaterCmd->SetToBeBroadcasted(false);
0067
0068 fWorldMaterCmd = new G4UIcmdWithAString("/tomography/det/setWorldMat", this);
0069 fWorldMaterCmd->SetGuidance("Select Material of the World.");
0070 fWorldMaterCmd->SetParameterName("wchoice", false);
0071 fWorldMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0072 fWorldMaterCmd->SetToBeBroadcasted(false);
0073
0074 fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setAbsThick", this);
0075 fAbsThickCmd->SetGuidance("Set Thickness of the Absorber");
0076 fAbsThickCmd->SetParameterName("SizeZ", false);
0077 fAbsThickCmd->SetRange("SizeZ>0.");
0078 fAbsThickCmd->SetUnitCategory("Length");
0079 fAbsThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0080 fAbsThickCmd->SetToBeBroadcasted(false);
0081
0082 fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setAbsYZ", this);
0083 fAbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber");
0084 fAbsSizYZCmd->SetParameterName("SizeYZ", false);
0085 fAbsSizYZCmd->SetRange("SizeYZ>0.");
0086 fAbsSizYZCmd->SetUnitCategory("Length");
0087 fAbsSizYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0088 fAbsSizYZCmd->SetToBeBroadcasted(false);
0089
0090 fAbsXposCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setAbsXpos", this);
0091 fAbsXposCmd->SetGuidance("Set X pos. of the Absorber");
0092 fAbsXposCmd->SetParameterName("Xpos", false);
0093 fAbsXposCmd->SetUnitCategory("Length");
0094 fAbsXposCmd->AvailableForStates(G4State_PreInit);
0095 fAbsXposCmd->SetToBeBroadcasted(false);
0096
0097 fWorldXCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setWorldX", this);
0098 fWorldXCmd->SetGuidance("Set X size of the World");
0099 fWorldXCmd->SetParameterName("WSizeX", false);
0100 fWorldXCmd->SetRange("WSizeX>0.");
0101 fWorldXCmd->SetUnitCategory("Length");
0102 fWorldXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0103 fWorldXCmd->SetToBeBroadcasted(false);
0104
0105 fWorldYZCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setWorldYZ", this);
0106 fWorldYZCmd->SetGuidance("Set sizeYZ of the World");
0107 fWorldYZCmd->SetParameterName("WSizeYZ", false);
0108 fWorldYZCmd->SetRange("WSizeYZ>0.");
0109 fWorldYZCmd->SetUnitCategory("Length");
0110 fWorldYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0111 fWorldYZCmd->SetToBeBroadcasted(false);
0112
0113 fPhantomType = new G4UIcmdWithAnInteger("/tomography/det/setPhantomType", this);
0114 fPhantomType->SetGuidance("Select the type of target object.");
0115 fPhantomType->SetParameterName("choice", false);
0116 fPhantomType->AvailableForStates(G4State_PreInit, G4State_Idle);
0117 fPhantomType->SetToBeBroadcasted(false);
0118 }
0119
0120
0121
0122 DetectorMessenger::~DetectorMessenger()
0123 {
0124 delete fAbsMaterCmd;
0125 delete fAbsThickCmd;
0126 delete fAbsSizYZCmd;
0127 delete fAbsXposCmd;
0128 delete fWorldMaterCmd;
0129 delete fWorldXCmd;
0130 delete fWorldYZCmd;
0131 delete fDetDir;
0132 delete fTomoDir;
0133 delete fPhantomType;
0134 }
0135
0136
0137
0138 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0139 {
0140 if (command == fAbsMaterCmd) {
0141 fDetector->SetAbsorberMaterial(newValue);
0142 }
0143
0144 if (command == fWorldMaterCmd) {
0145 fDetector->SetWorldMaterial(newValue);
0146 }
0147
0148 if (command == fAbsThickCmd) {
0149 fDetector->SetAbsorberThickness(fAbsThickCmd->GetNewDoubleValue(newValue));
0150 }
0151
0152 if (command == fAbsSizYZCmd) {
0153 fDetector->SetAbsorberSizeYZ(fAbsSizYZCmd->GetNewDoubleValue(newValue));
0154 }
0155
0156 if (command == fAbsXposCmd) {
0157 fDetector->SetAbsorberXpos(fAbsXposCmd->GetNewDoubleValue(newValue));
0158 }
0159
0160 if (command == fWorldXCmd) {
0161 fDetector->SetWorldSizeX(fWorldXCmd->GetNewDoubleValue(newValue));
0162 }
0163
0164 if (command == fWorldYZCmd) {
0165 fDetector->SetWorldSizeYZ(fWorldYZCmd->GetNewDoubleValue(newValue));
0166 }
0167
0168 if (command == fPhantomType) {
0169 fDetector->SetPhantomType(fPhantomType->GetNewIntValue(newValue));
0170 }
0171 }
0172
0173