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: not supported by cvs2svn $ >> 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( const G4ThreeVector& StartPointA, 100 const 105 const G4ThreeVector& EndPointB, 101 G4doub << 106 G4double &NewSafety, 102 G4doub << 107 G4double &PreviousSafety, 103 G4Thre << 108 G4ThreeVector &PreviousSftOrigin, 104 G4doub << 109 G4double &LinearStepLength, 105 G4Thre << 110 G4ThreeVector &IntersectionPoint, 106 G4bool << 111 G4bool *ptrCalledNavigator ) 107 { 112 { 108 G4bool CalledNavigator = false; 113 G4bool CalledNavigator = false; 109 114 110 // Calculate the direction and length of the 115 // Calculate the direction and length of the chord AB 111 116 112 G4ThreeVector ChordAB_Vector = EndPointB - 117 G4ThreeVector ChordAB_Vector = EndPointB - StartPointA; 113 G4double ChordAB_Length = ChordAB_Vect 118 G4double ChordAB_Length = ChordAB_Vector.mag(); // Magnitude (norm) 114 G4ThreeVector ChordAB_Dir = ChordAB_Vector. << 119 G4ThreeVector ChordAB_Dir = ChordAB_Vector.unit(); 115 G4bool intersects; 120 G4bool intersects; 116 G4ThreeVector OriginShift = StartPointA - Pr << 121 G4ThreeVector OriginShift = StartPointA - PreviousSftOrigin ; 117 G4double MagSqShift = OriginShift.mag2() ; << 122 G4double MagSqShift = OriginShift.mag2() ; 118 G4double currentSafety; << 123 G4double currentSafety; 119 124 120 if( MagSqShift >= sqr(PreviousSafety) ) 125 if( MagSqShift >= sqr(PreviousSafety) ) 121 { 126 { 122 currentSafety = 0.0 ; 127 currentSafety = 0.0 ; 123 } 128 } 124 else 129 else 125 { 130 { 126 currentSafety = PreviousSafety - std::sqrt 131 currentSafety = PreviousSafety - std::sqrt(MagSqShift) ; 127 } 132 } 128 133 129 if( fiUseSafety && (ChordAB_Length <= curren 134 if( fiUseSafety && (ChordAB_Length <= currentSafety) ) 130 { 135 { 131 // The Step is guaranteed to be taken 136 // The Step is guaranteed to be taken 132 137 133 LinearStepLength = ChordAB_Length; 138 LinearStepLength = ChordAB_Length; 134 intersects = false; 139 intersects = false; 135 NewSafety = currentSafety; << 140 NewSafety= currentSafety; 136 CalledNavigator = false; << 141 CalledNavigator= false; 137 } 142 } 138 else 143 else 139 { 144 { 140 // Check whether any volumes are encounter 145 // Check whether any volumes are encountered by the chord AB 141 146 142 LinearStepLength = GetNavigatorFor()->Comp 147 LinearStepLength = GetNavigatorFor()->ComputeStep( StartPointA, 143 ChordAB_Dir, 148 ChordAB_Dir, ChordAB_Length, NewSafety ); 144 intersects = (LinearStepLength <= ChordAB_ 149 intersects = (LinearStepLength <= ChordAB_Length); 145 // G4Navigator contracts to return k_in << 150 146 // and it did not find a surface bounda << 151 // G4Navigator contracts to return k_infinity if len==asked >> 152 // and it did not find a surface boundary at that length 147 153 148 LinearStepLength = std::min( LinearStepLen 154 LinearStepLength = std::min( LinearStepLength, ChordAB_Length); 149 CalledNavigator = true; 155 CalledNavigator = true; 150 156 151 // Save the last calculated safety! 157 // Save the last calculated safety! 152 158 153 PreviousSftOrigin = StartPointA; 159 PreviousSftOrigin = StartPointA; 154 PreviousSafety = NewSafety; 160 PreviousSafety = NewSafety; 155 161 156 if( intersects ) 162 if( intersects ) 157 { 163 { 158 // Intersection Point of chord AB and e 164 // Intersection Point of chord AB and either volume A's surface 159 // or a 165 // or a daughter volume's surface .. 160 IntersectionPoint = StartPointA + Linea 166 IntersectionPoint = StartPointA + LinearStepLength * ChordAB_Dir; 161 } 167 } 162 } 168 } 163 if( ptrCalledNavigator != nullptr ) << 169 if( ptrCalledNavigator ) 164 { 170 { 165 *ptrCalledNavigator = CalledNavigator; 171 *ptrCalledNavigator = CalledNavigator; 166 } 172 } 167 173 168 return intersects; 174 return intersects; 169 } 175 } 170 176