Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // >> 27 // $Id: G4MultiNavigator.hh,v 1.5 2008/10/24 14:00:03 gcosmo Exp $ >> 28 // GEANT4 tag $Name: geant4-09-03-patch-02 $ >> 29 // >> 30 // 26 // class G4MultiNavigator 31 // class G4MultiNavigator 27 // 32 // 28 // Class description: 33 // Class description: 29 // 34 // 30 // Utility class for polling the navigators of 35 // Utility class for polling the navigators of several geometries to 31 // identify the next boundary. << 36 // identify the next boundary. 32 37 33 // History: 38 // History: 34 // - Created. John Apostolakis, November 2006 39 // - Created. John Apostolakis, November 2006 35 // ------------------------------------------- << 40 // ********************************************************************* >> 41 36 #ifndef G4MULTINAVIGATOR_HH 42 #ifndef G4MULTINAVIGATOR_HH 37 #define G4MULTINAVIGATOR_HH 43 #define G4MULTINAVIGATOR_HH 38 44 39 #include <iostream> 45 #include <iostream> 40 46 41 #include "geomdefs.hh" 47 #include "geomdefs.hh" 42 #include "G4ThreeVector.hh" 48 #include "G4ThreeVector.hh" 43 #include "G4Navigator.hh" 49 #include "G4Navigator.hh" 44 50 45 #include "G4TouchableHandle.hh" << 51 #include "G4TouchableHistoryHandle.hh" 46 52 47 #include "G4NavigationHistory.hh" 53 #include "G4NavigationHistory.hh" 48 54 49 enum ELimited { kDoNot,kUnique,kSharedTranspo 55 enum ELimited { kDoNot,kUnique,kSharedTransport,kSharedOther,kUndefLimited }; 50 56 51 class G4TransportationManager; 57 class G4TransportationManager; 52 class G4VPhysicalVolume; 58 class G4VPhysicalVolume; 53 59 54 class G4MultiNavigator : public G4Navigator 60 class G4MultiNavigator : public G4Navigator 55 { 61 { 56 public: // with description 62 public: // with description 57 63 58 friend std::ostream& operator << (std::ostre << 64 friend std::ostream& operator << (std::ostream &os, const G4Navigator &n); 59 65 60 G4MultiNavigator(); 66 G4MultiNavigator(); 61 // Constructor - initialisers and setup. 67 // Constructor - initialisers and setup. 62 68 63 ~G4MultiNavigator() override; << 69 ~G4MultiNavigator(); 64 // Destructor. No actions. 70 // Destructor. No actions. 65 71 66 G4double ComputeStep( const G4ThreeVector& p << 72 G4double ComputeStep(const G4ThreeVector &pGlobalPoint, 67 const G4ThreeVector& p << 73 const G4ThreeVector &pDirection, 68 const G4double p << 74 const G4double pCurrentProposedStepLength, 69 G4double& p << 75 G4double &pNewSafety); 70 // Return the distance to the next boundar 76 // Return the distance to the next boundary of any geometry 71 77 72 G4double ObtainFinalStep( G4int navig 78 G4double ObtainFinalStep( G4int navigatorId, 73 G4double& pNewS << 79 G4double &pNewSafety, // for this geom 74 G4double& minSt << 80 G4double &minStepLast, 75 ELimited& limit << 81 ELimited &limitedStep); 76 // Get values for a single geometry 82 // Get values for a single geometry 77 83 78 void PrepareNavigators(); 84 void PrepareNavigators(); 79 // Find which geometries are registered fo 85 // Find which geometries are registered for this particles, and keep info 80 void PrepareNewTrack( const G4ThreeVector& p << 86 void PrepareNewTrack( const G4ThreeVector position, 81 const G4ThreeVector di 87 const G4ThreeVector direction ); 82 // Prepare Navigators and locate 88 // Prepare Navigators and locate 83 89 84 G4VPhysicalVolume* ResetHierarchyAndLocate( << 90 G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector &point, 85 const G4Thr << 91 const G4ThreeVector &direction, 86 const G4Tou << 92 const G4TouchableHistory &h); 87 // Reset the geometrical hierarchy for all 93 // Reset the geometrical hierarchy for all geometries. 88 // Use the touchable history for the first 94 // Use the touchable history for the first (mass) geometry. 89 // Return the volume in the first (mass) g 95 // Return the volume in the first (mass) geometry. 90 // 96 // 91 // Important Note: In order to call this t 97 // Important Note: In order to call this the geometries MUST be closed. 92 98 93 G4VPhysicalVolume* LocateGlobalPointAndSetup << 99 G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point, 94 const G4Thr << 100 const G4ThreeVector* direction=0, 95 const G4boo << 101 const G4bool pRelativeSearch=true, 96 const G4boo << 102 const G4bool ignoreDirection=true); 97 // Locate in all geometries. 103 // Locate in all geometries. 98 // Return the volume in the first (mass) g 104 // Return the volume in the first (mass) geometry 99 // Maintain vector of other volumes, to 105 // Maintain vector of other volumes, to be returned separately 100 // 106 // 101 // Important Note: In order to call this t 107 // Important Note: In order to call this the geometry MUST be closed. 102 108 103 void LocateGlobalPointWithinVolume( const G4 << 109 void LocateGlobalPointWithinVolume(const G4ThreeVector& position); 104 // Relocate in all geometries for point th 110 // Relocate in all geometries for point that has not changed volume 105 // (ie is within safety in all geometries 111 // (ie is within safety in all geometries or is distance less that 106 // along the direction of a computed step. 112 // along the direction of a computed step. 107 113 108 G4double ComputeSafety( const G4ThreeVector& << 114 G4double ComputeSafety(const G4ThreeVector &globalpoint, 109 const G4double pProp << 115 const G4double pProposedMaxLength = DBL_MAX, 110 const G4bool keepSta << 116 const G4bool keepState = false); 111 // Calculate the isotropic distance to the 117 // Calculate the isotropic distance to the nearest boundary 112 // in any geometry from the specified poin 118 // in any geometry from the specified point in the global coordinate 113 // system. The geometry must be closed. 119 // system. The geometry must be closed. 114 120 115 G4TouchableHandle CreateTouchableHistoryHand << 121 G4TouchableHistoryHandle CreateTouchableHistoryHandle() const; 116 // Returns a reference counted handle to a 122 // Returns a reference counted handle to a touchable history. 117 123 118 G4ThreeVector GetLocalExitNormal( G4bool* ob << 119 G4ThreeVector GetLocalExitNormalAndCheck( co << 120 G4 << 121 G4ThreeVector GetGlobalExitNormal( const G4T << 122 G4b << 123 // Return Exit Surface Normal and validity << 124 // Can only be called if the Navigator's l << 125 // - has just crossed a volume geometrica << 126 // - has arrived at a boundary in a Compu << 127 // It returns the Normal to the surface po << 128 // was left behind and/or into the volum << 129 // Convention:x << 130 // The *local* normal is in the coordina << 131 // Restriction: << 132 // Normals are not available for replica << 133 << 134 public: // without description 124 public: // without description 135 125 136 inline G4Navigator* GetNavigator( G4int n ) << 126 G4Navigator* GetNavigator(G4int n) const 137 { 127 { 138 if( (n>fNoActiveNavigators) || (n<0) ) { n << 128 if( (n>fNoActiveNavigators)||(n<0)){ n=0; } 139 return fpNavigator[n]; << 129 return fpNavigator[n]; 140 } 130 } 141 131 142 protected: // with description 132 protected: // with description 143 133 144 void ResetState() override; << 134 void ResetState(); 145 // Utility method to reset the navigator s 135 // Utility method to reset the navigator state machine. 146 136 147 void SetupHierarchy() override; << 137 void SetupHierarchy(); 148 // Renavigate & reset hierarchy described 138 // Renavigate & reset hierarchy described by current history 149 // o Reset volumes 139 // o Reset volumes 150 // o Recompute transforms and/or solids of 140 // o Recompute transforms and/or solids of replicated/parameterised 151 // volumes. 141 // volumes. 152 142 153 void WhichLimited(); // Flag which processes 143 void WhichLimited(); // Flag which processes limited the step 154 void PrintLimited(); // Auxiliary, debugging 144 void PrintLimited(); // Auxiliary, debugging printing 155 void CheckMassWorld(); 145 void CheckMassWorld(); 156 146 157 private: 147 private: 158 148 159 // STATE Information 149 // STATE Information 160 150 161 G4int fNoActiveNavigators = 0; << 151 G4int fNoActiveNavigators; 162 static const G4int fMaxNav = 16; << 152 static const G4int fMaxNav = 8; // rename to kMaxNoNav ?? 163 G4VPhysicalVolume* fLastMassWorld = nullptr << 153 G4VPhysicalVolume* fLastMassWorld; 164 154 165 G4Navigator* fpNavigator[fMaxNav]; << 155 // Global state (retained during stepping for one track 166 // Global state (retained during stepping << 156 G4Navigator* fpNavigator[fMaxNav]; // G4Navigator** fpNavigator; 167 157 168 // State after a step computation 158 // State after a step computation 169 // << 170 ELimited fLimitedStep[fMaxNav]; 159 ELimited fLimitedStep[fMaxNav]; 171 G4bool fLimitTruth[fMaxNav]; 160 G4bool fLimitTruth[fMaxNav]; 172 G4double fCurrentStepSize[fMaxNav]; 161 G4double fCurrentStepSize[fMaxNav]; 173 G4double fNewSafety[ fMaxNav ]; // Saf << 162 G4double fNewSafety[ fMaxNav ]; // Safety for starting point 174 G4int fNoLimitingStep = -1; // How << 163 175 G4int fIdNavLimiting = -1; // Id << 164 // Lowest values - determine step length, and safety 176 << 165 G4double fMinStep; // As reported by Navigators. Can be kInfinity 177 // Lowest values - determine step length, a << 166 G4double fMinSafety; 178 // << 167 G4double fTrueMinStep; // Corrected in case fMinStep >= proposed 179 G4double fMinStep = -kInfinity; // As << 180 G4double fMinSafety = -kInfinity; << 181 G4double fTrueMinStep = -kInfinity; // << 182 168 183 // State after calling 'locate' 169 // State after calling 'locate' 184 // << 185 G4VPhysicalVolume* fLocatedVolume[fMaxNav]; 170 G4VPhysicalVolume* fLocatedVolume[fMaxNav]; 186 G4ThreeVector fLastLocatedPosition; 171 G4ThreeVector fLastLocatedPosition; 187 172 188 // Cache of safety information << 173 // cache of safety information 189 // << 174 G4ThreeVector fSafetyLocation; // point where ComputeSafety is called 190 G4ThreeVector fSafetyLocation; << 175 G4double fMinSafety_atSafLocation; // /\ corresponding value of safety 191 // point where ComputeSafety is called << 176 G4ThreeVector fPreStepLocation; // point where last ComputeStep called 192 G4double fMinSafety_atSafLocation = -1 << 177 G4double fMinSafety_PreStepPt; // /\ corresponding value of safety 193 // - corresponding value of safety << 194 G4ThreeVector fPreStepLocation; << 195 // point where last ComputeStep called << 196 G4double fMinSafety_PreStepPt = -1.0; << 197 // - corresponding value of safety << 198 178 199 G4TransportationManager* pTransportManager; 179 G4TransportationManager* pTransportManager; // Cache for frequent use 200 }; 180 }; 201 181 202 #endif 182 #endif 203 183