|
|
|||
File indexing completed on 2026-08-25 09:07:47
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4Navigator class Inline implementation 0027 // 0028 // Author: Paul Kent (CERN), July 1995-1996 0029 // -------------------------------------------------------------------- 0030 0031 // ******************************************************************** 0032 // GetCurrentLocalCoordinate 0033 // 0034 // Returns the local coordinate of the current track 0035 // ******************************************************************** 0036 // 0037 inline 0038 G4ThreeVector G4Navigator::GetCurrentLocalCoordinate() const 0039 { 0040 return fLastLocatedPointLocal; 0041 } 0042 0043 // ******************************************************************** 0044 // ComputeLocalAxis 0045 // 0046 // Returns local direction of vector direction in world coord system 0047 // ******************************************************************** 0048 // 0049 inline 0050 G4ThreeVector G4Navigator::ComputeLocalAxis(const G4ThreeVector& pVec) const 0051 { 0052 return fHistory.GetTopTransform().TransformAxis(pVec); 0053 } 0054 0055 // ******************************************************************** 0056 // ComputeLocalPoint 0057 // 0058 // Returns local coordinates of a point in the world coord system 0059 // ******************************************************************** 0060 // 0061 inline 0062 G4ThreeVector 0063 G4Navigator::ComputeLocalPoint(const G4ThreeVector& pGlobalPoint) const 0064 { 0065 return fHistory.GetTopTransform().TransformPoint(pGlobalPoint); 0066 } 0067 0068 // ******************************************************************** 0069 // GetWorldVolume 0070 // 0071 // Returns the current world (`topmost') volume 0072 // ******************************************************************** 0073 // 0074 inline 0075 G4VPhysicalVolume* G4Navigator::GetWorldVolume() const 0076 { 0077 return fTopPhysical; 0078 } 0079 0080 // ******************************************************************** 0081 // SetWorldVolume 0082 // 0083 // Sets the world (`topmost') volume 0084 // ******************************************************************** 0085 // 0086 inline 0087 void G4Navigator::SetWorldVolume(G4VPhysicalVolume* pWorld) 0088 { 0089 if ( !(pWorld->GetTranslation() == G4ThreeVector(0,0,0)) ) 0090 { 0091 G4Exception ("G4Navigator::SetWorldVolume()", "GeomNav0002", 0092 FatalException, "Volume must be centered on the origin."); 0093 } 0094 const G4RotationMatrix* rm = pWorld->GetRotation(); 0095 if ( (rm != nullptr) && (!rm->isIdentity()) ) 0096 { 0097 G4Exception ("G4Navigator::SetWorldVolume()", "GeomNav0002", 0098 FatalException, "Volume must not be rotated."); 0099 } 0100 fTopPhysical = pWorld; 0101 fHistory.SetFirstEntry(pWorld); 0102 } 0103 0104 // ******************************************************************** 0105 // SetGeometrycallyLimitedStep 0106 // 0107 // Informs the navigator that the previous Step calculated 0108 // by the geometry was taken in its entirety 0109 // ******************************************************************** 0110 // 0111 inline 0112 void G4Navigator::SetGeometricallyLimitedStep() 0113 { 0114 fWasLimitedByGeometry = true; 0115 } 0116 0117 // ******************************************************************** 0118 // ResetStackAndState 0119 // 0120 // Resets stack and minimum of navigator state `machine' 0121 // ******************************************************************** 0122 // 0123 inline 0124 void G4Navigator::ResetStackAndState() 0125 { 0126 fHistory.Reset(); 0127 ResetState(); 0128 } 0129 0130 // ******************************************************************** 0131 // VolumeType 0132 // ******************************************************************** 0133 // 0134 inline 0135 EVolume G4Navigator::VolumeType(const G4VPhysicalVolume *pVol) const 0136 { 0137 return pVol->VolumeType(); 0138 } 0139 0140 // ******************************************************************** 0141 // CharacteriseDaughters 0142 // ******************************************************************** 0143 // 0144 inline 0145 EVolume G4Navigator::CharacteriseDaughters(const G4LogicalVolume *pLog) const 0146 { 0147 return pLog->CharacteriseDaughters(); 0148 } 0149 0150 // ******************************************************************** 0151 // GetDaughtersRegularStructureId 0152 // ******************************************************************** 0153 // 0154 inline 0155 G4int G4Navigator:: 0156 GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const 0157 { 0158 G4int regId = 0; 0159 G4VPhysicalVolume *pVol; 0160 0161 if ( pLog->GetNoDaughters() == 1 ) 0162 { 0163 pVol = pLog->GetDaughter(0); 0164 regId = pVol->GetRegularStructureId(); 0165 } 0166 return regId; 0167 } 0168 0169 // ******************************************************************** 0170 // GetGlobalToLocalTransform 0171 // 0172 // Returns local to global transformation. 0173 // I.e. transformation that will take point or axis in world coord system 0174 // and return one in the local coord system 0175 // ******************************************************************** 0176 // 0177 inline 0178 const G4AffineTransform& G4Navigator::GetGlobalToLocalTransform() const 0179 { 0180 return fHistory.GetTopTransform(); 0181 } 0182 0183 // ******************************************************************** 0184 // GetLocalToGlobalTransform 0185 // 0186 // Returns global to local transformation 0187 // ******************************************************************** 0188 // 0189 inline 0190 const G4AffineTransform G4Navigator::GetLocalToGlobalTransform() const 0191 { 0192 return fHistory.GetTopTransform().Inverse(); 0193 } 0194 0195 // ******************************************************************** 0196 // NetTranslation 0197 // 0198 // Computes+returns the local->global translation of current volume 0199 // ******************************************************************** 0200 // 0201 inline 0202 G4ThreeVector G4Navigator::NetTranslation() const 0203 { 0204 return fHistory.GetTopTransform().InverseNetTranslation(); 0205 } 0206 0207 // ******************************************************************** 0208 // NetRotation 0209 // 0210 // Computes+returns the local->global rotation of current volume 0211 // ******************************************************************** 0212 // 0213 inline 0214 G4RotationMatrix G4Navigator::NetRotation() const 0215 { 0216 return fHistory.GetTopTransform().InverseNetRotation(); 0217 } 0218 0219 // ******************************************************************** 0220 // CreateTouchableHistory 0221 // 0222 // `Touchable' creation method: caller has deletion responsibility 0223 // ******************************************************************** 0224 // 0225 inline 0226 G4TouchableHistory* G4Navigator::CreateTouchableHistory() const 0227 { 0228 return new G4TouchableHistory(fHistory); 0229 } 0230 0231 // ******************************************************************** 0232 // CreateTouchableHistory(history) 0233 // 0234 // `Touchable' creation method: caller has deletion responsibility 0235 // ******************************************************************** 0236 // 0237 inline 0238 G4TouchableHistory* 0239 G4Navigator::CreateTouchableHistory(const G4NavigationHistory* history) const 0240 { 0241 return new G4TouchableHistory(*history); 0242 } 0243 0244 // ******************************************************************** 0245 // LocateGlobalPointAndUpdateTouchableHandle 0246 // ******************************************************************** 0247 // 0248 inline 0249 void G4Navigator::LocateGlobalPointAndUpdateTouchableHandle( 0250 const G4ThreeVector& position, 0251 const G4ThreeVector& direction, 0252 G4TouchableHandle& oldTouchableToUpdate, 0253 const G4bool RelativeSearch ) 0254 { 0255 G4VPhysicalVolume* pPhysVol; 0256 pPhysVol = LocateGlobalPointAndSetup( position,&direction,RelativeSearch ); 0257 if( fEnteredDaughter || fExitedMother ) 0258 { 0259 oldTouchableToUpdate = CreateTouchableHistory(); 0260 if( pPhysVol == nullptr ) 0261 { 0262 // We want to ensure that the touchable is correct in this case. 0263 // The method below should do this and recalculate a lot more .... 0264 // 0265 oldTouchableToUpdate->UpdateYourself( pPhysVol, &fHistory ); 0266 } 0267 } 0268 return; 0269 } 0270 0271 // ******************************************************************** 0272 // LocateGlobalPointAndUpdateTouchable 0273 // 0274 // Use direction 0275 // ******************************************************************** 0276 // 0277 inline 0278 void G4Navigator::LocateGlobalPointAndUpdateTouchable( 0279 const G4ThreeVector& position, 0280 const G4ThreeVector& direction, 0281 G4VTouchable* touchableToUpdate, 0282 const G4bool RelativeSearch ) 0283 { 0284 G4VPhysicalVolume* pPhysVol; 0285 pPhysVol = LocateGlobalPointAndSetup( position, &direction, RelativeSearch); 0286 touchableToUpdate->UpdateYourself( pPhysVol, &fHistory ); 0287 } 0288 0289 // ******************************************************************** 0290 // LocateGlobalPointAndUpdateTouchable 0291 // ******************************************************************** 0292 // 0293 inline 0294 void G4Navigator::LocateGlobalPointAndUpdateTouchable( 0295 const G4ThreeVector& position, 0296 G4VTouchable* touchableToUpdate, 0297 const G4bool RelativeSearch ) 0298 { 0299 G4VPhysicalVolume* pPhysVol; 0300 pPhysVol = LocateGlobalPointAndSetup( position, nullptr, RelativeSearch); 0301 touchableToUpdate->UpdateYourself( pPhysVol, &fHistory ); 0302 } 0303 0304 // ******************************************************************** 0305 // GetVerboseLevel 0306 // ******************************************************************** 0307 // 0308 inline 0309 G4int G4Navigator::GetVerboseLevel() const 0310 { 0311 return fVerbose; 0312 } 0313 0314 // ******************************************************************** 0315 // SetVerboseLevel 0316 // ******************************************************************** 0317 // 0318 inline 0319 void G4Navigator::SetVerboseLevel(G4int level) 0320 { 0321 fVerbose = level; 0322 fnormalNav.SetVerboseLevel(level); 0323 GetVoxelNavigator().SetVerboseLevel(level); 0324 fparamNav.SetVerboseLevel(level); 0325 freplicaNav.SetVerboseLevel(level); 0326 fregularNav.SetVerboseLevel(level); 0327 if (fpExternalNav != nullptr) { fpExternalNav->SetVerboseLevel(level); } 0328 } 0329 0330 // ******************************************************************** 0331 // IsActive 0332 // ******************************************************************** 0333 // 0334 inline 0335 G4bool G4Navigator::IsActive() const 0336 { 0337 return fActive; 0338 } 0339 0340 // ******************************************************************** 0341 // Activate 0342 // ******************************************************************** 0343 // 0344 inline 0345 void G4Navigator::Activate(G4bool flag) 0346 { 0347 fActive = flag; 0348 } 0349 0350 // ******************************************************************** 0351 // EnteredDaughterVolume 0352 // 0353 // To inform the caller if the track is entering a daughter volume 0354 // ******************************************************************** 0355 // 0356 inline 0357 G4bool G4Navigator::EnteredDaughterVolume() const 0358 { 0359 return fEnteredDaughter; 0360 } 0361 0362 // ******************************************************************** 0363 // ExitedMotherVolume 0364 // ******************************************************************** 0365 // 0366 inline 0367 G4bool G4Navigator::ExitedMotherVolume() const 0368 { 0369 return fExitedMother; 0370 } 0371 0372 // ******************************************************************** 0373 // CheckMode 0374 // ******************************************************************** 0375 // 0376 inline 0377 void G4Navigator::CheckMode(G4bool mode) 0378 { 0379 fCheck = mode; 0380 fnormalNav.CheckMode(mode); 0381 GetVoxelNavigator().CheckMode(mode); 0382 fparamNav.CheckMode(mode); 0383 freplicaNav.CheckMode(mode); 0384 fregularNav.CheckMode(mode); 0385 if (fpExternalNav != nullptr) { fpExternalNav->CheckMode(mode); } 0386 } 0387 0388 // ******************************************************************** 0389 // IsCheckModeActive 0390 // ******************************************************************** 0391 // 0392 inline 0393 G4bool G4Navigator::IsCheckModeActive() const 0394 { 0395 return fCheck; 0396 } 0397 0398 // ******************************************************************** 0399 // SetPushVerbosity 0400 // ******************************************************************** 0401 // 0402 inline 0403 void G4Navigator::SetPushVerbosity(G4bool mode) 0404 { 0405 fWarnPush = mode; 0406 } 0407 0408 // ******************************************************************** 0409 // SeverityOfZeroStepping 0410 // 0411 // Reports on severity of error in case Navigator is stuck 0412 // and is returning zero steps 0413 // ******************************************************************** 0414 // 0415 inline 0416 G4int G4Navigator::SeverityOfZeroStepping( G4int* noZeroSteps ) const 0417 { 0418 G4int severity = 0, noZeros = fNumberZeroSteps; 0419 if( noZeroSteps != nullptr ) 0420 { 0421 *noZeroSteps = fNumberZeroSteps; 0422 } 0423 if( noZeros >= fAbandonThreshold_NoZeroSteps ) 0424 { 0425 severity = 10; 0426 } 0427 if( noZeros > 0 && noZeros < fActionThreshold_NoZeroSteps ) 0428 { 0429 severity = 5 * noZeros / fActionThreshold_NoZeroSteps; 0430 } 0431 else if( noZeros == fActionThreshold_NoZeroSteps ) 0432 { 0433 severity = 5; 0434 } 0435 else if( noZeros >= fAbandonThreshold_NoZeroSteps - 2 ) 0436 { 0437 severity = 9; 0438 } 0439 else if( noZeros < fAbandonThreshold_NoZeroSteps - 2 ) 0440 { 0441 severity = 5 + 4 * (noZeros-fAbandonThreshold_NoZeroSteps) 0442 / fActionThreshold_NoZeroSteps; 0443 } 0444 return severity; 0445 } 0446 0447 // ******************************************************************** 0448 // GetVoxelNavigator 0449 // ******************************************************************** 0450 // 0451 inline 0452 G4VoxelNavigation& G4Navigator::GetVoxelNavigator() 0453 { 0454 return *fpvoxelNav; 0455 } 0456 0457 // ******************************************************************** 0458 // EnableBestSafety 0459 // ******************************************************************** 0460 // 0461 inline void G4Navigator::EnableBestSafety( G4bool value ) 0462 { 0463 GetVoxelNavigator().EnableBestSafety( value ); 0464 } 0465 0466 // ******************************************************************** 0467 // SetExternalNavigation 0468 // ******************************************************************** 0469 // 0470 inline 0471 G4VExternalNavigation* G4Navigator::GetExternalNavigation() const 0472 { 0473 return fpExternalNav; 0474 } 0475 0476 // ******************************************************************** 0477 // Clone 0478 // ******************************************************************** 0479 // 0480 inline 0481 G4Navigator* G4Navigator::Clone() const 0482 { 0483 auto clone_nav = new G4Navigator(); 0484 clone_nav->SetWorldVolume(fTopPhysical); 0485 if( fpExternalNav != nullptr ) 0486 { 0487 clone_nav->SetExternalNavigation(fpExternalNav->Clone()); 0488 } 0489 return clone_nav; 0490 } 0491 0492 // ******************************************************************** 0493 // GetLastStepEndPoint 0494 // ******************************************************************** 0495 // 0496 inline 0497 G4ThreeVector G4Navigator::GetLastStepEndPoint() const 0498 { 0499 return fStepEndPoint; 0500 }
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|