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: G4MultiNavigator.hh,v 1.5 2008/10/24 14:00:03 gcosmo Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-cand-01 $ |
---|
29 | // |
---|
30 | // |
---|
31 | // class G4MultiNavigator |
---|
32 | // |
---|
33 | // Class description: |
---|
34 | // |
---|
35 | // Utility class for polling the navigators of several geometries to |
---|
36 | // identify the next boundary. |
---|
37 | |
---|
38 | // History: |
---|
39 | // - Created. John Apostolakis, November 2006 |
---|
40 | // ********************************************************************* |
---|
41 | |
---|
42 | #ifndef G4MULTINAVIGATOR_HH |
---|
43 | #define G4MULTINAVIGATOR_HH |
---|
44 | |
---|
45 | #include <iostream> |
---|
46 | |
---|
47 | #include "geomdefs.hh" |
---|
48 | #include "G4ThreeVector.hh" |
---|
49 | #include "G4Navigator.hh" |
---|
50 | |
---|
51 | #include "G4TouchableHistoryHandle.hh" |
---|
52 | |
---|
53 | #include "G4NavigationHistory.hh" |
---|
54 | |
---|
55 | enum ELimited { kDoNot,kUnique,kSharedTransport,kSharedOther,kUndefLimited }; |
---|
56 | |
---|
57 | class G4TransportationManager; |
---|
58 | class G4VPhysicalVolume; |
---|
59 | |
---|
60 | class G4MultiNavigator : public G4Navigator |
---|
61 | { |
---|
62 | public: // with description |
---|
63 | |
---|
64 | friend std::ostream& operator << (std::ostream &os, const G4Navigator &n); |
---|
65 | |
---|
66 | G4MultiNavigator(); |
---|
67 | // Constructor - initialisers and setup. |
---|
68 | |
---|
69 | ~G4MultiNavigator(); |
---|
70 | // Destructor. No actions. |
---|
71 | |
---|
72 | G4double ComputeStep(const G4ThreeVector &pGlobalPoint, |
---|
73 | const G4ThreeVector &pDirection, |
---|
74 | const G4double pCurrentProposedStepLength, |
---|
75 | G4double &pNewSafety); |
---|
76 | // Return the distance to the next boundary of any geometry |
---|
77 | |
---|
78 | G4double ObtainFinalStep( G4int navigatorId, |
---|
79 | G4double &pNewSafety, // for this geom |
---|
80 | G4double &minStepLast, |
---|
81 | ELimited &limitedStep); |
---|
82 | // Get values for a single geometry |
---|
83 | |
---|
84 | void PrepareNavigators(); |
---|
85 | // Find which geometries are registered for this particles, and keep info |
---|
86 | void PrepareNewTrack( const G4ThreeVector position, |
---|
87 | const G4ThreeVector direction ); |
---|
88 | // Prepare Navigators and locate |
---|
89 | |
---|
90 | G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector &point, |
---|
91 | const G4ThreeVector &direction, |
---|
92 | const G4TouchableHistory &h); |
---|
93 | // Reset the geometrical hierarchy for all geometries. |
---|
94 | // Use the touchable history for the first (mass) geometry. |
---|
95 | // Return the volume in the first (mass) geometry. |
---|
96 | // |
---|
97 | // Important Note: In order to call this the geometries MUST be closed. |
---|
98 | |
---|
99 | G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point, |
---|
100 | const G4ThreeVector* direction=0, |
---|
101 | const G4bool pRelativeSearch=true, |
---|
102 | const G4bool ignoreDirection=true); |
---|
103 | // Locate in all geometries. |
---|
104 | // Return the volume in the first (mass) geometry |
---|
105 | // Maintain vector of other volumes, to be returned separately |
---|
106 | // |
---|
107 | // Important Note: In order to call this the geometry MUST be closed. |
---|
108 | |
---|
109 | void LocateGlobalPointWithinVolume(const G4ThreeVector& position); |
---|
110 | // Relocate in all geometries for point that has not changed volume |
---|
111 | // (ie is within safety in all geometries or is distance less that |
---|
112 | // along the direction of a computed step. |
---|
113 | |
---|
114 | G4double ComputeSafety(const G4ThreeVector &globalpoint, |
---|
115 | const G4double pProposedMaxLength = DBL_MAX, |
---|
116 | const G4bool keepState = false); |
---|
117 | // Calculate the isotropic distance to the nearest boundary |
---|
118 | // in any geometry from the specified point in the global coordinate |
---|
119 | // system. The geometry must be closed. |
---|
120 | |
---|
121 | G4TouchableHistoryHandle CreateTouchableHistoryHandle() const; |
---|
122 | // Returns a reference counted handle to a touchable history. |
---|
123 | |
---|
124 | public: // without description |
---|
125 | |
---|
126 | G4Navigator* GetNavigator(G4int n) const |
---|
127 | { |
---|
128 | if( (n>fNoActiveNavigators)||(n<0)){ n=0; } |
---|
129 | return fpNavigator[n]; |
---|
130 | } |
---|
131 | |
---|
132 | protected: // with description |
---|
133 | |
---|
134 | void ResetState(); |
---|
135 | // Utility method to reset the navigator state machine. |
---|
136 | |
---|
137 | void SetupHierarchy(); |
---|
138 | // Renavigate & reset hierarchy described by current history |
---|
139 | // o Reset volumes |
---|
140 | // o Recompute transforms and/or solids of replicated/parameterised |
---|
141 | // volumes. |
---|
142 | |
---|
143 | void WhichLimited(); // Flag which processes limited the step |
---|
144 | void PrintLimited(); // Auxiliary, debugging printing |
---|
145 | void CheckMassWorld(); |
---|
146 | |
---|
147 | private: |
---|
148 | |
---|
149 | // STATE Information |
---|
150 | |
---|
151 | G4int fNoActiveNavigators; |
---|
152 | static const G4int fMaxNav = 8; // rename to kMaxNoNav ?? |
---|
153 | G4VPhysicalVolume* fLastMassWorld; |
---|
154 | |
---|
155 | // Global state (retained during stepping for one track |
---|
156 | G4Navigator* fpNavigator[fMaxNav]; // G4Navigator** fpNavigator; |
---|
157 | |
---|
158 | // State after a step computation |
---|
159 | ELimited fLimitedStep[fMaxNav]; |
---|
160 | G4bool fLimitTruth[fMaxNav]; |
---|
161 | G4double fCurrentStepSize[fMaxNav]; |
---|
162 | G4double fNewSafety[ fMaxNav ]; // Safety for starting point |
---|
163 | |
---|
164 | // Lowest values - determine step length, and safety |
---|
165 | G4double fMinStep; // As reported by Navigators. Can be kInfinity |
---|
166 | G4double fMinSafety; |
---|
167 | G4double fTrueMinStep; // Corrected in case fMinStep >= proposed |
---|
168 | |
---|
169 | // State after calling 'locate' |
---|
170 | G4VPhysicalVolume* fLocatedVolume[fMaxNav]; |
---|
171 | G4ThreeVector fLastLocatedPosition; |
---|
172 | |
---|
173 | // cache of safety information |
---|
174 | G4ThreeVector fSafetyLocation; // point where ComputeSafety is called |
---|
175 | G4double fMinSafety_atSafLocation; // /\ corresponding value of safety |
---|
176 | G4ThreeVector fPreStepLocation; // point where last ComputeStep called |
---|
177 | G4double fMinSafety_PreStepPt; // /\ corresponding value of safety |
---|
178 | |
---|
179 | G4TransportationManager* pTransportManager; // Cache for frequent use |
---|
180 | }; |
---|
181 | |
---|
182 | #endif |
---|