170 G4double geometryStepLength= -1.0, newSafety= -1.0;
171 fParticleIsLooping = false ;
184 fFirstStepInVolume= fNewTrack || fLastStepInVolume;
186 fLastStepInVolume=
false;
204 G4ThreeVector OriginShift = startPosition - fPreviousSftOrigin ;
206 if( MagSqShift >=
sqr(fPreviousSafety) )
208 currentSafety = 0.0 ;
212 currentSafety = fPreviousSafety - std::sqrt(MagSqShift) ;
221 fGeometryLimitedStep = false ;
231 G4bool fieldExertsForce = false ;
234 G4bool fieldExists=
false;
247 fieldExists = (ptrField!=0) ;
252 if( (particleCharge != 0.0)
253 || (fUseMagneticMoment && (magneticMoment != 0.0) )
254 || (gravityOn && (restMass != 0.0) )
257 fieldExertsForce = fieldExists;
263 fFieldExertedForce = fieldExertsForce;
265 if( !fieldExertsForce )
268 if( fShortStepOptimisation && (currentMinimumStep <= currentSafety) )
272 geometryStepLength = currentMinimumStep ;
273 fGeometryLimitedStep = false ;
279 linearStepLength = fLinearNavigator->
ComputeStep( startPosition,
285 fPreviousSftOrigin = startPosition ;
286 fPreviousSafety = newSafety ;
289 currentSafety = newSafety ;
291 fGeometryLimitedStep= (linearStepLength <= currentMinimumStep);
292 if( fGeometryLimitedStep )
295 geometryStepLength = linearStepLength ;
300 geometryStepLength = currentMinimumStep ;
303 fEndPointDistance = geometryStepLength ;
307 fTransportEndPosition = startPosition+geometryStepLength*startMomentumDir ;
311 fTransportEndMomentumDir = startMomentumDir ;
314 fParticleIsLooping = false ;
315 fMomentumChanged = false ;
316 fEndGlobalTimeComputed = false ;
332 ->GetEquationOfMotion();
352 if( currentMinimumStep > 0 )
356 lengthAlongCurve = fFieldPropagator->
ComputeStep( aFieldTrack,
366 geometryStepLength =
std::min( lengthAlongCurve, currentMinimumStep );
370 fPreviousSftOrigin = startPosition ;
371 fPreviousSafety = currentSafety ;
376 geometryStepLength = lengthAlongCurve= 0.0 ;
377 fGeometryLimitedStep = false ;
382 fTransportEndPosition = aFieldTrack.
GetPosition() ;
386 fMomentumChanged = true ;
397 fEndGlobalTimeComputed =
true;
407 fEndGlobalTimeComputed =
false;
412 G4double endEnergy= fTransportEndKineticEnergy;
415 G4double absEdiff = std::fabs(startEnergy- endEnergy);
421 if( fVerboseLevel > 1 )
423 if( std::fabs(startEnergy- endEnergy) >
perThousand * endEnergy )
428 if( (no_large_ediff% warnModulo) == 0 )
431 G4cout <<
"WARNING - G4Transportation::AlongStepGetPIL() "
432 <<
" Energy change in Step is above 1^-3 relative value. " <<
G4endl
433 <<
" Relative change in 'tracking' step = "
434 << std::setw(15) << (endEnergy-startEnergy)/startEnergy <<
G4endl
435 <<
" Starting E= " << std::setw(12) << startEnergy /
MeV <<
" MeV " <<
G4endl
436 <<
" Ending E= " << std::setw(12) << endEnergy /
MeV <<
" MeV " <<
G4endl;
437 G4cout <<
" Energy has been corrected -- however, review"
438 <<
" field propagation parameters for accuracy." <<
G4endl;
439 if( (fVerboseLevel > 2 ) || (no_warnings<4) || (no_large_ediff == warnModulo * moduloFactor) )
441 G4cout <<
" These include EpsilonStepMax(/Min) in G4FieldManager "
442 <<
" which determine fractional error per step for integrated quantities. " << G4endl
443 <<
" Note also the influence of the permitted number of integration steps."
446 G4cerr <<
"ERROR - G4Transportation::AlongStepGetPIL()" << G4endl
447 <<
" Bad 'endpoint'. Energy change detected"
448 <<
" and corrected. "
449 <<
" Has occurred already "
450 << no_large_ediff <<
" times." <<
G4endl;
451 if( no_large_ediff == warnModulo * moduloFactor )
453 warnModulo *= moduloFactor;
465 fTransportEndSpin = aFieldTrack.
GetSpin();
467 fEndPointDistance = (fTransportEndPosition - startPosition).mag() ;
473 if( currentMinimumStep == 0.0 )
475 if( currentSafety == 0.0 ) { fGeometryLimitedStep =
true; }
481 if( currentSafety < fEndPointDistance )
483 if( particleCharge != 0.0 )
487 currentSafety = endSafety ;
488 fPreviousSftOrigin = fTransportEndPosition ;
489 fPreviousSafety = currentSafety ;
495 currentSafety += fEndPointDistance ;
497 #ifdef G4DEBUG_TRANSPORT
499 G4cout <<
"***G4Transportation::AlongStepGPIL ** " <<
G4endl ;
500 G4cout <<
" Called Navigator->ComputeSafety at " << fTransportEndPosition
501 <<
" and it returned safety= " << endSafety <<
G4endl ;
502 G4cout <<
" Adding endpoint distance " << fEndPointDistance
503 <<
" to obtain pseudo-safety= " << currentSafety <<
G4endl ;
507 G4cout <<
"***G4Transportation::AlongStepGPIL ** " <<
G4endl ;
508 G4cout <<
" Avoiding call to ComputeSafety : " <<
G4endl;
517 return geometryStepLength ;
static constexpr double perMillion
const G4ThreeVector & GetPolarization() const
virtual void SetChargeMomentumMass(G4ChargeState particleCharge, G4double MomentumXc, G4double MassXc2)=0
G4double GetKineticEnergy() const
const G4DynamicParticle * GetDynamicParticle() const
const G4MagIntegratorStepper * GetStepper() const
const G4ThreeVector & GetPosition() const
const G4ThreeVector & GetMomentumDir() const
G4ThreeVector GetSpin() const
virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
G4ParticleDefinition * GetDefinition() const
G4double GetTotalMomentum() const
virtual void ConfigureForTrack(const G4Track *)
G4double GetKineticEnergy() const
G4ThreeVector GetPosition() const
G4GLOB_DLL std::ostream G4cout
const G4ThreeVector & GetMomentumDirection() const
G4double GetCharge() const
void ProposeTrueStepLength(G4double truePathLength)
void ProposeFirstStepInVolume(G4bool flag)
G4bool DoesFieldChangeEnergy() const
G4double GetGlobalTime() const
G4bool IsLastStepInVolume()
G4FieldManager * FindAndSetFieldManager(G4VPhysicalVolume *pCurrentPhysVol)
G4double ComputeStep(G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=0)
const G4ThreeVector & GetMomentumDirection() const
G4bool IsParticleLooping() const
G4double GetLabTimeOfFlight() const
G4bool IsGravityActive() const
G4ChordFinder * GetChordFinder()
G4FieldManager * GetCurrentFieldManager()
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4VPhysicalVolume * GetVolume() const
G4double GetPDGSpin() const
void SetCurrentSafety(G4double val, const G4ThreeVector &pos)
static constexpr double MeV
static constexpr double perThousand
G4double GetPDGMagneticMoment() const
const G4Field * GetDetectorField() const
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
G4MagInt_Driver * GetIntegrationDriver()
G4double GetMagneticMoment() const
G4GLOB_DLL std::ostream G4cerr