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: G4VIntersectionLocator.icc,v 1.3 2008/11/14 18:26:35 gcosmo Exp $ >> 28 // GEANT4 tag $Name: geant4-09-03-patch-01 $ >> 29 // >> 30 // 26 // Class G4VIntersectionLocator inline methods 31 // Class G4VIntersectionLocator inline methods 27 // 32 // 28 // 27.10.07 - John Apostolakis, Tatiana Nikiti 33 // 27.10.07 - John Apostolakis, Tatiana Nikitina 29 // ------------------------------------------- 34 // --------------------------------------------------------------------------- 30 35 31 inline G4double G4VIntersectionLocator::GetDel 36 inline G4double G4VIntersectionLocator::GetDeltaIntersectionFor() 32 { 37 { 33 return fiDeltaIntersection; 38 return fiDeltaIntersection; 34 } 39 } 35 40 36 inline G4double G4VIntersectionLocator::GetEps 41 inline G4double G4VIntersectionLocator::GetEpsilonStepFor() 37 { 42 { 38 return fiEpsilonStep; 43 return fiEpsilonStep; 39 } 44 } 40 45 41 inline G4Navigator* G4VIntersectionLocator::Ge 46 inline G4Navigator* G4VIntersectionLocator::GetNavigatorFor() 42 { 47 { 43 return fiNavigator; 48 return fiNavigator; 44 } 49 } 45 50 46 inline G4ChordFinder* G4VIntersectionLocator:: 51 inline G4ChordFinder* G4VIntersectionLocator::GetChordFinderFor() 47 { 52 { 48 return fiChordFinder; 53 return fiChordFinder; 49 } 54 } 50 55 51 inline G4int G4VIntersectionLocator::GetVerbos 56 inline G4int G4VIntersectionLocator::GetVerboseFor() 52 { 57 { 53 return fVerboseLevel; 58 return fVerboseLevel; 54 } 59 } 55 60 56 inline G4bool G4VIntersectionLocator::GetAdjus 61 inline G4bool G4VIntersectionLocator::GetAdjustementOfFoundIntersection() 57 { 62 { 58 return fUseNormalCorrection; 63 return fUseNormalCorrection; 59 } 64 } 60 65 61 inline void G4VIntersectionLocator:: 66 inline void G4VIntersectionLocator:: 62 AddAdjustementOfFoundIntersection(G4bool UseCo 67 AddAdjustementOfFoundIntersection(G4bool UseCorrection ) 63 { 68 { 64 fUseNormalCorrection = UseCorrection; << 69 fUseNormalCorrection=UseCorrection; 65 } 70 } 66 71 67 inline void G4VIntersectionLocator::SetEpsilon 72 inline void G4VIntersectionLocator::SetEpsilonStepFor( G4double EpsilonStep ) 68 { 73 { 69 fiEpsilonStep = EpsilonStep; << 74 fiEpsilonStep=EpsilonStep; 70 } 75 } 71 76 72 inline void G4VIntersectionLocator:: 77 inline void G4VIntersectionLocator:: 73 SetDeltaIntersectionFor( G4double deltaInterse 78 SetDeltaIntersectionFor( G4double deltaIntersection ) 74 { 79 { 75 fiDeltaIntersection = deltaIntersection; << 80 fiDeltaIntersection=deltaIntersection; 76 } 81 } 77 82 78 inline void G4VIntersectionLocator::SetNavigat << 83 inline void G4VIntersectionLocator::SetNavigatorFor( G4Navigator *fNavigator ) 79 { 84 { 80 fiNavigator = fNavigator; << 85 fiNavigator=fNavigator; 81 } 86 } 82 87 83 inline void G4VIntersectionLocator::SetChordFi << 88 inline void G4VIntersectionLocator::SetChordFinderFor(G4ChordFinder *fCFinder ) 84 { 89 { 85 fiChordFinder = fCFinder; << 90 fiChordFinder=fCFinder; 86 } 91 } 87 92 88 inline void G4VIntersectionLocator::SetSafetyP 93 inline void G4VIntersectionLocator::SetSafetyParametersFor(G4bool UseSafety ) 89 { 94 { 90 fiUseSafety = UseSafety; << 95 fiUseSafety=UseSafety; 91 } 96 } 92 97 93 inline void G4VIntersectionLocator::SetVerbose 98 inline void G4VIntersectionLocator::SetVerboseFor(G4int fVerbose) 94 { 99 { 95 fVerboseLevel = fVerbose; << 100 fVerboseLevel=fVerbose; 96 } 101 } 97 102 98 inline G4bool 103 inline G4bool 99 G4VIntersectionLocator::IntersectChord( const << 104 G4VIntersectionLocator::IntersectChord( G4ThreeVector StartPointA, 100 const << 105 G4ThreeVector EndPointB, 101 G4doub << 106 G4double &NewSafety, 102 G4doub << 107 G4double &fPreviousSafety, 103 G4Thre << 108 G4ThreeVector &fPreviousSftOrigin, 104 G4doub << 109 G4double &LinearStepLength, 105 G4Thre << 110 G4ThreeVector &IntersectionPoint ) 106 G4bool << 107 { 111 { 108 G4bool CalledNavigator = false; << 109 << 110 // Calculate the direction and length of the 112 // Calculate the direction and length of the chord AB 111 113 112 G4ThreeVector ChordAB_Vector = EndPointB - 114 G4ThreeVector ChordAB_Vector = EndPointB - StartPointA; 113 G4double ChordAB_Length = ChordAB_Vect 115 G4double ChordAB_Length = ChordAB_Vector.mag(); // Magnitude (norm) 114 G4ThreeVector ChordAB_Dir = ChordAB_Vector. << 116 G4ThreeVector ChordAB_Dir = ChordAB_Vector.unit(); 115 G4bool intersects; 117 G4bool intersects; 116 G4ThreeVector OriginShift = StartPointA - Pr << 118 G4ThreeVector OriginShift = StartPointA - fPreviousSftOrigin ; 117 G4double MagSqShift = OriginShift.mag2() ; << 119 G4double MagSqShift = OriginShift.mag2() ; 118 G4double currentSafety; << 120 G4double currentSafety; >> 121 G4bool doCallNav= false; 119 122 120 if( MagSqShift >= sqr(PreviousSafety) ) << 123 if( MagSqShift >= sqr(fPreviousSafety) ) 121 { 124 { 122 currentSafety = 0.0 ; 125 currentSafety = 0.0 ; 123 } 126 } 124 else 127 else 125 { 128 { 126 currentSafety = PreviousSafety - std::sqrt << 129 currentSafety = fPreviousSafety - std::sqrt(MagSqShift) ; 127 } 130 } 128 131 129 if( fiUseSafety && (ChordAB_Length <= curren 132 if( fiUseSafety && (ChordAB_Length <= currentSafety) ) 130 { 133 { 131 // The Step is guaranteed to be taken 134 // The Step is guaranteed to be taken 132 135 133 LinearStepLength = ChordAB_Length; 136 LinearStepLength = ChordAB_Length; 134 intersects = false; 137 intersects = false; 135 NewSafety = currentSafety; << 138 NewSafety= currentSafety; 136 CalledNavigator = false; << 137 } 139 } 138 else 140 else 139 { 141 { 140 // Check whether any volumes are encounter << 142 doCallNav= true; >> 143 // Check whether any volumes are encountered by the chord AB 141 144 142 LinearStepLength = GetNavigatorFor()->Comp 145 LinearStepLength = GetNavigatorFor()->ComputeStep( StartPointA, 143 ChordAB_Dir, 146 ChordAB_Dir, ChordAB_Length, NewSafety ); 144 intersects = (LinearStepLength <= ChordAB_ 147 intersects = (LinearStepLength <= ChordAB_Length); >> 148 145 // G4Navigator contracts to return k_in 149 // G4Navigator contracts to return k_infinity if len==asked 146 // and it did not find a surface bounda 150 // and it did not find a surface boundary at that length 147 << 151 148 LinearStepLength = std::min( LinearStepLen 152 LinearStepLength = std::min( LinearStepLength, ChordAB_Length); 149 CalledNavigator = true; << 150 153 151 // Save the last calculated safety! 154 // Save the last calculated safety! 152 155 153 PreviousSftOrigin = StartPointA; << 156 fPreviousSftOrigin = StartPointA; 154 PreviousSafety = NewSafety; << 157 fPreviousSafety= NewSafety; 155 158 156 if( intersects ) 159 if( intersects ) 157 { 160 { 158 // Intersection Point of chord AB and e 161 // Intersection Point of chord AB and either volume A's surface 159 // or a 162 // or a daughter volume's surface .. 160 IntersectionPoint = StartPointA + Linea 163 IntersectionPoint = StartPointA + LinearStepLength * ChordAB_Dir; 161 } 164 } 162 } 165 } 163 if( ptrCalledNavigator != nullptr ) << 164 { << 165 *ptrCalledNavigator = CalledNavigator; << 166 } << 167 << 168 return intersects; 166 return intersects; 169 } 167 } 170 168