Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 /// \file field/field04/src/F04DetectorMessenger.cc 28 /// \brief Implementation of the F04DetectorMessenger class 29 // 30 31 #include "F04DetectorMessenger.hh" 32 33 #include "G4UIcmdWithADoubleAndUnit.hh" 34 #include "G4UIcmdWithAString.hh" 35 #include "G4UIcmdWithAnInteger.hh" 36 #include "G4UIcmdWithoutParameter.hh" 37 #include "G4UIdirectory.hh" 38 39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 40 41 F04DetectorMessenger::F04DetectorMessenger(F04DetectorConstruction* detector) : fDetector(detector) 42 { 43 fDetDir = new G4UIdirectory("/field04/"); 44 fDetDir->SetGuidance(" field04 Simulation "); 45 46 fWorldMaterCmd = new G4UIcmdWithAString("/field04/SetWorldMat", this); 47 fWorldMaterCmd->SetGuidance("Select Material of the World"); 48 fWorldMaterCmd->SetParameterName("wchoice", true); 49 fWorldMaterCmd->SetDefaultValue("Air"); 50 fWorldMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 51 fWorldMaterCmd->SetToBeBroadcasted(false); 52 53 fWorldRCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetWorldR", this); 54 fWorldRCmd->SetGuidance("Set Radius of the World"); 55 fWorldRCmd->SetParameterName("WSizeR", false, false); 56 fWorldRCmd->SetDefaultUnit("cm"); 57 fWorldRCmd->SetRange("WSizeR>0."); 58 fWorldRCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 59 fWorldRCmd->SetToBeBroadcasted(false); 60 61 fWorldZCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetWorldZ", this); 62 fWorldZCmd->SetGuidance("Set Length of the World"); 63 fWorldZCmd->SetParameterName("WSizeZ", false, false); 64 fWorldZCmd->SetDefaultUnit("cm"); 65 fWorldZCmd->SetRange("WSizeZ>0."); 66 fWorldZCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 67 fWorldZCmd->SetToBeBroadcasted(false); 68 69 fCaptureRCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetCaptureR", this); 70 fCaptureRCmd->SetGuidance("Set Radius of the Capture Magnet"); 71 fCaptureRCmd->SetParameterName("CSizeR", false, false); 72 fCaptureRCmd->SetDefaultUnit("cm"); 73 fCaptureRCmd->SetRange("CSizeR>0."); 74 fCaptureRCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 75 fCaptureRCmd->SetToBeBroadcasted(false); 76 77 fCaptureZCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetCaptureZ", this); 78 fCaptureZCmd->SetGuidance("Set Length of the Capture Magnet"); 79 fCaptureZCmd->SetParameterName("CSizeZ", false, false); 80 fCaptureZCmd->SetDefaultUnit("cm"); 81 fCaptureZCmd->SetRange("CSizeZ>0."); 82 fCaptureZCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 83 fCaptureZCmd->SetToBeBroadcasted(false); 84 85 fTransferRCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferR", this); 86 fTransferRCmd->SetGuidance("Set Radius of the Transfer Magnet"); 87 fTransferRCmd->SetParameterName("TSizeR", false, false); 88 fTransferRCmd->SetDefaultUnit("cm"); 89 fTransferRCmd->SetRange("TSizeR>0."); 90 fTransferRCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 91 fTransferRCmd->SetToBeBroadcasted(false); 92 93 fTransferZCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferZ", this); 94 fTransferZCmd->SetGuidance("Set Length of the Transfer Magnet"); 95 fTransferZCmd->SetParameterName("TSizeZ", false, false); 96 fTransferZCmd->SetDefaultUnit("cm"); 97 fTransferZCmd->SetRange("TSizeZ>0."); 98 fTransferZCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 99 fTransferZCmd->SetToBeBroadcasted(false); 100 101 fTransferPCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferP", this); 102 fTransferPCmd->SetGuidance("Set Z pos of the T-Mgnt from end of C-Mgnt"); 103 fTransferPCmd->SetParameterName("TSizeP", false, false); 104 fTransferPCmd->SetDefaultUnit("cm"); 105 fTransferPCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 106 fTransferPCmd->SetToBeBroadcasted(false); 107 108 fTgtMaterCmd = new G4UIcmdWithAString("/field04/SetTgtMat", this); 109 fTgtMaterCmd->SetGuidance("Select Material of the Target"); 110 fTgtMaterCmd->SetParameterName("tchoice", true); 111 fTgtMaterCmd->SetDefaultValue("Tungsten"); 112 fTgtMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 113 fTgtMaterCmd->SetToBeBroadcasted(false); 114 115 fTgtRadCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTgtRad", this); 116 fTgtRadCmd->SetGuidance("Set Radius of the Target"); 117 fTgtRadCmd->SetParameterName("TgtSizeR", false, false); 118 fTgtRadCmd->SetDefaultUnit("cm"); 119 fTgtRadCmd->SetRange("TgtSizeR>0."); 120 fTgtRadCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 121 fTgtRadCmd->SetToBeBroadcasted(false); 122 123 fTgtThickCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTgtThick", this); 124 fTgtThickCmd->SetGuidance("Set Thickness of the Target"); 125 fTgtThickCmd->SetParameterName("TgtSizeZ", false, false); 126 fTgtThickCmd->SetDefaultUnit("cm"); 127 fTgtThickCmd->SetRange("TgtSizeZ>0."); 128 fTgtThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 129 fTgtThickCmd->SetToBeBroadcasted(false); 130 131 fTgtPosCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTgtPos", this); 132 fTgtPosCmd->SetGuidance("Set Z pos of the tgt relative to C-Mgnt centre"); 133 fTgtPosCmd->SetParameterName("TgtSizeP", false, false); 134 fTgtPosCmd->SetDefaultUnit("cm"); 135 fTgtPosCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 136 fTgtPosCmd->SetToBeBroadcasted(false); 137 138 fTgtAngCmd = new G4UIcmdWithAnInteger("/field04/SetTgtAng", this); 139 fTgtAngCmd->SetGuidance("Set the angle [in deg] of the Tgt relative to C-Mgnt centre"); 140 fTgtAngCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 141 fTgtAngCmd->SetToBeBroadcasted(false); 142 143 fDgrMaterCmd = new G4UIcmdWithAString("/field04/SetDgrMat", this); 144 fDgrMaterCmd->SetGuidance("Select Material of the Degrader"); 145 fDgrMaterCmd->SetParameterName("dchoice", true); 146 fDgrMaterCmd->SetDefaultValue("Lead"); 147 fDgrMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 148 fDgrMaterCmd->SetToBeBroadcasted(false); 149 150 fDgrRadCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetDgrRad", this); 151 fDgrRadCmd->SetGuidance("Set Radius of the Degrader"); 152 fDgrRadCmd->SetParameterName("DrgSizeR", false, false); 153 fDgrRadCmd->SetDefaultUnit("cm"); 154 fDgrRadCmd->SetRange("DrgSizeR>0."); 155 fDgrRadCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 156 fDgrRadCmd->SetToBeBroadcasted(false); 157 158 fDgrThickCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetDgrThick", this); 159 fDgrThickCmd->SetGuidance("Set Thickness of the Degrader"); 160 fDgrThickCmd->SetParameterName("DgrSizeZ", false, false); 161 fDgrThickCmd->SetDefaultUnit("cm"); 162 fDgrThickCmd->SetRange("DgrSizeZ>0."); 163 fDgrThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 164 fDgrThickCmd->SetToBeBroadcasted(false); 165 166 fDgrPosCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetDgrPos", this); 167 fDgrPosCmd->SetGuidance("Set Z pos of the Dgr relative to T-Mgnt centre"); 168 fDgrPosCmd->SetParameterName("DgrSizeP", false, false); 169 fDgrPosCmd->SetDefaultUnit("cm"); 170 fDgrPosCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 171 fDgrPosCmd->SetToBeBroadcasted(false); 172 } 173 174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 175 176 F04DetectorMessenger::~F04DetectorMessenger() 177 { 178 delete fDetDir; 179 180 delete fWorldMaterCmd; 181 delete fWorldRCmd; 182 delete fWorldZCmd; 183 184 delete fCaptureRCmd; 185 delete fCaptureZCmd; 186 187 delete fTransferRCmd; 188 delete fTransferZCmd; 189 delete fTransferPCmd; 190 191 delete fTgtMaterCmd; 192 delete fTgtRadCmd; 193 delete fTgtThickCmd; 194 delete fTgtPosCmd; 195 delete fTgtAngCmd; 196 197 delete fDgrMaterCmd; 198 delete fDgrRadCmd; 199 delete fDgrThickCmd; 200 delete fDgrPosCmd; 201 } 202 203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 204 205 void F04DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) 206 { 207 if (command == fWorldMaterCmd) { 208 fDetector->SetWorldMaterial(newValue); 209 } 210 211 if (command == fTgtMaterCmd) { 212 fDetector->SetTargetMaterial(newValue); 213 } 214 215 if (command == fDgrMaterCmd) { 216 fDetector->SetDegraderMaterial(newValue); 217 } 218 219 if (command == fWorldRCmd) { 220 fDetector->SetWorldSizeR(fWorldRCmd->GetNewDoubleValue(newValue)); 221 } 222 223 if (command == fWorldZCmd) { 224 fDetector->SetWorldSizeZ(fWorldZCmd->GetNewDoubleValue(newValue)); 225 } 226 227 if (command == fCaptureRCmd) 228 fDetector->SetCaptureMgntRadius(fCaptureRCmd->GetNewDoubleValue(newValue)); 229 230 if (command == fCaptureZCmd) 231 fDetector->SetCaptureMgntLength(fCaptureZCmd->GetNewDoubleValue(newValue)); 232 233 if (command == fTransferRCmd) 234 fDetector->SetTransferMgntRadius(fTransferRCmd->GetNewDoubleValue(newValue)); 235 236 if (command == fTransferZCmd) 237 fDetector->SetTransferMgntLength(fTransferZCmd->GetNewDoubleValue(newValue)); 238 239 if (command == fTransferPCmd) 240 fDetector->SetTransferMgntPos(fTransferPCmd->GetNewDoubleValue(newValue)); 241 242 if (command == fTgtRadCmd) fDetector->SetTargetRadius(fTgtRadCmd->GetNewDoubleValue(newValue)); 243 244 if (command == fTgtThickCmd) 245 fDetector->SetTargetThickness(fTgtThickCmd->GetNewDoubleValue(newValue)); 246 247 if (command == fTgtPosCmd) fDetector->SetTargetPos(fTgtPosCmd->GetNewDoubleValue(newValue)); 248 249 if (command == fTgtAngCmd) fDetector->SetTargetAngle(fTgtAngCmd->GetNewIntValue(newValue)); 250 251 if (command == fDgrRadCmd) fDetector->SetDegraderRadius(fDgrRadCmd->GetNewDoubleValue(newValue)); 252 253 if (command == fDgrThickCmd) 254 fDetector->SetDegraderThickness(fDgrThickCmd->GetNewDoubleValue(newValue)); 255 256 if (command == fDgrPosCmd) fDetector->SetDegraderPos(fDgrPosCmd->GetNewDoubleValue(newValue)); 257 258 if (command == fWorldZCmd) fDetector->SetWorldSizeZ(fWorldZCmd->GetNewDoubleValue(newValue)); 259 260 if (command == fWorldRCmd) fDetector->SetWorldSizeR(fWorldRCmd->GetNewDoubleValue(newValue)); 261 } 262