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,
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 )
268 std::ostringstream message;
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;
474 std::ostringstream message;
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 );
648std::vector<G4ThreeVector>*
686 0.0,0.0,0.0,0.0,0.0);
704 if( pCurrentPhysicalVolume !=
nullptr )
706 G4FieldManager *pRegionFieldMgr =
nullptr, *localFieldMgr =
nullptr;
709 if( pLogicalVol !=
nullptr )
714 if( pRegion !=
nullptr )
717 if( pRegionFieldMgr !=
nullptr )
719 currentFieldMgr= pRegionFieldMgr;
726 if ( localFieldMgr !=
nullptr )
728 currentFieldMgr = localFieldMgr;
738 return currentFieldMgr;
763 const char* methodName,
767 std::ostringstream message;
768 G4double fraction = StepTaken / StepRequested;
769 message <<
" Unfinished integration of track (likely looping particle) "
770 <<
" of momentum " << momentumVec <<
" ( magnitude = "
772 <<
" after " << count <<
" field substeps "
773 <<
" totaling " << std::setprecision(12) << StepTaken /
mm <<
" mm "
774 <<
" out of requested step " << std::setprecision(12)
775 << StepRequested /
mm <<
" mm ";
776 message <<
" a fraction of ";
778 if( fraction > 0.99 )
784 if (fraction > 0.97 ) {
prec = 5; }
786 message << std::setprecision(
prec)
787 << 100. * StepTaken / StepRequested <<
" % " <<
G4endl ;
790 message <<
" in volume " << pPhysVol->
GetName() ;
793 message <<
" with material " <<
material->GetName()
799 message <<
" in unknown (null) volume. " ;
811 std::ostringstream message;
812 message <<
"Particle is stuck; it will be killed." <<
G4endl
813 <<
" Zero progress for " << noZeroSteps <<
" attempted steps."
815 <<
" Proposed Step is " << proposedStep
816 <<
" but Step Taken is "<< lastTriedStep <<
G4endl;
817 if( physVol !=
nullptr )
818 message <<
" in volume " << physVol->
GetName() ;
820 message <<
" in unknown or null volume. " ;
G4double epsilon(G4double density, G4double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static constexpr double micrometer
static constexpr double millimeter
static constexpr double meter
static constexpr double mm
static constexpr double g
static constexpr double cm
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
G4double GetDeltaChord() const
G4VIntegrationDriver * GetIntegrationDriver()
void SetDeltaChord(G4double newval)
G4double AdvanceChordLimited(G4FieldTrack &yCurrent, G4double stepInitial, G4double epsStep_Relative, const G4ThreeVector &latestSafetyOrigin, G4double lasestSafetyRadius)
G4double GetMinimumEpsilonStep() const
G4double GetMaximumEpsilonStep() const
G4double GetDeltaOneStep() const
G4double GetDeltaIntersection() const
const G4ThreeVector & GetMomentumDir() const
G4double GetCurveLength() const
G4ThreeVector GetPosition() const
G4ThreeVector GetMomentum() const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4Region * GetRegion() const
G4Material * GetMaterial() const
G4FieldManager * GetFieldManager() const
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4VPhysicalVolume * GetWorldVolume() const
G4VCurvedTrajectoryFilter * fpTrajectoryFilter
void printStatus(const G4FieldTrack &startFT, const G4FieldTrack ¤tFT, G4double requestStep, G4double safety, G4int step, G4VPhysicalVolume *startVolume)
G4FieldManager * fCurrentFieldMgr
G4FieldManager * FindAndSetFieldManager(G4VPhysicalVolume *pCurrentPhysVol)
G4bool fParticleIsLooping
G4double fLast_ProposedStepLength
G4int SetVerboseLevel(G4int verbose)
G4ThreeVector fPreviousSftOrigin
void PrintStepLengthDiagnostic(G4double currentProposedStepLength, G4double decreaseFactor, G4double stepTrial, const G4FieldTrack &aFieldTrack)
G4PropagatorInField(G4Navigator *theNavigator, G4FieldManager *detectorFieldMgr, G4VIntersectionLocator *vLocator=nullptr)
G4VIntersectionLocator * fIntersectionLocator
G4bool fUseSafetyForOptimisation
G4int fAbandonThreshold_NoZeroSteps
void ReportStuckParticle(G4int noZeroSteps, G4double proposedStep, G4double lastTriedStep, G4VPhysicalVolume *physVol)
G4bool fFirstStepInVolume
G4int fSevereActionThreshold_NoZeroSteps
G4ChordFinder * GetChordFinder()
G4double fZeroStepThreshold
void ClearPropagatorState()
G4FieldTrack End_PointAndTangent
G4double fLargestAcceptableStep
void RefreshIntersectionLocator()
void ReportLoopingParticle(G4int count, G4double StepTaken, G4double stepRequest, const char *methodName, G4ThreeVector momentumVec, G4VPhysicalVolume *physVol)
G4bool IntersectChord(const G4ThreeVector &StartPointA, const G4ThreeVector &EndPointB, G4double &NewSafety, G4double &LinearStepLength, G4ThreeVector &IntersectionPoint)
G4double fFull_CurveLen_of_LastAttempt
G4int fIncreaseChordDistanceThreshold
G4int fActionThreshold_NoZeroSteps
std::vector< G4ThreeVector > * GimmeTrajectoryVectorAndForgetIt() const
void SetTrajectoryFilter(G4VCurvedTrajectoryFilter *filter)
G4double ComputeStep(G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=nullptr, G4bool canRelaxDeltaChord=false)
void SetEpsilonStep(G4double newEps)
G4FieldManager * fDetectorFieldMgr
G4FieldManager * GetFieldManager() const
std::vector< G4ThreeVector > * GimmeThePointsAndForgetThem()
void CreateNewTrajectorySegment()
virtual void TakeIntermediatePoint(G4ThreeVector newPoint)=0
virtual void SetVerboseLevel(G4int level)=0
void SetDeltaIntersectionFor(G4double deltaIntersection)
void SetSafetyParametersFor(G4bool UseSafety)
void SetChordFinderFor(G4ChordFinder *fCFinder)
void SetEpsilonStepFor(G4double EpsilonStep)
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
static const G4double kInfinity
static constexpr double perMillion
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments