Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 /// \file field/field04/src/F04DetectorConstru << 28 /// \brief Implementation of the F04DetectorCo << 29 // 27 // 30 //....oooOO0OOooo........oooOO0OOooo........oo << 31 //....oooOO0OOooo........oooOO0OOooo........oo << 32 28 33 #include "F04DetectorConstruction.hh" << 29 #include "G4ios.hh" >> 30 #include "globals.hh" 34 31 >> 32 #include "F04DetectorConstruction.hh" 35 #include "F04DetectorMessenger.hh" 33 #include "F04DetectorMessenger.hh" 36 #include "F04FocusSolenoid.hh" << 34 37 #include "F04GlobalField.hh" 35 #include "F04GlobalField.hh" 38 #include "F04Materials.hh" << 39 #include "F04SimpleSolenoid.hh" << 40 36 41 #include "G4AutoDelete.hh" << 37 #include "G4Tubs.hh" 42 #include "G4GeometryManager.hh" << 43 #include "G4LogicalVolume.hh" 38 #include "G4LogicalVolume.hh" 44 #include "G4LogicalVolumeStore.hh" << 39 #include "G4PVPlacement.hh" >> 40 45 #include "G4Material.hh" 41 #include "G4Material.hh" 46 #include "G4NistManager.hh" 42 #include "G4NistManager.hh" 47 #include "G4PVPlacement.hh" << 43 48 #include "G4PhysicalConstants.hh" << 44 #include "G4FieldManager.hh" >> 45 #include "G4UniformMagField.hh" >> 46 #include "G4TransportationManager.hh" >> 47 >> 48 #include "G4GeometryManager.hh" >> 49 >> 50 #include "G4SolidStore.hh" >> 51 #include "G4RegionStore.hh" >> 52 #include "G4LogicalVolumeStore.hh" 49 #include "G4PhysicalVolumeStore.hh" 53 #include "G4PhysicalVolumeStore.hh" 50 #include "G4RotationMatrix.hh" << 54 51 #include "G4RunManager.hh" 55 #include "G4RunManager.hh" 52 #include "G4SolidStore.hh" << 53 #include "G4StateManager.hh" << 54 #include "G4SystemOfUnits.hh" << 55 #include "G4Tubs.hh" << 56 #include "globals.hh" << 57 56 58 //....oooOO0OOooo........oooOO0OOooo........oo << 57 #include "F04DetectorConstruction.hh" >> 58 #include "F04DetectorMessenger.hh" >> 59 #include "F04Materials.hh" >> 60 >> 61 #include "G4RotationMatrix.hh" >> 62 >> 63 #include "F04SimpleSolenoid.hh" >> 64 #include "F04FocusSolenoid.hh" 59 65 60 F04DetectorConstruction::F04DetectorConstructi 66 F04DetectorConstruction::F04DetectorConstruction() >> 67 : solidWorld(0), logicWorld(0), physiWorld(0), >> 68 solidTarget(0), logicTarget(0), physiTarget(0), >> 69 solidDegrader(0),logicDegrader(0), physiDegrader(0), >> 70 solidCaptureMgnt(0), logicCaptureMgnt(0), physiCaptureMgnt(0), >> 71 solidTransferMgnt(0), logicTransferMgnt(0), physiTransferMgnt(0), >> 72 WorldMaterial(0), TargetMaterial(0), DegraderMaterial(0), >> 73 focusSolenoid(0), simpleSolenoid(0) 61 { 74 { >> 75 WorldSizeZ = 50.*m; >> 76 WorldSizeR = 5.*m; >> 77 >> 78 TargetRadius = 0.4*cm; >> 79 TargetThickness = 16.0*cm; >> 80 62 SetTargetAngle(170); 81 SetTargetAngle(170); 63 SetCaptureMgntB1(2.5 * tesla); << 64 SetCaptureMgntB2(5.0 * tesla); << 65 SetTransferMgntB(5.0 * tesla); << 66 82 67 fDegraderPos = -fTransferMgntLength / 2. + f << 83 DegraderRadius = 30.0*cm; >> 84 DegraderThickness = 0.1*cm; 68 85 69 fDetectorMessenger = new F04DetectorMessenge << 86 CaptureMgntRadius = 0.6*m; 70 } << 87 CaptureMgntLength = 4.0*m; 71 88 72 //....oooOO0OOooo........oooOO0OOooo........oo << 89 SetCaptureMgntB1(2.5*tesla); >> 90 SetCaptureMgntB2(5.0*tesla); 73 91 74 F04DetectorConstruction::~F04DetectorConstruct << 92 TransferMgntRadius = 0.3*m; 75 { << 93 TransferMgntLength = 15.0*m; 76 delete fDetectorMessenger; << 94 >> 95 SetTransferMgntB(5.0*tesla); >> 96 >> 97 DegraderPos = -TransferMgntLength/2. + DegraderThickness/2.; >> 98 >> 99 // ensure the global field is initialized >> 100 (void)F04GlobalField::getObject(); >> 101 >> 102 detectorMessenger = new F04DetectorMessenger(this); 77 } 103 } 78 104 79 //....oooOO0OOooo........oooOO0OOooo........oo << 105 F04DetectorConstruction::~F04DetectorConstruction() >> 106 { >> 107 delete detectorMessenger; >> 108 } 80 109 81 G4VPhysicalVolume* F04DetectorConstruction::Co 110 G4VPhysicalVolume* F04DetectorConstruction::Construct() 82 { 111 { 83 if (fPhysiWorld) { << 112 materials = F04Materials::GetInstance(); 84 G4GeometryManager::GetInstance()->OpenGeom << 85 G4PhysicalVolumeStore::GetInstance()->Clea << 86 G4LogicalVolumeStore::GetInstance()->Clean << 87 G4SolidStore::GetInstance()->Clean(); << 88 } << 89 << 90 fMaterials = F04Materials::GetInstance(); << 91 113 92 DefineMaterials(); 114 DefineMaterials(); 93 115 94 return ConstructDetector(); 116 return ConstructDetector(); 95 } 117 } 96 118 97 //....oooOO0OOooo........oooOO0OOooo........oo << 98 << 99 void F04DetectorConstruction::DefineMaterials( 119 void F04DetectorConstruction::DefineMaterials() 100 { 120 { 101 // define materials for the experiment << 121 //define materials for the experiment 102 122 103 fVacuum = fMaterials->GetMaterial("G4_Galact << 123 Vacuum = materials->GetMaterial("G4_Galactic"); 104 124 105 fWorldMaterial = fMaterials->GetMaterial("G4 << 125 WorldMaterial = materials->GetMaterial("G4_AIR"); 106 fDegraderMaterial = fMaterials->GetMaterial( << 126 DegraderMaterial = materials->GetMaterial("G4_Pb"); 107 fTargetMaterial = fMaterials->GetMaterial("G << 127 TargetMaterial = materials->GetMaterial("G4_W"); 108 } 128 } 109 129 110 //....oooOO0OOooo........oooOO0OOooo........oo << 111 << 112 G4VPhysicalVolume* F04DetectorConstruction::Co 130 G4VPhysicalVolume* F04DetectorConstruction::ConstructDetector() 113 { 131 { 114 fSolidWorld = new G4Tubs("World", 0., GetWor << 132 solidWorld = new G4Tubs("World", 115 << 133 0.,GetWorldSizeR(),GetWorldSizeZ()/2.,0.,twopi); 116 fLogicWorld = new G4LogicalVolume(fSolidWorl << 134 117 << 135 logicWorld = new G4LogicalVolume(solidWorld, 118 fPhysiWorld = << 136 GetWorldMaterial(), 119 new G4PVPlacement(nullptr, G4ThreeVector() << 137 "World"); >> 138 >> 139 physiWorld = new G4PVPlacement(0, >> 140 G4ThreeVector(), >> 141 "World", >> 142 logicWorld, >> 143 0, >> 144 false, >> 145 0); 120 146 121 // Capture Magnet 147 // Capture Magnet 122 148 123 fSolidCaptureMgnt = << 149 solidCaptureMgnt = new G4Tubs("CaptureMgnt", 124 new G4Tubs("CaptureMgnt", 0., GetCaptureMg << 150 0.,GetCaptureMgntRadius(), 125 << 151 GetCaptureMgntLength()/2.,0.,twopi); 126 fLogicCaptureMgnt = new G4LogicalVolume(fSol << 152 127 << 153 logicCaptureMgnt = new G4LogicalVolume(solidCaptureMgnt, 128 fCaptureMgntCenter = G4ThreeVector(); << 154 Vacuum, 129 << 155 "CaptureMgnt"); 130 fPhysiCaptureMgnt = new G4PVPlacement(nullpt << 156 131 fLogic << 157 G4ThreeVector CaptureMgntCenter = G4ThreeVector(); >> 158 >> 159 physiCaptureMgnt = new G4PVPlacement(0, >> 160 CaptureMgntCenter, >> 161 "CaptureMgnt", >> 162 logicCaptureMgnt, >> 163 physiWorld, >> 164 false, >> 165 0); 132 166 133 // Transfer Magnet 167 // Transfer Magnet 134 168 135 fSolidTransferMgnt = new G4Tubs("TransferMgn << 169 solidTransferMgnt = new G4Tubs("TransferMgnt", 136 GetTransferM << 170 0.,GetTransferMgntRadius(), 137 << 171 GetTransferMgntLength()/2.,0.,twopi); 138 fLogicTransferMgnt = new G4LogicalVolume(fSo << 172 >> 173 logicTransferMgnt = new G4LogicalVolume(solidTransferMgnt, >> 174 Vacuum, >> 175 "TransferMgnt"); >> 176 >> 177 G4double z = GetCaptureMgntLength()/2. + GetTransferMgntLength()/2. >> 178 + GetTransferMgntPos(); >> 179 G4double x = GetTransferMgntPos()/2.; 139 180 140 G4double z = GetCaptureMgntLength() / 2. + G << 181 G4ThreeVector TransferMgntCenter = G4ThreeVector(x,0.,z); 141 G4double x = GetTransferMgntPos() / 2.; << 142 182 143 fTransferMgntCenter = G4ThreeVector(x, 0., z << 183 G4RotationMatrix* g4rot = new G4RotationMatrix(); 144 << 184 *g4rot = stringToRotationMatrix("Y30,X10"); 145 auto g4rot = new G4RotationMatrix(); << 146 *g4rot = StringToRotationMatrix("Y30,X10"); << 147 *g4rot = g4rot->inverse(); 185 *g4rot = g4rot->inverse(); 148 if (*g4rot == G4RotationMatrix()) g4rot = nu << 186 if (*g4rot == G4RotationMatrix()) g4rot = NULL; 149 187 150 fPhysiTransferMgnt = new G4PVPlacement(g4rot << 188 physiTransferMgnt = new G4PVPlacement(g4rot, 151 fLogi << 189 TransferMgntCenter, >> 190 "TransferMgnt", >> 191 logicTransferMgnt, >> 192 physiWorld, >> 193 false, >> 194 0); 152 195 153 // Test Plane 196 // Test Plane 154 197 155 auto solidTestPlane = new G4Tubs("TestPlane" << 198 G4Tubs* solidTestPlane = new G4Tubs("TestPlane", 156 << 199 0.,GetTransferMgntRadius(), 157 auto logicTestPlane = new G4LogicalVolume(so << 200 1.*mm,0.,twopi); 158 << 201 159 z = GetTransferMgntLength() / 2. - 1. * mm; << 202 G4LogicalVolume* logicTestPlane = new G4LogicalVolume(solidTestPlane, 160 << 203 Vacuum, 161 G4ThreeVector testPlaneCenter = G4ThreeVecto << 204 "TestPlane"); 162 << 205 163 new G4PVPlacement(nullptr, testPlaneCenter, << 206 164 false, 0); << 207 z = GetTransferMgntLength()/2. - 1.*mm; >> 208 >> 209 G4ThreeVector TestPlaneCenter = G4ThreeVector(0.,0.,z); >> 210 >> 211 new G4PVPlacement(0, >> 212 TestPlaneCenter, >> 213 "TestPlane", >> 214 logicTestPlane, >> 215 physiTransferMgnt, >> 216 false, >> 217 0); 165 218 166 // Target 219 // Target 167 220 168 if (GetTargetThickness() > 0.) { << 221 if (GetTargetThickness() > 0.) 169 fSolidTarget = << 222 { 170 new G4Tubs("Target", 0., GetTargetRadius << 223 solidTarget = new G4Tubs("Target", 171 << 224 0.,GetTargetRadius(), 172 fLogicTarget = new G4LogicalVolume(fSolidT << 225 GetTargetThickness()/2.,0.,twopi); 173 << 226 174 G4int i = GetTargetAngle(); << 227 logicTarget = new G4LogicalVolume(solidTarget, 175 << 228 GetTargetMaterial(), 176 G4String angle = std::to_string(i); << 229 "Target"); 177 G4StrUtil::strip(angle); << 230 178 angle = "Y" + angle; << 231 G4int i = GetTargetAngle(); 179 << 232 180 g4rot = new G4RotationMatrix(); << 233 char c[4]; 181 *g4rot = StringToRotationMatrix(angle); << 234 sprintf(c,"%d",i); 182 *g4rot = g4rot->inverse(); << 235 G4String Angle = c; 183 if (*g4rot == G4RotationMatrix()) g4rot = << 236 Angle = Angle.strip(G4String::both,' '); 184 << 237 Angle = "Y" + Angle; 185 G4ThreeVector targetCenter(0., 0., GetTarg << 238 186 << 239 g4rot = new G4RotationMatrix(); 187 fPhysiTarget = << 240 *g4rot = stringToRotationMatrix(Angle); 188 new G4PVPlacement(g4rot, targetCenter, " << 241 *g4rot = g4rot->inverse(); >> 242 if (*g4rot == G4RotationMatrix()) g4rot = NULL; >> 243 >> 244 G4ThreeVector TargetCenter(0.,0.,GetTargetPos()); >> 245 >> 246 physiTarget = new G4PVPlacement(g4rot, >> 247 TargetCenter, >> 248 "Target", >> 249 logicTarget, >> 250 physiCaptureMgnt, >> 251 false, >> 252 0); 189 } 253 } 190 254 191 // Degrader 255 // Degrader 192 256 193 if (GetDegraderThickness() > 0.) { << 257 if (GetDegraderThickness() > 0.) 194 fSolidDegrader = << 258 { 195 new G4Tubs("Degrader", 0., GetDegraderRa << 259 solidDegrader = new G4Tubs("Degrader", 196 << 260 0., GetDegraderRadius(), 197 fLogicDegrader = new G4LogicalVolume(fSoli << 261 GetDegraderThickness()/2., 0.,twopi); 198 << 262 199 G4ThreeVector degraderCenter = G4ThreeVect << 263 logicDegrader = new G4LogicalVolume(solidDegrader, 200 << 264 GetDegraderMaterial(), 201 fPhysiDegrader = new G4PVPlacement(nullptr << 265 "Degrader"); 202 fPhysiT << 266 >> 267 G4ThreeVector DegraderCenter = G4ThreeVector(0.,0.,GetDegraderPos()); >> 268 >> 269 physiDegrader = new G4PVPlacement(0, >> 270 DegraderCenter, >> 271 "Degrader", >> 272 logicDegrader, >> 273 physiTransferMgnt, >> 274 false, >> 275 0); 203 } 276 } 204 277 205 return fPhysiWorld; << 278 G4double l = 0.0; 206 } << 279 G4double B1 = GetCaptureMgntB1(); >> 280 G4double B2 = GetCaptureMgntB2(); >> 281 >> 282 if (focusSolenoid) delete focusSolenoid; >> 283 focusSolenoid = new F04FocusSolenoid(B1, B2, l, >> 284 logicCaptureMgnt,CaptureMgntCenter); >> 285 focusSolenoid -> SetHalf(true); >> 286 >> 287 l = 0.0; >> 288 G4double B = GetTransferMgntB(); >> 289 >> 290 if (simpleSolenoid) delete simpleSolenoid; >> 291 simpleSolenoid = new F04SimpleSolenoid(B, l, >> 292 logicTransferMgnt,TransferMgntCenter); >> 293 >> 294 simpleSolenoid->setColor("1,0,1"); >> 295 simpleSolenoid->setColor("0,1,1"); >> 296 simpleSolenoid->setMaxStep(1.5*mm); >> 297 simpleSolenoid->setMaxStep(2.5*mm); 207 298 208 //....oooOO0OOooo........oooOO0OOooo........oo << 299 return physiWorld; >> 300 } 209 301 210 void F04DetectorConstruction::SetWorldMaterial 302 void F04DetectorConstruction::SetWorldMaterial(const G4String materialChoice) 211 { 303 { 212 G4Material* pttoMaterial = G4NistManager::In << 304 G4Material* pttoMaterial = >> 305 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 213 306 214 if (pttoMaterial != fWorldMaterial) { << 307 if (pttoMaterial != WorldMaterial) { 215 if (pttoMaterial) { << 308 if ( pttoMaterial ) { 216 fWorldMaterial = pttoMaterial; << 309 WorldMaterial = pttoMaterial; 217 G4RunManager::GetRunManager()->PhysicsHa << 310 } else { 218 } << 311 G4cout << "\n--> WARNING from SetWorldMaterial : " 219 else { << 312 << materialChoice << " not found" << G4endl; 220 G4cout << "\n--> WARNING from SetWorldMa << 313 } 221 << G4endl; << 222 } << 223 } 314 } 224 } 315 } 225 316 226 //....oooOO0OOooo........oooOO0OOooo........oo << 227 << 228 void F04DetectorConstruction::SetTargetMateria 317 void F04DetectorConstruction::SetTargetMaterial(const G4String materialChoice) 229 { 318 { 230 G4Material* pttoMaterial = G4NistManager::In << 319 G4Material* pttoMaterial = >> 320 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 231 321 232 if (pttoMaterial != fTargetMaterial) { << 322 if (pttoMaterial != TargetMaterial) { 233 if (pttoMaterial) { << 323 if ( pttoMaterial ) { 234 fTargetMaterial = pttoMaterial; << 324 TargetMaterial = pttoMaterial; 235 G4RunManager::GetRunManager()->PhysicsHa << 325 } else { 236 } << 326 G4cout << "\n--> WARNING from SetTargetMaterial : " 237 else { << 327 << materialChoice << " not found" << G4endl; 238 G4cout << "\n--> WARNING from SetTarget << 328 } 239 << G4endl; << 240 } << 241 } 329 } 242 } 330 } 243 331 244 //....oooOO0OOooo........oooOO0OOooo........oo << 245 << 246 void F04DetectorConstruction::SetDegraderMater 332 void F04DetectorConstruction::SetDegraderMaterial(const G4String materialChoice) 247 333 248 { 334 { 249 G4Material* pttoMaterial = G4NistManager::In << 335 G4Material* pttoMaterial = >> 336 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 250 337 251 if (pttoMaterial != fDegraderMaterial) { << 338 if (pttoMaterial != DegraderMaterial) { 252 if (pttoMaterial) { << 339 if ( pttoMaterial ) { 253 fDegraderMaterial = pttoMaterial; << 340 DegraderMaterial = pttoMaterial; 254 G4RunManager::GetRunManager()->PhysicsHa << 341 } else { 255 } << 342 G4cout << "\n--> WARNING from SetDegraderMaterial : " 256 else { << 343 << materialChoice << " not found" << G4endl; 257 G4cout << "\n--> WARNING from SetDegrade << 344 } 258 << G4endl; << 259 } << 260 } 345 } 261 } 346 } 262 347 263 //....oooOO0OOooo........oooOO0OOooo........oo << 264 << 265 void F04DetectorConstruction::SetWorldSizeZ(G4 348 void F04DetectorConstruction::SetWorldSizeZ(G4double val) 266 { 349 { 267 fWorldSizeZ = val; << 350 WorldSizeZ = val; 268 if (G4StateManager::GetStateManager()->GetCu << 269 G4RunManager::GetRunManager()->GeometryHas << 270 } 351 } 271 352 272 //....oooOO0OOooo........oooOO0OOooo........oo << 273 << 274 void F04DetectorConstruction::SetWorldSizeR(G4 353 void F04DetectorConstruction::SetWorldSizeR(G4double val) 275 { 354 { 276 fWorldSizeR = val; << 355 WorldSizeR = val; 277 if (G4StateManager::GetStateManager()->GetCu << 278 G4RunManager::GetRunManager()->GeometryHas << 279 } 356 } 280 357 281 //....oooOO0OOooo........oooOO0OOooo........oo << 282 << 283 void F04DetectorConstruction::SetCaptureMgntRa 358 void F04DetectorConstruction::SetCaptureMgntRadius(G4double val) 284 { 359 { 285 fCaptureMgntRadius = val; << 360 CaptureMgntRadius = val; 286 if (G4StateManager::GetStateManager()->GetCu << 287 G4RunManager::GetRunManager()->GeometryHas << 288 } 361 } 289 362 290 //....oooOO0OOooo........oooOO0OOooo........oo << 291 << 292 void F04DetectorConstruction::SetCaptureMgntLe 363 void F04DetectorConstruction::SetCaptureMgntLength(G4double val) 293 { 364 { 294 fCaptureMgntLength = val; << 365 CaptureMgntLength = val; 295 if (G4StateManager::GetStateManager()->GetCu << 296 G4RunManager::GetRunManager()->GeometryHas << 297 } 366 } 298 367 299 //....oooOO0OOooo........oooOO0OOooo........oo << 300 << 301 void F04DetectorConstruction::SetCaptureMgntB1 368 void F04DetectorConstruction::SetCaptureMgntB1(G4double val) 302 { 369 { 303 fCaptureMgntB1 = val; << 370 CaptureMgntB1 = val; 304 if (G4StateManager::GetStateManager()->GetCu << 305 G4RunManager::GetRunManager()->GeometryHas << 306 } 371 } 307 372 308 //....oooOO0OOooo........oooOO0OOooo........oo << 309 << 310 void F04DetectorConstruction::SetCaptureMgntB2 373 void F04DetectorConstruction::SetCaptureMgntB2(G4double val) 311 { 374 { 312 fCaptureMgntB2 = val; << 375 CaptureMgntB2 = val; 313 if (G4StateManager::GetStateManager()->GetCu << 314 G4RunManager::GetRunManager()->GeometryHas << 315 } 376 } 316 377 317 //....oooOO0OOooo........oooOO0OOooo........oo << 318 << 319 void F04DetectorConstruction::SetTransferMgntR 378 void F04DetectorConstruction::SetTransferMgntRadius(G4double val) 320 { 379 { 321 fTransferMgntRadius = val; << 380 TransferMgntRadius = val; 322 if (G4StateManager::GetStateManager()->GetCu << 323 G4RunManager::GetRunManager()->GeometryHas << 324 } 381 } 325 382 326 //....oooOO0OOooo........oooOO0OOooo........oo << 327 << 328 void F04DetectorConstruction::SetTransferMgntL 383 void F04DetectorConstruction::SetTransferMgntLength(G4double val) 329 { 384 { 330 fTransferMgntLength = val; << 385 TransferMgntLength = val; 331 if (G4StateManager::GetStateManager()->GetCu << 332 G4RunManager::GetRunManager()->GeometryHas << 333 } 386 } 334 387 335 //....oooOO0OOooo........oooOO0OOooo........oo << 336 << 337 void F04DetectorConstruction::SetTransferMgntB 388 void F04DetectorConstruction::SetTransferMgntB(G4double val) 338 { 389 { 339 fTransferMgntB = val; << 390 TransferMgntB = val; 340 if (G4StateManager::GetStateManager()->GetCu << 341 G4RunManager::GetRunManager()->GeometryHas << 342 } 391 } 343 392 344 //....oooOO0OOooo........oooOO0OOooo........oo << 345 << 346 void F04DetectorConstruction::SetTransferMgntP 393 void F04DetectorConstruction::SetTransferMgntPos(G4double val) 347 { 394 { 348 fTransferMgntPos = val; << 395 TransferMgntPos = val; 349 if (G4StateManager::GetStateManager()->GetCu << 350 G4RunManager::GetRunManager()->GeometryHas << 351 } 396 } 352 397 353 //....oooOO0OOooo........oooOO0OOooo........oo << 354 << 355 void F04DetectorConstruction::SetTargetRadius( 398 void F04DetectorConstruction::SetTargetRadius(G4double val) 356 { 399 { 357 fTargetRadius = val; << 400 TargetRadius = val; 358 if (G4StateManager::GetStateManager()->GetCu << 359 G4RunManager::GetRunManager()->GeometryHas << 360 } 401 } 361 402 362 //....oooOO0OOooo........oooOO0OOooo........oo << 363 << 364 void F04DetectorConstruction::SetTargetThickne 403 void F04DetectorConstruction::SetTargetThickness(G4double val) 365 { 404 { 366 fTargetThickness = val; << 405 TargetThickness = val; 367 if (G4StateManager::GetStateManager()->GetCu << 368 G4RunManager::GetRunManager()->GeometryHas << 369 } 406 } 370 407 371 //....oooOO0OOooo........oooOO0OOooo........oo << 372 << 373 void F04DetectorConstruction::SetTargetPos(G4d 408 void F04DetectorConstruction::SetTargetPos(G4double val) 374 { 409 { 375 fTargetPos = val; << 410 TargetPos = val; 376 if (G4StateManager::GetStateManager()->GetCu << 377 G4RunManager::GetRunManager()->GeometryHas << 378 } 411 } 379 412 380 //....oooOO0OOooo........oooOO0OOooo........oo << 381 << 382 void F04DetectorConstruction::SetTargetAngle(G 413 void F04DetectorConstruction::SetTargetAngle(G4int val) 383 { 414 { 384 fTargetAngle = val; << 415 TargetAngle = val; 385 if (G4StateManager::GetStateManager()->GetCu << 386 G4RunManager::GetRunManager()->GeometryHas << 387 } 416 } 388 417 389 //....oooOO0OOooo........oooOO0OOooo........oo << 390 << 391 void F04DetectorConstruction::SetDegraderRadiu 418 void F04DetectorConstruction::SetDegraderRadius(G4double val) 392 { 419 { 393 fDegraderRadius = val; << 420 DegraderRadius = val; 394 if (G4StateManager::GetStateManager()->GetCu << 395 G4RunManager::GetRunManager()->GeometryHas << 396 } 421 } 397 422 398 //....oooOO0OOooo........oooOO0OOooo........oo << 399 << 400 void F04DetectorConstruction::SetDegraderThick 423 void F04DetectorConstruction::SetDegraderThickness(G4double val) 401 { 424 { 402 fDegraderThickness = val; << 425 DegraderThickness = val; 403 if (G4StateManager::GetStateManager()->GetCu << 426 } 404 G4RunManager::GetRunManager()->GeometryHas << 405 } << 406 << 407 //....oooOO0OOooo........oooOO0OOooo........oo << 408 427 409 void F04DetectorConstruction::SetDegraderPos(G 428 void F04DetectorConstruction::SetDegraderPos(G4double val) 410 { 429 { 411 fDegraderPos = val; << 430 DegraderPos = val; 412 if (G4StateManager::GetStateManager()->GetCu << 431 } 413 G4RunManager::GetRunManager()->GeometryHas << 414 } << 415 << 416 //....oooOO0OOooo........oooOO0OOooo........oo << 417 432 418 void F04DetectorConstruction::ConstructSDandFi << 433 void F04DetectorConstruction::UpdateGeometry() 419 { 434 { 420 if (!fFieldSetUp.Get()) { << 435 if (!physiWorld) return; 421 F04GlobalField* field = F04GlobalField::Ge << 436 422 G4AutoDelete::Register(field); // Kernel << 437 // clean-up previous geometry 423 fFieldSetUp.Put(field); << 438 G4GeometryManager::GetInstance()->OpenGeometry(); 424 } << 439 425 } << 440 G4PhysicalVolumeStore::GetInstance()->Clean(); >> 441 G4LogicalVolumeStore::GetInstance()->Clean(); >> 442 G4SolidStore::GetInstance()->Clean(); 426 443 427 //....oooOO0OOooo........oooOO0OOooo........oo << 444 //define new one >> 445 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructDetector()); 428 446 429 G4RotationMatrix F04DetectorConstruction::Stri << 447 G4RunManager::GetRunManager()->GeometryHasBeenModified(); >> 448 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); >> 449 >> 450 G4RegionStore::GetInstance()->UpdateMaterialList(physiWorld); >> 451 >> 452 } >> 453 >> 454 G4RotationMatrix >> 455 F04DetectorConstruction::stringToRotationMatrix(G4String rotation) 430 { 456 { 431 // We apply successive rotations OF THE OBJE 457 // We apply successive rotations OF THE OBJECT around the FIXED 432 // axes of the parent's local coordinates; r 458 // axes of the parent's local coordinates; rotations are applied 433 // left-to-right (rotation="r1,r2,r3" => r1 459 // left-to-right (rotation="r1,r2,r3" => r1 then r2 then r3). 434 460 435 G4RotationMatrix rot; 461 G4RotationMatrix rot; 436 462 437 unsigned int place = 0; 463 unsigned int place = 0; 438 464 439 while (place < rotation.size()) { 465 while (place < rotation.size()) { 440 G4double angle; << 466 441 char* p(nullptr); << 467 G4double angle; 442 G4String current = rotation.substr(place + << 468 char* p(0); 443 angle = strtod(current.c_str(), &p) * deg; << 469 G4String current=rotation.substr(place+1); 444 << 470 angle = strtod(current.c_str(),&p) * deg; 445 if (!p || (*p != ',' && *p != '\0')) { << 471 446 G4cerr << "Invalid rotation specificatio << 472 if (!p || (*p != ',' && *p != '\0')) { 447 << 473 G4cerr << "Invalid rotation specification: " << 448 return rot; << 474 rotation.c_str() << G4endl; 449 } << 475 450 << 476 return rot; 451 G4RotationMatrix thisRotation; << 477 } 452 << 478 453 switch (rotation.substr(place, 1).c_str()[ << 479 G4RotationMatrix thisRotation; 454 case 'X': << 480 455 case 'x': << 481 switch(rotation.substr(place,1).c_str()[0]) { 456 thisRotation = G4RotationMatrix(CLHEP: << 482 case 'X': case 'x': 457 break; << 483 thisRotation = G4RotationMatrix(CLHEP::HepRotationX(angle)); 458 case 'Y': << 484 break; 459 case 'y': << 485 case 'Y': case 'y': 460 thisRotation = G4RotationMatrix(CLHEP: << 486 thisRotation = G4RotationMatrix(CLHEP::HepRotationY(angle)); 461 break; << 487 break; 462 case 'Z': << 488 case 'Z': case 'z': 463 case 'z': << 489 thisRotation = G4RotationMatrix(CLHEP::HepRotationZ(angle)); 464 thisRotation = G4RotationMatrix(CLHEP: << 490 break; 465 break; << 491 default: 466 default: << 492 G4cerr << " Invalid rotation specification: " 467 G4cerr << " Invalid rotation specifica << 493 << rotation << G4endl; 468 return rot; << 494 return rot; 469 } << 495 } 470 << 496 471 rot = thisRotation * rot; << 497 rot = thisRotation * rot; 472 place = rotation.find(',', place); << 498 place = rotation.find(',',place); 473 if (place > rotation.size()) break; << 499 if (place > rotation.size()) break; 474 ++place; << 500 ++place; 475 } 501 } 476 502 477 return rot; 503 return rot; >> 504 478 } 505 } 479 506