Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 08:57:12

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 // G4SafetyHelper
0027 //
0028 // Class description:
0029 //
0030 // This class is a helper for physics processes which require 
0031 // knowledge of the safety, and the step size for the 'mass' geometry.
0032 
0033 // Author: John Apostolakis (CERN), 5 July 2006
0034 // --------------------------------------------------------------------
0035 #ifndef G4SAFETYHELPER_HH
0036 #define G4SAFETYHELPER_HH 1
0037 
0038 #include <vector>
0039 
0040 #include "G4Types.hh"
0041 #include "G4ThreeVector.hh"
0042 #include "G4Navigator.hh"
0043 
0044 class G4PathFinder;
0045 
0046 /**
0047  * @brief G4SafetyHelper is a helper class for physics processes which require 
0048  * knowledge of the safety, and the step size for the 'mass' geometry.
0049  */
0050 
0051 class G4SafetyHelper
0052 {
0053   public:
0054 
0055     /**
0056      * Constructor and default Destructor.
0057      */
0058     G4SafetyHelper(); 
0059    ~G4SafetyHelper() = default;
0060 
0061     /**
0062      * Computes the distance in the mass geometry.
0063      *  @param[in] position Point in global coordinates.
0064      *  @param[in] direction Direction.
0065      *  @param[in] currentMaxStep Proposed step length to nearest boundary.
0066      *  @param[in,out] newSafety New safety.
0067      *  @returns The linear step for mass geometry.
0068      */
0069     G4double CheckNextStep( const G4ThreeVector& position, 
0070                             const G4ThreeVector& direction,
0071                             const G4double currentMaxStep,
0072                                   G4double& newSafety );
0073 
0074     /**
0075      * Computes the safety distance for all geometries.
0076      *  @param[in] pGlobalPoint Point in global coordinates.
0077      *  @param[in] maxRadius Radius of interest (e.g. maximum displacement).
0078      *             Giving this, one can reduce the average computational
0079      *             cost. If not provided, the real isotropic safety is computed.
0080      *  @returns The safety distance for all geometries.
0081      */
0082     G4double ComputeSafety( const G4ThreeVector& pGlobalPoint,
0083                             G4double maxRadius = DBL_MAX );
0084 
0085     /**
0086      * Locates the point for all geometries.
0087      *  @param[in] pGlobalPoint Point in global coordinates.
0088      *  @param[in] direction Direction.
0089      */
0090     void Locate(const G4ThreeVector& pGlobalPoint,
0091                 const G4ThreeVector& direction);
0092 
0093     /**
0094      * Relocates the point in the volume of interest.
0095      *  @param[in] pGlobalPoint Point in global coordinates.
0096      */
0097     void ReLocateWithinVolume(const G4ThreeVector& pGlobalPoint );
0098 
0099     /**
0100      * Enables navigation in parallel geometries.
0101      *  @param[in] parallel Flag to have parallel worlds considered.
0102      *             Alternative is to use single (mass) navigator directly.
0103      */
0104     inline void EnableParallelNavigation(G4bool parallel);
0105 
0106     /**
0107      * Checks for new navigator for tracking, and reinitialises pointer.
0108      */
0109     void InitialiseNavigator();
0110 
0111     /**
0112      * Verbosity control.
0113      *  @param[in] lev The new verbosity level to enable.
0114      *  @returns The old verbosity level.
0115      */
0116     inline G4int SetVerboseLevel( G4int lev );
0117 
0118     /**
0119      * Retrieves the world volume of the mass geometry.
0120      *  @returns The pointer to the mass geometry world volume.
0121      */
0122     inline G4VPhysicalVolume* GetWorldVolume();
0123 
0124     /**
0125      * Sets the safety value for the given position.
0126      *  @param[in] val The safety value.
0127      *  @param[in] pos The position.
0128      */
0129     inline void SetCurrentSafety(G4double val, const G4ThreeVector& pos);
0130 
0131     /**
0132      * Initialises all data and navigator.
0133      */
0134     void InitialiseHelper();
0135 
0136   private:
0137 
0138     G4PathFinder* fpPathFinder = nullptr;
0139     G4Navigator* fpMassNavigator = nullptr;
0140 
0141     /** Flag whether to use PathFinder or single (mass) navigator directly.
0142         By default, one geometry only. */
0143     G4bool fUseParallelGeometries = false; 
0144 
0145     /** Flag of first call. */
0146     G4bool fFirstCall = true;
0147 
0148     /** Whether to print warning in case of move outside safety. */
0149     G4int fVerbose = 0; 
0150 
0151     // State used during tracking -- for optimisation -------------------------
0152 
0153     G4ThreeVector fLastSafetyPosition;
0154     G4double fLastSafety = 0.0;
0155 
0156     // End State (tracking) ---------------------------------------------------
0157 };
0158 
0159 // --------------------------------------------------------------------
0160 // Inline definitions
0161 // --------------------------------------------------------------------
0162 
0163 #include "G4SafetyHelper.icc"
0164 
0165 #endif