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 // >> 26 // >> 27 // $Id: G4Region.cc,v 1.27 2009-11-27 16:34:37 gcosmo Exp $ >> 28 // GEANT4 tag $Name: not supported by cvs2svn $ >> 29 // 25 // 30 // 26 // G4Region class implementation << 31 // class G4Region Implementation 27 // 32 // 28 // 18.09.02, G.Cosmo - Initial version << 29 // ------------------------------------------- 33 // -------------------------------------------------------------------- 30 34 31 #include "G4Region.hh" 35 #include "G4Region.hh" 32 #include "G4RegionStore.hh" 36 #include "G4RegionStore.hh" 33 #include "G4LogicalVolume.hh" 37 #include "G4LogicalVolume.hh" 34 #include "G4VPhysicalVolume.hh" 38 #include "G4VPhysicalVolume.hh" 35 #include "G4LogicalVolumeStore.hh" 39 #include "G4LogicalVolumeStore.hh" 36 #include "G4VNestedParameterisation.hh" 40 #include "G4VNestedParameterisation.hh" 37 #include "G4VUserRegionInformation.hh" 41 #include "G4VUserRegionInformation.hh" 38 #include "G4Material.hh" << 39 << 40 // These macros changes the references to fiel << 41 // in the class G4RegionData. << 42 // << 43 #define G4MT_fsmanager ((subInstanceManager.of << 44 #define G4MT_rsaction ((subInstanceManager.off << 45 << 46 // This new field helps to use the class G4Reg << 47 // << 48 G4RegionManager G4Region::subInstanceManager; << 49 << 50 // ******************************************* << 51 // GetSubInstanceManager: << 52 // - Returns the private data instance manage << 53 // ******************************************* << 54 // << 55 const G4RegionManager& G4Region::GetSubInstanc << 56 { << 57 return subInstanceManager; << 58 } << 59 42 60 // ******************************************* 43 // ******************************************************************* 61 // Constructor: 44 // Constructor: 62 // - Adds self to region Store 45 // - Adds self to region Store 63 // ******************************************* 46 // ******************************************************************* 64 // 47 // 65 G4Region::G4Region(const G4String& pName) 48 G4Region::G4Region(const G4String& pName) 66 : fName(pName) << 49 : fName(pName), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0), >> 50 fFieldManager(0), fFastSimulationManager(0), fWorldPhys(0), >> 51 fRegionalSteppingAction(0), >> 52 fInMassGeometry(false), fInParallelGeometry(false) 67 { 53 { 68 << 69 instanceID = subInstanceManager.CreateSubIns << 70 G4MT_fsmanager = nullptr; << 71 G4MT_rsaction = nullptr; << 72 << 73 G4RegionStore* rStore = G4RegionStore::GetIn 54 G4RegionStore* rStore = G4RegionStore::GetInstance(); 74 if (rStore->GetRegion(pName, false) != nullp << 55 if (rStore->GetRegion(pName,false)) 75 { 56 { 76 std::ostringstream message; 57 std::ostringstream message; 77 message << "The region has NOT been regist 58 message << "The region has NOT been registered !" << G4endl 78 << " Region " << pName << 59 << " Region " << pName << " already existing in store !" 79 << G4endl; 60 << G4endl; 80 G4Exception("G4Region::G4Region()", "GeomM 61 G4Exception("G4Region::G4Region()", "GeomMgt1001", 81 JustWarning, message); 62 JustWarning, message); 82 } 63 } 83 else 64 else 84 { 65 { 85 rStore->Register(this); 66 rStore->Register(this); 86 } 67 } 87 } 68 } 88 69 89 // ******************************************* 70 // ******************************************************************** 90 // Fake default constructor - sets only member 71 // Fake default constructor - sets only member data and allocates memory 91 // for usage restri 72 // for usage restricted to object persistency. 92 // ******************************************* 73 // ******************************************************************** 93 // 74 // 94 G4Region::G4Region( __void__& ) 75 G4Region::G4Region( __void__& ) 95 : fName("") << 76 : fName(""), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0), >> 77 fFieldManager(0), fFastSimulationManager(0), fWorldPhys(0), >> 78 fRegionalSteppingAction(0), >> 79 fInMassGeometry(false), fInParallelGeometry(false) 96 { 80 { 97 instanceID = subInstanceManager.CreateSubIns << 98 G4MT_fsmanager = nullptr; << 99 G4MT_rsaction = nullptr; << 100 << 101 // Register to store 81 // Register to store 102 // 82 // 103 G4RegionStore::GetInstance()->Register(this) 83 G4RegionStore::GetInstance()->Register(this); 104 } 84 } 105 85 106 // ******************************************* 86 // ******************************************************************* 107 // Destructor: 87 // Destructor: 108 // - Removes self from region Store 88 // - Removes self from region Store 109 // ******************************************* 89 // ******************************************************************* 110 // 90 // 111 G4Region::~G4Region() 91 G4Region::~G4Region() 112 { 92 { 113 G4RegionStore::GetInstance()->DeRegister(thi 93 G4RegionStore::GetInstance()->DeRegister(this); 114 delete fUserInfo; << 94 if(fUserInfo) delete fUserInfo; 115 } << 116 << 117 // ******************************************* << 118 // SetName - Set region name and notify store << 119 // ******************************************* << 120 // << 121 void G4Region::SetName(const G4String& pName) << 122 { << 123 fName = pName; << 124 G4RegionStore::GetInstance()->SetMapValid(fa << 125 } << 126 << 127 // ******************************************* << 128 // SetFastSimulationManager << 129 // ******************************************* << 130 // << 131 void G4Region::SetFastSimulationManager(G4Fast << 132 { << 133 G4MT_fsmanager = fsm; << 134 } << 135 << 136 // ******************************************* << 137 // GetFastSimulationManager << 138 // ******************************************* << 139 // << 140 G4FastSimulationManager* G4Region::GetFastSimu << 141 { << 142 return G4MT_fsmanager; << 143 } << 144 << 145 // ******************************************* << 146 // SetRegionalSteppingAction << 147 // ******************************************* << 148 // << 149 void G4Region::SetRegionalSteppingAction(G4Use << 150 { << 151 G4MT_rsaction = rusa; << 152 } << 153 << 154 // ******************************************* << 155 // GetRegionalSteppingAction << 156 // ******************************************* << 157 // << 158 G4UserSteppingAction* G4Region::GetRegionalSte << 159 { << 160 return G4MT_rsaction; << 161 } 95 } 162 96 163 // ******************************************* 97 // ******************************************************************* 164 // ScanVolumeTree: 98 // ScanVolumeTree: 165 // - Scans recursively the 'lv' logical volum 99 // - Scans recursively the 'lv' logical volume tree, retrieves 166 // and places all materials in the list. 100 // and places all materials in the list. 167 // - The boolean flag 'region' identifies if 101 // - The boolean flag 'region' identifies if the volume tree must 168 // have region reset (false) or if the curr 102 // have region reset (false) or if the current region must be 169 // associated to the logical volume 'lv' an 103 // associated to the logical volume 'lv' and its tree (true). 170 // ******************************************* 104 // ******************************************************************* 171 // 105 // 172 void G4Region::ScanVolumeTree(G4LogicalVolume* 106 void G4Region::ScanVolumeTree(G4LogicalVolume* lv, G4bool region) 173 { 107 { 174 // If logical volume is going to become a re 108 // If logical volume is going to become a region, add 175 // its material to the list if not already p 109 // its material to the list if not already present 176 // 110 // 177 G4Region* currentRegion = nullptr; << 111 G4Region* currentRegion = 0; 178 std::size_t noDaughters = lv->GetNoDaughters << 112 size_t noDaughters = lv->GetNoDaughters(); 179 G4Material* volMat = lv->GetMaterial(); 113 G4Material* volMat = lv->GetMaterial(); 180 if((volMat == nullptr) && fInMassGeometry) << 114 if(!volMat && fInMassGeometry) 181 { 115 { 182 std::ostringstream message; 116 std::ostringstream message; 183 message << "Logical volume <" << lv->GetNa 117 message << "Logical volume <" << lv->GetName() << ">" << G4endl 184 << "does not have a valid material 118 << "does not have a valid material pointer." << G4endl 185 << "A logical volume belonging to 119 << "A logical volume belonging to the (tracking) world volume " 186 << "must have a valid material."; 120 << "must have a valid material."; 187 G4Exception("G4Region::ScanVolumeTree()", 121 G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002", 188 FatalException, message, "Chec 122 FatalException, message, "Check your geometry construction."); 189 } 123 } 190 if (region) 124 if (region) 191 { 125 { 192 currentRegion = this; 126 currentRegion = this; 193 if (volMat != nullptr) << 127 if(volMat) { AddMaterial(volMat); } 194 { << 195 AddMaterial(volMat); << 196 auto baseMat = const_cast<G4Material*>( << 197 if (baseMat != nullptr) { AddMaterial(ba << 198 } << 199 } 128 } 200 129 201 // Set the LV region to be either the curren 130 // Set the LV region to be either the current region or NULL, 202 // according to the boolean selector 131 // according to the boolean selector 203 // 132 // 204 lv->SetRegion(currentRegion); 133 lv->SetRegion(currentRegion); 205 134 206 // Stop recursion here if no further daughte 135 // Stop recursion here if no further daughters are involved 207 // 136 // 208 if(noDaughters==0) return; 137 if(noDaughters==0) return; 209 138 210 G4VPhysicalVolume* daughterPVol = lv->GetDau 139 G4VPhysicalVolume* daughterPVol = lv->GetDaughter(0); 211 if (daughterPVol->IsParameterised()) 140 if (daughterPVol->IsParameterised()) 212 { 141 { 213 // Adopt special treatment in case of para 142 // Adopt special treatment in case of parameterised volumes, 214 // where parameterisation involves a new m 143 // where parameterisation involves a new material scan 215 // 144 // 216 G4VPVParameterisation* pParam = daughterPV 145 G4VPVParameterisation* pParam = daughterPVol->GetParameterisation(); 217 146 218 if (pParam->GetMaterialScanner() != nullpt << 147 if (pParam->GetMaterialScanner()) 219 { 148 { 220 std::size_t matNo = pParam->GetMaterialS << 149 size_t matNo = pParam->GetMaterialScanner()->GetNumberOfMaterials(); 221 for (std::size_t mat=0; mat<matNo; ++mat << 150 for (register size_t mat=0; mat<matNo; mat++) 222 { 151 { 223 volMat = pParam->GetMaterialScanner()- << 152 volMat = pParam->GetMaterialScanner()->GetMaterial(mat); 224 if((volMat == nullptr) && fInMassGeome << 153 if(!volMat && fInMassGeometry) 225 { 154 { 226 std::ostringstream message; 155 std::ostringstream message; 227 message << "The parameterisation for 156 message << "The parameterisation for the physical volume <" 228 << daughterPVol->GetName() < 157 << daughterPVol->GetName() << ">" << G4endl 229 << "does not return a valid 158 << "does not return a valid material pointer." << G4endl 230 << "A volume belonging to th 159 << "A volume belonging to the (tracking) world volume must " 231 << "have a valid material."; 160 << "have a valid material."; 232 G4Exception("G4Region::ScanVolumeTre 161 G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002", 233 FatalException, message, 162 FatalException, message, "Check your parameterisation."); 234 } 163 } 235 if (volMat != nullptr) << 164 if(volMat) { AddMaterial(volMat); } 236 { << 237 AddMaterial(volMat); << 238 auto baseMat = const_cast<G4Materia << 239 if (baseMat != nullptr) { AddMateria << 240 } << 241 } 165 } 242 } 166 } 243 else 167 else 244 { 168 { 245 std::size_t repNo = daughterPVol->GetMul << 169 size_t repNo = daughterPVol->GetMultiplicity(); 246 for (std::size_t rep=0; rep<repNo; ++rep << 170 for (register size_t rep=0; rep<repNo; rep++) 247 { 171 { 248 volMat = pParam->ComputeMaterial((G4in << 172 volMat = pParam->ComputeMaterial(rep, daughterPVol); 249 if((volMat == nullptr) && fInMassGeome << 173 if(!volMat && fInMassGeometry) 250 { 174 { 251 std::ostringstream message; 175 std::ostringstream message; 252 message << "The parameterisation for 176 message << "The parameterisation for the physical volume <" 253 << daughterPVol->GetName() < 177 << daughterPVol->GetName() << ">" << G4endl 254 << "does not return a valid 178 << "does not return a valid material pointer." << G4endl 255 << "A volume belonging to th 179 << "A volume belonging to the (tracking) world volume must " 256 << "have a valid material."; 180 << "have a valid material."; 257 G4Exception("G4Region::ScanVolumeTre 181 G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002", 258 FatalException, message, 182 FatalException, message, "Check your parameterisation."); 259 } 183 } 260 if(volMat != nullptr) << 184 if(volMat) { AddMaterial(volMat); } 261 { << 262 AddMaterial(volMat); << 263 auto baseMat = const_cast<G4Materia << 264 if (baseMat != nullptr) { AddMateria << 265 } << 266 } 185 } 267 } 186 } 268 G4LogicalVolume* daughterLVol = daughterPV 187 G4LogicalVolume* daughterLVol = daughterPVol->GetLogicalVolume(); 269 ScanVolumeTree(daughterLVol, region); 188 ScanVolumeTree(daughterLVol, region); 270 } 189 } 271 else 190 else 272 { 191 { 273 for (std::size_t i=0; i<noDaughters; ++i) << 192 for (register size_t i=0; i<noDaughters; i++) 274 { 193 { 275 G4LogicalVolume* daughterLVol = lv->GetD 194 G4LogicalVolume* daughterLVol = lv->GetDaughter(i)->GetLogicalVolume(); 276 if (!daughterLVol->IsRootRegion()) 195 if (!daughterLVol->IsRootRegion()) 277 { 196 { 278 // Set daughter's LV to be a region an 197 // Set daughter's LV to be a region and store materials in 279 // the materials list, if the LV is no 198 // the materials list, if the LV is not already a root region 280 // 199 // 281 ScanVolumeTree(daughterLVol, region); 200 ScanVolumeTree(daughterLVol, region); 282 } 201 } 283 } 202 } 284 } 203 } 285 } 204 } 286 205 287 // ******************************************* 206 // ******************************************************************* 288 // AddRootLogicalVolume: 207 // AddRootLogicalVolume: 289 // - Adds a root logical volume and sets its 208 // - Adds a root logical volume and sets its daughters flags as 290 // regions. It also recomputes the material 209 // regions. It also recomputes the materials list for the region. 291 // ******************************************* 210 // ******************************************************************* 292 // 211 // 293 void G4Region::AddRootLogicalVolume(G4LogicalV << 212 void G4Region::AddRootLogicalVolume(G4LogicalVolume* lv) 294 { 213 { 295 // Check if logical volume is already belong << 296 // << 297 if ((lv->IsRootRegion()) && (lv->GetRegion() << 298 { << 299 std::ostringstream message; << 300 message << "Logical volume <" << lv->GetNa << 301 << "root for region <" << lv->GetR << 302 << "It cannot be root logical volu << 303 << ">" << G4endl; << 304 G4Exception("G4Region::AddRootLogicalVolum << 305 message, "A logical volume can << 306 return; << 307 } << 308 << 309 // Check the logical volume is not already i 214 // Check the logical volume is not already in the list 310 // 215 // 311 if (search) << 216 G4RootLVList::iterator pos; >> 217 pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv); >> 218 if (pos == fRootVolumes.end()) 312 { 219 { 313 auto pos = std::find(fRootVolumes.cbegin() << 220 // Insert the root volume in the list and set it as root region 314 if (pos == fRootVolumes.cend()) << 221 // 315 { << 316 // Insert the root volume in the list an << 317 // << 318 fRootVolumes.push_back(lv); << 319 lv->SetRegionRootFlag(true); << 320 } << 321 } << 322 else // WARNING: user *MUST* guarantee lv i << 323 { // Providing speedup for very complex << 324 fRootVolumes.push_back(lv); 222 fRootVolumes.push_back(lv); 325 lv->SetRegionRootFlag(true); 223 lv->SetRegionRootFlag(true); 326 } 224 } >> 225 327 // Scan recursively the tree of daugther vol 226 // Scan recursively the tree of daugther volumes and set regions 328 // 227 // 329 ScanVolumeTree(lv, true); 228 ScanVolumeTree(lv, true); 330 229 331 // Set region as modified 230 // Set region as modified 332 // 231 // 333 fRegionMod = true; 232 fRegionMod = true; 334 } 233 } 335 234 336 // ******************************************* 235 // ******************************************************************* 337 // RemoveRootLogicalVolume: 236 // RemoveRootLogicalVolume: 338 // - Removes a root logical volume and resets 237 // - Removes a root logical volume and resets its daughters flags as 339 // regions. It also recomputes the material 238 // regions. It also recomputes the materials list for the region. 340 // ******************************************* 239 // ******************************************************************* 341 // 240 // 342 void G4Region::RemoveRootLogicalVolume(G4Logic 241 void G4Region::RemoveRootLogicalVolume(G4LogicalVolume* lv, G4bool scan) 343 { 242 { 344 // Find and remove logical volume from the l 243 // Find and remove logical volume from the list 345 // 244 // 346 auto pos = std::find(fRootVolumes.cbegin(),f << 245 G4RootLVList::iterator pos; 347 if (pos != fRootVolumes.cend()) << 246 pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv); >> 247 if (pos != fRootVolumes.end()) 348 { 248 { 349 if (fRootVolumes.size() != 1) // Avoid re 249 if (fRootVolumes.size() != 1) // Avoid resetting flag for world since 350 { // volume m 250 { // volume may be already deleted ! 351 lv->SetRegionRootFlag(false); 251 lv->SetRegionRootFlag(false); 352 } 252 } 353 fRootVolumes.erase(pos); 253 fRootVolumes.erase(pos); 354 } 254 } 355 255 356 if (scan) // Update the materials list 256 if (scan) // Update the materials list 357 { 257 { 358 UpdateMaterialList(); 258 UpdateMaterialList(); 359 } 259 } 360 260 361 // Set region as modified 261 // Set region as modified 362 // 262 // 363 fRegionMod = true; 263 fRegionMod = true; 364 } 264 } 365 265 366 // ******************************************* << 367 // Clean << 368 // ******************************************* << 369 // << 370 void G4Region::Clean() << 371 { << 372 subInstanceManager.FreeSlave(); << 373 } << 374 << 375 // ******************************************* 266 // ******************************************************************* 376 // ClearMaterialList: 267 // ClearMaterialList: 377 // - Clears the material list. 268 // - Clears the material list. 378 // ******************************************* 269 // ******************************************************************* 379 // 270 // 380 void G4Region::ClearMaterialList() 271 void G4Region::ClearMaterialList() 381 { 272 { 382 fMaterials.clear(); 273 fMaterials.clear(); 383 } 274 } 384 275 385 // ******************************************* 276 // ******************************************************************* 386 // UpdateMaterialList: 277 // UpdateMaterialList: 387 // - computes material list looping through 278 // - computes material list looping through 388 // each root logical volume in the region. 279 // each root logical volume in the region. 389 // ******************************************* 280 // ******************************************************************* 390 // 281 // 391 void G4Region::UpdateMaterialList() 282 void G4Region::UpdateMaterialList() 392 { 283 { 393 // Reset the materials list 284 // Reset the materials list 394 // 285 // 395 ClearMaterialList(); 286 ClearMaterialList(); 396 287 397 // Loop over the root logical volumes and re 288 // Loop over the root logical volumes and rebuild the list 398 // of materials from scratch 289 // of materials from scratch 399 // 290 // 400 for (auto pLV=fRootVolumes.cbegin(); pLV!=fR << 291 G4RootLVList::iterator pLV; >> 292 for (pLV=fRootVolumes.begin(); pLV!=fRootVolumes.end(); pLV++) 401 { 293 { 402 ScanVolumeTree(*pLV, true); 294 ScanVolumeTree(*pLV, true); 403 } 295 } 404 } 296 } 405 297 406 // ******************************************* 298 // ******************************************************************* 407 // SetWorld: 299 // SetWorld: 408 // - Set the world physical volume if this re 300 // - Set the world physical volume if this region belongs to this 409 // world. If the given pointer is null, res 301 // world. If the given pointer is null, reset the pointer. 410 // ******************************************* 302 // ******************************************************************* 411 // 303 // 412 void G4Region::SetWorld(G4VPhysicalVolume* wp) 304 void G4Region::SetWorld(G4VPhysicalVolume* wp) 413 { 305 { 414 if(wp == nullptr) << 306 if(!wp) 415 { fWorldPhys = nullptr; } << 307 { fWorldPhys = 0; } 416 else 308 else 417 { if(BelongsTo(wp)) fWorldPhys = wp; } 309 { if(BelongsTo(wp)) fWorldPhys = wp; } 418 310 419 return; 311 return; 420 } 312 } 421 313 422 // ******************************************* 314 // ******************************************************************* 423 // BelongsTo: 315 // BelongsTo: 424 // - Returns whether this region belongs to t 316 // - Returns whether this region belongs to the given physical volume 425 // (recursively scanned to the bottom of th 317 // (recursively scanned to the bottom of the hierarchy) 426 // ******************************************* 318 // ******************************************************************* 427 // 319 // 428 G4bool G4Region::BelongsTo(G4VPhysicalVolume* 320 G4bool G4Region::BelongsTo(G4VPhysicalVolume* thePhys) const 429 { 321 { 430 G4LogicalVolume* currLog = thePhys->GetLogic 322 G4LogicalVolume* currLog = thePhys->GetLogicalVolume(); 431 if (currLog->GetRegion()==this) {return true 323 if (currLog->GetRegion()==this) {return true;} 432 324 433 std::size_t nDaughters = currLog->GetNoDaugh << 325 G4int nDaughters = currLog->GetNoDaughters(); 434 while ((nDaughters--) != 0) // Loop checkin << 326 while (nDaughters--) 435 { 327 { 436 if (BelongsTo(currLog->GetDaughter(nDaught 328 if (BelongsTo(currLog->GetDaughter(nDaughters))) {return true;} 437 } 329 } 438 330 439 return false; 331 return false; 440 } 332 } 441 333 442 // ******************************************* 334 // ******************************************************************* 443 // ClearFastSimulationManager: 335 // ClearFastSimulationManager: 444 // - Set G4FastSimulationManager pointer to t 336 // - Set G4FastSimulationManager pointer to the one for the parent region 445 // if it exists. Otherwise set to null. 337 // if it exists. Otherwise set to null. 446 // ******************************************* 338 // ******************************************************************* 447 // 339 // 448 void G4Region::ClearFastSimulationManager() 340 void G4Region::ClearFastSimulationManager() 449 { 341 { 450 G4bool isUnique; 342 G4bool isUnique; 451 G4Region* parent = GetParentRegion(isUnique) 343 G4Region* parent = GetParentRegion(isUnique); 452 if(parent != nullptr) << 344 if(parent) 453 { 345 { 454 if (isUnique) 346 if (isUnique) 455 { 347 { 456 G4MT_fsmanager = parent->GetFastSimulati << 348 fFastSimulationManager = parent->GetFastSimulationManager(); 457 } 349 } 458 else 350 else 459 { 351 { 460 std::ostringstream message; 352 std::ostringstream message; 461 message << "Region <" << fName << "> bel 353 message << "Region <" << fName << "> belongs to more than" 462 << " one parent region !" << G4e 354 << " one parent region !" << G4endl 463 << "A region cannot belong to mo 355 << "A region cannot belong to more than one direct parent region," 464 << G4endl 356 << G4endl 465 << "to have fast-simulation assi 357 << "to have fast-simulation assigned."; 466 G4Exception("G4Region::ClearFastSimulati 358 G4Exception("G4Region::ClearFastSimulationManager()", 467 "GeomMgt1002", JustWarning, 359 "GeomMgt1002", JustWarning, message); 468 G4MT_fsmanager = nullptr; << 360 fFastSimulationManager = 0; 469 } 361 } 470 } 362 } 471 else 363 else 472 { 364 { 473 G4MT_fsmanager = nullptr; << 365 fFastSimulationManager = 0; 474 } 366 } 475 } 367 } 476 368 477 // ******************************************* 369 // ******************************************************************* 478 // GetParentRegion: 370 // GetParentRegion: 479 // - Returns a region that contains this regi 371 // - Returns a region that contains this region. 480 // Otherwise null is returned. 372 // Otherwise null is returned. 481 // ******************************************* 373 // ******************************************************************* 482 // 374 // 483 G4Region* G4Region::GetParentRegion(G4bool& un 375 G4Region* G4Region::GetParentRegion(G4bool& unique) const 484 { 376 { 485 G4Region* parent = nullptr; unique = true; << 377 G4Region* parent = 0; unique = true; 486 G4LogicalVolumeStore* lvStore = G4LogicalVol 378 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance(); >> 379 G4LogicalVolumeStore::iterator lvItr; 487 380 488 // Loop over all logical volumes in the stor 381 // Loop over all logical volumes in the store 489 // 382 // 490 for(auto lvItr=lvStore->cbegin(); lvItr!=lvS << 383 for(lvItr=lvStore->begin(); lvItr!=lvStore->end(); lvItr++) 491 { 384 { 492 std::size_t nD = (*lvItr)->GetNoDaughters( << 385 G4int nD = (*lvItr)->GetNoDaughters(); 493 G4Region* aR = (*lvItr)->GetRegion(); 386 G4Region* aR = (*lvItr)->GetRegion(); 494 387 495 // Loop over all daughters of each logical 388 // Loop over all daughters of each logical volume 496 // 389 // 497 for(std::size_t iD=0; iD<nD; ++iD) << 390 for(G4int iD=0; iD<nD; iD++) 498 { 391 { 499 if((*lvItr)->GetDaughter(iD)->GetLogical 392 if((*lvItr)->GetDaughter(iD)->GetLogicalVolume()->GetRegion()==this) 500 { 393 { 501 if(parent != nullptr) << 394 if(parent) 502 { 395 { 503 if(parent!=aR) { unique = false; } 396 if(parent!=aR) { unique = false; } 504 } 397 } 505 else // Cache LV parent region which 398 else // Cache LV parent region which includes a daughter volume 506 // with the same associated regi 399 // with the same associated region as the current one 507 { 400 { 508 parent = aR; 401 parent = aR; 509 } 402 } 510 } 403 } 511 } 404 } 512 } 405 } 513 return parent; 406 return parent; 514 } 407 } 515 408