166 G4double geometryStepLength, newSafety ;
182 const G4DynamicParticle* pParticle =
track.GetDynamicParticle() ;
183 const G4ParticleDefinition* pParticleDef = pParticle->GetDefinition() ;
184 const G4ThreeVector& startMomentumDir = pParticle->GetMomentumDirection() ;
185 G4ThreeVector startPosition =
track.GetPosition() ;
194 G4double MagSqShift = OriginShift.mag2() ;
197 currentSafety = 0.0 ;
207 G4double particleElCharge = pParticle->GetCharge() ;
222 G4FieldManager* fieldMgr=0;
223 G4bool fieldExertsForce = false ;
224 if( (particleElCharge != 0.0) || (particleMagCharge!=0.0) )
232 if (fieldMgr != oldFieldMgr) {
238 if (fieldMgr !=
nullptr) {
240 fieldMgr->ConfigureForTrack( &
track );
245 if (particleMagCharge!=0.0) fieldMgr->SetFieldChangesEnergy(
true);
248 fieldExertsForce = (fieldMgr->GetDetectorField() !=
nullptr);
250 if( fieldExertsForce)
251 fEquationSetup->SwitchStepperAndChordFinder( (particleMagCharge != 0.0), fieldMgr );
260 if( !fieldExertsForce )
262 G4double linearStepLength ;
267 geometryStepLength = currentMinimumStep ;
286 currentSafety = newSafety ;
292 geometryStepLength = linearStepLength ;
297 geometryStepLength = currentMinimumStep ;
317 G4ThreeVector EndUnitMomentum ;
318 G4double lengthAlongCurve ;
319 G4double restMass = pParticleDef->GetPDGMass() ;
320 #if G4VERSION_NUMBER > 1009
321 G4double momentumMagnitude = pParticle->GetTotalMomentum();
322 G4ChargeState chargeState(particleElCharge,
323 pParticleDef->GetPDGSpin(),
327 G4EquationOfMotion* equationOfMotion = (
fFieldPropagator->GetChordFinder()->GetIntegrationDriver()->GetStepper())->GetEquationOfMotion();
328 equationOfMotion->SetChargeMomentumMass(chargeState,
337 G4ThreeVector
spin =
track.GetPolarization() ;
338 G4FieldTrack aFieldTrack = G4FieldTrack( startPosition,
339 track.GetMomentumDirection(),
341 track.GetKineticEnergy(),
344 track.GetGlobalTime(),
345 track.GetProperTime(),
347 if( currentMinimumStep > 0 )
355 track.GetVolume() ) ;
358 geometryStepLength = lengthAlongCurve ;
360 geometryStepLength = currentMinimumStep ;
365 geometryStepLength = lengthAlongCurve= 0.0 ;
407 G4double startEnergy=
track.GetKineticEnergy();
410 static std::atomic<G4int> no_inexact_steps=0, no_large_ediff;
411 G4double absEdiff = std::fabs(startEnergy- endEnergy);
421 static std::atomic<G4int> no_warnings= 0, warnModulo=1, moduloFactor= 10;
423 if( (no_large_ediff% warnModulo) == 0 )
426 G4cout <<
"WARNING - G4mplAtlasTransportation::AlongStepGetPIL() "
427 <<
" Energy change in Step is above 1^-3 relative value. " << G4endl
428 <<
" Relative change in 'tracking' step = "
429 << std::setw(15) << (endEnergy-startEnergy)/startEnergy << G4endl
430 <<
" Starting E= " << std::setw(12) << startEnergy /
CLHEP::MeV <<
" MeV " << G4endl
431 <<
" Ending E= " << std::setw(12) << endEnergy /
CLHEP::MeV <<
" MeV " << G4endl;
432 G4cout <<
" Energy has been corrected -- however, review"
433 <<
" field propagation parameters for accuracy." << G4endl;
434 if( (
fVerboseLevel > 2 ) || (no_warnings<4) || (no_large_ediff == warnModulo * moduloFactor) ){
435 G4cout <<
" These include EpsilonStepMax(/Min) in G4FieldManager "
436 <<
" which determine fractional error per step for integrated quantities. " << G4endl
437 <<
" Note also the influence of the permitted number of integration steps."
440 G4cerr <<
"ERROR - G4mplAtlasTransportation::AlongStepGetPIL()" << G4endl
441 <<
" Bad 'endpoint'. Energy change detected"
442 <<
" and corrected. "
443 <<
" Has occurred already "
444 << no_large_ediff <<
" times." << G4endl;
445 if( no_large_ediff == warnModulo * moduloFactor )
447 warnModulo = warnModulo * moduloFactor;
463 fieldMgr->SetFieldChangesEnergy(
false);
470 if( currentMinimumStep == 0.0 )
487 currentSafety = endSafety ;
497 #ifdef G4DEBUG_TRANSPORT
498 G4cout.precision(12) ;
499 G4cout <<
"***G4mplAtlasTransportation::AlongStepGPIL ** " << G4endl ;
501 <<
" and it returned safety= " << endSafety << G4endl ;
503 <<
" to obtain pseudo-safety= " << currentSafety << G4endl ;
532 return geometryStepLength ;