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