47 fUseNormalCorrection(false),
48 fiNavigator( theNavigator ),
50 fiEpsilonStep( -1.0 ),
51 fiDeltaIntersection( -1.0 ),
90 if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
92 oldprc =
G4cout.precision(4);
93 G4cout << std::setw( 6) <<
" "
94 << std::setw( 25) <<
" Current Position and Direction" <<
" "
96 G4cout << std::setw( 5) <<
"Step#"
97 << std::setw(10) <<
" s " <<
" "
98 << std::setw(10) <<
"X(mm)" <<
" "
99 << std::setw(10) <<
"Y(mm)" <<
" "
100 << std::setw(10) <<
"Z(mm)" <<
" "
101 << std::setw( 7) <<
" N_x " <<
" "
102 << std::setw( 7) <<
" N_y " <<
" "
103 << std::setw( 7) <<
" N_z " <<
" " ;
104 G4cout << std::setw( 7) <<
" Delta|N|" <<
" "
105 << std::setw( 9) <<
"StepLen" <<
" "
106 << std::setw(12) <<
"StartSafety" <<
" "
107 << std::setw( 9) <<
"PhsStep" <<
" ";
111 if((stepNo == 0) && (verboseLevel <=3))
117 if( verboseLevel <= 3 )
121 G4cout << std::setw( 4) << stepNo <<
" ";
125 G4cout << std::setw( 5) <<
"Start" ;
127 oldprc =
G4cout.precision(8);
129 G4cout << std::setw(10) << CurrentPosition.
x() <<
" "
130 << std::setw(10) << CurrentPosition.
y() <<
" "
131 << std::setw(10) << CurrentPosition.
z() <<
" ";
133 G4cout << std::setw( 7) << CurrentUnitVelocity.
x() <<
" "
134 << std::setw( 7) << CurrentUnitVelocity.
y() <<
" "
135 << std::setw( 7) << CurrentUnitVelocity.
z() <<
" ";
140 G4cout << std::setw( 9) << step_len <<
" ";
141 G4cout << std::setw(12) << safety <<
" ";
142 if( requestStep != -1.0 )
144 G4cout << std::setw( 9) << requestStep <<
" ";
148 G4cout << std::setw( 9) <<
"Init/NotKnown" <<
" ";
157 G4cout <<
"Step taken was " << step_len
158 <<
" out of PhysicalStep= " << requestStep <<
G4endl;
160 G4cout <<
"Chord length = " << (CurrentPosition-StartPosition).mag()
182 const G4int no_trials= 20;
188 G4double advanceLength= endCurveLen - currentCurveLen ;
199 while( !goodAdvance && (++itrial < no_trials) );
203 retEndPoint= newEndPoint;
207 retEndPoint= EstimatedEndStateB;
213 static const G4String MethodName(
"G4VIntersectionLocator::ReEstimateEndpoint");
216 G4int latest_good_trials=0;
221 G4cout << MethodName <<
" called - goodAdv= " << goodAdvance
222 <<
" trials = " << itrial
223 <<
" previous good= " << latest_good_trials
226 latest_good_trials=0;
230 latest_good_trials++;
241 G4cout << MethodName <<
"> AccurateAdvance failed " ;
242 G4cout <<
" in " << itrial <<
" integration trials/steps. " <<
G4endl;
243 G4cout <<
" It went only " << lengthDone <<
" instead of " << curveDist
244 <<
" -- a difference of " << curveDist - lengthDone <<
G4endl;
245 G4cout <<
" ReEstimateEndpoint> Reset endPoint to original value!"
250 static G4int noInaccuracyWarnings = 0;
251 G4int maxNoWarnings = 10;
252 if ( (noInaccuracyWarnings < maxNoWarnings )
255 G4cerr <<
"G4PropagatorInField::LocateIntersectionPoint():"
257 <<
" Warning: Integration inaccuracy requires"
258 <<
" an adjustment in the step's endpoint." <<
G4endl
259 <<
" Two mid-points are further apart than their"
260 <<
" curve length difference" <<
G4endl
261 <<
" Dist = " << std::sqrt(linearDistSq)
262 <<
" curve length = " << curveDist <<
G4endl;
263 G4cerr <<
" Correction applied is "
275 sumCorrectionsSq += (EstimatedEndStateB.
GetPosition() -
278 linearDistSq -= curveDist;
315 if( (pLogical != 0) && ( (pSolid=pLogical->
GetSolid()) !=0 ) )
327 if( std::fabs(Normal.mag2() - 1.0 ) > perMille)
329 G4cerr <<
"PROBLEM in G4VIntersectionLocator::GetLocalSurfaceNormal."
331 G4cerr <<
" Normal is not unit - mag=" << Normal.mag() <<
G4endl;
332 G4cerr <<
" at trial local point " << CurrentE_Point <<
G4endl;
360 G4bool goodAdjust=
false, Intersects_FP=
false, validNormal=
false;
365 if(!validNormal) {
return false; }
376 <<
"G4VIntersectionLocator::AdjustementOfFoundIntersection()"
378 <<
" No intersection. Parallels lines!" <<
G4endl;
381 lambda =- Normal.
dot(CurrentF_Point-CurrentE_Point)/n_d_m;
385 NewPoint = CurrentF_Point+lambda*MomentumDir;
389 dist = std::abs(lambda);
401 fPreviousSafety, fPreviousSftOrigin,
402 stepLengthFP, Point_G );
409 Intersects_FP =
IntersectChord( CurrentF_Point, NewPoint, NewSafety,
410 fPreviousSafety, fPreviousSftOrigin,
411 stepLengthFP, Point_G );
416 IntersectionPoint = Point_G;
429 G4ThreeVector NormalAtEntryLast, NormalAtEntryGlobal, diffNormals;
435 NormalAtEntryLast = GetLastSurfaceNormal( CurrentInt_Point, validNormalLast );
445 std::ostringstream message;
446 message <<
"G4VIntersectionLocator::GetSurfaceNormal -- identified problem."
448 message <<
"PROBLEM: Normal is not unit - magnitude = "
450 message <<
" at trial intersection point " << CurrentInt_Point <<
G4endl;
451 message <<
" Obtained from Get *Last* Surface Normal." <<
G4endl;
452 G4Exception(
"G4VIntersectionLocator::GetGlobalSurfaceNormal()",
457 if( validNormalLast )
459 NormalAtEntry=NormalAtEntryLast;
461 validNormal = validNormalLast;
463 return NormalAtEntry;
471 GetLocalSurfaceNormal( CurrentE_Point, validNormal );
478 if( validNormal && ( std::fabs(globalNormal.
mag2() - 1.0) >
perThousand ) )
480 std::ostringstream message;
481 message <<
"**************************************************************"
483 message <<
" Bad Normal in G4VIntersectionLocator::GetGlobalSurfaceNormal "
485 message <<
" * Constituents: " <<
G4endl;
486 message <<
" Local Normal= " << localNormal <<
G4endl;
487 message <<
" Transform: " << G4endl
490 <<
" Net Rotation = " << localToGlobal.
NetRotation()
492 message <<
" * Result: " <<
G4endl;
493 message <<
" Global Normal= " << localNormal <<
G4endl;
494 message <<
"**************************************************************"
496 G4Exception(
"G4VIntersectionLocator::GetGlobalSurfaceNormal()",
505 G4VIntersectionLocator::GetLastSurfaceNormal(
const G4ThreeVector& intersectPoint,
506 G4bool& normalIsValid)
const
511 normalIsValid= validNorm;
524 G4double MomDir_dot_Norm = NewMomentumDir.
dot( NormalAtEntry ) ;
526 MomDir_dot_ABchord= (1.0 / ABchord_length) * NewMomentumDir.
dot( ChordAB_v );
528 std::ostringstream outStream;
530 << std::setw(6) <<
" Step# "
531 << std::setw(17) <<
" |ChordEF|(mag)" <<
" "
532 << std::setw(18) <<
" uMomentum.Normal" <<
" "
533 << std::setw(18) <<
" uMomentum.ABdir " <<
" "
534 << std::setw(16) <<
" AB-dist " <<
" "
535 <<
" Chord Vector (EF) "
537 outStream.precision(7);
539 <<
" " << std::setw(5) << step_no
540 <<
" " << std::setw(18) << ChordEF_v.
mag()
541 <<
" " << std::setw(18) << MomDir_dot_Norm
542 <<
" " << std::setw(18) << MomDir_dot_ABchord
543 <<
" " << std::setw(12) << ABchord_length
547 <<
" MomentumDir= " <<
" " << NewMomentumDir
548 <<
" Normal at Entry E= " << NormalAtEntry
549 <<
" AB chord = " << ChordAB_v
551 G4cout << outStream.str();
555 G4cerr <<
" PROBLEM in G4VIntersectionLocator::ReportTrialStep " << G4endl
556 <<
" Normal is not unit - mag=" << NormalAtEntry.
mag()
557 <<
" ValidNormalAtE = " << validNormal
G4FieldTrack ReEstimateEndpoint(const G4FieldTrack &CurrentStateA, const G4FieldTrack &EstimtdEndStateB, G4double linearDistSq, G4double curveDist)
G4double GetCurveLength() const
CLHEP::Hep3Vector G4ThreeVector
double dot(const Hep3Vector &) const
G4ThreeVector GetGlobalSurfaceNormal(const G4ThreeVector &CurrentE_Point, G4bool &validNormal)
G4ThreeVector GetSurfaceNormal(const G4ThreeVector &CurrentInt_Point, G4bool &validNormal)
G4bool IntersectChord(const G4ThreeVector &StartPointA, const G4ThreeVector &EndPointB, G4double &NewSafety, G4double &PreviousSafety, G4ThreeVector &PreviousSftOrigin, G4double &LinearStepLength, G4ThreeVector &IntersectionPoint, G4bool *calledNavigator=0)
G4double GetSurfaceTolerance() const
const G4ThreeVector & GetMomentumDir() const
G4Navigator * fiNavigator
const G4AffineTransform GetLocalToGlobalTransform() const
G4double GetEpsilonStepFor()
G4ThreeVector GetPosition() const
G4GLOB_DLL std::ostream G4cout
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual ~G4VIntersectionLocator()
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
void ReportTrialStep(G4int step_no, const G4ThreeVector &ChordAB_v, const G4ThreeVector &ChordEF_v, const G4ThreeVector &NewMomentumDir, const G4ThreeVector &NormalAtEntry, G4bool validNormal)
G4Navigator * GetNavigatorFor()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4TouchableHistory * CreateTouchableHistory() const
G4LogicalVolume * GetLogicalVolume() const
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
G4Navigator * fHelpingNavigator
G4VIntersectionLocator(G4Navigator *theNavigator)
void printStatus(const G4FieldTrack &startFT, const G4FieldTrack ¤tFT, G4double requestStep, G4double safety, G4int step)
void SetWorldVolume(G4VPhysicalVolume *pWorld)
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
const G4AffineTransform & GetTopTransform() const
const G4NavigationHistory * GetHistory() const
G4ThreeVector GetMomentum() const
G4TouchableHistory * fpTouchable
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4MagInt_Driver * GetIntegrationDriver()
G4ChordFinder * GetChordFinderFor()
G4bool AccurateAdvance(G4FieldTrack &y_current, G4double hstep, G4double eps, G4double hinitial=0.0)
static G4GeometryTolerance * GetInstance()
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4VSolid * GetSolid() const
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)
G4GLOB_DLL std::ostream G4cerr