| 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 | // $Id: G4Navigator.hh,v 1.27 2008/10/24 14:00:03 gcosmo Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-02-cand-01 $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // class G4Navigator
|
|---|
| 32 | //
|
|---|
| 33 | // Class description:
|
|---|
| 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 | // History:
|
|---|
| 42 | // - Created. Paul Kent, Jul 95/96
|
|---|
| 43 | // - Zero step protections J.A. / G.C., Nov 2004
|
|---|
| 44 | // - Added check mode G. Cosmo, Mar 2004
|
|---|
| 45 | // - Made Navigator Abstract G. Cosmo, Nov 2003
|
|---|
| 46 | // *********************************************************************
|
|---|
| 47 |
|
|---|
| 48 | #ifndef G4NAVIGATOR_HH
|
|---|
| 49 | #define G4NAVIGATOR_HH
|
|---|
| 50 |
|
|---|
| 51 | #include "geomdefs.hh"
|
|---|
| 52 |
|
|---|
| 53 | #include "G4ThreeVector.hh"
|
|---|
| 54 | #include "G4AffineTransform.hh"
|
|---|
| 55 | #include "G4RotationMatrix.hh"
|
|---|
| 56 |
|
|---|
| 57 | #include "G4LogicalVolume.hh" // Used in inline methods
|
|---|
| 58 | #include "G4GRSVolume.hh" // " "
|
|---|
| 59 | #include "G4GRSSolid.hh" // " "
|
|---|
| 60 | #include "G4TouchableHandle.hh" // " "
|
|---|
| 61 | #include "G4TouchableHistoryHandle.hh"
|
|---|
| 62 |
|
|---|
| 63 | #include "G4NavigationHistory.hh"
|
|---|
| 64 | #include "G4NormalNavigation.hh"
|
|---|
| 65 | #include "G4VoxelNavigation.hh"
|
|---|
| 66 | #include "G4ParameterisedNavigation.hh"
|
|---|
| 67 | #include "G4ReplicaNavigation.hh"
|
|---|
| 68 | #include "G4RegularNavigation.hh"
|
|---|
| 69 |
|
|---|
| 70 | #include <iostream>
|
|---|
| 71 |
|
|---|
| 72 | class G4VPhysicalVolume;
|
|---|
| 73 |
|
|---|
| 74 | class G4Navigator
|
|---|
| 75 | {
|
|---|
| 76 | public: // with description
|
|---|
| 77 |
|
|---|
| 78 | friend std::ostream& operator << (std::ostream &os, const G4Navigator &n);
|
|---|
| 79 |
|
|---|
| 80 | G4Navigator();
|
|---|
| 81 | // Constructor - initialisers and setup.
|
|---|
| 82 |
|
|---|
| 83 | virtual ~G4Navigator();
|
|---|
| 84 | // Destructor. No actions.
|
|---|
| 85 |
|
|---|
| 86 | virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint,
|
|---|
| 87 | const G4ThreeVector &pDirection,
|
|---|
| 88 | const G4double pCurrentProposedStepLength,
|
|---|
| 89 | G4double &pNewSafety);
|
|---|
| 90 | // Calculate the distance to the next boundary intersected
|
|---|
| 91 | // along the specified NORMALISED vector direction and
|
|---|
| 92 | // from the specified point in the global coordinate
|
|---|
| 93 | // system. LocateGlobalPointAndSetup or LocateGlobalPointWithinVolume
|
|---|
| 94 | // must have been called with the same global point prior to this call.
|
|---|
| 95 | // The isotropic distance to the nearest boundary is also
|
|---|
| 96 | // calculated (usually an underestimate). The current
|
|---|
| 97 | // proposed Step length is used to avoid intersection
|
|---|
| 98 | // calculations: if it can be determined that the nearest
|
|---|
| 99 | // boundary is >pCurrentProposedStepLength away, kInfinity
|
|---|
| 100 | // is returned together with the computed isotropic safety
|
|---|
| 101 | // distance. Geometry must be closed.
|
|---|
| 102 |
|
|---|
| 103 | G4double CheckNextStep(const G4ThreeVector &pGlobalPoint,
|
|---|
| 104 | const G4ThreeVector &pDirection,
|
|---|
| 105 | const G4double pCurrentProposedStepLength,
|
|---|
| 106 | G4double &pNewSafety);
|
|---|
| 107 | // Same as above, but do not disturb the state of the Navigator.
|
|---|
| 108 |
|
|---|
| 109 | virtual
|
|---|
| 110 | G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector &point,
|
|---|
| 111 | const G4ThreeVector &direction,
|
|---|
| 112 | const G4TouchableHistory &h);
|
|---|
| 113 |
|
|---|
| 114 | // Resets the geometrical hierarchy and search for the volumes deepest
|
|---|
| 115 | // in the hierarchy containing the point in the global coordinate space.
|
|---|
| 116 | // The direction is used to check if a volume is entered.
|
|---|
| 117 | // The search begin is the geometrical hierarchy at the location of the
|
|---|
| 118 | // last located point, or the endpoint of the previous Step if
|
|---|
| 119 | // SetGeometricallyLimitedStep() has been called immediately before.
|
|---|
| 120 | //
|
|---|
| 121 | // Important Note: In order to call this the geometry MUST be closed.
|
|---|
| 122 |
|
|---|
| 123 | virtual
|
|---|
| 124 | G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
|
|---|
| 125 | const G4ThreeVector* direction=0,
|
|---|
| 126 | const G4bool pRelativeSearch=true,
|
|---|
| 127 | const G4bool ignoreDirection=true);
|
|---|
| 128 | // Search the geometrical hierarchy for the volumes deepest in the hierarchy
|
|---|
| 129 | // containing the point in the global coordinate space. Two main cases are:
|
|---|
| 130 | // i) If pRelativeSearch=false it makes use of no previous/state
|
|---|
| 131 | // information. Returns the physical volume containing the point,
|
|---|
| 132 | // with all previous mothers correctly set up.
|
|---|
| 133 | // ii) If pRelativeSearch is set to true, the search begin is the
|
|---|
| 134 | // geometrical hierarchy at the location of the last located point,
|
|---|
| 135 | // or the endpoint of the previous Step if SetGeometricallyLimitedStep()
|
|---|
| 136 | // has been called immediately before.
|
|---|
| 137 | // The direction is used (to check if a volume is entered) if either
|
|---|
| 138 | // - the argument ignoreDirection is false, or
|
|---|
| 139 | // - the Navigator has determined that it is on an edge shared by two or
|
|---|
| 140 | // more volumes. (This is state information.)
|
|---|
| 141 | //
|
|---|
| 142 | // Important Note: In order to call this the geometry MUST be closed.
|
|---|
| 143 |
|
|---|
| 144 | virtual
|
|---|
| 145 | void LocateGlobalPointWithinVolume(const G4ThreeVector& position);
|
|---|
| 146 | // Notify the Navigator that a track has moved to the new Global point
|
|---|
| 147 | // 'position', that is known to be within the current safety.
|
|---|
| 148 | // No check is performed to ensure that it is within the volume.
|
|---|
| 149 | // This method can be called instead of LocateGlobalPointAndSetup ONLY if
|
|---|
| 150 | // the caller is certain that the new global point (position) is inside the
|
|---|
| 151 | // same volume as the previous position. Usually this can be guaranteed
|
|---|
| 152 | // only if the point is within safety.
|
|---|
| 153 |
|
|---|
| 154 | inline void LocateGlobalPointAndUpdateTouchableHandle(
|
|---|
| 155 | const G4ThreeVector& position,
|
|---|
| 156 | const G4ThreeVector& direction,
|
|---|
| 157 | G4TouchableHandle& oldTouchableToUpdate,
|
|---|
| 158 | const G4bool RelativeSearch = true);
|
|---|
| 159 | // First, search the geometrical hierarchy like the above method
|
|---|
| 160 | // LocateGlobalPointAndSetup(). Then use the volume found and its
|
|---|
| 161 | // navigation history to update the touchable.
|
|---|
| 162 |
|
|---|
| 163 | inline void LocateGlobalPointAndUpdateTouchable(
|
|---|
| 164 | const G4ThreeVector& position,
|
|---|
| 165 | const G4ThreeVector& direction,
|
|---|
| 166 | G4VTouchable* touchableToUpdate,
|
|---|
| 167 | const G4bool RelativeSearch = true);
|
|---|
| 168 | // First, search the geometrical hierarchy like the above method
|
|---|
| 169 | // LocateGlobalPointAndSetup(). Then use the volume found and its
|
|---|
| 170 | // navigation history to update the touchable.
|
|---|
| 171 |
|
|---|
| 172 | inline void LocateGlobalPointAndUpdateTouchable(
|
|---|
| 173 | const G4ThreeVector& position,
|
|---|
| 174 | G4VTouchable* touchableToUpdate,
|
|---|
| 175 | const G4bool RelativeSearch = true);
|
|---|
| 176 | // Same as the method above but missing direction.
|
|---|
| 177 |
|
|---|
| 178 | inline void SetGeometricallyLimitedStep();
|
|---|
| 179 | // Inform the navigator that the previous Step calculated
|
|---|
| 180 | // by the geometry was taken in its entirety.
|
|---|
| 181 |
|
|---|
| 182 | virtual G4double ComputeSafety(const G4ThreeVector &globalpoint,
|
|---|
| 183 | const G4double pProposedMaxLength = DBL_MAX,
|
|---|
| 184 | const G4bool keepState = false);
|
|---|
| 185 | // Calculate the isotropic distance to the nearest boundary from the
|
|---|
| 186 | // specified point in the global coordinate system.
|
|---|
| 187 | // The globalpoint utilised must be within the current volume.
|
|---|
| 188 | // The value returned is usually an underestimate.
|
|---|
| 189 | // The proposed maximum length is used to avoid volume safety
|
|---|
| 190 | // calculations. The geometry must be closed.
|
|---|
| 191 |
|
|---|
| 192 | inline G4VPhysicalVolume* GetWorldVolume() const;
|
|---|
| 193 | // Return the current world (`topmost') volume.
|
|---|
| 194 |
|
|---|
| 195 | inline void SetWorldVolume(G4VPhysicalVolume* pWorld);
|
|---|
| 196 | // Set the world (`topmost') volume. This must be positioned at
|
|---|
| 197 | // origin (0,0,0) and unrotated.
|
|---|
| 198 |
|
|---|
| 199 | inline G4GRSVolume* CreateGRSVolume() const;
|
|---|
| 200 | inline G4GRSSolid* CreateGRSSolid() const;
|
|---|
| 201 | inline G4TouchableHistory* CreateTouchableHistory() const;
|
|---|
| 202 | // `Touchable' creation methods: caller has deletion responsibility.
|
|---|
| 203 |
|
|---|
| 204 | virtual G4TouchableHistoryHandle CreateTouchableHistoryHandle() const;
|
|---|
| 205 | // Returns a reference counted handle to a touchable history.
|
|---|
| 206 |
|
|---|
| 207 | virtual G4ThreeVector GetLocalExitNormal(G4bool* valid);
|
|---|
| 208 | // Returns Exit Surface Normal and validity too.
|
|---|
| 209 | // It can only be called if the Navigator's last Step has crossed a
|
|---|
| 210 | // volume geometrical boundary.
|
|---|
| 211 | // It returns the Normal to the surface pointing out of the volume that
|
|---|
| 212 | // was left behind and/or into the volume that was entered.
|
|---|
| 213 | // (The normal is in the coordinate system of the final volume.)
|
|---|
| 214 | // This function takes full care about how to calculate this normal,
|
|---|
| 215 | // but if the surfaces are not convex it will return valid=false.
|
|---|
| 216 |
|
|---|
| 217 | inline G4int GetVerboseLevel() const;
|
|---|
| 218 | inline void SetVerboseLevel(G4int level);
|
|---|
| 219 | // Get/Set Verbose(ness) level.
|
|---|
| 220 | // [if level>0 && G4VERBOSE, printout can occur]
|
|---|
| 221 |
|
|---|
| 222 | inline G4bool IsActive() const;
|
|---|
| 223 | // Verify if the navigator is active.
|
|---|
| 224 | inline void Activate(G4bool flag);
|
|---|
| 225 | // Activate/inactivate the navigator.
|
|---|
| 226 |
|
|---|
| 227 | inline G4bool EnteredDaughterVolume() const;
|
|---|
| 228 | // The purpose of this function is to inform the caller if the track is
|
|---|
| 229 | // entering a daughter volume while exiting from the current volume.
|
|---|
| 230 | // This method returns
|
|---|
| 231 | // - True only in case 1) above, that is when the Step has caused
|
|---|
| 232 | // the track to arrive at a boundary of a daughter.
|
|---|
| 233 | // - False in cases 2), 3) and 4), i.e. in all other cases.
|
|---|
| 234 | // This function is not guaranteed to work if SetGeometricallyLimitedStep()
|
|---|
| 235 | // was not called when it should have been called.
|
|---|
| 236 | inline G4bool ExitedMotherVolume() const;
|
|---|
| 237 | // Verify if the step has exited the mother volume.
|
|---|
| 238 |
|
|---|
| 239 | inline void CheckMode(G4bool mode);
|
|---|
| 240 | // Run navigation in "check-mode", therefore using additional
|
|---|
| 241 | // verifications and more strict correctness conditions.
|
|---|
| 242 | // Is effective only with G4VERBOSE set.
|
|---|
| 243 |
|
|---|
| 244 | void PrintState() const;
|
|---|
| 245 | // Print the internal state of the Navigator (for debugging).
|
|---|
| 246 | // The level of detail is according to the verbosity.
|
|---|
| 247 |
|
|---|
| 248 | inline const G4AffineTransform& GetGlobalToLocalTransform() const;
|
|---|
| 249 | inline const G4AffineTransform GetLocalToGlobalTransform() const;
|
|---|
| 250 | // Obtain the transformations Global/Local (and inverse).
|
|---|
| 251 | // Clients of these methods must copy the data if they need to keep it.
|
|---|
| 252 |
|
|---|
| 253 | inline void ResetStackAndState();
|
|---|
| 254 | // Reset stack and minimum or navigator state machine necessary for reset
|
|---|
| 255 | // as needed by LocalGlobalPointAndSetup.
|
|---|
| 256 | // [Does not perform clears, resizes, or reset fLastLocatedPointLocal]
|
|---|
| 257 |
|
|---|
| 258 | inline G4int SeverityOfZeroStepping( G4int* noZeroSteps ) const;
|
|---|
| 259 | // Report on severity of error and number of zero steps,
|
|---|
| 260 | // in case Navigator is stuck and is returning zero steps.
|
|---|
| 261 | // Values: 1 (small problem), 5 (correcting),
|
|---|
| 262 | // 9 (ready to abandon), 10 (abandoned)
|
|---|
| 263 |
|
|---|
| 264 | // inline
|
|---|
| 265 | void SetSavedState();
|
|---|
| 266 | // ( fValidExitNormal, fExitNormal, fExiting, fEntering,
|
|---|
| 267 | // fBlockedPhysicalVolume, fBlockedReplicaNo, fLastStepWasZero);
|
|---|
| 268 | // inline
|
|---|
| 269 | void RestoreSavedState();
|
|---|
| 270 | // Copy aspects of the state, to enable a non-state changing
|
|---|
| 271 | // call to ComputeStep
|
|---|
| 272 |
|
|---|
| 273 | public: // with description
|
|---|
| 274 |
|
|---|
| 275 | inline G4ThreeVector GetCurrentLocalCoordinate() const;
|
|---|
| 276 | // Return the local coordinate of the point in the reference system
|
|---|
| 277 | // of its containing volume that was found by LocalGlobalPointAndSetup.
|
|---|
| 278 | // The local coordinate of the last located track.
|
|---|
| 279 |
|
|---|
| 280 | inline G4ThreeVector NetTranslation() const;
|
|---|
| 281 | inline G4RotationMatrix NetRotation() const;
|
|---|
| 282 | // Compute+return the local->global translation/rotation of current volume.
|
|---|
| 283 |
|
|---|
| 284 | protected: // with description
|
|---|
| 285 | inline G4ThreeVector ComputeLocalPoint(const G4ThreeVector& rGlobPoint) const;
|
|---|
| 286 | // Return position vector in local coordinate system, given a position
|
|---|
| 287 | // vector in world coordinate system.
|
|---|
| 288 |
|
|---|
| 289 | inline G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pVec) const;
|
|---|
| 290 | // Return the local direction of the specified vector in the reference
|
|---|
| 291 | // system of the volume that was found by LocalGlobalPointAndSetup.
|
|---|
| 292 | // The Local Coordinates of point in world coordinate system.
|
|---|
| 293 |
|
|---|
| 294 | virtual void ResetState();
|
|---|
| 295 | // Utility method to reset the navigator state machine.
|
|---|
| 296 |
|
|---|
| 297 | inline EVolume VolumeType(const G4VPhysicalVolume *pVol) const;
|
|---|
| 298 | // Characterise `type' of volume - normal/replicated/parameterised.
|
|---|
| 299 |
|
|---|
| 300 | inline EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const;
|
|---|
| 301 | // Characterise daughter of logical volume.
|
|---|
| 302 |
|
|---|
| 303 | inline G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const;
|
|---|
| 304 | // Get regular structure ID of first daughter
|
|---|
| 305 |
|
|---|
| 306 | virtual void SetupHierarchy();
|
|---|
| 307 | // Renavigate & reset hierarchy described by current history
|
|---|
| 308 | // o Reset volumes
|
|---|
| 309 | // o Recompute transforms and/or solids of replicated/parameterised
|
|---|
| 310 | // volumes.
|
|---|
| 311 |
|
|---|
| 312 | protected: // without description
|
|---|
| 313 |
|
|---|
| 314 | G4double kCarTolerance;
|
|---|
| 315 | // Geometrical tolerance for surface thickness of shapes.
|
|---|
| 316 |
|
|---|
| 317 | //
|
|---|
| 318 | // BEGIN State information
|
|---|
| 319 | //
|
|---|
| 320 |
|
|---|
| 321 | G4NavigationHistory fHistory;
|
|---|
| 322 | // Transformation and history of the current path
|
|---|
| 323 | // through the geometrical hierarchy.
|
|---|
| 324 |
|
|---|
| 325 | G4bool fEnteredDaughter;
|
|---|
| 326 | // A memory of whether in this Step a daughter volume is entered
|
|---|
| 327 | // (set in Compute & Locate).
|
|---|
| 328 | // After Compute: it expects to enter a daughter
|
|---|
| 329 | // After Locate: it has entered a daughter
|
|---|
| 330 |
|
|---|
| 331 | G4bool fExitedMother;
|
|---|
| 332 | // A similar memory whether the Step exited current "mother" volume
|
|---|
| 333 | // completely, not entering daughter.
|
|---|
| 334 |
|
|---|
| 335 | G4bool fWasLimitedByGeometry;
|
|---|
| 336 | // Set true if last Step was limited by geometry.
|
|---|
| 337 |
|
|---|
| 338 | G4ThreeVector fStepEndPoint;
|
|---|
| 339 | // Endpoint of last ComputeStep
|
|---|
| 340 | // - can be used for optimisation (eg when computing safety)
|
|---|
| 341 |
|
|---|
| 342 | G4int fVerbose;
|
|---|
| 343 | // Verbose(ness) level [if > 0, printout can occur].
|
|---|
| 344 |
|
|---|
| 345 | private:
|
|---|
| 346 |
|
|---|
| 347 | G4bool fActive;
|
|---|
| 348 | // States if the navigator is activated or not.
|
|---|
| 349 |
|
|---|
| 350 | G4bool fEntering,fExiting;
|
|---|
| 351 | // Entering/Exiting volumes blocking/setup
|
|---|
| 352 | // o If exiting
|
|---|
| 353 | // volume ptr & replica number (set & used by Locate..())
|
|---|
| 354 | // used for blocking on redescent of geometry
|
|---|
| 355 | // o If entering
|
|---|
| 356 | // volume ptr & replica number (set by ComputeStep(),used by
|
|---|
| 357 | // Locate..()) of volume for `automatic' entry
|
|---|
| 358 |
|
|---|
| 359 | G4VPhysicalVolume *fBlockedPhysicalVolume;
|
|---|
| 360 | G4int fBlockedReplicaNo;
|
|---|
| 361 |
|
|---|
| 362 | // G4VPhysicalVolume *fCandidatePhysicalVolume; // Unused
|
|---|
| 363 | // G4int fCandidateReplicaNo;
|
|---|
| 364 |
|
|---|
| 365 | G4ThreeVector fLastLocatedPointLocal;
|
|---|
| 366 | // Position of the last located point relative to its containing volume.
|
|---|
| 367 | G4bool fLocatedOutsideWorld;
|
|---|
| 368 | // Whether the last call to Locate methods left the world
|
|---|
| 369 | // G4PhysicalVolume* fLastVolumeLocated;
|
|---|
| 370 |
|
|---|
| 371 | G4bool fValidExitNormal; // Set true if have leaving volume normal
|
|---|
| 372 | G4ThreeVector fExitNormal; // Leaving volume normal, in the
|
|---|
| 373 | // volume containing the exited
|
|---|
| 374 | // volume's coordinate system
|
|---|
| 375 | G4ThreeVector fGrandMotherExitNormal; // Leaving volume normal, in its
|
|---|
| 376 | // own coordinate system
|
|---|
| 377 |
|
|---|
| 378 | // Count zero steps - as one or two can occur due to changing momentum at
|
|---|
| 379 | // a boundary or at an edge common between volumes
|
|---|
| 380 | // - several are likely a problem in the geometry
|
|---|
| 381 | // description or in the navigation
|
|---|
| 382 | //
|
|---|
| 383 | G4bool fLastStepWasZero;
|
|---|
| 384 | // Whether the last ComputeStep moved Zero. Used to check for edges.
|
|---|
| 385 |
|
|---|
| 386 | G4bool fLocatedOnEdge;
|
|---|
| 387 | // Whether the Navigator has detected an edge
|
|---|
| 388 | G4int fNumberZeroSteps;
|
|---|
| 389 | // Number of preceding moves that were Zero. Reset to 0 after finite step
|
|---|
| 390 | G4int fActionThreshold_NoZeroSteps;
|
|---|
| 391 | // After this many failed/zero steps, act (push etc)
|
|---|
| 392 | G4int fAbandonThreshold_NoZeroSteps;
|
|---|
| 393 | // After this many failed/zero steps, abandon track
|
|---|
| 394 |
|
|---|
| 395 | G4ThreeVector fPreviousSftOrigin;
|
|---|
| 396 | G4double fPreviousSafety;
|
|---|
| 397 | // Memory of last safety origin & value. Used in ComputeStep to ensure
|
|---|
| 398 | // that origin of current Step is in the same volume as the point of the
|
|---|
| 399 | // last relocation
|
|---|
| 400 |
|
|---|
| 401 | //
|
|---|
| 402 | // END State information
|
|---|
| 403 | //
|
|---|
| 404 |
|
|---|
| 405 | // Save key state information (NOT the navigation history stack)
|
|---|
| 406 | //
|
|---|
| 407 | struct G4SaveNavigatorState
|
|---|
| 408 | {
|
|---|
| 409 | G4ThreeVector sExitNormal;
|
|---|
| 410 | G4bool sValidExitNormal;
|
|---|
| 411 | G4bool sEntering, sExiting;
|
|---|
| 412 | G4VPhysicalVolume* spBlockedPhysicalVolume;
|
|---|
| 413 | G4int sBlockedReplicaNo;
|
|---|
| 414 | G4int sLastStepWasZero;
|
|---|
| 415 |
|
|---|
| 416 | // Potentially relevant
|
|---|
| 417 | //
|
|---|
| 418 | G4bool sLocatedOutsideWorld;
|
|---|
| 419 | G4ThreeVector sLastLocatedPointLocal;
|
|---|
| 420 | G4bool sEnteredDaughter, sExitedMother;
|
|---|
| 421 | G4ThreeVector sPreviousSftOrigin;
|
|---|
| 422 | G4double sPreviousSafety;
|
|---|
| 423 | } fSaveState;
|
|---|
| 424 |
|
|---|
| 425 | // Tracking Invariants
|
|---|
| 426 | //
|
|---|
| 427 | G4VPhysicalVolume *fTopPhysical;
|
|---|
| 428 | // A link to the topmost physical volume in the detector.
|
|---|
| 429 | // Must be positioned at the origin and unrotated.
|
|---|
| 430 |
|
|---|
| 431 | // Utility information
|
|---|
| 432 | //
|
|---|
| 433 | G4bool fCheck;
|
|---|
| 434 | // Check-mode flag [if true, more strict checks are performed].
|
|---|
| 435 | G4bool fPushed;
|
|---|
| 436 | // Push flag [if true, means a stuck particle has been pushed].
|
|---|
| 437 |
|
|---|
| 438 | // Helpers/Utility classes
|
|---|
| 439 | //
|
|---|
| 440 | G4NormalNavigation fnormalNav;
|
|---|
| 441 | G4VoxelNavigation fvoxelNav;
|
|---|
| 442 | G4ParameterisedNavigation fparamNav;
|
|---|
| 443 | G4ReplicaNavigation freplicaNav;
|
|---|
| 444 | G4RegularNavigation fregularNav;
|
|---|
| 445 | };
|
|---|
| 446 |
|
|---|
| 447 | #include "G4Navigator.icc"
|
|---|
| 448 |
|
|---|
| 449 | #endif
|
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 | // NOTES:
|
|---|
| 453 | //
|
|---|
| 454 | // The following methods provide detailed information when a Step has
|
|---|
| 455 | // arrived at a geometrical boundary. They distinguish between the different
|
|---|
| 456 | // causes that can result in the track leaving its current volume.
|
|---|
| 457 | //
|
|---|
| 458 | // Four cases are possible:
|
|---|
| 459 | //
|
|---|
| 460 | // 1) The particle has reached a boundary of a daughter of the current volume:
|
|---|
| 461 | // (this could cause the relocation to enter the daughter itself
|
|---|
| 462 | // or a potential granddaughter or further descendant)
|
|---|
| 463 | //
|
|---|
| 464 | // 2) The particle has reached a boundary of the current
|
|---|
| 465 | // volume, exiting into a mother (regardless the level
|
|---|
| 466 | // at which it is located in the tree):
|
|---|
| 467 | //
|
|---|
| 468 | // 3) The particle has reached a boundary of the current
|
|---|
| 469 | // volume, exiting into a volume which is not in its
|
|---|
| 470 | // parental hierarchy:
|
|---|
| 471 | //
|
|---|
| 472 | // 4) The particle is not on a boundary between volumes:
|
|---|
| 473 | // the function returns an exception, and the caller is
|
|---|
| 474 | // reccomended to compare the G4touchables associated
|
|---|
| 475 | // to the preStepPoint and postStepPoint to handle this case.
|
|---|
| 476 | //
|
|---|
| 477 | // G4bool EnteredDaughterVolume()
|
|---|
| 478 | // G4bool IsExitNormalValid()
|
|---|
| 479 | // G4ThreeVector GetLocalExitNormal()
|
|---|
| 480 | //
|
|---|
| 481 | // The expected usefulness of these methods is to allow the caller to
|
|---|
| 482 | // determine how to compute the surface normal at the volume boundary. The two
|
|---|
| 483 | // possibilities are to obtain the normal from:
|
|---|
| 484 | //
|
|---|
| 485 | // i) the solid associated with the volume of the initial point of the Step.
|
|---|
| 486 | // This is valid for cases 2 and 3.
|
|---|
| 487 | // (Note that the initial point is generally the PreStepPoint of a Step).
|
|---|
| 488 | // or
|
|---|
| 489 | //
|
|---|
| 490 | // ii) the solid of the final point, ie of the volume after the relocation.
|
|---|
| 491 | // This is valid for case 1.
|
|---|
| 492 | // (Note that the final point is generally the PreStepPoint of a Step).
|
|---|
| 493 | //
|
|---|
| 494 | // This way the caller can always get a valid normal, pointing outside
|
|---|
| 495 | // the solid for which it is computed, that can be used at his own
|
|---|
| 496 | // discretion.
|
|---|