00001 #include "BesMagneticFieldMessenger.hh"
00002 #include "BesMagneticField.hh"
00003
00004 #include "G4UIdirectory.hh"
00005 #include "G4UIcmdWithAString.hh"
00006 #include "G4UIcmdWithAnInteger.hh"
00007 #include "G4UIcmdWithADouble.hh"
00008 #include "G4UIcmdWithADoubleAndUnit.hh"
00009 #include "G4UIcmdWithoutParameter.hh"
00010
00011
00012 BesMagneticFieldMessenger::BesMagneticFieldMessenger(BesMagneticField* pEMfieldSetup):fEMfieldSetup(pEMfieldSetup)
00013 {
00014 F01detDir= new G4UIdirectory("/field/");
00015 F01detDir->SetGuidance("Bes MagneticField tracking control.");
00016
00017 StepperCmd= new G4UIcmdWithAnInteger("/field/SetStepperType",this);
00018 StepperCmd->SetGuidance("Select stepper type for magnetic field");
00019 StepperCmd->SetParameterName("choice",true);
00020 StepperCmd->SetDefaultValue(4);
00021 StepperCmd->SetRange("choice>=0&&choice<=9");
00022
00023 MinStepCmd= new G4UIcmdWithADoubleAndUnit("/field/SetMinStep",this);
00024 MinStepCmd->SetGuidance("Please change it carefully,it is better keep it const");
00025 MinStepCmd->SetParameterName("MinStep",true);
00026 MinStepCmd->SetDefaultUnit("mm");
00027 MinStepCmd->SetDefaultValue(0.01);
00028 MinStepCmd->SetRange("MinStep>=0&&MinStep<=1");
00029
00030 DeltaOneStepCmd= new G4UIcmdWithADoubleAndUnit("/field/SetDeltaOneStep",this);
00031 DeltaOneStepCmd->SetGuidance("Set DeltaOneStep for tracking");
00032 DeltaOneStepCmd->SetParameterName("DeltaOneStep",true);
00033 DeltaOneStepCmd->SetDefaultUnit("mm");
00034 DeltaOneStepCmd->SetDefaultValue(0.01);
00035 DeltaOneStepCmd->SetRange("DeltaOneStep>=0");
00036
00037 DeltaIntersectionCmd=new G4UIcmdWithADoubleAndUnit("/field/SetDeltaIntersection",this);
00038 DeltaIntersectionCmd->SetGuidance("Set DeltaIntersection for tracking");
00039 DeltaIntersectionCmd->SetParameterName("DeltaIntersection",true);
00040 DeltaIntersectionCmd->SetDefaultUnit("mm");
00041 DeltaIntersectionCmd->SetDefaultValue(0.001);
00042 DeltaIntersectionCmd->SetRange("DeltaIntersection>=0");
00043
00044 MinimumEpsilonStepCmd=new G4UIcmdWithADouble("/field/SetMinimumEpsilonStep",this);
00045 MinimumEpsilonStepCmd->SetGuidance("Set Minimum Epsilon Step for tracking");
00046 MinimumEpsilonStepCmd->SetParameterName("MinimumEpsilonStep",true);
00047 MinimumEpsilonStepCmd->SetDefaultValue(5.0e-5);
00048 MinimumEpsilonStepCmd->SetRange("MinimumEpsilonStep>=0");
00049
00050 MaximumEpsilonStepCmd=new G4UIcmdWithADouble("/field/SetMaximumEpsilonStep",this);
00051 MaximumEpsilonStepCmd->SetGuidance("Set Maximum Epsilon Step for tracking");
00052 MaximumEpsilonStepCmd->SetParameterName("MaximumEpsilonStep",true);
00053 MaximumEpsilonStepCmd->SetDefaultValue(1.0e-3);
00054 MaximumEpsilonStepCmd->SetRange("MaximumEpsilonStep>=0");
00055 }
00056
00057 BesMagneticFieldMessenger::~BesMagneticFieldMessenger()
00058 {
00059 delete MaximumEpsilonStepCmd;
00060 delete MinimumEpsilonStepCmd;
00061 delete DeltaIntersectionCmd;
00062 delete DeltaOneStepCmd;
00063 delete MinStepCmd;
00064 delete StepperCmd;
00065 delete F01detDir;
00066 }
00067
00068 void BesMagneticFieldMessenger::SetNewValue( G4UIcommand* command, G4String newvalue)
00069 {
00070
00071 if(command==StepperCmd)
00072 {
00073 fEMfieldSetup->SetStepperType(StepperCmd->GetNewIntValue(newvalue));
00074 fEMfieldSetup->CreateStepperAndChordFinder();
00075 }
00076 if(command==MinStepCmd)
00077 {
00078 fEMfieldSetup->SetMinStep(MinStepCmd->GetNewDoubleValue(newvalue));
00079 fEMfieldSetup->CreateStepperAndChordFinder();
00080 }
00081 if(command==DeltaOneStepCmd)
00082 {
00083 fEMfieldSetup->SetDeltaOneStep(DeltaOneStepCmd->GetNewDoubleValue(newvalue));
00084 }
00085 if(command==DeltaIntersectionCmd)
00086 {
00087 fEMfieldSetup->SetDeltaIntersection(DeltaIntersectionCmd->GetNewDoubleValue(newvalue));
00088 }
00089 if(command==MinimumEpsilonStepCmd)
00090 {
00091 fEMfieldSetup->SetMinimumEpsilonStep(MinimumEpsilonStepCmd->GetNewDoubleValue(newvalue));
00092 }
00093 if(command==MaximumEpsilonStepCmd)
00094 {
00095 fEMfieldSetup->SetMaximumEpsilonStep(MaximumEpsilonStepCmd->GetNewDoubleValue(newvalue));
00096 }
00097
00098 }