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