58 : fDetectorFieldMgr(detectorFieldMgr),
59 fNavigator(theNavigator),
60 fCurrentFieldMgr(detectorFieldMgr),
73 G4cout <<
" PiF: Zero Step Threshold set to "
76 G4cout <<
" PiF: Value of kCarTolerance = "
84 if ( vLocator ==
nullptr )
123 G4bool canRelaxDeltaChord)
131 const char* methodName =
"G4PropagatorInField::ComputeStep";
151 G4cout <<
" Starting FT: " << pFieldTrack;
152 G4cout <<
" Requested length = " << CurrentProposedStepLength <<
G4endl;
164 G4double TruePathLength = CurrentProposedStepLength;
168 G4bool first_substep =
true;
195 G4double trialProposedStep = 1.e2 * ( 10.0 *
cm +
197 GetSolid()->DistanceToOut(StartPointA, VelocityUnit) );
198 CurrentProposedStepLength =
std::min( trialProposedStep,
204 if( epsilon < epsilonMin ) { epsilon = epsilonMin; }
205 if( epsilon > epsilonMax ) { epsilon = epsilonMax; }
231 decreaseFactor= 0.25;
240 decreaseFactor = 0.35;
244 decreaseFactor= 0.75;
248 stepTrial *= decreaseFactor;
254 G4cerr <<
" " << methodName
255 <<
" Decreasing step after " <<
fNoZeroStep <<
" zero steps "
256 <<
" - in volume " << pPhysVol;
258 G4cerr <<
" with name " << pPhysVol->GetName();
260 G4cerr <<
" i.e. *unknown* volume.";
263 stepTrial, pFieldTrack);
266 if( stepTrial == 0.0 )
269 message <<
"Particle abandoned due to lack of progress in field."
271 <<
" Properties : " << pFieldTrack <<
G4endl
272 <<
" Attempting a zero step = " << stepTrial <<
G4endl
273 <<
" while attempting to progress after " <<
fNoZeroStep
274 <<
" trial steps. Will abandon step.";
279 if( stepTrial < CurrentProposedStepLength )
281 CurrentProposedStepLength = stepTrial;
286 G4int do_loop_count = 0;
296 G4cout <<
" PiF: Calling Nav/Locate Global Point within-Volume "
304 h_TrialStepSize = CurrentProposedStepLength - StepTaken;
306 if (canRelaxDeltaChord &&
335 NewSafety, LinearStepLength,
336 InterSectionPointE );
342 currentSafety = NewSafety;
351 G4bool recalculatedEndPt =
false;
354 EstimateIntersectionPoint( SubStepStartState, CurrentState,
355 InterSectionPointE, IntersectPointVelct_G,
358 intersects = found_intersection;
359 if( found_intersection )
362 StepTaken = TruePathLength = IntersectPointVelct_G.
GetCurveLength()
370 if( recalculatedEndPt )
376 G4bool shortEnd = endAchieved
385 CurrentState = IntersectPointVelct_G;
386 s_length_taken = stepAchieved;
396 StepTaken += s_length_taken;
403 first_substep =
false;
409 G4cout <<
" Above 'Severe Action' threshold -- for Zero steps. ";
411 G4cout <<
" Above 'action' threshold -- for Zero steps. ";
414 CurrentState, CurrentProposedStepLength,
415 NewSafety, do_loop_count, pPhysVol );
421 G4cout <<
" G4PropagatorInField::ComputeStep(): " <<
G4endl
422 <<
" Difficult track - taking many sub steps." <<
G4endl;
423 printStatus( SubStepStartState, SubStepStartState, CurrentProposedStepLength,
424 NewSafety, 0, pPhysVol );
426 printStatus( SubStepStartState, CurrentState, CurrentProposedStepLength,
427 NewSafety, do_loop_count, pPhysVol );
433 }
while( (!intersects )
446 CurrentProposedStepLength, methodName,
456 TruePathLength = StepTaken;
475 message <<
"Curve length mis-match between original state "
476 <<
"and proposed endpoint of propagation." <<
G4endl
477 <<
" The curve length of the endpoint should be: "
479 <<
" and it is instead: "
481 <<
" A difference of: "
484 <<
" Original state = " << OriginalState <<
G4endl
490 if( TruePathLength+
kCarTolerance >= CurrentProposedStepLength )
517 return TruePathLength;
541 if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
543 oldprec =
G4cout.precision(4);
544 G4cout << std::setw( 5) <<
"Step#"
545 << std::setw(10) <<
" s " <<
" "
546 << std::setw(10) <<
"X(mm)" <<
" "
547 << std::setw(10) <<
"Y(mm)" <<
" "
548 << std::setw(10) <<
"Z(mm)" <<
" "
549 << std::setw( 7) <<
" N_x " <<
" "
550 << std::setw( 7) <<
" N_y " <<
" "
551 << std::setw( 7) <<
" N_z " <<
" " ;
552 G4cout << std::setw( 7) <<
" Delta|N|" <<
" "
553 << std::setw( 9) <<
"StepLen" <<
" "
554 << std::setw(12) <<
"StartSafety" <<
" "
555 << std::setw( 9) <<
"PhsStep" <<
" ";
556 if( startVolume !=
nullptr )
557 {
G4cout << std::setw(18) <<
"NextVolume" <<
" "; }
558 G4cout.precision(oldprec);
561 if((stepNo == 0) && (verboseLevel <=3))
565 printStatus( StartFT, StartFT, -1.0, safety, -1, startVolume);
567 if( verboseLevel <= 3 )
570 {
G4cout << std::setw( 4) << stepNo <<
" "; }
572 {
G4cout << std::setw( 5) <<
"Start" ; }
573 oldprec =
G4cout.precision(8);
576 G4cout << std::setw(10) << CurrentPosition.
x() <<
" "
577 << std::setw(10) << CurrentPosition.
y() <<
" "
578 << std::setw(10) << CurrentPosition.
z() <<
" ";
580 G4cout << std::setw( 7) << CurrentUnitVelocity.
x() <<
" "
581 << std::setw( 7) << CurrentUnitVelocity.
y() <<
" "
582 << std::setw( 7) << CurrentUnitVelocity.
z() <<
" ";
586 G4cout << std::setw( 9) << step_len <<
" ";
587 G4cout << std::setw(12) << safety <<
" ";
588 if( requestStep != -1.0 )
589 {
G4cout << std::setw( 9) << requestStep <<
" "; }
591 {
G4cout << std::setw( 9) <<
"Init/NotKnown" <<
" "; }
592 if( startVolume != 0)
593 {
G4cout << std::setw(12) << startVolume->
GetName() <<
" "; }
594 G4cout.precision(oldprec);
601 G4cout <<
"Step taken was " << step_len
602 <<
" out of PhysicalStep = " << requestStep <<
G4endl;
604 G4cout <<
"Chord length = " << (CurrentPosition-StartPosition).mag()
621 G4cout <<
" " << std::setw(12) <<
" PiF: NoZeroStep "
622 <<
" " << std::setw(20) <<
" CurrentProposed len "
623 <<
" " << std::setw(18) <<
" Full_curvelen_last"
624 <<
" " << std::setw(18) <<
" last proposed len "
625 <<
" " << std::setw(18) <<
" decrease factor "
626 <<
" " << std::setw(15) <<
" step trial "
630 <<
" " << std::setw(20) << CurrentProposedStepLength
633 <<
" " << std::setw(18) << decreaseFactor
634 <<
" " << std::setw(15) << stepTrial
636 G4cout.precision( iprec );
648 std::vector<G4ThreeVector>*
683 0.0,0.0,0.0,0.0,0.0);
699 if( pCurrentPhysicalVolume !=
nullptr )
701 G4FieldManager *pRegionFieldMgr =
nullptr, *localFieldMgr =
nullptr;
704 if( pLogicalVol !=
nullptr )
709 if( pRegion !=
nullptr )
712 if( pRegionFieldMgr !=
nullptr )
714 currentFieldMgr= pRegionFieldMgr;
721 if ( localFieldMgr !=
nullptr )
723 currentFieldMgr = localFieldMgr;
733 return currentFieldMgr;
758 const char* methodName,
763 G4double fraction = StepTaken / StepRequested;
764 message <<
" Unfinished integration of track (likely looping particle) "
765 <<
" of momentum " << momentumVec <<
" ( magnitude = "
767 <<
" after " << count <<
" field substeps "
768 <<
" totaling " << std::setprecision(12) << StepTaken /
mm <<
" mm "
769 <<
" out of requested step " << std::setprecision(12)
770 << StepRequested /
mm <<
" mm ";
771 message <<
" a fraction of ";
773 if( fraction > 0.99 )
779 if (fraction > 0.97 ) { prec = 5; }
781 message << std::setprecision(prec)
782 << 100. * StepTaken / StepRequested <<
" % " <<
G4endl ;
785 message <<
" in volume " << pPhysVol->
GetName() ;
788 message <<
" with material " <<
material->GetName()
794 message <<
" in unknown (null) volume. " ;
807 message <<
"Particle is stuck; it will be killed." <<
G4endl
808 <<
" Zero progress for " << noZeroSteps <<
" attempted steps."
810 <<
" Proposed Step is " << proposedStep
811 <<
" but Step Taken is "<< lastTriedStep <<
G4endl;
812 if( physVol !=
nullptr )
813 message <<
" in volume " << physVol->
GetName() ;
815 message <<
" in unknown or null volume. " ;