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