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