Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SafetyCalculator.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// G4SafetyCalculator
27//
28// Class description:
29//
30// A class that provides an estimate of the isotropic safety, the minimum
31// distance from a global point to the nearest boundary of the current volume
32// or the nearest daughter volumes.
33// This estimate can be an underestimate, either because a solid provides an
34// underestimate (for speed) or in order to avoid substantial additional
35// computations.
36// Obtains from the navigator the current transformation history.
37
38// Author: John Apostolakis (CERN), February 2023
39// --------------------------------------------------------------------
40#ifndef G4SafetyCalculator_HH
41#define G4SafetyCalculator_HH 1
42
43#include "geomdefs.hh"
44
45#include "G4ThreeVector.hh"
46#include "G4AffineTransform.hh"
47#include "G4RotationMatrix.hh"
48
49#include "G4LogicalVolume.hh" // Used in inline methods
51
53#include "G4NormalNavigation.hh"
54#include "G4VoxelNavigation.hh"
59
60#include "G4VoxelSafety.hh"
61
62#include <iostream>
63
65
66/**
67 * @brief G4SafetyCalculator is a class that provides an estimate of the
68 * isotropic safety (the minimum distance from a global point to the nearest
69 * boundary of the current volume or the nearest daughter volumes).
70 */
71
73{
74 public:
75
76 /**
77 * Constructor, initialisers and setup.
78 */
79 G4SafetyCalculator( const G4Navigator& navigator,
80 const G4NavigationHistory& navHistory );
81
82 /**
83 * Copy constructor & assignment operator not allowed.
84 */
87
88 /**
89 * Destructor. No actions.
90 */
92
93 /**
94 * Calculates the isotropic distance to the nearest boundary from the
95 * specified point in the global coordinate system.
96 * @param[in] globalPoint The point in global coordinates; it *must* be
97 * located exactly within the current volume (it also must
98 * *not* be in a daughter volume.
99 * @param[in] physicalVolume Current volume.
100 * @param[in] pProposedMaxLength The calculation will not look beyond
101 * the proposed maximum length to avoid extra volume safety
102 * calculations.
103 * @param[in] verbose Flag to enable verbosity (default is false).
104 * @returns An underestimate of the safety distance (and typically will be
105 * if complex volumes are involved.
106 */
108 G4VPhysicalVolume* physicalVolume,
109 const G4double pProposedMaxLength = DBL_MAX,
110 G4bool verbose = false );
111
112 /**
113 * Accessor & modifier for custom external navigation.
114 */
117
118 /**
119 * Compares estimates of the safety, and reports if found difference(s).
120 */
121 void CompareSafetyValues( G4double oldSafety,
122 G4double newValue,
123 G4VPhysicalVolume* motherPhysical,
124 const G4ThreeVector &globalPoint,
125 G4bool keepState,
126 G4double maxLength,
127 G4bool enteredVolume,
128 G4bool exitedVolume );
129
130 protected:
131
132 /**
133 * Prepare state of sub-navigators by informing them of current point.
134 * @param[in] pointLocal Point in local coordinates.
135 * @param[in] motherPhysical Pointer to current volume where to relocate
136 * in case an external custom navigator is used.
137 */
138 void QuickLocateWithinVolume(const G4ThreeVector& pointLocal,
139 G4VPhysicalVolume* motherPhysical);
140
141 /**
142 * Computes point in local coordinates system, given a position
143 * vector in world coordinate system.
144 * @param[in] rGlobPoint Point in global coordinates.
145 * @returns The point in local coordinates system.
146 */
147 inline G4ThreeVector ComputeLocalPoint(const G4ThreeVector& rGlobPoint) const;
148
149 /**
150 * Computes the local direction of the specified vector in the reference
151 * system of the volume that was found by LocateGlobalPointAndSetup().
152 * @param[in] pVec Vector in global coordinates.
153 * @returns The local direction of the specified vector in global
154 * coordinates.
155 */
157
158 /**
159 * Characterises the daughter of logical volume.
160 */
162
163 /**
164 * Gets regular structure ID of first daughter.
165 */
167
168 private:
169
170 // BEGIN -- Tracking Invariants part 1 ------------------------------------
171
172 /** Associated navigator. Needed for optimisation. */
173 const G4Navigator& fNavigator;
174
175 /** Associated navigator's navigation history. Transformation and history
176 of the current path through the geometrical hierarchy. */
177 const G4NavigationHistory& fNavHistory;
178
179 // END -- Tracking Invariants part 1 ------------------------------------
180
181 /** Cached tolerance. */
182 G4double fkCarTolerance;
183
184 // BEGIN State information ------------------------------------------------
185
186 /** Previous safety origin. */
187 G4ThreeVector fPreviousSftOrigin;
188
189 /** Memory of last safety origin & value. Used in ComputeStep() to ensure
190 that origin of current Step is in the same volume as the point of the
191 last relocation. */
192 G4double fPreviousSafety = 0.0;
193
194 /** Helpers/Utility classes - their state can change. */
195 G4NormalNavigation fnormalNav;
196 G4VoxelNavigation fvoxelNav;
198 G4ReplicaNavigation freplicaNav;
199 G4RegularNavigation fregularNav;
200 G4VExternalNavigation* fpExternalNav = nullptr;
201 G4VoxelSafety fVoxelSafety;
202};
203
204// Auxiliary inline methods -- copied from G4Navigator
205//
206#include "G4SafetyCalculator.icc"
207
208#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4LogicalVolume represents a leaf node or unpositioned subtree in the geometry hierarchy....
G4NavigationHistory is a class responsible for the maintenance of the history of the path taken throu...
G4Navigator is a class for use by the tracking management, able to obtain/calculate dynamic tracking ...
G4NormalNavigation is a concrete utility class for navigation in volumes containing only G4PVPlacemen...
G4ParameterisedNavigation is a concrete utility class for navigation in volumes containing a single G...
G4RegularNavigation is a concrete utility class for fast navigation in volumes containing a regular p...
G4ReplicaNavigation is a utility class for navigation in volumes containing a single G4PVParameterise...
void SetExternalNavigation(G4VExternalNavigation *externalNav)
G4VExternalNavigation * GetExternalNavigation() const
G4SafetyCalculator & operator=(const G4SafetyCalculator &)=delete
G4SafetyCalculator(const G4Navigator &navigator, const G4NavigationHistory &navHistory)
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLv) const
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
void QuickLocateWithinVolume(const G4ThreeVector &pointLocal, G4VPhysicalVolume *motherPhysical)
void CompareSafetyValues(G4double oldSafety, G4double newValue, G4VPhysicalVolume *motherPhysical, const G4ThreeVector &globalPoint, G4bool keepState, G4double maxLength, G4bool enteredVolume, G4bool exitedVolume)
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &rGlobPoint) const
~G4SafetyCalculator()=default
G4double SafetyInCurrentVolume(const G4ThreeVector &globalpoint, G4VPhysicalVolume *physicalVolume, const G4double pProposedMaxLength=DBL_MAX, G4bool verbose=false)
G4SafetyCalculator(const G4SafetyCalculator &)=delete
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
G4VExternalNavigation is a pure virtual class to be specialised by the user for tracking with an exte...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VoxelNavigation is a concrete utility class for navigation in volumes containing only G4PVPlacement...
G4VoxelSafety is an utility class for the handling isotropic safety in volumes containing only G4PVPl...
EVolume
Definition geomdefs.hh:83
#define DBL_MAX
Definition templates.hh:62