Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:22

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Class G4VIntersectionLocator inline methods
0027 //
0028 // 27.10.07 - John Apostolakis, Tatiana Nikitina
0029 // ---------------------------------------------------------------------------
0030 
0031 inline G4double G4VIntersectionLocator::GetDeltaIntersectionFor()
0032 {
0033   return fiDeltaIntersection;
0034 } 
0035 
0036 inline G4double G4VIntersectionLocator::GetEpsilonStepFor()
0037 {
0038   return fiEpsilonStep;
0039 }
0040 
0041 inline G4Navigator* G4VIntersectionLocator::GetNavigatorFor()
0042 {
0043   return fiNavigator;
0044 }
0045 
0046 inline G4ChordFinder* G4VIntersectionLocator::GetChordFinderFor()
0047 {
0048   return fiChordFinder;
0049 }
0050 
0051 inline G4int G4VIntersectionLocator::GetVerboseFor()
0052 {
0053   return fVerboseLevel;
0054 }
0055 
0056 inline G4bool G4VIntersectionLocator::GetAdjustementOfFoundIntersection()
0057 {
0058   return fUseNormalCorrection;
0059 }
0060 
0061 inline void G4VIntersectionLocator::
0062 AddAdjustementOfFoundIntersection(G4bool UseCorrection )
0063 {
0064   fUseNormalCorrection = UseCorrection;
0065 }
0066 
0067 inline void G4VIntersectionLocator::SetEpsilonStepFor( G4double EpsilonStep )
0068 {
0069   fiEpsilonStep = EpsilonStep;
0070 }
0071 
0072 inline void G4VIntersectionLocator::
0073 SetDeltaIntersectionFor( G4double deltaIntersection )
0074 {
0075   fiDeltaIntersection = deltaIntersection;
0076 }
0077 
0078 inline void G4VIntersectionLocator::SetNavigatorFor( G4Navigator* fNavigator )
0079 {
0080   fiNavigator = fNavigator;
0081 }
0082 
0083 inline void G4VIntersectionLocator::SetChordFinderFor(G4ChordFinder* fCFinder )
0084 {
0085   fiChordFinder = fCFinder;
0086 }
0087 
0088 inline void G4VIntersectionLocator::SetSafetyParametersFor(G4bool UseSafety )
0089 {
0090   fiUseSafety = UseSafety;
0091 }
0092 
0093 inline void G4VIntersectionLocator::SetVerboseFor(G4int fVerbose)
0094 {
0095   fVerboseLevel = fVerbose;
0096 }
0097 
0098 inline G4bool
0099 G4VIntersectionLocator::IntersectChord( const G4ThreeVector&  StartPointA,
0100                                         const G4ThreeVector&  EndPointB,
0101                                         G4double&      NewSafety,
0102                                         G4double&      PreviousSafety,
0103                                         G4ThreeVector& PreviousSftOrigin,
0104                                         G4double&      LinearStepLength,
0105                                         G4ThreeVector& IntersectionPoint,
0106                                         G4bool*        ptrCalledNavigator )
0107 {
0108   G4bool CalledNavigator = false; 
0109 
0110   // Calculate the direction and length of the chord AB
0111 
0112   G4ThreeVector  ChordAB_Vector = EndPointB - StartPointA;
0113   G4double       ChordAB_Length = ChordAB_Vector.mag();  // Magnitude (norm)
0114   G4ThreeVector  ChordAB_Dir = ChordAB_Vector.unit();
0115   G4bool intersects;
0116   G4ThreeVector OriginShift = StartPointA - PreviousSftOrigin ;
0117   G4double MagSqShift  = OriginShift.mag2() ;
0118   G4double currentSafety;
0119 
0120   if( MagSqShift >= sqr(PreviousSafety) )
0121   {
0122     currentSafety = 0.0 ;
0123   }
0124   else
0125   {
0126     currentSafety = PreviousSafety - std::sqrt(MagSqShift) ;
0127   }
0128 
0129   if( fiUseSafety && (ChordAB_Length <= currentSafety) )
0130   {
0131     // The Step is guaranteed to be taken
0132 
0133     LinearStepLength = ChordAB_Length;
0134     intersects = false;
0135     NewSafety = currentSafety;
0136     CalledNavigator = false;
0137   }
0138   else
0139   {
0140     // Check whether any volumes are encountered by the chord AB
0141 
0142     LinearStepLength = GetNavigatorFor()->ComputeStep( StartPointA,
0143                                  ChordAB_Dir, ChordAB_Length, NewSafety );
0144     intersects = (LinearStepLength <= ChordAB_Length); 
0145        // G4Navigator contracts to return k_infinity if len==asked
0146        // and it did not find a surface boundary at that length
0147     
0148     LinearStepLength = std::min( LinearStepLength, ChordAB_Length);
0149     CalledNavigator = true; 
0150 
0151     // Save the last calculated safety!
0152 
0153     PreviousSftOrigin = StartPointA;
0154     PreviousSafety    = NewSafety;
0155 
0156     if( intersects )
0157     {
0158        // Intersection Point of chord AB and either volume A's surface 
0159        //                                or a daughter volume's surface ..
0160        IntersectionPoint = StartPointA + LinearStepLength * ChordAB_Dir;
0161     }
0162   }
0163   if( ptrCalledNavigator != nullptr )
0164   { 
0165     *ptrCalledNavigator = CalledNavigator; 
0166   }
0167 
0168   return intersects;
0169 }