File indexing completed on 2026-09-23 08:29:14
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 #include "VG01DetectorMessenger.hh"
0034
0035 #include "VG01DetectorConstruction.hh"
0036
0037 #include "G4UIcmdWithADoubleAndUnit.hh"
0038 #include "G4UIcmdWithAString.hh"
0039 #include "G4UIdirectory.hh"
0040 #include "globals.hh"
0041
0042 VG01DetectorMessenger::VG01DetectorMessenger(VG01DetectorConstruction* myDet)
0043 : G4UImessenger(), fDetector(myDet)
0044 {
0045 fDetectorDir = new G4UIdirectory("/mydet/");
0046 fDetectorDir->SetGuidance("Detector control.");
0047
0048 fFieldCommand = new G4UIcmdWithADoubleAndUnit("/mydet/setField", this);
0049 fFieldCommand->SetGuidance("Define uniform magnetic field along Z.");
0050 fFieldCommand->SetGuidance(" -> in unit of [Tesla]");
0051 fFieldCommand->SetParameterName("By", false);
0052 fFieldCommand->SetDefaultValue(0.0);
0053 fFieldCommand->SetUnitCategory("Magnetic flux density");
0054 fFieldCommand->AvailableForStates(G4State_PreInit, G4State_Idle);
0055
0056 fGDMLCommand = new G4UIcmdWithAString("/mydet/setGdmlFile", this);
0057 fGDMLCommand->SetGuidance("Set the GDML file.");
0058 fGDMLCommand->SetDefaultValue("TestNTST.gdml");
0059 fGDMLCommand->AvailableForStates(G4State_PreInit, G4State_Idle);
0060 }
0061
0062
0063
0064 VG01DetectorMessenger::~VG01DetectorMessenger()
0065 {
0066 delete fFieldCommand;
0067 delete fDetectorDir;
0068 }
0069
0070
0071
0072 void VG01DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0073 {
0074 if (command == fFieldCommand) {
0075 fDetector->SetMagFieldValue(fFieldCommand->GetNewDoubleValue(newValue));
0076 }
0077 else {
0078 if (command == fGDMLCommand) {
0079 fDetector->SetGDMLFileName(newValue);
0080 }
0081 else {
0082 G4cerr << "VG01DetectorMessenger: ERROR> Unknown command " << G4endl;
0083 }
0084 }
0085 }