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