00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "BesEmcDetectorMessenger.hh"
00011
00012 #include "G4ThreeVector.hh"
00013 #include "BesEmcConstruction.hh"
00014 #include "BesEmcGeometry.hh"
00015 #include "G4UIdirectory.hh"
00016 #include "G4UIcmdWithAString.hh"
00017 #include "G4UIcmdWithAnInteger.hh"
00018 #include "G4UIcmdWithADoubleAndUnit.hh"
00019 #include "G4UIcmdWith3VectorAndUnit.hh"
00020 #include "G4UIcmdWithoutParameter.hh"
00021 #include "G4Material.hh"
00022
00023
00024 BesEmcDetectorMessenger::BesEmcDetectorMessenger(
00025 BesEmcConstruction* BesDet,
00026 BesEmcGeometry* besEMCGeometry)
00027 :BesEmc(BesDet)
00028 {
00029 fBesEmcGeometry=besEMCGeometry;
00030
00031 BesdetDir = new G4UIdirectory("/calor/");
00032 BesdetDir->SetGuidance("Bes calorimeter detector control.");
00033
00034 verboseCmd = new G4UIcmdWithAnInteger("/calor/verbose",this);
00035 verboseCmd->SetGuidance("Set Verbose level of calor management category.");
00036 verboseCmd->SetGuidance(" 0 : Important information");
00037 verboseCmd->SetGuidance(" 1 : Base information");
00038 verboseCmd->SetGuidance(" 2 : More...");
00039 verboseCmd->SetParameterName("level",true);
00040 verboseCmd->SetRange("level>=0");
00041 verboseCmd->SetDefaultValue(0);
00042
00043 CryMaterCmd = new G4UIcmdWithAString("/calor/setCryMat",this);
00044 CryMaterCmd->SetGuidance("Select Material of the Crystal.");
00045 CryMaterCmd->SetParameterName("choice",true,true);
00046
00047
00048 CasingMaterCmd = new G4UIcmdWithAString("/calor/setCasMat",this);
00049 CasingMaterCmd->SetGuidance("Select Material of the Casing.");
00050 CasingMaterCmd->SetParameterName("choice",true,true);
00051
00052
00053 CasingThickCmd = new G4UIcmdWith3VectorAndUnit("/calor/setCasThick",this);
00054 CasingThickCmd->SetGuidance("Set Thickness of the Casing");
00055 CasingThickCmd->SetParameterName("TyvekThk","AlThk","MylarThk",true);
00056 CasingThickCmd->SetRange("Size>=0.");
00057 CasingThickCmd->SetUnitCategory("Length");
00058 CasingThickCmd->SetDefaultValue(fBesEmcGeometry->GetCasingThickness()/mm);
00059 CasingThickCmd->SetDefaultUnit("mm");
00060
00061
00062 SizeRminCmd = new G4UIcmdWithADoubleAndUnit("/calor/setSizeRmin",this);
00063 SizeRminCmd->SetGuidance("Set Rmin size of the barrel calorimeter");
00064 SizeRminCmd->SetParameterName("Size",true);
00065 SizeRminCmd->SetRange("Size>0.");
00066 SizeRminCmd->SetUnitCategory("Length");
00067 SizeRminCmd->SetDefaultValue(fBesEmcGeometry->GetBSCRmin()/cm);
00068 SizeRminCmd->SetDefaultUnit("cm");
00069
00070
00071 NbPhiCmd = new G4UIcmdWithAnInteger("/calor/setNbPhi",this);
00072 NbPhiCmd->SetGuidance("Set number of crystals at phi direction.");
00073 NbPhiCmd->SetParameterName("NbCrystals",false);
00074 NbPhiCmd->SetRange("NbCrystals>0 && NbCrystals<=150");
00075
00076
00077 NbThetaCmd = new G4UIcmdWithAnInteger("/calor/setNbTheta",this);
00078 NbThetaCmd->SetGuidance("Set number of crystals at theta direction.");
00079 NbThetaCmd->SetParameterName("NbCrystals",false);
00080 NbThetaCmd->SetRange("NbCrystals>0 && NbCrystals<=22");
00081
00082
00083 StartIDThetaCmd = new G4UIcmdWithAnInteger("/calor/setStartTheta",this);
00084 StartIDThetaCmd->SetGuidance("Set ID of starting crystals at theta direction.");
00085 StartIDThetaCmd->SetParameterName("IDCrystal",false);
00086 StartIDThetaCmd->SetRange("IDCrystal>=0 && IDCrystal<22");
00087
00088
00089 LengthCmd = new G4UIcmdWithADoubleAndUnit("/calor/setCryLength",this);
00090 LengthCmd->SetGuidance("Set Length of crystals of barrel calorimeter");
00091 LengthCmd->SetParameterName("Size",true);
00092 LengthCmd->SetRange("Size>0.");
00093 LengthCmd->SetUnitCategory("Length");
00094 LengthCmd->SetDefaultValue(fBesEmcGeometry->GetBSCCryLength()/cm);
00095 LengthCmd->SetDefaultUnit("cm");
00096
00097
00098 UpdateCmd = new G4UIcmdWithoutParameter("/calor/update",this);
00099 UpdateCmd->SetGuidance("Update calorimeter geometry.");
00100 UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
00101 UpdateCmd->SetGuidance("if you changed geometrical value(s).");
00102
00103
00104 MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/calor/setField",this);
00105 MagFieldCmd->SetGuidance("Define magnetic field.");
00106 MagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
00107 MagFieldCmd->SetParameterName("Bz",true);
00108 MagFieldCmd->SetRange("Bz>=0.");
00109 MagFieldCmd->SetUnitCategory("Magnetic flux density");
00110 MagFieldCmd->SetDefaultValue(BesEmc->GetMagField()/tesla);
00111 MagFieldCmd->SetDefaultUnit("tesla");
00112
00113 }
00114
00115
00116
00117 BesEmcDetectorMessenger::~BesEmcDetectorMessenger()
00118 {
00119 delete verboseCmd;
00120 delete LengthCmd;
00121 delete NbPhiCmd; delete NbThetaCmd;
00122 delete StartIDThetaCmd;
00123 delete CryMaterCmd; delete CasingMaterCmd;
00124 delete CasingThickCmd;
00125 delete SizeRminCmd;
00126 delete UpdateCmd;
00127 delete MagFieldCmd;
00128 delete BesdetDir;
00129 }
00130
00131
00132
00133 void BesEmcDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
00134 {
00135 if( command == verboseCmd )
00136 {
00137 BesEmc->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
00138 }
00139
00140 if( command == CryMaterCmd )
00141 { BesEmc->SetCrystalMaterial(newValue);}
00142
00143 if( command == CasingMaterCmd )
00144 { BesEmc->SetCasingMaterial(newValue);}
00145
00146 if( command == CasingThickCmd )
00147 { BesEmc->SetCasingThickness(CasingThickCmd->GetNew3VectorValue(newValue));}
00148
00149 if( command == SizeRminCmd )
00150 { BesEmc->SetBSCRmin(SizeRminCmd->GetNewDoubleValue(newValue));}
00151
00152 if( command == NbPhiCmd )
00153 { BesEmc->SetBSCNbPhi(NbPhiCmd->GetNewIntValue(newValue));}
00154
00155 if( command == NbThetaCmd )
00156 { BesEmc->SetBSCNbTheta(NbThetaCmd->GetNewIntValue(newValue));}
00157
00158 if( command == StartIDThetaCmd )
00159 { BesEmc->SetStartIDTheta(StartIDThetaCmd->GetNewIntValue(newValue));}
00160
00161 if( command == LengthCmd )
00162 { BesEmc->SetBSCCrystalLength(LengthCmd->GetNewDoubleValue(newValue));}
00163
00164 if( command == UpdateCmd )
00165 { BesEmc->UpdateGeometry(); }
00166
00167 if( command == MagFieldCmd )
00168 { BesEmc->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));}
00169 }
00170
00171
00172
00173 G4String BesEmcDetectorMessenger::GetCurrentValue(G4UIcommand * command)
00174 {
00175 G4String cv;
00176
00177 if( command == verboseCmd )
00178 { cv = verboseCmd->ConvertToString(BesEmc->GetVerboseLevel()); }
00179
00180 if( command == CryMaterCmd )
00181 { cv = BesEmc->GetCrystalMaterial()->GetName(); }
00182
00183 if( command == CasingMaterCmd )
00184 { cv = BesEmc->GetCasingMaterial()->GetName(); }
00185
00186 return cv;
00187 }
00188
00189