Geant4 Cross Reference |
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 // 27 // 28 // class G4ITNavigator1 Inline implementation 29 // 30 // G4ITNavigator1 is a duplicate version of G4Navigator started from Geant4.9.5 31 // initially written by Paul Kent and colleagues. 32 // The only difference resides in the way the information is saved and managed 33 // 34 // ******************************************************************** 35 36 // ******************************************************************** 37 // GetCurrentLocalCoordinate 38 // 39 // Returns the local coordinate of the current track 40 // ******************************************************************** 41 // 42 inline 43 G4ThreeVector G4ITNavigator1::GetCurrentLocalCoordinate() const 44 { 45 return fLastLocatedPointLocal; 46 } 47 48 // ******************************************************************** 49 // ComputeLocalAxis 50 // 51 // Returns local direction of vector direction in world coord system 52 // ******************************************************************** 53 // 54 inline 55 G4ThreeVector G4ITNavigator1::ComputeLocalAxis(const G4ThreeVector& pVec) const 56 { 57 return (fHistory.GetTopTransform().IsRotated()) 58 ? fHistory.GetTopTransform().TransformAxis(pVec) : pVec ; 59 } 60 61 // ******************************************************************** 62 // ComputeLocalPoint 63 // 64 // Returns local coordinates of a point in the world coord system 65 // ******************************************************************** 66 // 67 inline 68 G4ThreeVector 69 G4ITNavigator1::ComputeLocalPoint(const G4ThreeVector& pGlobalPoint) const 70 { 71 return ( fHistory.GetTopTransform().TransformPoint(pGlobalPoint) ) ; 72 } 73 74 // ******************************************************************** 75 // GetWorldVolume 76 // 77 // Returns the current world (`topmost') volume 78 // ******************************************************************** 79 // 80 inline 81 G4VPhysicalVolume* G4ITNavigator1::GetWorldVolume() const 82 { 83 return fTopPhysical; 84 } 85 86 // ******************************************************************** 87 // SetWorldVolume 88 // 89 // Sets the world (`topmost') volume 90 // ******************************************************************** 91 // 92 inline 93 void G4ITNavigator1::SetWorldVolume(G4VPhysicalVolume* pWorld) 94 { 95 if ( !(pWorld->GetTranslation()==G4ThreeVector(0,0,0)) ) 96 { 97 G4Exception ("G4ITNavigator1::SetWorldVolume()", "GeomNav0002", 98 FatalException, "Volume must be centered on the origin."); 99 } 100 const G4RotationMatrix* rm = pWorld->GetRotation(); 101 if ( (rm != nullptr) && (!rm->isIdentity()) ) 102 { 103 G4Exception ("G4ITNavigator1::SetWorldVolume()", "GeomNav0002", 104 FatalException, "Volume must not be rotated."); 105 } 106 fTopPhysical = pWorld; 107 fHistory.SetFirstEntry(pWorld); 108 } 109 110 // ******************************************************************** 111 // SetGeometrycallyLimitedStep 112 // 113 // Informs the navigator that the previous Step calculated 114 // by the geometry was taken in its entirety 115 // ******************************************************************** 116 // 117 inline 118 void G4ITNavigator1::SetGeometricallyLimitedStep() 119 { 120 fWasLimitedByGeometry=true; 121 } 122 123 // ******************************************************************** 124 // ResetStackAndState 125 // 126 // Resets stack and minimum of navigator state `machine' 127 // ******************************************************************** 128 // 129 inline 130 void G4ITNavigator1::ResetStackAndState() 131 { 132 fHistory.Reset(); 133 ResetState(); 134 } 135 136 // ******************************************************************** 137 // VolumeType 138 // ******************************************************************** 139 // 140 inline 141 EVolume G4ITNavigator1::VolumeType(const G4VPhysicalVolume *pVol) const 142 { 143 return pVol->VolumeType(); 144 } 145 146 // ******************************************************************** 147 // CharacteriseDaughters 148 // ******************************************************************** 149 // 150 inline 151 EVolume G4ITNavigator1::CharacteriseDaughters(const G4LogicalVolume *pLog) const 152 { 153 return pLog->CharacteriseDaughters(); 154 } 155 156 // ******************************************************************** 157 // GetDaughtersRegularStructureId 158 // ******************************************************************** 159 // 160 inline 161 G4int G4ITNavigator1:: 162 GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const 163 { 164 G4int regId = 0; 165 G4VPhysicalVolume *pVol; 166 167 if ( pLog->GetNoDaughters()==1 ) 168 { 169 pVol = pLog->GetDaughter(0); 170 regId = pVol->GetRegularStructureId(); 171 } 172 return regId; 173 } 174 175 // ******************************************************************** 176 // GetGlobalToLocalTransform 177 // 178 // Returns local to global transformation. 179 // I.e. transformation that will take point or axis in world coord system 180 // and return one in the local coord system 181 // ******************************************************************** 182 // 183 inline 184 const G4AffineTransform& G4ITNavigator1::GetGlobalToLocalTransform() const 185 { 186 return fHistory.GetTopTransform(); 187 } 188 189 // ******************************************************************** 190 // GetLocalToGlobalTransform 191 // 192 // Returns global to local transformation 193 // ******************************************************************** 194 // 195 inline 196 const G4AffineTransform G4ITNavigator1::GetLocalToGlobalTransform() const 197 { 198 G4AffineTransform tempTransform; 199 tempTransform = fHistory.GetTopTransform().Inverse(); 200 return tempTransform; 201 } 202 203 // ******************************************************************** 204 // NetTranslation 205 // 206 // Computes+returns the local->global translation of current volume 207 // ******************************************************************** 208 // 209 inline 210 G4ThreeVector G4ITNavigator1::NetTranslation() const 211 { 212 G4AffineTransform tf(fHistory.GetTopTransform().Inverse()); 213 return tf.NetTranslation(); 214 } 215 216 // ******************************************************************** 217 // NetRotation 218 // 219 // Computes+returns the local->global rotation of current volume 220 // ******************************************************************** 221 // 222 inline 223 G4RotationMatrix G4ITNavigator1::NetRotation() const 224 { 225 G4AffineTransform tf(fHistory.GetTopTransform().Inverse()); 226 return tf.NetRotation(); 227 } 228 229 // ******************************************************************** 230 // CreateTouchableHistory 231 // 232 // `Touchable' creation method: caller has deletion responsibility 233 // ******************************************************************** 234 // 235 inline 236 G4TouchableHistory* G4ITNavigator1::CreateTouchableHistory() const 237 { 238 return new G4TouchableHistory(fHistory); 239 } 240 241 // ******************************************************************** 242 // CreateTouchableHistory(history) 243 // 244 // `Touchable' creation method: caller has deletion responsibility 245 // ******************************************************************** 246 // 247 inline 248 G4TouchableHistory* 249 G4ITNavigator1::CreateTouchableHistory(const G4NavigationHistory* history) const 250 { 251 return new G4TouchableHistory(*history); 252 } 253 254 // ******************************************************************** 255 // LocateGlobalPointAndUpdateTouchableHandle 256 // ******************************************************************** 257 // 258 inline 259 void G4ITNavigator1::LocateGlobalPointAndUpdateTouchableHandle( 260 const G4ThreeVector& position, 261 const G4ThreeVector& direction, 262 G4TouchableHandle& oldTouchableToUpdate, 263 const G4bool RelativeSearch ) 264 { 265 G4VPhysicalVolume* pPhysVol; 266 pPhysVol = LocateGlobalPointAndSetup( position,&direction,RelativeSearch ); 267 if( fEnteredDaughter || fExitedMother ) 268 { 269 oldTouchableToUpdate = CreateTouchableHistory(); 270 if( pPhysVol == nullptr ) 271 { 272 // We want to ensure that the touchable is correct in this case. 273 // The method below should do this and recalculate a lot more .... 274 // 275 oldTouchableToUpdate->UpdateYourself( pPhysVol, &fHistory ); 276 } 277 } 278 return; 279 } 280 281 // ******************************************************************** 282 // LocateGlobalPointAndUpdateTouchable 283 // 284 // Use direction 285 // ******************************************************************** 286 // 287 inline 288 void G4ITNavigator1::LocateGlobalPointAndUpdateTouchable( 289 const G4ThreeVector& position, 290 const G4ThreeVector& direction, 291 G4VTouchable* touchableToUpdate, 292 const G4bool RelativeSearch ) 293 { 294 G4VPhysicalVolume* pPhysVol; 295 pPhysVol = LocateGlobalPointAndSetup( position, &direction, RelativeSearch); 296 touchableToUpdate->UpdateYourself( pPhysVol, &fHistory ); 297 } 298 299 // ******************************************************************** 300 // LocateGlobalPointAndUpdateTouchable 301 // ******************************************************************** 302 // 303 inline 304 void G4ITNavigator1::LocateGlobalPointAndUpdateTouchable( 305 const G4ThreeVector& position, 306 G4VTouchable* touchableToUpdate, 307 const G4bool RelativeSearch ) 308 { 309 G4VPhysicalVolume* pPhysVol; 310 pPhysVol = LocateGlobalPointAndSetup( position, nullptr, RelativeSearch); 311 touchableToUpdate->UpdateYourself( pPhysVol, &fHistory ); 312 } 313 314 // ******************************************************************** 315 // GetVerboseLevel 316 // ******************************************************************** 317 // 318 inline 319 G4int G4ITNavigator1::GetVerboseLevel() const 320 { 321 return fVerbose; 322 } 323 324 // ******************************************************************** 325 // SetVerboseLevel 326 // ******************************************************************** 327 // 328 inline 329 void G4ITNavigator1::SetVerboseLevel(G4int level) 330 { 331 fVerbose = level; 332 fnormalNav.SetVerboseLevel(level); 333 fvoxelNav.SetVerboseLevel(level); 334 fparamNav.SetVerboseLevel(level); 335 freplicaNav.SetVerboseLevel(level); 336 fregularNav.SetVerboseLevel(level); 337 } 338 339 // ******************************************************************** 340 // IsActive 341 // ******************************************************************** 342 // 343 inline 344 G4bool G4ITNavigator1::IsActive() const 345 { 346 return fActive; 347 } 348 349 // ******************************************************************** 350 // Activate 351 // ******************************************************************** 352 // 353 inline 354 void G4ITNavigator1::Activate(G4bool flag) 355 { 356 fActive = flag; 357 } 358 359 // ******************************************************************** 360 // EnteredDaughterVolume 361 // 362 // To inform the caller if the track is entering a daughter volume 363 // ******************************************************************** 364 // 365 inline 366 G4bool G4ITNavigator1::EnteredDaughterVolume() const 367 { 368 return fEnteredDaughter; 369 } 370 371 // ******************************************************************** 372 // ExitedMotherVolume 373 // ******************************************************************** 374 // 375 inline 376 G4bool G4ITNavigator1::ExitedMotherVolume() const 377 { 378 return fExitedMother; 379 } 380 381 // ******************************************************************** 382 // CheckMode 383 // ******************************************************************** 384 // 385 inline 386 void G4ITNavigator1::CheckMode(G4bool mode) 387 { 388 fCheck = mode; 389 fnormalNav.CheckMode(mode); 390 fvoxelNav.CheckMode(mode); 391 fparamNav.CheckMode(mode); 392 freplicaNav.CheckMode(mode); 393 fregularNav.CheckMode(mode); 394 } 395 396 // ******************************************************************** 397 // IsCheckModeActive 398 // ******************************************************************** 399 // 400 inline 401 G4bool G4ITNavigator1::IsCheckModeActive() const 402 { 403 return fCheck; 404 } 405 406 // ******************************************************************** 407 // SetPushVerbosity 408 // ******************************************************************** 409 // 410 inline 411 void G4ITNavigator1::SetPushVerbosity(G4bool mode) 412 { 413 fWarnPush = mode; 414 } 415 416 // ******************************************************************** 417 // SeverityOfZeroStepping 418 // 419 // Reports on severity of error in case Navigator is stuck 420 // and is returning zero steps 421 // ******************************************************************** 422 // 423 inline 424 G4int G4ITNavigator1::SeverityOfZeroStepping( G4int* noZeroSteps ) const 425 { 426 G4int severity=0, noZeros= fNumberZeroSteps; 427 if( noZeroSteps != nullptr) *noZeroSteps = fNumberZeroSteps; 428 429 if( noZeros >= fAbandonThreshold_NoZeroSteps ) 430 { 431 severity = 10; 432 } 433 if( noZeros > 0 && noZeros < fActionThreshold_NoZeroSteps ) 434 { 435 severity = 5 * noZeros / fActionThreshold_NoZeroSteps; 436 } 437 else if( noZeros == fActionThreshold_NoZeroSteps ) 438 { 439 severity = 5; 440 } 441 else if( noZeros >= fAbandonThreshold_NoZeroSteps - 2 ) 442 { 443 severity = 9; 444 } 445 else if( noZeros < fAbandonThreshold_NoZeroSteps - 2 ) 446 { 447 severity = 5 + 4 * (noZeros-fAbandonThreshold_NoZeroSteps) 448 / fActionThreshold_NoZeroSteps; 449 } 450 return severity; 451 } 452 453 // ******************************************************************** 454 // EnableBestSafety 455 // ******************************************************************** 456 // 457 inline void G4ITNavigator1::EnableBestSafety( G4bool value ) 458 { 459 fvoxelNav.EnableBestSafety( value ); 460 } 461