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