Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SafetyHelper.hh
Go to the documentation of this file.
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// G4SafetyHelper
27//
28// Class description:
29//
30// This class is a helper for physics processes which require
31// knowledge of the safety, and the step size for the 'mass' geometry.
32
33// Author: John Apostolakis (CERN), 5 July 2006
34// --------------------------------------------------------------------
35#ifndef G4SAFETYHELPER_HH
36#define G4SAFETYHELPER_HH 1
37
38#include <vector>
39
40#include "G4Types.hh"
41#include "G4ThreeVector.hh"
42#include "G4Navigator.hh"
43
44class G4PathFinder;
45
46/**
47 * @brief G4SafetyHelper is a helper class for physics processes which require
48 * knowledge of the safety, and the step size for the 'mass' geometry.
49 */
50
52{
53 public:
54
55 /**
56 * Constructor and default Destructor.
57 */
59 ~G4SafetyHelper() = default;
60
61 /**
62 * Computes the distance in the mass geometry.
63 * @param[in] position Point in global coordinates.
64 * @param[in] direction Direction.
65 * @param[in] currentMaxStep Proposed step length to nearest boundary.
66 * @param[in,out] newSafety New safety.
67 * @returns The linear step for mass geometry.
68 */
70 const G4ThreeVector& direction,
71 const G4double currentMaxStep,
72 G4double& newSafety );
73
74 /**
75 * Computes the safety distance for all geometries.
76 * @param[in] pGlobalPoint Point in global coordinates.
77 * @param[in] maxRadius Radius of interest (e.g. maximum displacement).
78 * Giving this, one can reduce the average computational
79 * cost. If not provided, the real isotropic safety is computed.
80 * @returns The safety distance for all geometries.
81 */
82 G4double ComputeSafety( const G4ThreeVector& pGlobalPoint,
83 G4double maxRadius = DBL_MAX );
84
85 /**
86 * Locates the point for all geometries.
87 * @param[in] pGlobalPoint Point in global coordinates.
88 * @param[in] direction Direction.
89 */
90 void Locate(const G4ThreeVector& pGlobalPoint,
91 const G4ThreeVector& direction);
92
93 /**
94 * Relocates the point in the volume of interest.
95 * @param[in] pGlobalPoint Point in global coordinates.
96 */
97 void ReLocateWithinVolume(const G4ThreeVector& pGlobalPoint );
98
99 /**
100 * Enables navigation in parallel geometries.
101 * @param[in] parallel Flag to have parallel worlds considered.
102 * Alternative is to use single (mass) navigator directly.
103 */
104 inline void EnableParallelNavigation(G4bool parallel);
105
106 /**
107 * Checks for new navigator for tracking, and reinitialises pointer.
108 */
109 void InitialiseNavigator();
110
111 /**
112 * Verbosity control.
113 * @param[in] lev The new verbosity level to enable.
114 * @returns The old verbosity level.
115 */
117
118 /**
119 * Retrieves the world volume of the mass geometry.
120 * @returns The pointer to the mass geometry world volume.
121 */
123
124 /**
125 * Sets the safety value for the given position.
126 * @param[in] val The safety value.
127 * @param[in] pos The position.
128 */
129 inline void SetCurrentSafety(G4double val, const G4ThreeVector& pos);
130
131 /**
132 * Initialises all data and navigator.
133 */
134 void InitialiseHelper();
135
136 private:
137
138 G4PathFinder* fpPathFinder = nullptr;
139 G4Navigator* fpMassNavigator = nullptr;
140
141 /** Flag whether to use PathFinder or single (mass) navigator directly.
142 By default, one geometry only. */
143 G4bool fUseParallelGeometries = false;
144
145 /** Flag of first call. */
146 G4bool fFirstCall = true;
147
148 /** Whether to print warning in case of move outside safety. */
149 G4int fVerbose = 0;
150
151 // State used during tracking -- for optimisation -------------------------
152
153 G4ThreeVector fLastSafetyPosition;
154 G4double fLastSafety = 0.0;
155
156 // End State (tracking) ---------------------------------------------------
157};
158
159// --------------------------------------------------------------------
160// Inline definitions
161// --------------------------------------------------------------------
162
163#include "G4SafetyHelper.icc"
164
165#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4Navigator is a class for use by the tracking management, able to obtain/calculate dynamic tracking ...
G4PathFinder directs the lock-stepped propagation of a track in the 'mass' and other parallel geometr...
G4double ComputeSafety(const G4ThreeVector &pGlobalPoint, G4double maxRadius=DBL_MAX)
G4double CheckNextStep(const G4ThreeVector &position, const G4ThreeVector &direction, const G4double currentMaxStep, G4double &newSafety)
void InitialiseNavigator()
G4int SetVerboseLevel(G4int lev)
void Locate(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &direction)
void ReLocateWithinVolume(const G4ThreeVector &pGlobalPoint)
G4VPhysicalVolume * GetWorldVolume()
void EnableParallelNavigation(G4bool parallel)
void SetCurrentSafety(G4double val, const G4ThreeVector &pos)
~G4SafetyHelper()=default
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
#define DBL_MAX
Definition templates.hh:62