00001 //---------------------------------------------------------------------------// 00002 //Description: Messenger class 00003 //Author: Wu Chen(wuchen@mail.ihep.ac.cn) 00004 //Created: 17 Oct, 2012 00005 //Comment: 00006 //---------------------------------------------------------------------------// 00007 00008 #include "DetectorMessenger.hh" 00009 00010 #include "DetectorConstruction.hh" 00011 #include "G4UIdirectory.hh" 00012 #include "G4UIcmdWithoutParameter.hh" 00013 #include "G4UIcmdWithAString.hh" 00014 00015 DetectorMessenger::DetectorMessenger( 00016 DetectorConstruction* Det) 00017 :Detector(Det) 00018 { 00019 g4simDir = new G4UIdirectory("/g4sim/"); 00020 g4simDir->SetGuidance("UI commands of this example"); 00021 00022 detDir = new G4UIdirectory("/g4sim/det/"); 00023 detDir->SetGuidance("detector control"); 00024 00025 ResetMagCmd = new G4UIcmdWithAString("/g4sim/det/ResetMag",this); 00026 ResetMagCmd->SetGuidance("Reset magnetic field according to given file."); 00027 ResetMagCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 00028 00029 ReloadGeoCmd = new G4UIcmdWithAString("/g4sim/det/ReloadGeo",this); 00030 ReloadGeoCmd->SetGuidance("Reload geometry according to given file."); 00031 ReloadGeoCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 00032 00033 UpdateCmd = new G4UIcmdWithoutParameter("/g4sim/det/update",this); 00034 UpdateCmd->SetGuidance("Update calorimeter geometry."); 00035 UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); 00036 UpdateCmd->SetGuidance("if you changed geometrical value(s)."); 00037 UpdateCmd->AvailableForStates(G4State_Idle); 00038 } 00039 00040 DetectorMessenger::~DetectorMessenger() 00041 { 00042 delete g4simDir; 00043 delete detDir; 00044 delete ResetMagCmd; 00045 delete ReloadGeoCmd; 00046 delete UpdateCmd; 00047 } 00048 00049 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 00050 { 00051 if( command == UpdateCmd ) { Detector->UpdateGeometry(); } 00052 if( command == ResetMagCmd ) { Detector->ResetMag(newValue); } 00053 if( command == ReloadGeoCmd ) { Detector->ReloadGeo(newValue); } 00054 }