File indexing completed on 2025-02-23 09:22:19
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 #include "DetectorMessenger.hh"
0031
0032 #include "G4UIcmdWith3VectorAndUnit.hh"
0033 #include "G4UIcmdWithADoubleAndUnit.hh"
0034 #include "G4UIcmdWithAString.hh"
0035 #include "G4UIcommand.hh"
0036 #include "G4UIdirectory.hh"
0037 #include "G4UIparameter.hh"
0038
0039 #include "DetectorConstruction.hh"
0040
0041 namespace RadioBio
0042 {
0043
0044
0045
0046 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : fDetector(Det)
0047 {
0048 fGeometryDir = new G4UIdirectory("/detectorGeom/");
0049 fGeometryDir->SetGuidance("commands to change geometry material and size");
0050
0051 fMaterCmd = new G4UIcmdWithAString("/detectorGeom/setMat", this);
0052 fMaterCmd->SetGuidance("Select material of the box.");
0053 fMaterCmd->SetParameterName("choice", false);
0054 fMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0055 fMaterCmd->SetToBeBroadcasted(false);
0056
0057 fSizeCmd = new G4UIcmdWithADoubleAndUnit("/detectorGeom/setSize", this);
0058 fSizeCmd->SetGuidance("Set size of the cubic box");
0059 fSizeCmd->SetParameterName("Size", false);
0060 fSizeCmd->SetRange("Size>0.");
0061 fSizeCmd->SetUnitCategory("Length");
0062 fSizeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0063 fSizeCmd->SetToBeBroadcasted(false);
0064
0065 fSizeVectorCmd = new G4UIcmdWith3VectorAndUnit("/detectorGeom/setBoxSizes", this);
0066 fSizeVectorCmd->SetGuidance("Insert sizes X Y and Z");
0067 fSizeVectorCmd->SetParameterName("SizeAlongX", "SizeAlongY", "SizeAlongZ", false);
0068 fSizeVectorCmd->SetRange("SizeAlongX>0. && SizeAlongY>0. && SizeAlongZ>0.");
0069 fSizeVectorCmd->SetUnitCategory("Length");
0070 fSizeVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0071 fSizeVectorCmd->SetToBeBroadcasted(false);
0072
0073 fSizeXCmd = new G4UIcmdWithADoubleAndUnit("/detectorGeom/setSizeX", this);
0074 fSizeXCmd->SetGuidance("Set X size of the box");
0075 fSizeXCmd->SetParameterName("Size", false);
0076 fSizeXCmd->SetRange("Size>0.");
0077 fSizeXCmd->SetUnitCategory("Length");
0078 fSizeXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0079 fSizeXCmd->SetToBeBroadcasted(false);
0080
0081 fSizeYCmd = new G4UIcmdWithADoubleAndUnit("/detectorGeom/setSizeY", this);
0082 fSizeYCmd->SetGuidance("Set Y size of the box");
0083 fSizeYCmd->SetParameterName("Size", false);
0084 fSizeYCmd->SetRange("Size>0.");
0085 fSizeYCmd->SetUnitCategory("Length");
0086 fSizeYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0087 fSizeYCmd->SetToBeBroadcasted(false);
0088
0089 fSizeZCmd = new G4UIcmdWithADoubleAndUnit("/detectorGeom/setSizeZ", this);
0090 fSizeZCmd->SetGuidance("Set Z size of the box");
0091 fSizeZCmd->SetParameterName("Size", false);
0092 fSizeZCmd->SetRange("Size>0.");
0093 fSizeZCmd->SetUnitCategory("Length");
0094 fSizeZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0095 fSizeZCmd->SetToBeBroadcasted(false);
0096 }
0097
0098
0099
0100 DetectorMessenger::~DetectorMessenger()
0101 {
0102 delete fGeometryDir;
0103 delete fMaterCmd;
0104 delete fSizeCmd;
0105 delete fSizeVectorCmd;
0106 delete fSizeXCmd;
0107 delete fSizeYCmd;
0108 delete fSizeZCmd;
0109 }
0110
0111
0112
0113 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0114 {
0115 if (command == fMaterCmd) {
0116 fDetector->SetMaterial(newValue);
0117 }
0118
0119 if (command == fSizeCmd) {
0120 fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));
0121 }
0122
0123 if (command == fSizeVectorCmd) {
0124 fDetector->SetSize(fSizeVectorCmd->GetNew3VectorValue(newValue));
0125 }
0126
0127 if (command == fSizeXCmd) {
0128 fDetector->SetSizeX(fSizeXCmd->GetNewDoubleValue(newValue));
0129 }
0130
0131 if (command == fSizeYCmd) {
0132 fDetector->SetSizeY(fSizeYCmd->GetNewDoubleValue(newValue));
0133 }
0134
0135 if (command == fSizeZCmd) {
0136 fDetector->SetSizeZ(fSizeZCmd->GetNewDoubleValue(newValue));
0137 }
0138 }
0139
0140
0141
0142 }