Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:14:04

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 // G4RegularNavigation
0027 //
0028 // Class description:
0029 //
0030 // Utility for fast navigation in volumes containing a regular
0031 // parameterisation. If two contiguous voxels have the same material,
0032 // navigation does not stop at the surface.
0033 
0034 // Author: Pedro Arce (CIEMAT), May 2007
0035 // --------------------------------------------------------------------
0036 #ifndef G4RegularNavigation_HH
0037 #define G4RegularNavigation_HH 1
0038 
0039 #include <vector>
0040 
0041 #include "G4Types.hh"
0042 #include "G4ThreeVector.hh"
0043 #include "G4VNavigation.hh"
0044 
0045 class G4NormalNavigation;
0046 class G4VPhysicalVolume;
0047 class G4Navigator;
0048 class G4NavigationHistory;
0049 
0050 /**
0051  * @brief G4RegularNavigation is a concrete utility class for fast navigation
0052  * in volumes containing a regular parameterisation. If two contiguous voxels
0053  * have the same material, navigation does not stop at the surface.
0054  */
0055 
0056 class G4RegularNavigation : public G4VNavigation
0057 {
0058   public:
0059   
0060     /**
0061      * Constructor and Destructor.
0062      */
0063     G4RegularNavigation();
0064    ~G4RegularNavigation() override;
0065   
0066     /**
0067      * Locates a point using its position with respect to regular
0068      * parameterisation container volume.
0069      *  @param[in,out] history Navigation history.
0070      *  @param[in,out] blockedVol Blocked volume to be ignored in queries.
0071      *  @param[in,out] blockedNum Copy number for blocked replica volumes.
0072      *  @param[in,out] globalPoint Point in global coordinates system.
0073      *  @param[in,out] globalDirection Global direction vector.
0074      *  @param[in,out] localPoint Point in local coordinates system.
0075      *  @returns Whether a containing volume has been found.
0076      */
0077     G4bool LevelLocate(      G4NavigationHistory& history,
0078                        const G4VPhysicalVolume* blockedVol,
0079                        const G4int blockedNum,
0080                        const G4ThreeVector& globalPoint,
0081                        const G4ThreeVector* globalDirection,
0082                        const G4bool pLocatedOnEdge, 
0083                              G4ThreeVector& localPoint ) final;
0084 
0085     /**
0086      * Method never called because to be called the daughter has to be a
0087      * 'regular' volume. This would only happen if the track is in the
0088      * mother of voxels volume. But the voxels fill completely their mother,
0089      * so when a track enters the mother it automatically enters a voxel.
0090      */
0091     G4double ComputeStep( const G4ThreeVector& localPoint,
0092                           const G4ThreeVector& localDirection,
0093                           const G4double currentProposedStepLength,
0094                                 G4double& newSafety,
0095                                 G4NavigationHistory& history,
0096                                 G4bool& validExitNormal,
0097                                 G4ThreeVector& exitNormal,
0098                                 G4bool& exiting,
0099                                 G4bool& entering,
0100                                 G4VPhysicalVolume *(*pBlockedPhysical),
0101                                 G4int& blockedReplicaNo ) final;
0102   
0103     /**
0104      * Computes the step skipping surfaces when they separate voxels with
0105      * equal materials. Loops to voxels until a different material is found:
0106      * invokes G4NormalNavigation::ComputeStep() in each voxel and moves the
0107      * point to the next voxel.
0108      *  @param[in] localPoint Local point.
0109      *  @param[in] localDirection Local direction vector.
0110      *  @param[in] currentProposedStepLength Current proposed step length.
0111      *  @param[in,out] newSafety New safety.
0112      *  @param[in,out] history Navigation history.
0113      *  @param[in,out] validExitNormal Flag to indicate whether exit normal is
0114      *                 valid or not.
0115      *  @param[in,out] exitNormal Exit normal.
0116      *  @param[in,out] exiting Flag to indicate whether exiting a volume.
0117      *  @param[in,out] entering Flag to indicate whether entering a volume.
0118      *  @param[in,out] pBlockedPhysical Blocked physical volume that should be
0119      *                 ignored in queries.
0120      *  @param[in,out] blockedReplicaNo Copy number for blocked replica volumes.
0121      *  @param[in] pCurrentPhysical Pointer to current volume.
0122      *  @returns Length from current point to next boundary surface along
0123      *           the direction.
0124      */
0125     G4double ComputeStepSkippingEqualMaterials( 
0126                                 G4ThreeVector& localPoint,
0127                           const G4ThreeVector& localDirection,
0128                           const G4double currentProposedStepLength,
0129                                 G4double& newSafety,
0130                                 G4NavigationHistory& history,
0131                                 G4bool& validExitNormal,
0132                                 G4ThreeVector& exitNormal,
0133                                 G4bool& exiting,
0134                                 G4bool& entering,
0135                                 G4VPhysicalVolume *(*pBlockedPhysical),
0136                                 G4int& blockedReplicaNo,
0137                                 G4VPhysicalVolume* pCurrentPhysical);
0138 
0139     /**
0140      * Method never called because to be called the daughter has to be a
0141      * 'regular' volume. This would only happen if the track is in the
0142      * mother of voxels volume. But the voxels fill completely their mother,
0143      * so when a track enters the mother it automatically enters a voxel.
0144      */
0145     G4double ComputeSafety( const G4ThreeVector& localPoint,
0146                             const G4NavigationHistory& history,
0147                             const G4double pProposedMaxLength = DBL_MAX ) final;
0148 
0149     /**
0150      * Setter for normal navigation.
0151      */
0152     void SetNormalNavigation( G4NormalNavigation* fnormnav );
0153 
0154   private:
0155 
0156     /** Cached pointer to normal navigation. */
0157     G4NormalNavigation* fnormalNav = nullptr;
0158 
0159     /** Surface tolerance. */
0160     G4double kCarTolerance;
0161 
0162     /** Cached minimum step. */
0163     G4double fMinStep;
0164  
0165     /** Whether the last ComputeStep moved Zero. Used to check for edges. */
0166     G4bool fLastStepWasZero = false;
0167 
0168     /** Number of preceding moves that were 0. Reset to 0 after finite step. */
0169     G4int fNumberZeroSteps = 0;
0170 
0171     /** After this many failed/zero steps, act (push etc). */
0172     G4int fActionThreshold_NoZeroSteps = 2;  
0173 
0174     /** After this many failed/zero steps, abandon track. */
0175     G4int fAbandonThreshold_NoZeroSteps = 25; 
0176 
0177     /** Maximum number of steps a track can travel skipping voxels
0178         (if there are more, track is assumed to be stuck and it is killed). */
0179     G4int fNoStepsAllowed = 10000;
0180 };
0181 
0182 #endif