Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ITMultiNavigator.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//
27//
28//
29// class G4ITMultiNavigator
30//
31// Class description:
32//
33// Utility class for polling the navigators of several geometries to
34// identify the next boundary.
35
36/// \brief { Class description:
37///
38/// G4ITMultiNavigator is a duplicate version of G4MultiNavigator
39///
40/// Utility class for polling the navigators of several geometries to
41/// identify the next boundary.
42///
43/// }
44
45// History:
46// - Created. John Apostolakis, November 2006
47// *********************************************************************
48
49#ifndef G4ITMULTINAVIGATOR_HH
50#define G4ITMULTINAVIGATOR_HH
51
52#include <iostream>
53
54#include "geomdefs.hh"
55#include "G4ThreeVector.hh"
56#include "G4ITNavigator.hh"
57
58#include "G4TouchableHandle.hh"
59
61#include "G4TrackState.hh"
62#include "G4MultiNavigator.hh"
63
77
79
80// Global state (retained during stepping for one track
81template<>
82 class G4TrackState<G4ITMultiNavigator> : public G4TrackState<G4ITNavigator>
83 {
84 public:
85 ~G4TrackState() override
86 = default;
87
89 {
90 G4ThreeVector Big3Vector(kInfinity, kInfinity, kInfinity);
91 fLastLocatedPosition = Big3Vector;
92 fSafetyLocation = Big3Vector;
93 fPreStepLocation = Big3Vector;
94
97 fMinSafety = -kInfinity;
98 fTrueMinStep = fMinStep = -kInfinity;
99
100 for (G4int num = 0; num < G4ITNavigator::fMaxNav; ++num)
101 {
102 fLimitTruth[num] = false;
104 fCurrentStepSize[num] = fNewSafety[num] = -1.0;
105 fLocatedVolume[num] = nullptr;
106 }
107
108 fNoLimitingStep = -1; // How many geometries limited the step
109 fIdNavLimiting = -1; // Id of Navigator limiting step (if only one limits)
110 fWasLimitedByGeometry = false;
111 }
112 ;
113
114 protected:
115 friend class G4ITMultiNavigator;
116 // State after a step computation
117 ELimited fLimitedStep[G4ITNavigator::fMaxNav];
118 G4bool fLimitTruth[G4ITNavigator::fMaxNav];
119 G4double fCurrentStepSize[G4ITNavigator::fMaxNav];
120 G4double fNewSafety[G4ITNavigator::fMaxNav]; // Safety for starting point
121 G4int fNoLimitingStep; // How many geometries limited the step
122 G4int fIdNavLimiting; // Id of Navigator limiting step (if only one limits)
123
125
126 // Lowest values - determine step length, and safety
127 G4double fMinStep; // As reported by Navigators. Can be kInfinity
129 G4double fTrueMinStep; // Corrected in case fMinStep >= proposed
130
131 // State after calling 'locate'
132 G4VPhysicalVolume* fLocatedVolume[G4ITNavigator::fMaxNav];
134
135 // cache of safety information
136 G4ThreeVector fSafetyLocation; // point where ComputeSafety is called
137 G4double fMinSafety_atSafLocation; // /\ corresponding value of safety
138 G4ThreeVector fPreStepLocation; // point where last ComputeStep called
139 G4double fMinSafety_PreStepPt; // /\ corresponding value of safety
140 };
141
142class G4ITMultiNavigator : public G4ITNavigator,
143 public G4TrackStateDependent<G4ITMultiNavigator>
144{
145public:
146 // with description
147
148 friend std::ostream& operator <<(std::ostream &os, const G4ITNavigator &n);
149
151 // Constructor - initialisers and setup.
152
154 // Destructor. No actions.
155
156 G4double ComputeStep(const G4ThreeVector &pGlobalPoint,
157 const G4ThreeVector &pDirection,
158 const G4double pCurrentProposedStepLength,
159 G4double &pNewSafety) override;
160 // Return the distance to the next boundary of any geometry
161
162 G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, // for this geom
163 G4double &minStepLast,
164 ELimited &limitedStep);
165 // Get values for a single geometry
166
167 void PrepareNavigators();
168 // Find which geometries are registered for this particles, and keep info
170 const G4ThreeVector direction);
171 // Prepare Navigators and locate
172
174 const G4ThreeVector &direction,
175 const G4TouchableHistory &h) override;
176 // Reset the geometrical hierarchy for all geometries.
177 // Use the touchable history for the first (mass) geometry.
178 // Return the volume in the first (mass) geometry.
179 //
180 // Important Note: In order to call this the geometries MUST be closed.
181
183 const G4ThreeVector* direction =
184 nullptr,
185 const G4bool pRelativeSearch =
186 true,
187 const G4bool ignoreDirection =
188 true) override;
189 // Locate in all geometries.
190 // Return the volume in the first (mass) geometry
191 // Maintain vector of other volumes, to be returned separately
192 //
193 // Important Note: In order to call this the geometry MUST be closed.
194
196 // Relocate in all geometries for point that has not changed volume
197 // (ie is within safety in all geometries or is distance less that
198 // along the direction of a computed step.
199
200 G4double ComputeSafety(const G4ThreeVector &globalpoint,
201 const G4double pProposedMaxLength = DBL_MAX,
202 const G4bool keepState = false) override;
203 // Calculate the isotropic distance to the nearest boundary
204 // in any geometry from the specified point in the global coordinate
205 // system. The geometry must be closed.
206
208 // Returns a reference counted handle to a touchable history.
209
210 G4ThreeVector GetLocalExitNormal(G4bool* obtained) override;// const
212 G4bool* obtained) override;// const
213 G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point,
214 G4bool* obtained) override;// const
215 // Return Exit Surface Normal and validity too.
216 // Can only be called if the Navigator's last Step either
217 // - has just crossed a volume geometrical boundary and relocated, or
218 // - has arrived at a boundary in a ComputeStep
219 // It returns the Normal to the surface pointing out of the volume that
220 // was left behind and/or into the volume that was entered.
221 // Convention:x
222 // The *local* normal is in the coordinate system of the *final* volume.
223 // Restriction:
224 // Normals are not available for replica volumes (returns obtained= false)
225
226public:// without description
227
228 G4ITNavigator* GetNavigator(G4int n) const
229 {
230 if( (n>fNoActiveNavigators)||(n<0))
231 { n=0;}
232 return fpNavigator[n];
233 }
234
235protected: // with description
236
237 void ResetState() override;
238 // Utility method to reset the navigator state machine.
239
240 void SetupHierarchy() override;
241 // Renavigate & reset hierarchy described by current history
242 // o Reset volumes
243 // o Recompute transforms and/or solids of replicated/parameterised
244 // volumes.
245
246 void WhichLimited();// Flag which processes limited the step
247 void PrintLimited();// Auxiliary, debugging printing
248 void CheckMassWorld();
249
250private:
251
252 G4int fNoActiveNavigators;
253 G4VPhysicalVolume* fLastMassWorld{nullptr};
254
255 G4ITNavigator* fpNavigator[fMaxNav];// G4ITNavigator** fpNavigator;
256
257 G4ITTransportationManager* pTransportManager;// Cache for frequent use
258};
259
260#endif
#define fMinStep
#define fLocatedVolume
#define fWasLimitedByGeometry
#define fMinSafety
#define fTrueMinStep
#define fLimitTruth
#define fIdNavLimiting
#define fNoLimitingStep
#define fMinSafety_atSafLocation
#define fNewSafety
#define fLastLocatedPosition
#define fPreStepLocation
#define fCurrentStepSize
#define fLimitedStep
#define fSafetyLocation
#define fMinSafety_PreStepPt
@ kUndefLimited
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true) override
friend std::ostream & operator<<(std::ostream &os, const G4ITNavigator &n)
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h) override
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety) override
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false) override
G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point, G4bool *obtained) override
void ResetState() override
void PrepareNewTrack(const G4ThreeVector position, const G4ThreeVector direction)
G4ITNavigator * GetNavigator(G4int n) const
G4TouchableHandle CreateTouchableHistoryHandle() const override
G4ThreeVector GetLocalExitNormal(G4bool *obtained) override
void SetupHierarchy() override
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point, G4bool *obtained) override
void LocateGlobalPointWithinVolume(const G4ThreeVector &position) override
~G4ITMultiNavigator() override
{ Class description:
#define DBL_MAX
Definition templates.hh:62