00001
00002
00003
00004
00005
00006 #include "DetectorMessenger.hh"
00007
00008 #include "DetectorConstruction.hh"
00009 #include "G4UIdirectory.hh"
00010 #include "G4UIcmdWithAString.hh"
00011 #include "G4UIcmdWithADoubleAndUnit.hh"
00012 #include "G4UIcmdWithoutParameter.hh"
00013
00014
00015
00016 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
00017 :m_detector(Det)
00018 {
00019 m_detDir = new G4UIdirectory("/tutorial/det/");
00020 m_detDir->SetGuidance("detector construction commands");
00021
00022 m_materialCmd = new G4UIcmdWithAString ("/tutorial/det/spacecraftMaterial", this);
00023 m_materialCmd->SetGuidance("Select spacecraft material");
00024 m_materialCmd->SetParameterName("spacecraftMaterial",false);
00025
00026 m_thicknessCmd = new G4UIcmdWithADoubleAndUnit("/tutorial/det/spacecraftThickness",this);
00027 m_thicknessCmd->SetGuidance("Select spacecraft thickness");
00028 m_thicknessCmd->SetParameterName("spacecraftThickness",false);
00029 m_thicknessCmd->SetRange("spacecraftThickness>0.");
00030 m_thicknessCmd->SetUnitCategory("Length");
00031
00032 m_radiusCmd = new G4UIcmdWithADoubleAndUnit ("/tutorial/det/cabinRadius", this);
00033 m_radiusCmd->SetGuidance("Select spacecraft radius");
00034 m_radiusCmd->SetParameterName("cabinRadius",false);
00035 m_radiusCmd->SetUnitCategory("Length");
00036
00037 m_lengthCmd = new G4UIcmdWithADoubleAndUnit ("/tutorial/det/cabinLength", this);
00038 m_lengthCmd->SetGuidance("Select spacecraft length");
00039 m_lengthCmd->SetParameterName("spacecraftLength",false);
00040 m_lengthCmd->SetRange("cabinLength>0.&&cabinLength<20*m");
00041 m_lengthCmd->SetUnitCategory("Length");
00042
00043 m_magFieldCmd = new G4UIcmdWithADoubleAndUnit("/tutorial/det/setField",this);
00044 m_magFieldCmd->SetGuidance("Define magnetic field.");
00045 m_magFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
00046 m_magFieldCmd->SetParameterName("Bz",false);
00047 m_magFieldCmd->SetUnitCategory("Magnetic flux density");
00048 m_magFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00049
00050 m_stepMaxCmd = new G4UIcmdWithADoubleAndUnit("/tutorial/det/stepMax",this);
00051 m_stepMaxCmd->SetGuidance("Define a step max");
00052 m_stepMaxCmd->SetParameterName("stepMax",false);
00053 m_stepMaxCmd->SetUnitCategory("Length");
00054 m_stepMaxCmd->AvailableForStates(G4State_Idle);
00055
00056 m_updateCmd = new G4UIcmdWithoutParameter("/tutorial/det/update",this);
00057 m_updateCmd->SetGuidance("force to recompute geometry.");
00058 m_updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
00059 m_updateCmd->SetGuidance("if you changed geometrical value(s).");
00060 m_updateCmd->AvailableForStates(G4State_Idle);
00061 }
00062
00063
00064
00065 DetectorMessenger::~DetectorMessenger()
00066 {
00067 delete m_materialCmd;
00068 delete m_thicknessCmd;
00069 delete m_radiusCmd;
00070 delete m_lengthCmd;
00071 delete m_magFieldCmd;
00072 delete m_stepMaxCmd;
00073 delete m_updateCmd;
00074
00075 delete m_detDir;
00076 }
00077
00078
00079
00080 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
00081 {
00082 if( command == m_materialCmd )
00083 { m_detector->SetSpacecraftMaterial(newValue);}
00084
00085 if( command == m_thicknessCmd )
00086 { m_detector->SetSpacecraftThickness(m_thicknessCmd->GetNewDoubleValue(newValue));}
00087
00088 if( command == m_radiusCmd )
00089 { m_detector->SetCabinRadius(m_radiusCmd->GetNewDoubleValue(newValue));}
00090
00091 if( command == m_lengthCmd )
00092 { m_detector->SetCabinLength(m_lengthCmd->GetNewDoubleValue(newValue));}
00093
00094 if( command == m_magFieldCmd )
00095 { m_detector->SetMagField(m_magFieldCmd->GetNewDoubleValue(newValue));}
00096
00097 if( command == m_stepMaxCmd )
00098 { m_detector->SetMaxStep(m_stepMaxCmd->GetNewDoubleValue(newValue));}
00099
00100 if( command == m_updateCmd )
00101 { m_detector->UpdateGeometry();}
00102 }
00103
00104