00001 #include "musrDetectorMessenger.hh"
00002 #include "musrDetectorConstruction.hh"
00003 #include "G4UIdirectory.hh"
00004 #include "G4UIcmdWithAString.hh"
00005 #include "G4UIcmdWithADoubleAndUnit.hh"
00006 #include "G4UIcmdWithAnInteger.hh"
00007 #include "G4UIcmdWithoutParameter.hh"
00008
00009 #include "globals.hh"
00010
00011
00012
00013 musrDetectorMessenger::musrDetectorMessenger(musrDetectorConstruction* myDet)
00014 :myDetector(myDet)
00015 {
00016 alcDir = new G4UIdirectory("/musr/");
00017 alcDir->SetGuidance("UI commands specific to this example.");
00018
00019 detDir = new G4UIdirectory("/musr/det/");
00020 detDir->SetGuidance("detector control.");
00021
00022 TargetPosCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setTPos",this);
00023 TargetPosCmd->SetGuidance("Set position of the target");
00024 TargetPosCmd->SetParameterName("Pos",false);
00025 TargetPosCmd->SetUnitCategory("Length");
00026 TargetPosCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00027
00028 TargetLengthCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setTLength",this);
00029 TargetLengthCmd->SetGuidance("Set thickness of the target");
00030 TargetLengthCmd->SetParameterName("TT",false);
00031 TargetLengthCmd->SetUnitCategory("Length");
00032 TargetLengthCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00033
00034
00035 TargetMaterCmd = new G4UIcmdWithAString("/musr/det/setTargetMat",this);
00036 TargetMaterCmd->SetGuidance("Select Material of the Target");
00037 TargetMaterCmd->SetParameterName("choice",false);
00038 TargetMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00039
00040 DetSepCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setDetSep",this);
00041 DetSepCmd->SetGuidance("Set detector separation");
00042 DetSepCmd->SetParameterName("Sep",false);
00043 DetSepCmd->SetUnitCategory("Length");
00044 DetSepCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00045
00046 RadialNumberCmd = new G4UIcmdWithAnInteger("/musr/det/setRadialNo",this);
00047 RadialNumberCmd->SetGuidance("Set number of radial pixels");
00048 RadialNumberCmd->SetParameterName("rno",false);
00049 RadialNumberCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00050
00051 LengthNumberCmd = new G4UIcmdWithAnInteger("/musr/det/setLengthNo",this);
00052 LengthNumberCmd->SetGuidance("Set number of length pixels");
00053 LengthNumberCmd->SetParameterName("lno",false);
00054 LengthNumberCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00055
00056 LRadiusCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setLRadius",this);
00057 LRadiusCmd->SetGuidance("Set large radius");
00058 LRadiusCmd->SetParameterName("lrad",false);
00059 LRadiusCmd->SetUnitCategory("Length");
00060 LRadiusCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00061
00062 SRadiusCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setSRadius",this);
00063 SRadiusCmd->SetGuidance("Set small radius");
00064 SRadiusCmd->SetParameterName("srad",false);
00065 SRadiusCmd->SetUnitCategory("Length");
00066 SRadiusCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00067
00068
00069 ArrayLengthCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setArrayLength",this);
00070 ArrayLengthCmd->SetGuidance("Set array length");
00071 ArrayLengthCmd->SetParameterName("array",false);
00072 ArrayLengthCmd->SetUnitCategory("Length");
00073 ArrayLengthCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00074
00075 DetectorThicknessCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setDetectorThickness",this);
00076 DetectorThicknessCmd->SetGuidance("Set detector thickness");
00077 DetectorThicknessCmd->SetParameterName("detthick",false);
00078 DetectorThicknessCmd->SetUnitCategory("Length");
00079 DetectorThicknessCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00080
00081 BeampipeClearanceCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setBeampipeClearance",this);
00082 BeampipeClearanceCmd->SetGuidance("Set Beampipe clearance");
00083 BeampipeClearanceCmd->SetParameterName("bclear",false);
00084 BeampipeClearanceCmd->SetUnitCategory("Length");
00085 BeampipeClearanceCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00086
00087 ColRadiusCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setColRadius",this);
00088 ColRadiusCmd->SetGuidance("Set collimator radius");
00089 ColRadiusCmd->SetParameterName("crad",false);
00090 ColRadiusCmd->SetUnitCategory("Length");
00091 ColRadiusCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00092
00093
00094 UpdateCmd = new G4UIcmdWithoutParameter("/musr/det/update",this);
00095 UpdateCmd->SetGuidance("Update calorimeter geometry.");
00096 UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
00097 UpdateCmd->SetGuidance("if you changed geometrical value(s).");
00098 UpdateCmd->AvailableForStates(G4State_Idle);
00099
00100 FieldCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setField",this);
00101 FieldCmd->SetGuidance("Define magnetic field.");
00102 FieldCmd->SetGuidance("Magnetic field will be in Z direction.");
00103 FieldCmd->SetParameterName("Bz",false);
00104 FieldCmd->SetUnitCategory("Magnetic flux density");
00105 FieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00106
00107 UFieldCmd = new G4UIcmdWithADoubleAndUnit("/musr/det/setUniformField",this);
00108 UFieldCmd->SetGuidance("Define uniform magnetic field.");
00109 UFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
00110 UFieldCmd->SetParameterName("Bz",false);
00111 UFieldCmd->SetUnitCategory("Magnetic flux density");
00112 UFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00113
00114
00115
00116
00117
00118 }
00119
00120
00121
00122 musrDetectorMessenger::~musrDetectorMessenger()
00123 {
00124 delete TargetPosCmd;
00125 delete TargetMaterCmd;
00126 delete DetSepCmd;
00127 delete RadialNumberCmd;
00128 delete LengthNumberCmd;
00129 delete LRadiusCmd;
00130 delete SRadiusCmd;
00131 delete ArrayLengthCmd;
00132 delete DetectorThicknessCmd;
00133 delete ColRadiusCmd;
00134 delete BeampipeClearanceCmd;
00135 delete UpdateCmd;
00136 delete detDir;
00137 delete alcDir;
00138 delete FieldCmd;
00139 delete UFieldCmd;
00140 delete TargetLengthCmd;
00141
00142 }
00143
00144
00145
00146 void musrDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
00147 {
00148
00149 if( command == TargetPosCmd )
00150 { myDetector->SetTargetPos(TargetPosCmd->GetNewDoubleValue(newValue));}
00151
00152 if( command == TargetLengthCmd )
00153 { myDetector->SetTargetThickness(TargetLengthCmd->GetNewDoubleValue(newValue));}
00154
00155 if( command == TargetMaterCmd )
00156 { myDetector->SetTargetMaterial(newValue);}
00157
00158 if( command == DetSepCmd )
00159 { myDetector->SetDetSep(DetSepCmd->GetNewDoubleValue(newValue));}
00160
00161 if( command == RadialNumberCmd )
00162 { myDetector->SetRadialNumber(RadialNumberCmd->GetNewIntValue(newValue));}
00163
00164 if( command == LengthNumberCmd )
00165 { myDetector->SetLengthNumber(LengthNumberCmd->GetNewIntValue(newValue));}
00166
00167 if( command == LRadiusCmd )
00168 { myDetector->SetLargeRadius(LRadiusCmd->GetNewDoubleValue(newValue));}
00169
00170 if( command == SRadiusCmd )
00171 { myDetector->SetSmallRadius(SRadiusCmd->GetNewDoubleValue(newValue));}
00172
00173 if( command == ArrayLengthCmd )
00174 { myDetector->SetArrayLength(ArrayLengthCmd->GetNewDoubleValue(newValue));}
00175
00176 if( command == DetectorThicknessCmd )
00177 { myDetector->SetDetectorThickness(DetectorThicknessCmd->GetNewDoubleValue(newValue));}
00178
00179 if( command == ColRadiusCmd )
00180 { myDetector->SetCollimatorRadius(ColRadiusCmd->GetNewDoubleValue(newValue));}
00181
00182 if( command == BeampipeClearanceCmd )
00183 { myDetector->SetBeampipeClearance(BeampipeClearanceCmd->GetNewDoubleValue(newValue));}
00184
00185
00186 if( command == UpdateCmd )
00187 { myDetector->UpdateGeometry(); }
00188
00189 if( command == FieldCmd )
00190 { myDetector->SetMagField(FieldCmd->GetNewDoubleValue(newValue));}
00191
00192 if( command == UFieldCmd )
00193 { myDetector->SetUniformMagField(UFieldCmd->GetNewDoubleValue(newValue));}
00194
00195 }
00196
00197