Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4MultiNavigator.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// $Id$
28//
29//
30// class G4MultiNavigator
31//
32// Class description:
33//
34// Utility class for polling the navigators of several geometries to
35// identify the next boundary.
36
37// History:
38// - Created. John Apostolakis, November 2006
39// *********************************************************************
40
41#ifndef G4MULTINAVIGATOR_HH
42#define G4MULTINAVIGATOR_HH
43
44#include <iostream>
45
46#include "geomdefs.hh"
47#include "G4ThreeVector.hh"
48#include "G4Navigator.hh"
49
51
53
55
58
60{
61 public: // with description
62
63 friend std::ostream& operator << (std::ostream &os, const G4Navigator &n);
64
66 // Constructor - initialisers and setup.
67
69 // Destructor. No actions.
70
71 G4double ComputeStep(const G4ThreeVector &pGlobalPoint,
72 const G4ThreeVector &pDirection,
73 const G4double pCurrentProposedStepLength,
74 G4double &pNewSafety);
75 // Return the distance to the next boundary of any geometry
76
77 G4double ObtainFinalStep( G4int navigatorId,
78 G4double &pNewSafety, // for this geom
79 G4double &minStepLast,
80 ELimited &limitedStep);
81 // Get values for a single geometry
82
83 void PrepareNavigators();
84 // Find which geometries are registered for this particles, and keep info
86 const G4ThreeVector direction );
87 // Prepare Navigators and locate
88
90 const G4ThreeVector &direction,
91 const G4TouchableHistory &h);
92 // Reset the geometrical hierarchy for all geometries.
93 // Use the touchable history for the first (mass) geometry.
94 // Return the volume in the first (mass) geometry.
95 //
96 // Important Note: In order to call this the geometries MUST be closed.
97
99 const G4ThreeVector* direction=0,
100 const G4bool pRelativeSearch=true,
101 const G4bool ignoreDirection=true);
102 // Locate in all geometries.
103 // Return the volume in the first (mass) geometry
104 // Maintain vector of other volumes, to be returned separately
105 //
106 // Important Note: In order to call this the geometry MUST be closed.
107
109 // Relocate in all geometries for point that has not changed volume
110 // (ie is within safety in all geometries or is distance less that
111 // along the direction of a computed step.
112
113 G4double ComputeSafety(const G4ThreeVector &globalpoint,
114 const G4double pProposedMaxLength = DBL_MAX,
115 const G4bool keepState = false);
116 // Calculate the isotropic distance to the nearest boundary
117 // in any geometry from the specified point in the global coordinate
118 // system. The geometry must be closed.
119
121 // Returns a reference counted handle to a touchable history.
122
123 virtual G4ThreeVector GetLocalExitNormal(G4bool* obtained); // const
124 virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point,
125 G4bool* obtained); // const
126 virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point,
127 G4bool* obtained); // const
128 // Return Exit Surface Normal and validity too.
129 // Can only be called if the Navigator's last Step either
130 // - has just crossed a volume geometrical boundary and relocated, or
131 // - has arrived at a boundary in a ComputeStep
132 // It returns the Normal to the surface pointing out of the volume that
133 // was left behind and/or into the volume that was entered.
134 // Convention:x
135 // The *local* normal is in the coordinate system of the *final* volume.
136 // Restriction:
137 // Normals are not available for replica volumes (returns obtained= false)
138
139 public: // without description
140
142 {
143 if( (n>fNoActiveNavigators)||(n<0)){ n=0; }
144 return fpNavigator[n];
145 }
146
147 protected: // with description
148
149 void ResetState();
150 // Utility method to reset the navigator state machine.
151
152 void SetupHierarchy();
153 // Renavigate & reset hierarchy described by current history
154 // o Reset volumes
155 // o Recompute transforms and/or solids of replicated/parameterised
156 // volumes.
157
158 void WhichLimited(); // Flag which processes limited the step
159 void PrintLimited(); // Auxiliary, debugging printing
160 void CheckMassWorld();
161
162 private:
163
164 // STATE Information
165
166 G4int fNoActiveNavigators;
167 static const G4int fMaxNav = 8; // rename to kMaxNoNav ??
168 G4VPhysicalVolume* fLastMassWorld;
169
170 // Global state (retained during stepping for one track
171 G4Navigator* fpNavigator[fMaxNav]; // G4Navigator** fpNavigator;
172
173 // State after a step computation
174 ELimited fLimitedStep[fMaxNav];
175 G4bool fLimitTruth[fMaxNav];
176 G4double fCurrentStepSize[fMaxNav];
177 G4double fNewSafety[ fMaxNav ]; // Safety for starting point
178 G4int fNoLimitingStep; // How many geometries limited the step
179 G4int fIdNavLimiting; // Id of Navigator limiting step (if only one limits)
180
181 // Lowest values - determine step length, and safety
182 G4double fMinStep; // As reported by Navigators. Can be kInfinity
183 G4double fMinSafety;
184 G4double fTrueMinStep; // Corrected in case fMinStep >= proposed
185
186 // State after calling 'locate'
187 G4VPhysicalVolume* fLocatedVolume[fMaxNav];
188 G4ThreeVector fLastLocatedPosition;
189
190 // cache of safety information
191 G4ThreeVector fSafetyLocation; // point where ComputeSafety is called
192 G4double fMinSafety_atSafLocation; // /\ corresponding value of safety
193 G4ThreeVector fPreStepLocation; // point where last ComputeStep called
194 G4double fMinSafety_PreStepPt; // /\ corresponding value of safety
195
196 G4TransportationManager* pTransportManager; // Cache for frequent use
197};
198
199#endif
ELimited
@ kDoNot
@ kUndefLimited
@ kUnique
@ kSharedOther
@ kSharedTransport
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4Navigator * GetNavigator(G4int n) const
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
void PrepareNewTrack(const G4ThreeVector position, const G4ThreeVector direction)
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
virtual G4ThreeVector GetLocalExitNormal(G4bool *obtained)
G4TouchableHistoryHandle CreateTouchableHistoryHandle() const
friend std::ostream & operator<<(std::ostream &os, const G4Navigator &n)
#define DBL_MAX
Definition: templates.hh:83