Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 // 28 // 29 // class G4ITMultiNavigator 30 // 31 // Class description: 32 // 33 // Utility class for polling the navigators of 34 // identify the next boundary. 35 36 /// \brief { Class description: 37 /// 38 /// G4ITMultiNavigator is a duplicate version 39 /// 40 /// Utility class for polling the navigators o 41 /// identify the next boundary. 42 /// 43 /// } 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 58 #include "G4TouchableHandle.hh" 59 60 #include "G4NavigationHistory.hh" 61 #include "G4TrackState.hh" 62 #include "G4MultiNavigator.hh" 63 64 namespace G4ITMN 65 { 66 enum ELimited 67 { 68 kDoNot, 69 kUnique, 70 kSharedTransport, 71 kSharedOther, 72 kUndefLimited 73 }; 74 } 75 class G4ITTransportationManager; 76 class G4VPhysicalVolume; 77 78 class G4ITMultiNavigator; 79 80 // Global state (retained during stepping for 81 template<> 82 class G4TrackState<G4ITMultiNavigator> : pub 83 { 84 public: 85 ~G4TrackState() override 86 = default; 87 88 G4TrackState() 89 { 90 G4ThreeVector Big3Vector(kInfinity, kInf 91 fLastLocatedPosition = Big3Vector; 92 fSafetyLocation = Big3Vector; 93 fPreStepLocation = Big3Vector; 94 95 fMinSafety_PreStepPt = -1.0; 96 fMinSafety_atSafLocation = -1.0; 97 fMinSafety = -kInfinity; 98 fTrueMinStep = fMinStep = -kInfinity; 99 100 for (G4int num = 0; num < G4ITNavigator: 101 { 102 fLimitTruth[num] = false; 103 fLimitedStep[num] = kUndefLimited; 104 fCurrentStepSize[num] = fNewSafety[num 105 fLocatedVolume[num] = nullptr; 106 } 107 108 fNoLimitingStep = -1; // How many geomet 109 fIdNavLimiting = -1; // Id of Navigator 110 fWasLimitedByGeometry = false; 111 } 112 ; 113 114 protected: 115 friend class G4ITMultiNavigator; 116 // State after a step computation 117 ELimited fLimitedStep[G4ITNavigator::fMaxN 118 G4bool fLimitTruth[G4ITNavigator::fMaxNav] 119 G4double fCurrentStepSize[G4ITNavigator::f 120 G4double fNewSafety[G4ITNavigator::fMaxNav 121 G4int fNoLimitingStep; // How many geometr 122 G4int fIdNavLimiting; // Id of Navigator l 123 124 G4bool fWasLimitedByGeometry; 125 126 // Lowest values - determine step length, 127 G4double fMinStep; // As reported by Navig 128 G4double fMinSafety; 129 G4double fTrueMinStep; // Corrected in cas 130 131 // State after calling 'locate' 132 G4VPhysicalVolume* fLocatedVolume[G4ITNavi 133 G4ThreeVector fLastLocatedPosition; 134 135 // cache of safety information 136 G4ThreeVector fSafetyLocation; // point w 137 G4double fMinSafety_atSafLocation; // /\ c 138 G4ThreeVector fPreStepLocation; // point 139 G4double fMinSafety_PreStepPt; // /\ cor 140 }; 141 142 class G4ITMultiNavigator : public G4ITNavigato 143 public G4TrackState 144 { 145 public: 146 // with description 147 148 friend std::ostream& operator <<(std::ostrea 149 150 G4ITMultiNavigator(); 151 // Constructor - initialisers and setup. 152 153 ~G4ITMultiNavigator() override; 154 // Destructor. No actions. 155 156 G4double ComputeStep(const G4ThreeVector &pG 157 const G4ThreeVector &pD 158 const G4double pCurrent 159 G4double &pNewSafety) o 160 // Return the distance to the next boundary 161 162 G4double ObtainFinalStep(G4int navigatorId, 163 G4double &minStepLa 164 ELimited &limitedSt 165 // Get values for a single geometry 166 167 void PrepareNavigators(); 168 // Find which geometries are registered for 169 void PrepareNewTrack(const G4ThreeVector pos 170 const G4ThreeVector dir 171 // Prepare Navigators and locate 172 173 G4VPhysicalVolume* ResetHierarchyAndLocate(c 174 c 175 c 176 // Reset the geometrical hierarchy for all g 177 // Use the touchable history for the first ( 178 // Return the volume in the first (mass) geo 179 // 180 // Important Note: In order to call this the 181 182 G4VPhysicalVolume* LocateGlobalPointAndSetup 183 184 185 186 187 188 189 // Locate in all geometries. 190 // Return the volume in the first (mass) geo 191 // Maintain vector of other volumes, to be 192 // 193 // Important Note: In order to call this the 194 195 void LocateGlobalPointWithinVolume(const G4T 196 // Relocate in all geometries for point that 197 // (ie is within safety in all geometries o 198 // along the direction of a computed step. 199 200 G4double ComputeSafety(const G4ThreeVector & 201 const G4double pPropo 202 const G4bool keepStat 203 // Calculate the isot 204 // in any geometry fr 205 // system. The geomet 206 207 G4TouchableHandle CreateTouchableHistoryHand 208 // Returns a reference counted handle to a t 209 210 G4ThreeVector GetLocalExitNormal(G4bool* obt 211 G4ThreeVector GetLocalExitNormalAndCheck(con 212 G4bool* obtained) override;// const 213 G4ThreeVector GetGlobalExitNormal(const G4Th 214 G4bool* obtained) override;// const 215 // Return Exit Surface Normal and validity t 216 // Can only be called if the Navigator's las 217 // - has just crossed a volume geometrical 218 // - has arrived at a boundary in a Compute 219 // It returns the Normal to the surface poin 220 // was left behind and/or into the volume 221 // Convention:x 222 // The *local* normal is in the coordinate 223 // Restriction: 224 // Normals are not available for replica v 225 226 public:// without description 227 228 G4ITNavigator* GetNavigator(G4int n) const 229 { 230 if( (n>fNoActiveNavigators)||(n<0)) 231 { n=0;} 232 return fpNavigator[n]; 233 } 234 235 protected: // with description 236 237 void ResetState() override; 238 // Utility method to reset the navigator sta 239 240 void SetupHierarchy() override; 241 // Renavigate & reset hierarchy described by 242 // o Reset volumes 243 // o Recompute transforms and/or solids of r 244 // volumes. 245 246 void WhichLimited();// Flag which processes 247 void PrintLimited();// Auxiliary, debugging 248 void CheckMassWorld(); 249 250 private: 251 252 G4int fNoActiveNavigators; 253 G4VPhysicalVolume* fLastMassWorld{nullptr}; 254 255 G4ITNavigator* fpNavigator[fMaxNav];// G4ITN 256 257 G4ITTransportationManager* pTransportManager 258 }; 259 260 #endif 261