File indexing completed on 2025-02-23 09:22:37
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 #include "ExP01DetectorMessenger.hh"
0035
0036 #include "ExP01DetectorConstruction.hh"
0037
0038 #include "G4UIcmdWithADoubleAndUnit.hh"
0039 #include "G4UIcmdWithAString.hh"
0040 #include "G4UIdirectory.hh"
0041 #include "globals.hh"
0042
0043
0044
0045 ExP01DetectorMessenger::ExP01DetectorMessenger(ExP01DetectorConstruction* myDet)
0046 : G4UImessenger(),
0047 fDetector(myDet),
0048 fN02Dir(0),
0049 fDetDir(0),
0050 fTargMatCmd(0),
0051 fChamMatCmd(0),
0052 fFieldCmd(0)
0053 {
0054 fN02Dir = new G4UIdirectory("/P01/");
0055 fN02Dir->SetGuidance("UI commands specific to this example.");
0056
0057 fDetDir = new G4UIdirectory("/P01/det/");
0058 fDetDir->SetGuidance("detector control.");
0059
0060 fTargMatCmd = new G4UIcmdWithAString("/P01/det/setTargetMate", this);
0061 fTargMatCmd->SetGuidance("Select Material of the Target.");
0062 fTargMatCmd->SetParameterName("choice", false);
0063 fTargMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0064
0065 fChamMatCmd = new G4UIcmdWithAString("/P01/det/setChamberMate", this);
0066 fChamMatCmd->SetGuidance("Select Material of the Target.");
0067 fChamMatCmd->SetParameterName("choice", false);
0068 fChamMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0069
0070 fFieldCmd = new G4UIcmdWithADoubleAndUnit("/P01/det/setField", this);
0071 fFieldCmd->SetGuidance("Define magnetic field.");
0072 fFieldCmd->SetGuidance("Magnetic field will be in X direction.");
0073 fFieldCmd->SetParameterName("Bx", false);
0074 fFieldCmd->SetUnitCategory("Magnetic flux density");
0075 fFieldCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0076 }
0077
0078
0079
0080 ExP01DetectorMessenger::~ExP01DetectorMessenger()
0081 {
0082 delete fTargMatCmd;
0083 delete fChamMatCmd;
0084 delete fFieldCmd;
0085 delete fDetDir;
0086 delete fN02Dir;
0087 }
0088
0089
0090
0091 void ExP01DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0092 {
0093 if (command == fTargMatCmd) {
0094 fDetector->SetTargetMaterial(newValue);
0095 }
0096
0097 if (command == fChamMatCmd) {
0098 fDetector->SetChamberMaterial(newValue);
0099 }
0100
0101 if (command == fFieldCmd) {
0102 fDetector->SetMagField(fFieldCmd->GetNewDoubleValue(newValue));
0103 }
0104 }
0105
0106