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 // G4SafetyCalculator 27 // 28 // Class description: 29 // 30 // A class that provides an estimate of the is 31 // minimum distance from a global point to t 32 // of the current volume or the nearest daug 33 // This estimate can be an underestimate, eith 34 // provides an underestimate (for speed) or 35 // substantial additional computations. 36 // 37 // Obtains from the navigator the current tran 38 39 // Author: John Apostolakis, CERN - February 2 40 // ------------------------------------------- 41 #ifndef G4SafetyCalculator_HH 42 #define G4SafetyCalculator_HH 1 43 44 #include "geomdefs.hh" 45 46 #include "G4ThreeVector.hh" 47 #include "G4AffineTransform.hh" 48 #include "G4RotationMatrix.hh" 49 50 #include "G4LogicalVolume.hh" // U 51 #include "G4TouchableHistoryHandle.hh" 52 53 #include "G4NavigationHistory.hh" 54 #include "G4NormalNavigation.hh" 55 #include "G4VoxelNavigation.hh" 56 #include "G4ParameterisedNavigation.hh" 57 #include "G4ReplicaNavigation.hh" 58 #include "G4RegularNavigation.hh" 59 #include "G4VExternalNavigation.hh" 60 61 #include "G4VoxelSafety.hh" 62 63 #include <iostream> 64 65 class G4VPhysicalVolume; 66 67 class G4SafetyCalculator 68 { 69 public: 70 71 G4SafetyCalculator( const G4Navigator& nav 72 const G4NavigationHist 73 // Constructor - initialisers and setup. 74 75 G4SafetyCalculator(const G4SafetyCalculato 76 G4SafetyCalculator& operator=(const G4Safe 77 // Copy constructor & assignment operato 78 79 ~G4SafetyCalculator() = default; 80 // Destructor. No actions. 81 82 G4double SafetyInCurrentVolume(const G4Thr 83 G4VPh 84 const G4dou 85 G4boo 86 // Calculate the isotropic distance to t 87 // specified point in the global coordin 88 // The globalpoint utilised *must* be lo 89 // current volume (it also must *not* be 90 // The value returned can be an underest 91 // if complex volumes are involved). 92 // The calculation will not look beyond 93 // to avoid extra volume safety calculat 94 95 G4VExternalNavigation* GetExternalNavigati 96 void SetExternalNavigation(G4VExternalNavi 97 // Accessor & modifier for custom extern 98 99 void CompareSafetyValues( G4double oldSafe 100 G4double newValu 101 G4VPhysicalVolum 102 const G4ThreeVector &g 103 G4bool keepState 104 G4double maxLeng 105 G4bool enteredVo 106 G4bool exitedVol 107 // Compare estimates of the safety, and 108 109 protected: 110 111 void QuickLocateWithinVolume(const G4Three 112 G4VPhys 113 // Prepare state of sub-navigators by in 114 115 inline G4ThreeVector ComputeLocalPoint(con 116 // Return position vector in local coord 117 // vector in world coordinate system. 118 119 inline G4ThreeVector ComputeLocalAxis(cons 120 // Return the local direction of the spe 121 // system of the volume that was found b 122 // The Local Coordinates of point in wor 123 124 inline EVolume CharacteriseDaughters(const 125 // Characterise daughter of logical volu 126 127 inline G4int GetDaughtersRegularStructureI 128 // Get regular structure ID of first dau 129 130 private: 131 132 // BEGIN -- Tracking Invariants part 1 133 // 134 const G4Navigator& fNavigator; 135 // Associated navigator. Needed for deta 136 // for optimisation 137 138 const G4NavigationHistory& fNavHistory; 139 // Associated navigator's navigation his 140 // of the current path through the geome 141 // 142 // END -- Tracking Invariants part 1 143 144 G4double fkCarTolerance; 145 // Cached tolerance. 146 147 // BEGIN State information 148 // 149 G4ThreeVector fPreviousSftOrigin; 150 G4double fPreviousSafety = 0.0; 151 // Memory of last safety origin & value. 152 // that origin of current Step is in the 153 // last relocation. 154 155 // Helpers/Utility classes - their state c 156 // 157 G4NormalNavigation fnormalNav; 158 G4VoxelNavigation fvoxelNav; 159 G4ParameterisedNavigation fparamNav; 160 G4ReplicaNavigation freplicaNav; 161 G4RegularNavigation fregularNav; 162 G4VExternalNavigation* fpExternalNav = nul 163 G4VoxelSafety fVoxelSafety; 164 }; 165 166 // Auxiliary inline methods -- copied from G4N 167 168 // Return local coordinates given point in th 169 // 170 inline G4ThreeVector 171 G4SafetyCalculator::ComputeLocalPoint(const G4 172 { 173 return fNavHistory.GetTopTransform().Transfo 174 } 175 176 // Returns local direction given vector direct 177 // 178 inline G4ThreeVector 179 G4SafetyCalculator::ComputeLocalAxis(const G4T 180 { 181 return fNavHistory.GetTopTransform().Transfo 182 } 183 184 inline EVolume 185 G4SafetyCalculator::CharacteriseDaughters(cons 186 { 187 return pLog->CharacteriseDaughters(); 188 } 189 190 inline G4int 191 G4SafetyCalculator::GetDaughtersRegularStructu 192 { 193 G4int regId = 0; 194 G4VPhysicalVolume *pVol; 195 196 if ( pLog->GetNoDaughters() == 1 ) 197 { 198 pVol = pLog->GetDaughter(0); 199 regId = pVol->GetRegularStructureId(); 200 } 201 return regId; 202 } 203 204 #endif 205