G4VIntersectionLocator Class Reference

#include <G4VIntersectionLocator.hh>

Inheritance diagram for G4VIntersectionLocator:

G4BrentLocator G4MultiLevelLocator G4SimpleLocator

Public Member Functions

 G4VIntersectionLocator (G4Navigator *theNavigator)
virtual ~G4VIntersectionLocator ()
virtual G4bool EstimateIntersectionPoint (const G4FieldTrack &curveStartPointTangent, const G4FieldTrack &curveEndPointTangent, const G4ThreeVector &trialPoint, G4FieldTrack &intersectPointTangent, G4bool &recalculatedEndPoint, G4double &fPreviousSafety, G4ThreeVector &fPreviousSftOrigin)=0
void printStatus (const G4FieldTrack &startFT, const G4FieldTrack &currentFT, G4double requestStep, G4double safety, G4int step)
G4bool IntersectChord (const G4ThreeVector &StartPointA, const G4ThreeVector &EndPointB, G4double &NewSafety, G4double &PreviousSafety, G4ThreeVector &PreviousSftOrigin, G4double &LinearStepLength, G4ThreeVector &IntersectionPoint, G4bool *calledNavigator=0)
void SetEpsilonStepFor (G4double EpsilonStep)
void SetDeltaIntersectionFor (G4double deltaIntersection)
void SetNavigatorFor (G4Navigator *fNavigator)
void SetChordFinderFor (G4ChordFinder *fCFinder)
void SetVerboseFor (G4int fVerbose)
G4int GetVerboseFor ()
G4double GetDeltaIntersectionFor ()
G4double GetEpsilonStepFor ()
G4Navigator * GetNavigatorFor ()
G4ChordFinder * GetChordFinderFor ()
void SetSafetyParametersFor (G4bool UseSafety)
void AddAdjustementOfFoundIntersection (G4bool UseCorrection)
G4bool GetAdjustementOfFoundIntersection ()
void AdjustIntersections (G4bool UseCorrection)
G4bool AreIntersectionsAdjusted ()

Protected Member Functions

G4FieldTrack ReEstimateEndpoint (const G4FieldTrack &CurrentStateA, const G4FieldTrack &EstimtdEndStateB, G4double linearDistSq, G4double curveDist)
G4ThreeVector GetSurfaceNormal (const G4ThreeVector &CurrentInt_Point, G4bool &validNormal)
G4ThreeVector GetGlobalSurfaceNormal (const G4ThreeVector &CurrentE_Point, G4bool &validNormal)
G4bool AdjustmentOfFoundIntersection (const G4ThreeVector &A, const G4ThreeVector &CurrentE_Point, const G4ThreeVector &CurrentF_Point, const G4ThreeVector &MomentumDir, const G4bool IntersectAF, G4ThreeVector &IntersectionPoint, G4double &NewSafety, G4double &fPrevSafety, G4ThreeVector &fPrevSftOrigin)
void ReportTrialStep (G4int step_no, const G4ThreeVector &ChordAB_v, const G4ThreeVector &ChordEF_v, const G4ThreeVector &NewMomentumDir, const G4ThreeVector &NormalAtEntry, G4bool validNormal)

Protected Attributes

G4double kCarTolerance
G4int fVerboseLevel
G4bool fUseNormalCorrection
G4Navigator * fiNavigator
G4ChordFinder * fiChordFinder
G4double fiEpsilonStep
G4double fiDeltaIntersection
G4bool fiUseSafety
G4Navigator * fHelpingNavigator
G4TouchableHistory * fpTouchable

Detailed Description

Definition at line 56 of file G4VIntersectionLocator.hh.


Constructor & Destructor Documentation

G4VIntersectionLocator::G4VIntersectionLocator ( G4Navigator *  theNavigator  ) 

Definition at line 46 of file G4VIntersectionLocator.cc.

References fHelpingNavigator, fVerboseLevel, G4GeometryTolerance::GetInstance(), G4GeometryTolerance::GetSurfaceTolerance(), and kCarTolerance.

00046                                                                         : 
00047   fUseNormalCorrection(false), 
00048   fiNavigator( theNavigator ),
00049   fiChordFinder( 0 ),            // Not set - overridden at each step
00050   fiEpsilonStep( -1.0 ),         // Out of range - overridden at each step
00051   fiDeltaIntersection( -1.0 ),   // Out of range - overridden at each step
00052   fiUseSafety(false),            // Default - overridden at each step
00053   fpTouchable(0)           
00054 {
00055   kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
00056   fVerboseLevel = 0;
00057   fHelpingNavigator = new G4Navigator();
00058 }      

G4VIntersectionLocator::~G4VIntersectionLocator (  )  [virtual]

Definition at line 64 of file G4VIntersectionLocator.cc.

References fHelpingNavigator, and fpTouchable.

00065 {
00066   delete fHelpingNavigator;
00067   delete fpTouchable;
00068 }


Member Function Documentation

void G4VIntersectionLocator::AddAdjustementOfFoundIntersection ( G4bool  UseCorrection  )  [inline]

Definition at line 66 of file G4VIntersectionLocator.icc.

References fUseNormalCorrection.

00067 {
00068   fUseNormalCorrection=UseCorrection;
00069 }

void G4VIntersectionLocator::AdjustIntersections ( G4bool  UseCorrection  )  [inline]

G4bool G4VIntersectionLocator::AdjustmentOfFoundIntersection ( const G4ThreeVector &  A,
const G4ThreeVector &  CurrentE_Point,
const G4ThreeVector &  CurrentF_Point,
const G4ThreeVector &  MomentumDir,
const G4bool  IntersectAF,
G4ThreeVector &  IntersectionPoint,
G4double &  NewSafety,
G4double &  fPrevSafety,
G4ThreeVector &  fPrevSftOrigin 
) [protected]

Definition at line 348 of file G4VIntersectionLocator.cc.

References fVerboseLevel, G4cerr, G4endl, GetGlobalSurfaceNormal(), GetNavigatorFor(), IntersectChord(), kCarTolerance, G4InuclParticleNames::lambda, and G4Navigator::LocateGlobalPointWithinVolume().

Referenced by G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), and G4BrentLocator::EstimateIntersectionPoint().

00357 {     
00358   G4double dist,lambda;
00359   G4ThreeVector Normal, NewPoint, Point_G;
00360   G4bool goodAdjust=false, Intersects_FP=false, validNormal=false;
00361 
00362   // Get SurfaceNormal of Intersecting Solid
00363   //
00364   Normal = GetGlobalSurfaceNormal(CurrentE_Point,validNormal);
00365   if(!validNormal) { return false; }
00366 
00367   // Intersection between Line and Plane
00368   //
00369   G4double n_d_m = Normal.dot(MomentumDir);
00370   if ( std::abs(n_d_m)>kCarTolerance )
00371   {
00372 #ifdef G4VERBOSE
00373     if ( fVerboseLevel>1 )
00374     {
00375       G4cerr << "WARNING - "
00376              << "G4VIntersectionLocator::AdjustementOfFoundIntersection()"
00377              << G4endl
00378              << "        No intersection. Parallels lines!" << G4endl;
00379     }
00380 #endif
00381     lambda =- Normal.dot(CurrentF_Point-CurrentE_Point)/n_d_m;
00382 
00383     // New candidate for Intersection
00384     //
00385     NewPoint = CurrentF_Point+lambda*MomentumDir;
00386 
00387     // Distance from CurrentF to Calculated Intersection
00388     //
00389     dist = std::abs(lambda);
00390 
00391     if ( dist<kCarTolerance*0.001 )  { return false; }
00392 
00393     // Calculation of new intersection point on the path.
00394     //
00395     if ( IntersectAF )  //  First part intersects
00396     {
00397       G4double stepLengthFP; 
00398       G4ThreeVector Point_P = CurrentA_Point;
00399       GetNavigatorFor()->LocateGlobalPointWithinVolume(Point_P);
00400       Intersects_FP = IntersectChord( Point_P, NewPoint, NewSafety,
00401                                       fPreviousSafety, fPreviousSftOrigin,
00402                                       stepLengthFP, Point_G );
00403 
00404     }
00405     else   // Second part intersects
00406     {      
00407       G4double stepLengthFP; 
00408       GetNavigatorFor()->LocateGlobalPointWithinVolume(CurrentF_Point );
00409       Intersects_FP = IntersectChord( CurrentF_Point, NewPoint, NewSafety,
00410                                       fPreviousSafety, fPreviousSftOrigin,
00411                                       stepLengthFP, Point_G );
00412     }
00413     if ( Intersects_FP )
00414     {
00415       goodAdjust = true;
00416       IntersectionPoint = Point_G;              
00417     }
00418   }
00419 
00420   return goodAdjust;
00421 }

G4bool G4VIntersectionLocator::AreIntersectionsAdjusted (  )  [inline]

Definition at line 125 of file G4VIntersectionLocator.hh.

References fUseNormalCorrection.

00125 { return fUseNormalCorrection; }  

virtual G4bool G4VIntersectionLocator::EstimateIntersectionPoint ( const G4FieldTrack &  curveStartPointTangent,
const G4FieldTrack &  curveEndPointTangent,
const G4ThreeVector &  trialPoint,
G4FieldTrack &  intersectPointTangent,
G4bool &  recalculatedEndPoint,
G4double &  fPreviousSafety,
G4ThreeVector &  fPreviousSftOrigin 
) [pure virtual]

Implemented in G4BrentLocator, G4MultiLevelLocator, and G4SimpleLocator.

G4bool G4VIntersectionLocator::GetAdjustementOfFoundIntersection (  )  [inline]

Definition at line 60 of file G4VIntersectionLocator.icc.

References fUseNormalCorrection.

Referenced by G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), and G4BrentLocator::EstimateIntersectionPoint().

00061 {
00062   return fUseNormalCorrection;
00063 }

G4ChordFinder * G4VIntersectionLocator::GetChordFinderFor (  )  [inline]

Definition at line 50 of file G4VIntersectionLocator.icc.

References fiChordFinder.

Referenced by G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), G4BrentLocator::EstimateIntersectionPoint(), and ReEstimateEndpoint().

00051 {
00052   return fiChordFinder;
00053 }

G4double G4VIntersectionLocator::GetDeltaIntersectionFor (  )  [inline]

Definition at line 35 of file G4VIntersectionLocator.icc.

References fiDeltaIntersection.

Referenced by G4BrentLocator::EstimateIntersectionPoint().

00036 {
00037   return fiDeltaIntersection;
00038 } 

G4double G4VIntersectionLocator::GetEpsilonStepFor (  )  [inline]

Definition at line 40 of file G4VIntersectionLocator.icc.

References fiEpsilonStep.

Referenced by G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), G4BrentLocator::EstimateIntersectionPoint(), and ReEstimateEndpoint().

00041 {
00042   return fiEpsilonStep;
00043 }

G4ThreeVector G4VIntersectionLocator::GetGlobalSurfaceNormal ( const G4ThreeVector &  CurrentE_Point,
G4bool &  validNormal 
) [protected]

Definition at line 467 of file G4VIntersectionLocator.cc.

References fHelpingNavigator, G4endl, G4Exception(), G4Navigator::GetLocalToGlobalTransform(), JustWarning, G4AffineTransform::NetRotation(), G4AffineTransform::NetTranslation(), and G4AffineTransform::TransformAxis().

Referenced by AdjustmentOfFoundIntersection().

00469 {
00470   G4ThreeVector     localNormal=
00471       GetLocalSurfaceNormal( CurrentE_Point, validNormal );
00472   G4AffineTransform localToGlobal=           //  Must use the same Navigator !!
00473       fHelpingNavigator->GetLocalToGlobalTransform();
00474   G4ThreeVector     globalNormal =
00475     localToGlobal.TransformAxis( localNormal );
00476 
00477 #ifdef G4DEBUG_FIELD
00478   if( validNormal && ( std::fabs(globalNormal.mag2() - 1.0) > perThousand ) ) 
00479   {
00480     std::ostringstream message; 
00481     message << "**************************************************************"
00482             << G4endl;
00483     message << " Bad Normal in G4VIntersectionLocator::GetGlobalSurfaceNormal "
00484             << G4endl;
00485     message << "  * Constituents: " << G4endl;
00486     message << "    Local  Normal= " << localNormal << G4endl;
00487     message << "    Transform: " << G4endl
00488             << "      Net Translation= " << localToGlobal.NetTranslation()
00489             << G4endl
00490             << "      Net Rotation   = " << localToGlobal.NetRotation()
00491             << G4endl;
00492     message << "  * Result: " << G4endl;
00493     message << "     Global Normal= " << localNormal << G4endl;
00494     message << "**************************************************************"
00495             << G4endl;
00496     G4Exception("G4VIntersectionLocator::GetGlobalSurfaceNormal()",
00497                 "GeomNav1002", JustWarning, message);
00498   }
00499 #endif
00500 
00501   return globalNormal;
00502 }

G4Navigator * G4VIntersectionLocator::GetNavigatorFor (  )  [inline]

Definition at line 45 of file G4VIntersectionLocator.icc.

References fiNavigator.

Referenced by AdjustmentOfFoundIntersection(), G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), G4BrentLocator::EstimateIntersectionPoint(), and IntersectChord().

00046 {
00047   return fiNavigator;
00048 }

G4ThreeVector G4VIntersectionLocator::GetSurfaceNormal ( const G4ThreeVector &  CurrentInt_Point,
G4bool &  validNormal 
) [protected]

Definition at line 424 of file G4VIntersectionLocator.cc.

References G4endl, G4Exception(), and JustWarning.

Referenced by G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), and G4BrentLocator::EstimateIntersectionPoint().

00426 {
00427   G4ThreeVector NormalAtEntry; // ( -10. , -10., -10. ); 
00428 
00429   G4ThreeVector NormalAtEntryLast, NormalAtEntryGlobal, diffNormals;
00430   G4bool validNormalLast; 
00431 
00432   // Relies on a call to Navigator::ComputeStep in IntersectChord before
00433   // this call
00434   //
00435   NormalAtEntryLast = GetLastSurfaceNormal( CurrentInt_Point, validNormalLast );
00436     // May return valid=false in cases, including
00437     //  - if the candidate volume was not found (eg exiting world), or
00438     //  - a replica was involved -- determined the step size.
00439     // (This list is not complete.) 
00440 
00441 #ifdef G4DEBUG_FIELD
00442   if  ( validNormalLast
00443    && ( std::fabs(NormalAtEntryLast.mag2() - 1.0) > perThousand ) )
00444   {
00445     std::ostringstream message; 
00446     message << "G4VIntersectionLocator::GetSurfaceNormal -- identified problem."
00447             << G4endl;
00448     message << "PROBLEM: Normal is not unit - magnitude = "
00449             << NormalAtEntryLast.mag() << G4endl; 
00450     message << "   at trial intersection point " << CurrentInt_Point << G4endl;
00451     message << "   Obtained from Get *Last* Surface Normal." << G4endl; 
00452     G4Exception("G4VIntersectionLocator::GetGlobalSurfaceNormal()",
00453                 "GeomNav1002", JustWarning, message);
00454   }
00455 #endif
00456 
00457   if( validNormalLast ) 
00458   {
00459     NormalAtEntry=NormalAtEntryLast;  
00460   }
00461   validNormal  = validNormalLast;
00462 
00463   return NormalAtEntry;
00464 }

G4int G4VIntersectionLocator::GetVerboseFor (  )  [inline]

Definition at line 55 of file G4VIntersectionLocator.icc.

References fVerboseLevel.

00056 {
00057   return fVerboseLevel;
00058 }

G4bool G4VIntersectionLocator::IntersectChord ( const G4ThreeVector &  StartPointA,
const G4ThreeVector &  EndPointB,
G4double &  NewSafety,
G4double &  PreviousSafety,
G4ThreeVector &  PreviousSftOrigin,
G4double &  LinearStepLength,
G4ThreeVector &  IntersectionPoint,
G4bool *  calledNavigator = 0 
) [inline]

Definition at line 103 of file G4VIntersectionLocator.icc.

References G4Navigator::ComputeStep(), fiUseSafety, GetNavigatorFor(), and sqr().

Referenced by AdjustmentOfFoundIntersection(), G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), G4BrentLocator::EstimateIntersectionPoint(), and G4PropagatorInField::IntersectChord().

00111 {
00112   G4bool CalledNavigator = false; 
00113 
00114   // Calculate the direction and length of the chord AB
00115 
00116   G4ThreeVector  ChordAB_Vector = EndPointB - StartPointA;
00117   G4double       ChordAB_Length = ChordAB_Vector.mag();  // Magnitude (norm)
00118   G4ThreeVector  ChordAB_Dir =    ChordAB_Vector.unit();
00119   G4bool intersects;
00120   G4ThreeVector OriginShift = StartPointA -  PreviousSftOrigin ;
00121   G4double      MagSqShift  = OriginShift.mag2() ;
00122   G4double      currentSafety;
00123 
00124   if( MagSqShift >= sqr(PreviousSafety) )
00125   {
00126     currentSafety = 0.0 ;
00127   }
00128   else
00129   {
00130     currentSafety = PreviousSafety - std::sqrt(MagSqShift) ;
00131   }
00132 
00133   if( fiUseSafety && (ChordAB_Length <= currentSafety) )
00134   {
00135     // The Step is guaranteed to be taken
00136 
00137     LinearStepLength = ChordAB_Length;
00138     intersects = false;
00139     NewSafety= currentSafety;
00140     CalledNavigator= false;
00141     // G4cout << " IntersectChord> Step 'guaranteed' taken:  safety= " << currentSafety << " chordAB-len= " << ChordAB_Length << G4endl;
00142   }
00143   else
00144   {
00145     // G4cout << " IntersectChord> Step asking Navigator:    safety= " << currentSafety << " chordAB-len= " << ChordAB_Length << G4endl;
00146     
00147     // Check whether any volumes are encountered by the chord AB
00148 
00149     LinearStepLength = GetNavigatorFor()->ComputeStep( StartPointA,
00150                                  ChordAB_Dir, ChordAB_Length, NewSafety );
00151     intersects = (LinearStepLength <= ChordAB_Length); 
00152        // G4Navigator contracts to return k_infinity if len==asked
00153        // and it did not find a surface boundary at that length
00154     
00155     // G4cout << "G4VIntersectionLocator:  intersect= " << intersects
00156     //       << " step= " << LinearStepLength << " Chord length= " << ChordAB_Length;
00157 
00158     LinearStepLength = std::min( LinearStepLength, ChordAB_Length);
00159     CalledNavigator = true; 
00160 
00161     // Save the last calculated safety!
00162 
00163     PreviousSftOrigin = StartPointA;
00164     PreviousSafety    = NewSafety;
00165 
00166     if( intersects )
00167     {
00168        // Intersection Point of chord AB and either volume A's surface 
00169        //                                or a daughter volume's surface ..
00170        IntersectionPoint = StartPointA + LinearStepLength * ChordAB_Dir;
00171     }
00172   }
00173   if( ptrCalledNavigator )
00174   { 
00175     *ptrCalledNavigator = CalledNavigator; 
00176   }
00177 
00178   return intersects;
00179 }

void G4VIntersectionLocator::printStatus ( const G4FieldTrack &  startFT,
const G4FieldTrack &  currentFT,
G4double  requestStep,
G4double  safety,
G4int  step 
)

Definition at line 75 of file G4VIntersectionLocator.cc.

References fVerboseLevel, G4cout, G4endl, G4FieldTrack::GetCurveLength(), G4FieldTrack::GetMomentum(), G4FieldTrack::GetMomentumDir(), and G4FieldTrack::GetPosition().

Referenced by G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), and G4BrentLocator::EstimateIntersectionPoint().

00080 {
00081   const G4int verboseLevel= fVerboseLevel;
00082   const G4ThreeVector StartPosition       = StartFT.GetPosition();
00083   const G4ThreeVector StartUnitVelocity   = StartFT.GetMomentumDir();
00084   const G4ThreeVector CurrentPosition     = CurrentFT.GetPosition();
00085   const G4ThreeVector CurrentUnitVelocity = CurrentFT.GetMomentumDir();
00086 
00087   G4double step_len = CurrentFT.GetCurveLength() - StartFT.GetCurveLength();
00088   G4int oldprc;  // cout/cerr precision settings
00089 
00090   if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
00091   {
00092     oldprc = G4cout.precision(4);
00093     G4cout << std::setw( 6)  << " " 
00094            << std::setw( 25) << " Current Position  and  Direction" << " "
00095            << G4endl; 
00096     G4cout << std::setw( 5) << "Step#" 
00097            << std::setw(10) << "  s  " << " "
00098            << std::setw(10) << "X(mm)" << " "
00099            << std::setw(10) << "Y(mm)" << " "  
00100            << std::setw(10) << "Z(mm)" << " "
00101            << std::setw( 7) << " N_x " << " "
00102            << std::setw( 7) << " N_y " << " "
00103            << std::setw( 7) << " N_z " << " " ;
00104     G4cout << std::setw( 7) << " Delta|N|" << " "
00105            << std::setw( 9) << "StepLen" << " "  
00106            << std::setw(12) << "StartSafety" << " "  
00107            << std::setw( 9) << "PhsStep" << " ";  
00108     G4cout << G4endl;
00109     G4cout.precision(oldprc);
00110   }
00111   if((stepNo == 0) && (verboseLevel <=3))
00112   {
00113     // Recurse to print the start values
00114     //
00115     printStatus( StartFT, StartFT, -1.0, safety, -1);
00116   }
00117   if( verboseLevel <= 3 )
00118   {
00119     if( stepNo >= 0)
00120     {
00121        G4cout << std::setw( 4) << stepNo << " ";
00122     }
00123     else
00124     {
00125        G4cout << std::setw( 5) << "Start" ;
00126     }
00127     oldprc = G4cout.precision(8);
00128     G4cout << std::setw(10) << CurrentFT.GetCurveLength() << " "; 
00129     G4cout << std::setw(10) << CurrentPosition.x() << " "
00130            << std::setw(10) << CurrentPosition.y() << " "
00131            << std::setw(10) << CurrentPosition.z() << " ";
00132     G4cout.precision(4);
00133     G4cout << std::setw( 7) << CurrentUnitVelocity.x() << " "
00134            << std::setw( 7) << CurrentUnitVelocity.y() << " "
00135            << std::setw( 7) << CurrentUnitVelocity.z() << " ";
00136     G4cout.precision(3); 
00137     G4cout << std::setw( 7)
00138            << CurrentFT.GetMomentum().mag()- StartFT.GetMomentum().mag()
00139            << " "; 
00140     G4cout << std::setw( 9) << step_len << " "; 
00141     G4cout << std::setw(12) << safety << " ";
00142     if( requestStep != -1.0 )
00143     {
00144       G4cout << std::setw( 9) << requestStep << " ";
00145     }
00146     else
00147     {
00148       G4cout << std::setw( 9) << "Init/NotKnown" << " "; 
00149     }
00150     G4cout << G4endl;
00151     G4cout.precision(oldprc);
00152   }
00153   else // if( verboseLevel > 3 )
00154   {
00155     //  Multi-line output
00156        
00157     G4cout << "Step taken was " << step_len  
00158            << " out of PhysicalStep= " <<  requestStep << G4endl;
00159     G4cout << "Final safety is: " << safety << G4endl;
00160     G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
00161            << G4endl;
00162     G4cout << G4endl; 
00163   }
00164 }

G4FieldTrack G4VIntersectionLocator::ReEstimateEndpoint ( const G4FieldTrack &  CurrentStateA,
const G4FieldTrack &  EstimtdEndStateB,
G4double  linearDistSq,
G4double  curveDist 
) [protected]

Definition at line 171 of file G4VIntersectionLocator.cc.

References G4MagInt_Driver::AccurateAdvance(), fVerboseLevel, G4cerr, G4cout, G4endl, GetChordFinderFor(), G4FieldTrack::GetCurveLength(), GetEpsilonStepFor(), G4ChordFinder::GetIntegrationDriver(), G4FieldTrack::GetPosition(), and kCarTolerance.

Referenced by G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), and G4BrentLocator::EstimateIntersectionPoint().

00175 {  
00176   G4FieldTrack newEndPoint( CurrentStateA );
00177   G4MagInt_Driver* integrDriver= GetChordFinderFor()->GetIntegrationDriver(); 
00178 
00179   G4FieldTrack retEndPoint( CurrentStateA );
00180   G4bool goodAdvance;
00181   G4int  itrial=0;
00182   const G4int no_trials= 20;
00183 
00184   G4double endCurveLen= EstimatedEndStateB.GetCurveLength();
00185   do
00186   {
00187      G4double currentCurveLen= newEndPoint.GetCurveLength();
00188      G4double advanceLength= endCurveLen - currentCurveLen ; 
00189      if (std::abs(advanceLength)<kCarTolerance)
00190      {
00191        goodAdvance=true;
00192      }
00193      else{
00194      goodAdvance= 
00195        integrDriver->AccurateAdvance(newEndPoint, advanceLength,
00196                                      GetEpsilonStepFor());
00197      }
00198   }
00199   while( !goodAdvance && (++itrial < no_trials) );
00200 
00201   if( goodAdvance )
00202   {
00203     retEndPoint= newEndPoint; 
00204   }
00205   else
00206   {
00207     retEndPoint= EstimatedEndStateB; // Could not improve without major work !!
00208   }
00209 
00210   //  All the work is done
00211   //  below are some diagnostics only -- before the return!
00212   // 
00213   static const G4String MethodName("G4VIntersectionLocator::ReEstimateEndpoint");
00214 
00215 #ifdef G4VERBOSE
00216   G4int  latest_good_trials=0;
00217   if( itrial > 1)
00218   {
00219     if( fVerboseLevel > 0 )
00220     {
00221       G4cout << MethodName << " called - goodAdv= " << goodAdvance
00222              << " trials = " << itrial
00223              << " previous good= " << latest_good_trials
00224              << G4endl;
00225     }
00226     latest_good_trials=0; 
00227   }
00228   else
00229   {   
00230     latest_good_trials++; 
00231   }
00232 #endif
00233 
00234 #ifdef G4DEBUG_FIELD
00235   G4double lengthDone = newEndPoint.GetCurveLength() 
00236                       - CurrentStateA.GetCurveLength(); 
00237   if( !goodAdvance )
00238   {
00239     if( fVerboseLevel >= 3 )
00240     {
00241       G4cout << MethodName << "> AccurateAdvance failed " ;
00242       G4cout << " in " << itrial << " integration trials/steps. " << G4endl;
00243       G4cout << " It went only " << lengthDone << " instead of " << curveDist
00244              << " -- a difference of " << curveDist - lengthDone  << G4endl;
00245       G4cout << " ReEstimateEndpoint> Reset endPoint to original value!"
00246              << G4endl;
00247     }
00248   }
00249 
00250   static G4int noInaccuracyWarnings = 0; 
00251   G4int maxNoWarnings = 10;
00252   if (  (noInaccuracyWarnings < maxNoWarnings ) 
00253        || (fVerboseLevel > 1) )
00254     {
00255       G4cerr << "G4PropagatorInField::LocateIntersectionPoint():"
00256              << G4endl
00257              << " Warning: Integration inaccuracy requires" 
00258              <<   " an adjustment in the step's endpoint."  << G4endl
00259              << "   Two mid-points are further apart than their"
00260              <<   " curve length difference"                << G4endl 
00261              << "   Dist = "       << std::sqrt(linearDistSq)
00262              << " curve length = " << curveDist             << G4endl; 
00263       G4cerr << " Correction applied is " 
00264              << (newEndPoint.GetPosition()-EstimatedEndStateB.GetPosition()).mag()
00265              << G4endl;
00266     }
00267 #else
00268   // Statistics on the RMS value of the corrections
00269 
00270   static G4int    noCorrections=0;
00271   static G4double sumCorrectionsSq = 0;
00272   noCorrections++; 
00273   if( goodAdvance )
00274   {
00275     sumCorrectionsSq += (EstimatedEndStateB.GetPosition() - 
00276                          newEndPoint.GetPosition()).mag2();
00277   }
00278   linearDistSq -= curveDist; // To use linearDistSq ... !
00279 #endif
00280 
00281   return retEndPoint;
00282 }

void G4VIntersectionLocator::ReportTrialStep ( G4int  step_no,
const G4ThreeVector &  ChordAB_v,
const G4ThreeVector &  ChordEF_v,
const G4ThreeVector &  NewMomentumDir,
const G4ThreeVector &  NormalAtEntry,
G4bool  validNormal 
) [protected]

Definition at line 516 of file G4VIntersectionLocator.cc.

References G4cerr, G4cout, and G4endl.

Referenced by G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), and G4BrentLocator::EstimateIntersectionPoint().

00522 {
00523   G4double       ABchord_length  = ChordAB_v.mag(); 
00524   G4double       MomDir_dot_Norm = NewMomentumDir.dot( NormalAtEntry ) ;
00525   G4double       MomDir_dot_ABchord;
00526   MomDir_dot_ABchord= (1.0 / ABchord_length) * NewMomentumDir.dot( ChordAB_v );
00527 
00528   std::ostringstream  outStream; 
00529   outStream // G4cout 
00530     << std::setw(6)  << " Step# "
00531     << std::setw(17) << " |ChordEF|(mag)" << "  "
00532     << std::setw(18) << " uMomentum.Normal" << "  "
00533     << std::setw(18) << " uMomentum.ABdir " << "  " 
00534     << std::setw(16) << " AB-dist         " << " " 
00535     << " Chord Vector (EF) " 
00536     << G4endl;
00537   outStream.precision(7); 
00538   outStream  // G4cout 
00539     << " " << std::setw(5)  << step_no           
00540     << " " << std::setw(18) << ChordEF_v.mag() 
00541     << " " << std::setw(18) << MomDir_dot_Norm    
00542     << " " << std::setw(18) << MomDir_dot_ABchord 
00543     << " " << std::setw(12) << ABchord_length     
00544     << " " << ChordEF_v
00545     << G4endl;
00546   outStream  // G4cout
00547     << " MomentumDir= " << " " << NewMomentumDir 
00548     << " Normal at Entry E= " << NormalAtEntry
00549     << " AB chord =   " << ChordAB_v
00550     << G4endl;
00551   G4cout << outStream.str();  // ostr_verbose;
00552 
00553   if( ( std::fabs(NormalAtEntry.mag2() - 1.0) > perThousand ) ) 
00554   {
00555     G4cerr << " PROBLEM in G4VIntersectionLocator::ReportTrialStep " << G4endl
00556            << "         Normal is not unit - mag=" <<  NormalAtEntry.mag() 
00557            << "         ValidNormalAtE = " << validNormal
00558            << G4endl; 
00559   }
00560   return; 
00561 }

void G4VIntersectionLocator::SetChordFinderFor ( G4ChordFinder *  fCFinder  )  [inline]

Definition at line 87 of file G4VIntersectionLocator.icc.

References fiChordFinder.

Referenced by G4PropagatorInField::RefreshIntersectionLocator().

00088 {
00089   fiChordFinder=fCFinder;
00090 }

void G4VIntersectionLocator::SetDeltaIntersectionFor ( G4double  deltaIntersection  )  [inline]

Definition at line 77 of file G4VIntersectionLocator.icc.

References fiDeltaIntersection.

Referenced by G4PropagatorInField::RefreshIntersectionLocator().

00078 {
00079   fiDeltaIntersection=deltaIntersection;
00080 }

void G4VIntersectionLocator::SetEpsilonStepFor ( G4double  EpsilonStep  )  [inline]

Definition at line 71 of file G4VIntersectionLocator.icc.

References fiEpsilonStep.

Referenced by G4PropagatorInField::RefreshIntersectionLocator().

00072 {
00073   fiEpsilonStep=EpsilonStep;
00074 }

void G4VIntersectionLocator::SetNavigatorFor ( G4Navigator *  fNavigator  )  [inline]

Definition at line 82 of file G4VIntersectionLocator.icc.

References fiNavigator.

Referenced by G4PropagatorInField::SetNavigatorForPropagating().

00083 {
00084   fiNavigator=fNavigator;
00085 }

void G4VIntersectionLocator::SetSafetyParametersFor ( G4bool  UseSafety  )  [inline]

Definition at line 92 of file G4VIntersectionLocator.icc.

References fiUseSafety.

Referenced by G4PropagatorInField::RefreshIntersectionLocator().

00093 {
00094   fiUseSafety=UseSafety;
00095 }

void G4VIntersectionLocator::SetVerboseFor ( G4int  fVerbose  )  [inline]

Definition at line 97 of file G4VIntersectionLocator.icc.

References fVerboseLevel.

00098 {
00099   fVerboseLevel=fVerbose;
00100 }


Field Documentation

G4Navigator* G4VIntersectionLocator::fHelpingNavigator [protected]

Definition at line 203 of file G4VIntersectionLocator.hh.

Referenced by G4VIntersectionLocator(), GetGlobalSurfaceNormal(), and ~G4VIntersectionLocator().

G4ChordFinder* G4VIntersectionLocator::fiChordFinder [protected]

Definition at line 196 of file G4VIntersectionLocator.hh.

Referenced by GetChordFinderFor(), and SetChordFinderFor().

G4double G4VIntersectionLocator::fiDeltaIntersection [protected]

Definition at line 198 of file G4VIntersectionLocator.hh.

Referenced by G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), G4BrentLocator::EstimateIntersectionPoint(), GetDeltaIntersectionFor(), and SetDeltaIntersectionFor().

G4double G4VIntersectionLocator::fiEpsilonStep [protected]

Definition at line 197 of file G4VIntersectionLocator.hh.

Referenced by GetEpsilonStepFor(), and SetEpsilonStepFor().

G4Navigator* G4VIntersectionLocator::fiNavigator [protected]

Definition at line 194 of file G4VIntersectionLocator.hh.

Referenced by GetNavigatorFor(), and SetNavigatorFor().

G4bool G4VIntersectionLocator::fiUseSafety [protected]

Definition at line 199 of file G4VIntersectionLocator.hh.

Referenced by IntersectChord(), and SetSafetyParametersFor().

G4TouchableHistory* G4VIntersectionLocator::fpTouchable [protected]

Definition at line 206 of file G4VIntersectionLocator.hh.

Referenced by ~G4VIntersectionLocator().

G4bool G4VIntersectionLocator::fUseNormalCorrection [protected]

Definition at line 192 of file G4VIntersectionLocator.hh.

Referenced by AddAdjustementOfFoundIntersection(), AreIntersectionsAdjusted(), and GetAdjustementOfFoundIntersection().

G4int G4VIntersectionLocator::fVerboseLevel [protected]

Definition at line 191 of file G4VIntersectionLocator.hh.

Referenced by AdjustmentOfFoundIntersection(), G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), G4BrentLocator::EstimateIntersectionPoint(), G4VIntersectionLocator(), GetVerboseFor(), printStatus(), ReEstimateEndpoint(), SetVerboseFor(), and G4BrentLocator::~G4BrentLocator().

G4double G4VIntersectionLocator::kCarTolerance [protected]

Definition at line 189 of file G4VIntersectionLocator.hh.

Referenced by AdjustmentOfFoundIntersection(), G4SimpleLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), G4BrentLocator::EstimateIntersectionPoint(), G4VIntersectionLocator(), and ReEstimateEndpoint().


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:44 2013 for Geant4 by  doxygen 1.4.7