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 // Original author: Paul Kent, July 95/96 28 // 29 /// \brief { Class description: 30 /// 31 /// G4ITNavigator is a duplicate version of G4Navigator started from Geant4.9.5 32 /// initially written by Paul Kent and colleagues. 33 /// The only difference resides in the way the information is saved and managed 34 /// 35 /// A class for use by the tracking management, able to obtain/calculate 36 /// dynamic tracking time information such as the distance to the next volume, 37 /// or to find the physical volume containing a given point in the world 38 /// reference system. The navigator maintains a transformation history and 39 /// other information to optimise the tracking time performance.} 40 // 41 // Contact : Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 42 // 43 // WARNING : This class is released as a prototype. 44 // It might strongly evolve or even disappear in the next releases. 45 // 46 // We would be very happy hearing from you, send us your feedback! :) 47 // 48 // History: 49 // - Created. Paul Kent, Jul 95/96 50 // - Zero step protections J.A. / G.C., Nov 2004 51 // - Added check mode G. Cosmo, Mar 2004 52 // - Made Navigator Abstract G. Cosmo, Nov 2003 53 // - G4ITNavigator created M.K., Nov 2012 54 // ********************************************************************* 55 56 #ifndef G4ITNAVIGATOR_HH 57 #define G4ITNAVIGATOR_HH 58 59 #include "geomdefs.hh" 60 61 #include "G4ThreeVector.hh" 62 #include "G4AffineTransform.hh" 63 #include "G4RotationMatrix.hh" 64 65 #include "G4LogicalVolume.hh" // Used in inline methods 66 #include "G4TouchableHandle.hh" // " " 67 68 #include "G4NavigationHistory.hh" 69 #include "G4NormalNavigation.hh" 70 #include "G4VoxelNavigation.hh" 71 #include "G4ParameterisedNavigation.hh" 72 #include "G4ReplicaNavigation.hh" 73 #include "G4RegularNavigation.hh" 74 75 #include <iostream> 76 #include "G4TrackState.hh" 77 #include <memory> 78 79 class G4VPhysicalVolume; 80 81 struct G4ITNavigatorState_Lock2 82 { 83 virtual ~G4ITNavigatorState_Lock2() = default; 84 protected: 85 G4ITNavigatorState_Lock2() = default; 86 }; 87 88 class G4ITNavigator2 89 { 90 public: 91 static const G4int fMaxNav = 8; // rename to kMaxNoNav ?? 92 93 public: 94 // with description 95 96 friend std::ostream& operator <<(std::ostream &os, const G4ITNavigator2 &n); 97 98 G4ITNavigator2(); 99 // Constructor - initialisers and setup. 100 101 virtual ~G4ITNavigator2(); 102 // Destructor. No actions. 103 104 G4ITNavigator2(const G4ITNavigator2&) = delete; 105 G4ITNavigator2& operator=(const G4ITNavigator2&) = delete; 106 107 // !> 108 G4ITNavigatorState_Lock2* GetNavigatorState(); 109 void SetNavigatorState(G4ITNavigatorState_Lock2*); 110 void NewNavigatorState(); 111 void NewNavigatorState(const G4TouchableHistory &h); 112 void ResetNavigatorState(); 113 G4VPhysicalVolume* NewNavigatorStateAndLocate(const G4ThreeVector &p, 114 const G4ThreeVector &direction); 115 void CheckNavigatorState() const; 116 117 inline std::shared_ptr<G4ITNavigatorState_Lock2> GetSnapshotOfState(); 118 inline void ResetFromSnapshot(std::shared_ptr<G4ITNavigatorState_Lock2>); 119 // <! 120 121 virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint, 122 const G4ThreeVector &pDirection, 123 const G4double pCurrentProposedStepLength, 124 G4double &pNewSafety); 125 // Calculate the distance to the next boundary intersected 126 // along the specified NORMALISED vector direction and 127 // from the specified point in the global coordinate 128 // system. LocateGlobalPointAndSetup or LocateGlobalPointWithinVolume 129 // must have been called with the same global point prior to this call. 130 // The isotropic distance to the nearest boundary is also 131 // calculated (usually an underestimate). The current 132 // proposed Step length is used to avoid intersection 133 // calculations: if it can be determined that the nearest 134 // boundary is >pCurrentProposedStepLength away, kInfinity 135 // is returned together with the computed isotropic safety 136 // distance. Geometry must be closed. 137 138 G4double CheckNextStep(const G4ThreeVector &pGlobalPoint, 139 const G4ThreeVector &pDirection, 140 const G4double pCurrentProposedStepLength, 141 G4double &pNewSafety); 142 // Same as above, but do not disturb the state of the Navigator. 143 144 virtual G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector &point, 145 const G4ThreeVector &direction, 146 const G4TouchableHistory &h); 147 148 // Resets the geometrical hierarchy and search for the volumes deepest 149 // in the hierarchy containing the point in the global coordinate space. 150 // The direction is used to check if a volume is entered. 151 // The search begin is the geometrical hierarchy at the location of the 152 // last located point, or the endpoint of the previous Step if 153 // SetGeometricallyLimitedStep() has been called immediately before. 154 // 155 // Important Note: In order to call this the geometry MUST be closed. 156 157 virtual 158 G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point, 159 const G4ThreeVector* direction=nullptr, 160 const G4bool pRelativeSearch=true, 161 const G4bool ignoreDirection=true); 162 // Search the geometrical hierarchy for the volumes deepest in the hierarchy 163 // containing the point in the global coordinate space. Two main cases are: 164 // i) If pRelativeSearch=false it makes use of no previous/state 165 // information. Returns the physical volume containing the point, 166 // with all previous mothers correctly set up. 167 // ii) If pRelativeSearch is set to true, the search begin is the 168 // geometrical hierarchy at the location of the last located point, 169 // or the endpoint of the previous Step if SetGeometricallyLimitedStep() 170 // has been called immediately before. 171 // The direction is used (to check if a volume is entered) if either 172 // - the argument ignoreDirection is false, or 173 // - the Navigator has determined that it is on an edge shared by two or 174 // more volumes. (This is state information.) 175 // 176 // Important Note: In order to call this the geometry MUST be closed. 177 178 //---------------------------------------------------------------------------- 179 EInside InsideCurrentVolume(const G4ThreeVector& globalPoint) const; 180 181 void GetRandomInCurrentVolume(G4ThreeVector& rndmPoint) const; 182 //---------------------------------------------------------------------------- 183 184 virtual 185 void LocateGlobalPointWithinVolume(const G4ThreeVector& position); 186 // Notify the Navigator that a track has moved to the new Global point 187 // 'position', that is known to be within the current safety. 188 // No check is performed to ensure that it is within the volume. 189 // This method can be called instead of LocateGlobalPointAndSetup ONLY if 190 // the caller is certain that the new global point (position) is inside the 191 // same volume as the previous position. Usually this can be guaranteed 192 // only if the point is within safety. 193 194 inline void LocateGlobalPointAndUpdateTouchableHandle( 195 const G4ThreeVector& position, 196 const G4ThreeVector& direction, 197 G4TouchableHandle& oldTouchableToUpdate, 198 const G4bool RelativeSearch = true); 199 // First, search the geometrical hierarchy like the above method 200 // LocateGlobalPointAndSetup(). Then use the volume found and its 201 // navigation history to update the touchable. 202 203 inline void LocateGlobalPointAndUpdateTouchable( 204 const G4ThreeVector& position, 205 const G4ThreeVector& direction, 206 G4VTouchable* touchableToUpdate, 207 const G4bool RelativeSearch = true); 208 // First, search the geometrical hierarchy like the above method 209 // LocateGlobalPointAndSetup(). Then use the volume found and its 210 // navigation history to update the touchable. 211 212 inline void LocateGlobalPointAndUpdateTouchable( 213 const G4ThreeVector& position, 214 G4VTouchable* touchableToUpdate, 215 const G4bool RelativeSearch = true); 216 // Same as the method above but missing direction. 217 218 inline void SetGeometricallyLimitedStep(); 219 // Inform the navigator that the previous Step calculated 220 // by the geometry was taken in its entirety. 221 222 virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, 223 const G4double pProposedMaxLength = DBL_MAX, 224 const G4bool keepState = true); 225 // Calculate the isotropic distance to the nearest boundary from the 226 // specified point in the global coordinate system. 227 // The globalpoint utilised must be within the current volume. 228 // The value returned is usually an underestimate. 229 // The proposed maximum length is used to avoid volume safety 230 // calculations. The geometry must be closed. 231 // To ensure minimum side effects from the call, keepState 232 // must be true. 233 234 virtual G4bool RecheckDistanceToCurrentBoundary( 235 const G4ThreeVector &pGlobalPoint, 236 const G4ThreeVector &pDirection, 237 const G4double CurrentProposedStepLength, 238 G4double *prDistance, 239 G4double *prNewSafety=nullptr) const; 240 // Trial method for checking potential displacement for MS 241 // Check new Globalpoint, to see whether it is in current volume 242 // (mother) and not in potential entering daughter. 243 // If in mother, check distance to boundary along pDirection. 244 // If in entering daughter, check distance back to boundary. 245 // NOTE: 246 // Can be called only after ComputeStep is called - before ReLocation 247 // Deals only with current volume (and potentially entered) 248 249 inline G4VPhysicalVolume* GetWorldVolume() const; 250 // Return the current world (`topmost') volume. 251 252 inline void SetWorldVolume(G4VPhysicalVolume* pWorld); 253 // Set the world (`topmost') volume. This must be positioned at 254 // origin (0,0,0) and unrotated. 255 256 inline G4TouchableHistory* CreateTouchableHistory() const; 257 inline G4TouchableHistory* CreateTouchableHistory(const G4NavigationHistory*) const; 258 // `Touchable' creation methods: caller has deletion responsibility. 259 260 virtual G4TouchableHandle CreateTouchableHistoryHandle() const; 261 // Returns a reference counted handle to a touchable history. 262 263 virtual G4ThreeVector GetLocalExitNormal(G4bool* valid); 264 virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector& point, 265 G4bool* valid); 266 virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector& point, 267 G4bool* valid); 268 // Return Exit Surface Normal and validity too. 269 // Can only be called if the Navigator's last Step has crossed a 270 // volume geometrical boundary. 271 // It returns the Normal to the surface pointing out of the volume that 272 // was left behind and/or into the volume that was entered. 273 // Convention: 274 // The *local* normal is in the coordinate system of the *final* volume. 275 // Restriction: 276 // Normals are not available for replica volumes (returns valid= false) 277 // These methods takes full care about how to calculate this normal, 278 // but if the surfaces are not convex it will return valid=false. 279 280 inline G4int GetVerboseLevel() const; 281 inline void SetVerboseLevel(G4int level); 282 // Get/Set Verbose(ness) level. 283 // [if level>0 && G4VERBOSE, printout can occur] 284 285 inline G4bool IsActive() const; 286 // Verify if the navigator is active. 287 inline void Activate(G4bool flag); 288 // Activate/inactivate the navigator. 289 290 inline G4bool EnteredDaughterVolume() const; 291 // The purpose of this function is to inform the caller if the track is 292 // entering a daughter volume while exiting from the current volume. 293 // This method returns 294 // - True only in case 1) above, that is when the Step has caused 295 // the track to arrive at a boundary of a daughter. 296 // - False in cases 2), 3) and 4), i.e. in all other cases. 297 // This function is not guaranteed to work if SetGeometricallyLimitedStep() 298 // was not called when it should have been called. 299 inline G4bool ExitedMotherVolume() const; 300 // Verify if the step has exited the mother volume. 301 302 inline void CheckMode(G4bool mode); 303 // Run navigation in "check-mode", therefore using additional 304 // verifications and more strict correctness conditions. 305 // Is effective only with G4VERBOSE set. 306 inline G4bool IsCheckModeActive() const; 307 inline void SetPushVerbosity(G4bool mode); 308 // Set/unset verbosity for pushed tracks (default is true). 309 310 void PrintState() const; 311 // Print the internal state of the Navigator (for debugging). 312 // The level of detail is according to the verbosity. 313 314 inline const G4AffineTransform& GetGlobalToLocalTransform() const; 315 inline const G4AffineTransform GetLocalToGlobalTransform() const; 316 // Obtain the transformations Global/Local (and inverse). 317 // Clients of these methods must copy the data if they need to keep it. 318 319 G4AffineTransform GetMotherToDaughterTransform(G4VPhysicalVolume* dVolume, 320 G4int dReplicaNo, 321 EVolume dVolumeType ); 322 // Obtain mother to daughter transformation 323 324 inline void ResetStackAndState(); 325 // Reset stack and minimum or navigator state machine necessary for reset 326 // as needed by LocalGlobalPointAndSetup. 327 // [Does not perform clears, resizes, or reset fLastLocatedPointLocal] 328 329 inline G4int SeverityOfZeroStepping( G4int* noZeroSteps ) const; 330 // Report on severity of error and number of zero steps, 331 // in case Navigator is stuck and is returning zero steps. 332 // Values: 1 (small problem), 5 (correcting), 333 // 9 (ready to abandon), 10 (abandoned) 334 335 /* 336 void SetSavedState(); 337 // ( fValidExitNormal, fExitNormal, fExiting, fEntering, 338 // fBlockedPhysicalVolume, fBlockedReplicaNo, fLastStepWasZero); 339 void RestoreSavedState(); 340 // Copy aspects of the state, to enable a non-state changing 341 // call to ComputeStep 342 */ 343 inline G4ThreeVector GetCurrentLocalCoordinate() const; 344 // Return the local coordinate of the point in the reference system 345 // of its containing volume that was found by LocalGlobalPointAndSetup. 346 // The local coordinate of the last located track. 347 348 inline G4ThreeVector NetTranslation() const; 349 inline G4RotationMatrix NetRotation() const; 350 // Compute+return the local->global translation/rotation of current volume. 351 352 inline void EnableBestSafety( G4bool value= false ); 353 // Enable best-possible evaluation of isotropic safety 354 355 protected:// with description 356 357 inline G4ThreeVector ComputeLocalPoint(const G4ThreeVector& rGlobPoint) const; 358 // Return position vector in local coordinate system, given a position 359 // vector in world coordinate system. 360 361 inline G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pVec) const; 362 // Return the local direction of the specified vector in the reference 363 // system of the volume that was found by LocalGlobalPointAndSetup. 364 // The Local Coordinates of point in world coordinate system. 365 366 virtual void ResetState(); 367 // Utility method to reset the navigator state machine. 368 369 inline EVolume VolumeType(const G4VPhysicalVolume *pVol) const; 370 // Characterise `type' of volume - normal/replicated/parameterised. 371 372 inline EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const; 373 // Characterise daughter of logical volume. 374 375 inline G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const; 376 // Get regular structure ID of first daughter 377 378 virtual void SetupHierarchy(); 379 // Renavigate & reset hierarchy described by current history 380 // o Reset volumes 381 // o Recompute transforms and/or solids of replicated/parameterised 382 // volumes. 383 384 private: 385 386 void ComputeStepLog(const G4ThreeVector& pGlobalpoint, 387 G4double moveLenSq) const; 388 // Log and checks for steps larger than the tolerance 389 390 protected:// without description 391 392 G4double kCarTolerance; 393 // Geometrical tolerance for surface thickness of shapes. 394 395 G4int fVerbose{0}; 396 // Verbose(ness) level [if > 0, printout can occur]. 397 398 private: 399 400 G4bool fActive; 401 // States if the navigator is activated or not. 402 403 G4int fActionThreshold_NoZeroSteps; 404 // After this many failed/zero steps, act (push etc) 405 G4int fAbandonThreshold_NoZeroSteps; 406 // After this many failed/zero steps, abandon track 407 408 protected: 409 public: 410 struct G4SaveNavigatorState; 411 412 // 413 // BEGIN State information 414 // 415 struct G4NavigatorState : public G4ITNavigatorState_Lock2 416 { 417 G4NavigatorState(); 418 G4NavigatorState(const G4NavigatorState&); 419 ~G4NavigatorState() override 420 { ;} 421 422 G4NavigatorState& operator=(const G4NavigatorState& ); 423 G4NavigatorState& operator=(const G4SaveNavigatorState& ); 424 425 void ResetState(); 426 void ResetStack(); 427 void ResetStackAndState(); 428 429 G4NavigationHistory fHistory; 430 // Transformation and history of the current path 431 // through the geometrical hierarchy. 432 433 G4bool fEnteredDaughter; 434 // A memory of whether in this Step a daughter volume is entered 435 // (set in Compute & Locate). 436 // After Compute: it expects to enter a daughter 437 // After Locate: it has entered a daughter 438 439 G4bool fExitedMother; 440 // A similar memory whether the Step exited current "mother" volume 441 // completely, not entering daughter. 442 443 G4bool fWasLimitedByGeometry; 444 // Set true if last Step was limited by geometry. 445 446 G4ThreeVector fStepEndPoint; 447 // Endpoint of last ComputeStep 448 // can be used for optimisation (e.g. when computing safety). 449 G4ThreeVector fLastStepEndPointLocal; 450 // Position of the end-point of the last call to ComputeStep 451 // in last Local coordinates. 452 453 G4bool fPushed; 454 // Push flags [if true, means a stuck particle has been pushed]. 455 456 private: 457 friend class G4ITNavigator2; 458 // The friend class would allow G4Navigator to access the private members 459 // of G4NavigatorState but not the classes inheriting from G4Navigator 460 461 friend struct G4SaveNavigatorState; 462 friend std::ostream& operator << (std::ostream &os,const G4ITNavigator2 &n); 463 464 G4bool fLastTriedStepComputation; 465 // Whether ComputeStep was called since the last call to a Locate method 466 // Uses: - distinguish parts of state which differ before/after calls 467 // to ComputeStep or one of the Locate methods; 468 // - avoid two consecutive calls to compute-step (illegal). 469 470 G4bool fEntering,fExiting; 471 // Entering/Exiting volumes blocking/setup 472 // o If exiting 473 // volume ptr & replica number (set & used by Locate..()) 474 // used for blocking on redescent of geometry 475 // o If entering 476 // volume ptr & replica number (set by ComputeStep(),used by 477 // Locate..()) of volume for `automatic' entry 478 479 G4VPhysicalVolume *fBlockedPhysicalVolume; 480 G4int fBlockedReplicaNo; 481 482 G4ThreeVector fLastLocatedPointLocal; 483 // Position of the last located point relative to its containing volume. 484 G4bool fLocatedOutsideWorld; 485 // Whether the last call to Locate methods left the world 486 487 G4bool fValidExitNormal;// Set true if have leaving volume normal 488 G4ThreeVector fExitNormal;// Leaving volume normal, in the 489 // volume containing the exited 490 // volume's coordinate system 491 G4ThreeVector fGrandMotherExitNormal;// Leaving volume normal, in its 492 // own coordinate system 493 G4bool fChangedGrandMotherRefFrame;// Whether frame is changed 494 495 G4ThreeVector fExitNormalGlobalFrame;// Leaving volume normal, in the 496 // global coordinate system 497 G4bool fCalculatedExitNormal;// Has it been computed since 498 // the last call to ComputeStep 499 // Covers both Global and GrandMother 500 501 // Count zero steps - as one or two can occur due to changing momentum at 502 // a boundary or at an edge common between volumes 503 // - several are likely a problem in the geometry 504 // description or in the navigation 505 // 506 G4bool fLastStepWasZero; 507 // Whether the last ComputeStep moved Zero. Used to check for edges. 508 509 G4bool fLocatedOnEdge; 510 // Whether the Navigator has detected an edge 511 G4int fNumberZeroSteps; 512 // Number of preceding moves that were Zero. Reset to 0 after finite step 513 514 G4ThreeVector fPreviousSftOrigin; 515 G4double fPreviousSafety; 516 // Memory of last safety origin & value. Used in ComputeStep to ensure 517 // that origin of current Step is in the same volume as the point of the 518 // last relocation 519 520 // 521 // END State information 522 // 523 }; 524 525 G4NavigatorState* fpNavigatorState; 526 527 // Save key state information (NOT the navigation history stack) 528 // 529 struct G4SaveNavigatorState 530 { 531 G4SaveNavigatorState(); 532 G4SaveNavigatorState(G4NavigatorState*); 533 virtual ~G4SaveNavigatorState() 534 { ;} 535 G4ThreeVector sExitNormal; 536 G4bool sValidExitNormal; 537 G4bool sEntering, sExiting; 538 G4VPhysicalVolume* spBlockedPhysicalVolume; 539 G4int sBlockedReplicaNo; 540 G4int sLastStepWasZero; 541 542 // !> 543 // G4bool sLocatedOnEdge; 544 // G4bool sPushed; 545 // G4int sNumberZeroSteps; 546 // <! 547 548 // Potentially relevant 549 // 550 G4bool sLocatedOutsideWorld; 551 G4ThreeVector sLastLocatedPointLocal; 552 G4bool sEnteredDaughter, sExitedMother; 553 G4bool sWasLimitedByGeometry; 554 555 G4ThreeVector sPreviousSftOrigin; 556 G4double sPreviousSafety; 557 }; 558 559 // G4SaveNavigatorState* fpSaveState; 560 561 // Tracking Invariants 562 // 563 G4VPhysicalVolume *fTopPhysical{nullptr}; 564 // A link to the topmost physical volume in the detector. 565 // Must be positioned at the origin and unrotated. 566 567 // Utility information 568 // 569 G4bool fCheck{false}; 570 // Check-mode flag [if true, more strict checks are performed]. 571 572 G4bool fWarnPush{true}; 573 // Push flag [for verbose]. 574 575 // Helpers/Utility classes 576 // 577 G4NormalNavigation fnormalNav; 578 G4VoxelNavigation fvoxelNav; 579 G4ParameterisedNavigation fparamNav; 580 G4ReplicaNavigation freplicaNav; 581 G4RegularNavigation fregularNav; 582 G4VoxelSafety *fpVoxelSafety; 583 }; 584 585 RegisterTrackState(G4ITNavigator2, G4NavigatorState) 586 587 #define CheckNavigatorStateIsValid() \ 588 if(fpNavigatorState == 0) \ 589 { \ 590 G4ExceptionDescription exceptionDescription; \ 591 exceptionDescription << "The navigator state is NULL. "; \ 592 exceptionDescription << "Either NewNavigatorStateAndLocate was not called "; \ 593 exceptionDescription << "or the provided navigator state was already NULL."; \ 594 G4Exception((G4String("G4Navigator")+G4String(__FUNCTION__)).c_str(),\ 595 "NavigatorStateNotValid",FatalException,exceptionDescription); \ 596 } 597 598 #include "G4ITNavigator2.icc" 599 600 #endif 601 602 // NOTES: 603 // 604 // The following methods provide detailed information when a Step has 605 // arrived at a geometrical boundary. They distinguish between the different 606 // causes that can result in the track leaving its current volume. 607 // 608 // Four cases are possible: 609 // 610 // 1) The particle has reached a boundary of a daughter of the current volume: 611 // (this could cause the relocation to enter the daughter itself 612 // or a potential granddaughter or further descendant) 613 // 614 // 2) The particle has reached a boundary of the current 615 // volume, exiting into a mother (regardless the level 616 // at which it is located in the tree): 617 // 618 // 3) The particle has reached a boundary of the current 619 // volume, exiting into a volume which is not in its 620 // parental hierarchy: 621 // 622 // 4) The particle is not on a boundary between volumes: 623 // the function returns an exception, and the caller is 624 // reccomended to compare the G4touchables associated 625 // to the preStepPoint and postStepPoint to handle this case. 626 // 627 // G4bool EnteredDaughterVolume() 628 // G4bool IsExitNormalValid() 629 // G4ThreeVector GetLocalExitNormal() 630 // 631 // The expected usefulness of these methods is to allow the caller to 632 // determine how to compute the surface normal at the volume boundary. The two 633 // possibilities are to obtain the normal from: 634 // 635 // i) the solid associated with the volume of the initial point of the Step. 636 // This is valid for cases 2 and 3. 637 // (Note that the initial point is generally the PreStepPoint of a Step). 638 // or 639 // 640 // ii) the solid of the final point, ie of the volume after the relocation. 641 // This is valid for case 1. 642 // (Note that the final point is generally the PreStepPoint of a Step). 643 // 644 // This way the caller can always get a valid normal, pointing outside 645 // the solid for which it is computed, that can be used at his own 646 // discretion. 647