Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ReplicaNavigation.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// G4ReplicaNavigation
27//
28// Class description:
29//
30// Utility for navigation in volumes containing a single G4PVParameterised
31// volume for which voxels for the replicated volumes have been constructed.
32// [Voxels MUST be along one axis only: NOT refined]
33
34// Author: Paul Kent (CERN), August 1996
35// --------------------------------------------------------------------
36#ifndef G4REPLICANAVIGATION_HH
37#define G4REPLICANAVIGATION_HH 1
38
40
41#include "G4Types.hh"
43#include "G4LogicalVolume.hh"
44#include "G4VPhysicalVolume.hh"
45#include "G4ThreeVector.hh"
46#include "G4BlockingList.hh"
47
48// Required for voxel handling
49//
50#include "G4SmartVoxelHeader.hh"
51
52class G4VSolid;
53
55{
56 /**
57 * @brief G4ExitNormal, a bucket to hold value of Normal (3-vector), Booleans
58 * for calculated and leave-behind or 'validConvex', and exiting side..
59 */
60
61 /** Identity of 'Side' of Replicas. Used by DistanceToOut methods. */
63
65 G4bool calculated; // Normal
66 G4bool validConvex; // Solid locally convex
68
69 public:
70
71 G4ExitNormal(const G4ThreeVector& norm = G4ThreeVector(0.,0.,0.),
72 G4bool calc = false,
73 G4bool valid= false,
74 ESide side = kNull )
75 { exitNormal= norm; calculated= calc; validConvex=valid; exitSide=side;}
76};
77
78/**
79 * @brief G4ReplicaNavigation is a utility class for navigation in volumes
80 * containing a single G4PVParameterised volume for which voxels for the
81 * replicated volumes have been constructed.
82 * @note Voxels MUST be along one axis only: NOT refined.
83 */
84
86{
87 public:
88
89 /**
90 * Constructor and default Destructor.
91 */
94
95 /**
96 * Searches positioned volumes in mother at current top level of @p history
97 * for volume containing @p globalPoint. Do not test against @p blockedVol.
98 * If a containing volume is found, push it onto navigation history state.
99 * @param[in,out] history Navigation history.
100 * @param[in,out] blockedVol Blocked volume to be ignored in queries.
101 * @param[in,out] blockedNum Copy number for blocked replica volumes.
102 * @param[in,out] globalPoint Point in global coordinates system.
103 * @param[in,out] globalDirection Pointer to global direction or null.
104 * @param[in,out] localPoint Point in local coordinates system.
105 * @returns Whether a containing volume has been found.
106 */
108 const G4VPhysicalVolume* blockedVol,
109 const G4int blockedNum,
110 const G4ThreeVector& globalPoint,
111 const G4ThreeVector* globalDirection,
112 const G4bool pLocatedOnEdge,
113 G4ThreeVector& localPoint );
114
115 /**
116 * Computes the length of a step to the next boundary.
117 * Do not test against @p pBlockedPhysical. Identify the next candidate
118 * volume (if a daughter of the current volume), and return it in:
119 * pBlockedPhysical, blockedReplicaNo.
120 * @param[in] globalPoint Global point.
121 * @param[in] globalDirection Global direction vector.
122 * @param[in] localPoint Local point.
123 * @param[in] localDirection Local direction vector.
124 * @param[in] currentProposedStepLength Current proposed step length.
125 * @param[in,out] newSafety New safety.
126 * @param[in,out] history Navigation history.
127 * @param[in,out] validExitNormal Flag to indicate whether exit normal is
128 * valid or not.
129 * @param[in,out] exitNormal Exit normal.
130 * @param[in,out] exiting Flag to indicate whether exiting a volume.
131 * @param[in,out] entering Flag to indicate whether entering a volume.
132 * @param[in,out] pBlockedPhysical Blocked physical volume that should be
133 * ignored in queries.
134 * @param[in,out] blockedReplicaNo Copy number for blocked replica volumes.
135 * @returns Length from current point to next boundary surface along
136 * @p localDirection.
137 */
138 G4double ComputeStep( const G4ThreeVector& globalPoint,
139 const G4ThreeVector& globalDirection,
140 const G4ThreeVector& localPoint,
141 const G4ThreeVector& localDirection,
142 const G4double currentProposedStepLength,
143 G4double& newSafety,
144 G4NavigationHistory& history,
145 G4bool& validExitNormal,
146 G4bool& calculatedExitNormal,
147 G4ThreeVector &exitNormal,
148 G4bool& exiting,
149 G4bool& entering,
150 G4VPhysicalVolume* (*pBlockedPhysical),
151 G4int &blockedReplicaNo );
152
153 /**
154 * Calculates the isotropic distance to the nearest boundary from the
155 * specified point in the local/global coordinate system.
156 * The localpoint utilised must be within the current volume.
157 * @param[in] globalPoint Global point.
158 * @param[in] localPoint Local point.
159 * @param[in] history Navigation history.
160 * @param[in] pProposedMaxLength Maximum step length beyond which volumes
161 * need not be checked.
162 * @returns Length from current point to closest surface.
163 */
164 G4double ComputeSafety( const G4ThreeVector& globalPoint,
165 const G4ThreeVector& localPoint,
166 const G4NavigationHistory& history,
167 const G4double pProposedMaxLength = DBL_MAX ) const;
168
169 /**
170 * Locates the specified point in the local/global coordinate system.
171 * The localpoint utilised must be within the current volume.
172 * @param[in] history Navigation history.
173 * @param[in] globalPoint Global point.
174 * @param[in] localPoint Local point.
175 * @param[in,out] exiting Flag to indicate whether exiting a volume.
176 * @param[in,out] notKnownInside Flag to indicate whether exiting replica.
177 * @returns If point is located inside the current replica volume.
178 */
180 const G4ThreeVector& globalPoint,
181 G4ThreeVector& localPoint,
182 const G4bool& exiting,
183 G4bool& notKnownInside ) const;
184
185 /**
186 * Setups transformation and transform point into local system.
187 */
188 void ComputeTransformation( const G4int replicaNo,
189 G4VPhysicalVolume* pVol,
190 G4ThreeVector& point ) const;
191
192 /**
193 * Setups transformation into local system.
194 */
195 void ComputeTransformation( const G4int replicaNo,
196 G4VPhysicalVolume* pVol ) const;
197
198 /**
199 * Computes if local point point is inside the reference volume or not.
200 * @param[in] pVol Pointer to the reference volume.
201 * @param[in] replicaNo Replica number of current volume.
202 * @param[in] localPoint Point in local coordinates system.
203 * @returns If point is inside referenced replica volume or not.
204 */
205 EInside Inside( const G4VPhysicalVolume* pVol,
206 const G4int replicaNo,
207 const G4ThreeVector& localPoint ) const;
208
209 /**
210 * Estimates the isotropic distance to exit the reference volume from
211 * the provided local point.
212 * @param[in] pVol Pointer to the reference volume.
213 * @param[in] replicaNo Replica number of current volume.
214 * @param[in] localPoint Point in local coordinates system.
215 * @returns The isotropic distance to exit.
216 */
218 const G4int replicaNo,
219 const G4ThreeVector& localPoint ) const;
220
221 /**
222 * Calculates the distance to exit the reference volume from the provided
223 * local point, given its direction.
224 * @param[in] pVol Pointer to the reference volume.
225 * @param[in] replicaNo Replica number of current volume.
226 * @param[in] localPoint Point in local coordinates system.
227 * @param[in] localDirection The local direction.
228 * @param[in,out] candidateNormal The candidate exit notmal.
229 * @returns The distance to exit.
230 */
232 const G4int replicaNo,
233 const G4ThreeVector& localPoint,
234 const G4ThreeVector& localDirection,
235 G4ExitNormal& candidateNormal ) const;
236
237 /**
238 * Verbosity control.
239 * @note If level>0 && G4VERBOSE, printout can occur.
240 */
241 inline G4int GetVerboseLevel() const;
242 inline void SetVerboseLevel(G4int level);
243
244 /**
245 * Run navigation in "check-mode", therefore using additional
246 * verifications and more strict correctness conditions.
247 * @note Is effective only with G4VERBOSE set.
248 * @param[in] mode Flag to enable/disable check-mode.
249 */
250 inline void CheckMode(G4bool mode);
251
252 private:
253
254 /**
255 * Locates voxel node based on given point.
256 * @param[in] pHead Pointer to header of nodes to look through.
257 * @param[in] localPoint Local point
258 * @param[in] blocked Flag to indicate if volume is blocked or not.
259 * @returns Pointer to the node where the given point is located.
260 */
261 inline G4int VoxelLocate( const G4SmartVoxelHeader* pHead,
262 const G4ThreeVector& localPoint,
263 const G4int blocked=-1 ) const;
264
265 /**
266 * Computes distance to exit for phi replica.
267 */
268 G4double DistanceToOutPhi( const G4ThreeVector& localPoint,
269 const G4ThreeVector& localDirection,
270 const G4double width,
271 G4ExitNormal& foundNormal ) const;
272
273 /**
274 * Computes distance to exit for radial replica.
275 */
276 G4double DistanceToOutRad( const G4ThreeVector& localPoint,
277 const G4ThreeVector& localDirection,
278 const G4double width,
279 const G4double offset,
280 const G4int replicaNo,
281 G4ExitNormal& foundNormal ) const;
282
283 /**
284 * Sets phi rotation of target volume.
285 */
286 inline void SetPhiTransformation( const G4double ang,
287 G4VPhysicalVolume* pVol = nullptr ) const;
288
289 private:
290
291 // Invariants - unaltered during navigation -------------------------------
292 // **********
293
294 /** Check mode. */
295 G4bool fCheck = false;
296
297 /** Verbosity. */
298 G4int fVerbose = 0;
299
300 /** Local cached constants. */
301 G4double kCarTolerance, kRadTolerance, kAngTolerance,
302 halfkCarTolerance, halfkRadTolerance, halfkAngTolerance,
303 fMinStep;
304};
305
306#include "G4ReplicaNavigation.icc"
307
308#endif
G4ThreadLocal T * G4GeomSplitter< T >::offset
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4NavigationHistory is a class responsible for the maintenance of the history of the path taken throu...
G4double DistanceToOut(const G4VPhysicalVolume *pVol, const G4int replicaNo, const G4ThreeVector &localPoint) const
~G4ReplicaNavigation()=default
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4bool &calculatedExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
G4double ComputeSafety(const G4ThreeVector &globalPoint, const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX) const
void ComputeTransformation(const G4int replicaNo, G4VPhysicalVolume *pVol, G4ThreeVector &point) const
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
void CheckMode(G4bool mode)
EInside Inside(const G4VPhysicalVolume *pVol, const G4int replicaNo, const G4ThreeVector &localPoint) const
G4int GetVerboseLevel() const
void SetVerboseLevel(G4int level)
EInside BackLocate(G4NavigationHistory &history, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint, const G4bool &exiting, G4bool &notKnownInside) const
G4SmartVoxelHeader represents a set of voxels, created by a single axis of virtual division....
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
Definition G4VSolid.hh:80
EInside
Definition geomdefs.hh:67
ESide
G4ExitNormal, a bucket to hold value of Normal (3-vector), Booleans for calculated and leave-behind o...
G4ThreeVector exitNormal
G4ExitNormal(const G4ThreeVector &norm=G4ThreeVector(0., 0., 0.), G4bool calc=false, G4bool valid=false, ESide side=kNull)
#define DBL_MAX
Definition templates.hh:62