[831] | 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 | // |
---|
[850] | 27 | // $Id: G4LogicalVolume.icc,v 1.25 2008/07/10 09:40:08 gcosmo Exp $ |
---|
[1228] | 28 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
[831] | 29 | // |
---|
| 30 | // |
---|
| 31 | // class G4LogicalVolume Inline Implementation file |
---|
| 32 | // |
---|
| 33 | // 10.20.97 - P. MoraDeFreitas : Added SetFastSimulation method. |
---|
| 34 | // 05.11.98 - M. Verderi: Add Get/Set methods for fBiasWeight |
---|
| 35 | // 09.11.98 - J. Apostolakis: Changed MagneticField to FieldManager |
---|
| 36 | // 12.02.99 - S.Giani: Added set/get methods for voxelization quality |
---|
| 37 | // 18.04.01 - G.Cosmo: Migrated to STL vector |
---|
| 38 | // 17.05.02 - G.Cosmo: Added IsToOptimise() method |
---|
| 39 | // -------------------------------------------------------------------- |
---|
| 40 | |
---|
| 41 | // ******************************************************************** |
---|
| 42 | // GetName |
---|
| 43 | // ******************************************************************** |
---|
| 44 | // |
---|
| 45 | inline |
---|
| 46 | G4String G4LogicalVolume::GetName() const |
---|
| 47 | { |
---|
| 48 | return fName; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | // ******************************************************************** |
---|
| 52 | // SetName |
---|
| 53 | // ******************************************************************** |
---|
| 54 | // |
---|
| 55 | inline |
---|
| 56 | void G4LogicalVolume::SetName(const G4String& pName) |
---|
| 57 | { |
---|
| 58 | fName = pName; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | // ******************************************************************** |
---|
| 62 | // GetFieldManager |
---|
| 63 | // ******************************************************************** |
---|
| 64 | // |
---|
| 65 | inline |
---|
| 66 | G4FieldManager* G4LogicalVolume::GetFieldManager() const |
---|
| 67 | { |
---|
| 68 | return fFieldManager; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | // ******************************************************************** |
---|
| 72 | // GetNoDaughters |
---|
| 73 | // ******************************************************************** |
---|
| 74 | // |
---|
| 75 | inline |
---|
| 76 | G4int G4LogicalVolume::GetNoDaughters() const |
---|
| 77 | { |
---|
| 78 | return fDaughters.size(); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | // ******************************************************************** |
---|
| 82 | // GetDaughter |
---|
| 83 | // ******************************************************************** |
---|
| 84 | // |
---|
| 85 | inline |
---|
| 86 | G4VPhysicalVolume* G4LogicalVolume::GetDaughter(const G4int i) const |
---|
| 87 | { |
---|
| 88 | return fDaughters[i]; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | // ******************************************************************** |
---|
| 92 | // GetFastSimulationManager |
---|
| 93 | // ******************************************************************** |
---|
| 94 | // |
---|
| 95 | inline |
---|
| 96 | G4FastSimulationManager* G4LogicalVolume::GetFastSimulationManager () const |
---|
| 97 | { |
---|
| 98 | G4FastSimulationManager* fFSM = 0; |
---|
| 99 | if(fRegion) fFSM = fRegion->GetFastSimulationManager(); |
---|
| 100 | return fFSM; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | // ******************************************************************** |
---|
| 104 | // AddDaughter |
---|
| 105 | // ******************************************************************** |
---|
| 106 | // |
---|
| 107 | inline |
---|
| 108 | void G4LogicalVolume::AddDaughter(G4VPhysicalVolume* pNewDaughter) |
---|
| 109 | { |
---|
| 110 | if( !fDaughters.empty() && fDaughters[0]->IsReplicated() ) |
---|
| 111 | { |
---|
| 112 | G4cerr << "ERROR - Attempt to place a volume in a mother volume" << G4endl |
---|
| 113 | << " already containing a replicated volume." << G4endl |
---|
| 114 | << " A volume can either contain several placements" << G4endl |
---|
| 115 | << " or a unique replica or parameterised volume !" << G4endl |
---|
| 116 | << " Mother logical volume: " << GetName() << G4endl |
---|
| 117 | << " Placing volume: " << pNewDaughter->GetName() << G4endl; |
---|
| 118 | G4Exception("G4LogicalVolume::AddDaughter()", "InvalidSetup", FatalException, |
---|
| 119 | "Replica or parameterised volume must be the only daughter !"); |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | fMass = 0.; |
---|
| 123 | fDaughters.push_back(pNewDaughter); |
---|
| 124 | |
---|
| 125 | G4LogicalVolume* pDaughterLogical = pNewDaughter->GetLogicalVolume(); |
---|
| 126 | |
---|
| 127 | // Propagate the Field Manager, if the daughter has no field Manager. |
---|
| 128 | // |
---|
| 129 | G4FieldManager* pDaughterFieldManager = pDaughterLogical->GetFieldManager(); |
---|
| 130 | |
---|
| 131 | if( pDaughterFieldManager == 0 ) |
---|
| 132 | { |
---|
| 133 | pDaughterLogical->SetFieldManager(fFieldManager, true); |
---|
| 134 | } |
---|
| 135 | if (fRegion) |
---|
| 136 | { |
---|
| 137 | PropagateRegion(); |
---|
| 138 | fRegion->RegionModified(true); |
---|
| 139 | } |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | // ******************************************************************** |
---|
| 143 | // IsDaughter |
---|
| 144 | // ******************************************************************** |
---|
| 145 | // |
---|
| 146 | inline |
---|
| 147 | G4bool G4LogicalVolume::IsDaughter(const G4VPhysicalVolume* p) const |
---|
| 148 | { |
---|
| 149 | G4PhysicalVolumeList::const_iterator i; |
---|
| 150 | for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i ) |
---|
| 151 | { |
---|
| 152 | if (**i==*p) return true; |
---|
| 153 | } |
---|
| 154 | return false; |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | // ******************************************************************** |
---|
| 158 | // RemoveDaughter |
---|
| 159 | // ******************************************************************** |
---|
| 160 | // |
---|
| 161 | inline |
---|
| 162 | void G4LogicalVolume::RemoveDaughter(const G4VPhysicalVolume* p) |
---|
| 163 | { |
---|
| 164 | G4PhysicalVolumeList::iterator i; |
---|
| 165 | for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i ) |
---|
| 166 | { |
---|
| 167 | if (**i==*p) |
---|
| 168 | { |
---|
| 169 | fDaughters.erase(i); |
---|
| 170 | break; |
---|
| 171 | } |
---|
| 172 | } |
---|
| 173 | if (fRegion) |
---|
| 174 | { |
---|
| 175 | fRegion->RegionModified(true); |
---|
| 176 | } |
---|
| 177 | fMass = 0.; |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | // ******************************************************************** |
---|
| 181 | // ClearDaughters |
---|
| 182 | // ******************************************************************** |
---|
| 183 | // |
---|
| 184 | inline |
---|
| 185 | void G4LogicalVolume::ClearDaughters() |
---|
| 186 | { |
---|
| 187 | G4PhysicalVolumeList::iterator i; |
---|
| 188 | for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i ) |
---|
| 189 | { |
---|
| 190 | fDaughters.erase(i); |
---|
| 191 | } |
---|
| 192 | if (fRegion) |
---|
| 193 | { |
---|
| 194 | fRegion->RegionModified(true); |
---|
| 195 | } |
---|
| 196 | fMass = 0.; |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | // ******************************************************************** |
---|
| 200 | // GetSolid |
---|
| 201 | // ******************************************************************** |
---|
| 202 | // |
---|
| 203 | inline |
---|
| 204 | G4VSolid* G4LogicalVolume::GetSolid() const |
---|
| 205 | { |
---|
| 206 | return fSolid; |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | // ******************************************************************** |
---|
| 210 | // SetSolid |
---|
| 211 | // ******************************************************************** |
---|
| 212 | // |
---|
| 213 | inline |
---|
| 214 | void G4LogicalVolume::SetSolid(G4VSolid *pSolid) |
---|
| 215 | { |
---|
| 216 | assert(pSolid != 0); |
---|
| 217 | fSolid=pSolid; |
---|
| 218 | fMass = 0.; |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | // ******************************************************************** |
---|
| 222 | // GetMaterial |
---|
| 223 | // ******************************************************************** |
---|
| 224 | // |
---|
| 225 | inline |
---|
| 226 | G4Material* G4LogicalVolume::GetMaterial() const |
---|
| 227 | { |
---|
| 228 | return fMaterial; |
---|
| 229 | } |
---|
| 230 | |
---|
| 231 | // ******************************************************************** |
---|
| 232 | // SetMaterial |
---|
| 233 | // ******************************************************************** |
---|
| 234 | // |
---|
| 235 | inline |
---|
| 236 | void G4LogicalVolume::SetMaterial(G4Material *pMaterial) |
---|
| 237 | { |
---|
| 238 | fMaterial=pMaterial; |
---|
| 239 | fMass = 0.; |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | // ******************************************************************** |
---|
| 243 | // UpdateMaterial |
---|
| 244 | // ******************************************************************** |
---|
| 245 | // |
---|
| 246 | inline |
---|
| 247 | void G4LogicalVolume::UpdateMaterial(G4Material *pMaterial) |
---|
| 248 | { |
---|
| 249 | fMaterial=pMaterial; |
---|
| 250 | if(fRegion) { fCutsCouple = fRegion->FindCouple(pMaterial); } |
---|
| 251 | fMass = 0.; |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | // ******************************************************************** |
---|
| 255 | // GetSensitiveDetector |
---|
| 256 | // ******************************************************************** |
---|
| 257 | // |
---|
| 258 | inline |
---|
| 259 | G4VSensitiveDetector* G4LogicalVolume::GetSensitiveDetector() const |
---|
| 260 | { |
---|
| 261 | return fSensitiveDetector; |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | // ******************************************************************** |
---|
| 265 | // SetSensitiveDetector |
---|
| 266 | // ******************************************************************** |
---|
| 267 | // |
---|
| 268 | inline |
---|
| 269 | void G4LogicalVolume::SetSensitiveDetector(G4VSensitiveDetector* pSDetector) |
---|
| 270 | { |
---|
| 271 | fSensitiveDetector = pSDetector; |
---|
| 272 | } |
---|
| 273 | |
---|
| 274 | // ******************************************************************** |
---|
| 275 | // GetUserLimits |
---|
| 276 | // ******************************************************************** |
---|
| 277 | // |
---|
| 278 | inline |
---|
| 279 | G4UserLimits* G4LogicalVolume::GetUserLimits() const |
---|
| 280 | { |
---|
| 281 | if(fUserLimits) return fUserLimits; |
---|
| 282 | if(fRegion) return fRegion->GetUserLimits(); |
---|
| 283 | return 0; |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | // ******************************************************************** |
---|
| 287 | // SetUserLimits |
---|
| 288 | // ******************************************************************** |
---|
| 289 | // |
---|
| 290 | inline |
---|
| 291 | void G4LogicalVolume::SetUserLimits(G4UserLimits* pULimits) |
---|
| 292 | { |
---|
| 293 | fUserLimits = pULimits; |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | // ******************************************************************** |
---|
| 297 | // GetVoxelHeader |
---|
| 298 | // ******************************************************************** |
---|
| 299 | // |
---|
| 300 | inline |
---|
| 301 | G4SmartVoxelHeader* G4LogicalVolume::GetVoxelHeader() const |
---|
| 302 | { |
---|
| 303 | return fVoxel; |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | // ******************************************************************** |
---|
| 307 | // SetVoxelHeader |
---|
| 308 | // ******************************************************************** |
---|
| 309 | // |
---|
| 310 | inline |
---|
| 311 | void G4LogicalVolume::SetVoxelHeader(G4SmartVoxelHeader* pVoxel) |
---|
| 312 | { |
---|
| 313 | fVoxel = pVoxel; |
---|
| 314 | } |
---|
| 315 | |
---|
| 316 | // ******************************************************************** |
---|
| 317 | // GetSmartless |
---|
| 318 | // ******************************************************************** |
---|
| 319 | // |
---|
| 320 | inline |
---|
| 321 | G4double G4LogicalVolume::GetSmartless() const |
---|
| 322 | { |
---|
| 323 | return fSmartless; |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | // ******************************************************************** |
---|
| 327 | // SetSmartless |
---|
| 328 | // ******************************************************************** |
---|
| 329 | // |
---|
| 330 | inline |
---|
| 331 | void G4LogicalVolume::SetSmartless(G4double s) |
---|
| 332 | { |
---|
| 333 | fSmartless = s; |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | // ******************************************************************** |
---|
| 337 | // IsToOptimise |
---|
| 338 | // ******************************************************************** |
---|
| 339 | // |
---|
| 340 | inline |
---|
| 341 | G4bool G4LogicalVolume::IsToOptimise() const |
---|
| 342 | { |
---|
| 343 | return fOptimise; |
---|
| 344 | } |
---|
| 345 | |
---|
| 346 | // ******************************************************************** |
---|
| 347 | // SetOptimisation |
---|
| 348 | // ******************************************************************** |
---|
| 349 | // |
---|
| 350 | inline |
---|
| 351 | void G4LogicalVolume::SetOptimisation(G4bool optim) |
---|
| 352 | { |
---|
| 353 | fOptimise = optim; |
---|
| 354 | } |
---|
| 355 | |
---|
| 356 | // ******************************************************************** |
---|
| 357 | // IsRootRegion |
---|
| 358 | // ******************************************************************** |
---|
| 359 | // |
---|
| 360 | inline |
---|
| 361 | G4bool G4LogicalVolume::IsRootRegion() const |
---|
| 362 | { |
---|
| 363 | return fRootRegion; |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | // ******************************************************************** |
---|
| 367 | // SetRegionRootFlag |
---|
| 368 | // ******************************************************************** |
---|
| 369 | // |
---|
| 370 | inline |
---|
| 371 | void G4LogicalVolume::SetRegionRootFlag(G4bool rreg) |
---|
| 372 | { |
---|
| 373 | fRootRegion = rreg; |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | // ******************************************************************** |
---|
| 377 | // IsRegion |
---|
| 378 | // ******************************************************************** |
---|
| 379 | // |
---|
| 380 | inline |
---|
| 381 | G4bool G4LogicalVolume::IsRegion() const |
---|
| 382 | { |
---|
| 383 | G4bool reg = false; |
---|
| 384 | if (fRegion) reg = true; |
---|
| 385 | return reg; |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | // ******************************************************************** |
---|
| 389 | // SetRegion |
---|
| 390 | // ******************************************************************** |
---|
| 391 | // |
---|
| 392 | inline |
---|
| 393 | void G4LogicalVolume::SetRegion(G4Region* reg) |
---|
| 394 | { |
---|
| 395 | fRegion = reg; |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | // ******************************************************************** |
---|
| 399 | // GetRegion |
---|
| 400 | // ******************************************************************** |
---|
| 401 | // |
---|
| 402 | inline |
---|
| 403 | G4Region* G4LogicalVolume::GetRegion() const |
---|
| 404 | { |
---|
| 405 | return fRegion; |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | // ******************************************************************** |
---|
| 409 | // PropagateRegion |
---|
| 410 | // ******************************************************************** |
---|
| 411 | // |
---|
| 412 | inline |
---|
| 413 | void G4LogicalVolume::PropagateRegion() |
---|
| 414 | { |
---|
| 415 | fRegion->ScanVolumeTree(this, true); |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | // ******************************************************************** |
---|
| 419 | // GetMaterialCutsCouple |
---|
| 420 | // ******************************************************************** |
---|
| 421 | // |
---|
| 422 | inline |
---|
| 423 | const G4MaterialCutsCouple* G4LogicalVolume::GetMaterialCutsCouple() const |
---|
| 424 | { |
---|
| 425 | return fCutsCouple; |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | // ******************************************************************** |
---|
| 429 | // SetMaterialCutsCouple |
---|
| 430 | // ******************************************************************** |
---|
| 431 | // |
---|
| 432 | inline |
---|
| 433 | void G4LogicalVolume::SetMaterialCutsCouple(G4MaterialCutsCouple* cuts) |
---|
| 434 | { |
---|
| 435 | fCutsCouple = cuts; |
---|
| 436 | } |
---|
| 437 | |
---|
| 438 | // ******************************************************************** |
---|
[850] | 439 | // Lock |
---|
| 440 | // ******************************************************************** |
---|
| 441 | // |
---|
| 442 | inline |
---|
| 443 | void G4LogicalVolume::Lock() |
---|
| 444 | { |
---|
| 445 | fLock = true; |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | // ******************************************************************** |
---|
[831] | 449 | // Operator == |
---|
| 450 | // ******************************************************************** |
---|
| 451 | // |
---|
| 452 | inline |
---|
| 453 | G4bool G4LogicalVolume::operator == ( const G4LogicalVolume& lv) const |
---|
| 454 | { |
---|
| 455 | return (this==&lv) ? true : false; |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | // ******************************************************************** |
---|
| 459 | // GetVisAttributes |
---|
| 460 | // ******************************************************************** |
---|
| 461 | // |
---|
| 462 | inline |
---|
| 463 | const G4VisAttributes* G4LogicalVolume::GetVisAttributes () const |
---|
| 464 | { |
---|
| 465 | return fVisAttributes; |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | // ******************************************************************** |
---|
| 469 | // SetVisAttributes |
---|
| 470 | // ******************************************************************** |
---|
| 471 | // |
---|
| 472 | inline |
---|
| 473 | void G4LogicalVolume::SetVisAttributes (const G4VisAttributes* pVA) |
---|
| 474 | { |
---|
| 475 | fVisAttributes = pVA; |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | // ******************************************************************** |
---|
| 479 | // SetBiasWeight |
---|
| 480 | // ******************************************************************** |
---|
| 481 | // |
---|
| 482 | inline |
---|
| 483 | void G4LogicalVolume::SetBiasWeight(G4double w) |
---|
| 484 | { |
---|
| 485 | fBiasWeight = w; |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | // ******************************************************************** |
---|
| 489 | // GetBiasWeight |
---|
| 490 | // ******************************************************************** |
---|
| 491 | // |
---|
| 492 | inline |
---|
| 493 | G4double G4LogicalVolume::GetBiasWeight() const |
---|
| 494 | { |
---|
| 495 | return fBiasWeight; |
---|
| 496 | } |
---|
| 497 | |
---|