00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "G4ErrorPropagationNavigator.hh"
00035
00036 #include "globals.hh"
00037 #include "G4ThreeVector.hh"
00038 #include "G4ErrorPropagatorData.hh"
00039 #include "G4ErrorSurfaceTarget.hh"
00040
00041
00042
00043 G4ErrorPropagationNavigator::G4ErrorPropagationNavigator()
00044 : G4Navigator()
00045 {
00046 }
00047
00048
00049
00050 G4ErrorPropagationNavigator::~G4ErrorPropagationNavigator()
00051 {
00052 }
00053
00054
00055
00056 G4double G4ErrorPropagationNavigator::
00057 ComputeStep ( const G4ThreeVector &pGlobalPoint,
00058 const G4ThreeVector &pDirection,
00059 const G4double pCurrentProposedStepLength,
00060 G4double &pNewSafety )
00061 {
00062 G4double Step = G4Navigator::ComputeStep(pGlobalPoint, pDirection,
00063 pCurrentProposedStepLength,
00064 pNewSafety);
00065
00066 G4ErrorPropagatorData * g4edata
00067 = G4ErrorPropagatorData::GetErrorPropagatorData();
00068
00069 if (g4edata !=0)
00070 {
00071 const G4ErrorTarget* target = g4edata->GetTarget();
00072 if( target != 0 )
00073 {
00074 G4double StepPlane= target->GetDistanceFromPoint(pGlobalPoint,pDirection);
00075
00076 if( StepPlane < 0. )
00077 {
00078 StepPlane = DBL_MAX;
00079 }
00080 #ifdef G4VERBOSE
00081 if( G4ErrorPropagatorData::verbose() >= 4 )
00082 {
00083 G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl
00084 << " Target step: " << StepPlane
00085 << ", Transportation step: " << Step << G4endl;
00086 target->Dump( "G4ErrorPropagationNavigator::ComputeStep Target " );
00087 }
00088 #endif
00089
00090 if(StepPlane<Step)
00091 {
00092 #ifdef G4VERBOSE
00093 if( G4ErrorPropagatorData::verbose() >= 2 )
00094 {
00095 G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl
00096 << " TargetCloserThanBoundary: " << StepPlane << " < "
00097 << Step << G4endl;
00098 }
00099 #endif
00100 Step = StepPlane;
00101 g4edata->SetState(G4ErrorState_TargetCloserThanBoundary);
00102 }
00103 else
00104 {
00105 g4edata->SetState(G4ErrorState_Propagating);
00106 }
00107 }
00108 }
00109 pNewSafety = ComputeSafety(pGlobalPoint, pCurrentProposedStepLength);
00110
00111 #ifdef G4VERBOSE
00112 if( G4ErrorPropagatorData::verbose() >= 3 )
00113 {
00114 G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl
00115 << " Step: " << Step << ", ComputeSafety: " << pNewSafety
00116 << G4endl;
00117 }
00118 #endif
00119
00120 return Step;
00121 }
00122
00123
00124
00125 G4double G4ErrorPropagationNavigator::
00126 ComputeSafety( const G4ThreeVector &pGlobalpoint,
00127 const G4double pMaxLength,
00128 const G4bool keepState )
00129 {
00130 G4double newSafety = G4Navigator::ComputeSafety(pGlobalpoint,
00131 pMaxLength, keepState);
00132
00133 G4ErrorPropagatorData *g4edata
00134 = G4ErrorPropagatorData::GetErrorPropagatorData();
00135
00136 if (g4edata !=0)
00137 {
00138 const G4ErrorTarget* target = g4edata->GetTarget();
00139 if( target != 0 )
00140 {
00141 G4double distance = target->GetDistanceFromPoint(pGlobalpoint);
00142
00143 if(distance<newSafety)
00144 {
00145 newSafety = distance;
00146 }
00147 }
00148 }
00149 return newSafety;
00150 }