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