64 fMax_loop_count(1000),
65 fUseSafetyForOptimisation(true),
66 fZeroStepThreshold( 0.0 ),
67 fDetectorFieldMgr(detectorFieldMgr),
68 fpTrajectoryFilter( 0 ),
69 fNavigator(theNavigator),
70 fCurrentFieldMgr(detectorFieldMgr),
74 fParticleIsLooping(false),
78 fFirstStepInVolume(true),
79 fLastStepInVolume(true),
97 G4cout <<
" PiF: Zero Step Threshold set to "
100 G4cout <<
" PiF: Value of kCarTolerance = "
172 G4cout <<
"G4PropagatorInField::ComputeStep() called" <<
G4endl;
173 G4cout <<
" Starting FT: " << pFieldTrack;
174 G4cout <<
" Requested length = " << CurrentProposedStepLength <<
G4endl;
186 G4double TruePathLength = CurrentProposedStepLength;
190 G4bool first_substep =
true;
219 G4double trialProposedStep = 1.e2 * ( 10.0 *
cm +
221 GetSolid()->DistanceToOut(StartPointA, VelocityUnit) );
222 CurrentProposedStepLength=
std::min( trialProposedStep,
229 if( epsilon < epsilonMin ) epsilon = epsilonMin;
230 if( epsilon > epsilonMax ) epsilon = epsilonMax;
252 decreaseFactor= 0.25;
261 decreaseFactor = 0.35;
265 decreaseFactor= 0.75;
269 stepTrial *= decreaseFactor;
272 G4cerr <<
" G4PropagatorInField::ComputeStep(): " <<
G4endl
273 <<
" Decreasing step - in volume " << pPhysVol;
275 G4cerr <<
" with name " << pPhysVol->GetName();
278 stepTrial, pFieldTrack);
280 if( stepTrial == 0.0 )
282 std::ostringstream message;
283 message <<
"Particle abandoned due to lack of progress in field."
285 <<
" Properties : " << pFieldTrack << G4endl
286 <<
" Attempting a zero step = " << stepTrial << G4endl
287 <<
" while attempting to progress after " <<
fNoZeroStep
288 <<
" trial steps. Will abandon step.";
289 G4Exception(
"G4PropagatorInField::ComputeStep()",
"GeomNav1002",
294 if( stepTrial < CurrentProposedStepLength )
295 CurrentProposedStepLength = stepTrial;
299 G4int do_loop_count = 0;
309 G4cout <<
" PiF: Calling Nav/Locate Global Point within-Volume "
317 h_TrialStepSize = CurrentProposedStepLength - StepTaken;
338 NewSafety, LinearStepLength,
339 InterSectionPointE );
345 currentSafety = NewSafety;
354 G4bool recalculatedEndPt=
false;
357 EstimateIntersectionPoint( SubStepStartState, CurrentState,
358 InterSectionPointE, IntersectPointVelct_G,
361 intersects = found_intersection;
362 if( found_intersection )
365 StepTaken = TruePathLength = IntersectPointVelct_G.
GetCurveLength()
373 if( recalculatedEndPt )
379 G4bool shortEnd = endAchieved
388 CurrentState= IntersectPointVelct_G;
389 s_length_taken = stepAchieved;
399 StepTaken += s_length_taken;
405 first_substep =
false;
411 CurrentState, CurrentProposedStepLength,
412 NewSafety, do_loop_count, pPhysVol );
418 G4cout <<
" G4PropagatorInField::ComputeStep(): " <<
G4endl
419 <<
" Difficult track - taking many sub steps." <<
G4endl;
421 printStatus( SubStepStartState, CurrentState, CurrentProposedStepLength,
422 NewSafety, do_loop_count, pPhysVol );
428 }
while( (!intersects )
448 TruePathLength = StepTaken;
465 std::ostringstream message;
466 message <<
"Curve length mis-match between original state "
467 <<
"and proposed endpoint of propagation." <<
G4endl
468 <<
" The curve length of the endpoint should be: "
470 <<
" and it is instead: "
472 <<
" A difference of: "
475 <<
" Original state = " << OriginalState <<
G4endl
482 if( TruePathLength+
kCarTolerance >= CurrentProposedStepLength )
507 return TruePathLength;
532 if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
534 oldprec =
G4cout.precision(4);
535 G4cout << std::setw( 6) <<
" "
536 << std::setw( 25) <<
" Current Position and Direction" <<
" "
538 G4cout << std::setw( 5) <<
"Step#"
539 << std::setw(10) <<
" s " <<
" "
540 << std::setw(10) <<
"X(mm)" <<
" "
541 << std::setw(10) <<
"Y(mm)" <<
" "
542 << std::setw(10) <<
"Z(mm)" <<
" "
543 << std::setw( 7) <<
" N_x " <<
" "
544 << std::setw( 7) <<
" N_y " <<
" "
545 << std::setw( 7) <<
" N_z " <<
" " ;
546 G4cout << std::setw( 7) <<
" Delta|N|" <<
" "
547 << std::setw( 9) <<
"StepLen" <<
" "
548 << std::setw(12) <<
"StartSafety" <<
" "
549 << std::setw( 9) <<
"PhsStep" <<
" ";
551 {
G4cout << std::setw(18) <<
"NextVolume" <<
" "; }
552 G4cout.precision(oldprec);
555 if((stepNo == 0) && (verboseLevel <=3))
559 printStatus( StartFT, StartFT, -1.0, safety, -1, startVolume);
561 if( verboseLevel <= 3 )
564 {
G4cout << std::setw( 4) << stepNo <<
" "; }
566 {
G4cout << std::setw( 5) <<
"Start" ; }
567 oldprec =
G4cout.precision(8);
570 G4cout << std::setw(10) << CurrentPosition.x() <<
" "
571 << std::setw(10) << CurrentPosition.y() <<
" "
572 << std::setw(10) << CurrentPosition.z() <<
" ";
574 G4cout << std::setw( 7) << CurrentUnitVelocity.x() <<
" "
575 << std::setw( 7) << CurrentUnitVelocity.y() <<
" "
576 << std::setw( 7) << CurrentUnitVelocity.z() <<
" ";
580 G4cout << std::setw( 9) << step_len <<
" ";
581 G4cout << std::setw(12) << safety <<
" ";
582 if( requestStep != -1.0 )
583 {
G4cout << std::setw( 9) << requestStep <<
" "; }
585 {
G4cout << std::setw( 9) <<
"Init/NotKnown" <<
" "; }
586 if( startVolume != 0)
587 {
G4cout << std::setw(12) << startVolume->
GetName() <<
" "; }
588 G4cout.precision(oldprec);
595 G4cout <<
"Step taken was " << step_len
596 <<
" out of PhysicalStep = " << requestStep <<
G4endl;
598 G4cout <<
"Chord length = " << (CurrentPosition-StartPosition).mag()
616 G4cout <<
" " << std::setw(12) <<
" PiF: NoZeroStep "
617 <<
" " << std::setw(20) <<
" CurrentProposed len "
618 <<
" " << std::setw(18) <<
" Full_curvelen_last"
619 <<
" " << std::setw(18) <<
" last proposed len "
620 <<
" " << std::setw(18) <<
" decrease factor "
621 <<
" " << std::setw(15) <<
" step trial "
625 <<
" " << std::setw(20) << CurrentProposedStepLength
628 <<
" " << std::setw(18) << decreaseFactor
629 <<
" " << std::setw(15) << stepTrial
631 G4cout.precision( iprec );
644 std::vector<G4ThreeVector>*
677 0.0,0.0,0.0,0.0,0.0);
691 if( pCurrentPhysicalVolume)
701 if( pRegionFieldMgr )
702 currentFieldMgr= pRegionFieldMgr;
708 currentFieldMgr = localFieldMgr;
717 return currentFieldMgr;
739 std::ostringstream message;
740 message <<
" Killing looping particle "
741 <<
" after " << count <<
" field substeps "
742 <<
" totaling " << StepTaken /
mm <<
" mm " ;
745 message <<
" in *volume* " << pPhysVol->
GetName() ;
749 message <<
" in unknown or null volume. " ;
751 G4Exception(
"G4PropagatorInField::ComputeStep()",
"GeomNav1002",
760 std::ostringstream message;
761 message <<
"Particle is stuck; it will be killed." <<
G4endl
762 <<
" Zero progress for " << noZeroSteps <<
" attempted steps."
764 <<
" Proposed Step is " << proposedStep
765 <<
" but Step Taken is "<< lastTriedStep <<
G4endl;
767 message <<
" in volume " << physVol->
GetName() ;
769 message <<
" in unknown or null volume. " ;
G4FieldManager * fCurrentFieldMgr
void SetEpsilonStep(G4double newEps)
G4VCurvedTrajectoryFilter * fpTrajectoryFilter
static const G4double kInfinity
G4double GetCurveLength() const
std::vector< G4ThreeVector > * GimmeTrajectoryVectorAndForgetIt() const
CLHEP::Hep3Vector G4ThreeVector
void SetVerboseLevel(G4int newLevel)
virtual void TakeIntermediatePoint(G4ThreeVector newPoint)=0
void PrintStepLengthDiagnostic(G4double currentProposedStepLength, G4double decreaseFactor, G4double stepTrial, const G4FieldTrack &aFieldTrack)
G4double fLast_ProposedStepLength
void RefreshIntersectionLocator()
G4double GetSurfaceTolerance() const
const G4ThreeVector & GetMomentumDir() const
G4double GetDeltaOneStep() const
std::vector< G4ThreeVector > * GimmeThePointsAndForgetThem()
G4PropagatorInField(G4Navigator *theNavigator, G4FieldManager *detectorFieldMgr, G4VIntersectionLocator *vLocator=0)
void SetChordFinderFor(G4ChordFinder *fCFinder)
G4Region * GetRegion() const
G4ThreeVector fPreviousSftOrigin
G4double fFull_CurveLen_of_LastAttempt
G4bool fUseSafetyForOptimisation
G4int SetVerboseLevel(G4int verbose)
G4FieldManager * GetFieldManager() const
G4ThreeVector GetPosition() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
static const double meter
void ReportLoopingParticle(G4int count, double StepTaken, G4VPhysicalVolume *pPhysVol)
G4double GetMaximumEpsilonStep() const
G4double fZeroStepThreshold
G4double fLargestAcceptableStep
void CreateNewTrajectorySegment()
G4FieldManager * FindAndSetFieldManager(G4VPhysicalVolume *pCurrentPhysVol)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4FieldManager * GetFieldManager() const
G4double AdvanceChordLimited(G4FieldTrack &yCurrent, G4double stepInitial, G4double epsStep_Relative, const G4ThreeVector latestSafetyOrigin, G4double lasestSafetyRadius)
static const double perMillion
static const double micrometer
G4double ComputeStep(G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=0)
G4int fSevereActionThreshold_NoZeroSteps
G4double GetDeltaIntersection() const
G4LogicalVolume * GetLogicalVolume() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void ReportStuckParticle(G4int noZeroSteps, G4double proposedStep, G4double lastTriedStep, G4VPhysicalVolume *physVol)
G4ChordFinder * GetChordFinder()
G4bool fFirstStepInVolume
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4FieldManager * fDetectorFieldMgr
G4bool IntersectChord(const G4ThreeVector &StartPointA, const G4ThreeVector &EndPointB, G4double &NewSafety, G4double &LinearStepLength, G4ThreeVector &IntersectionPoint)
void SetTrajectoryFilter(G4VCurvedTrajectoryFilter *filter)
static const double millimeter
void ClearPropagatorState()
G4bool fParticleIsLooping
void SetSafetyParametersFor(G4bool UseSafety)
G4int fAbandonThreshold_NoZeroSteps
G4FieldTrack End_PointAndTangent
G4ThreeVector GetMomentum() const
G4MagInt_Driver * GetIntegrationDriver()
G4int fActionThreshold_NoZeroSteps
G4VPhysicalVolume * GetWorldVolume() const
void SetEpsilonStepFor(G4double EpsilonStep)
double epsilon(double density, double temperature)
static G4GeometryTolerance * GetInstance()
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4VIntersectionLocator * fIntersectionLocator
G4GLOB_DLL std::ostream G4cerr
void SetDeltaIntersectionFor(G4double deltaIntersection)
void printStatus(const G4FieldTrack &startFT, const G4FieldTrack ¤tFT, G4double requestStep, G4double safety, G4int step, G4VPhysicalVolume *startVolume)
G4double GetMinimumEpsilonStep() const