63 fParticleIsLooping( false ),
64 fPreviousSftOrigin (0.,0.,0.),
65 fPreviousSafety ( 0.0 ),
66 fThreshold_Warning_Energy( 100 *
MeV ),
67 fThreshold_Important_Energy( 250 *
MeV ),
68 fThresholdTrials( 10 ),
69 fUnimportant_Energy( 1 *
MeV ),
71 fSumEnergyKilled( 0.0 ), fMaxEnergyKilled( 0.0 ),
72 fShortStepOptimisation(false),
101 fCurrentTouchableHandle = nullTouchableHandle;
103 fEndGlobalTimeComputed =
false;
104 fCandidateEndGlobalTime = 0;
111 if( (fVerboseLevel > 0) && (fSumEnergyKilled > 0.0 ) ){
112 G4cout <<
" G4MonopoleTransportation: Statistics for looping particles "
114 G4cout <<
" Sum of energy of loopers killed: " << fSumEnergyKilled <<
G4endl;
115 G4cout <<
" Max energy of loopers killed: " << fMaxEnergyKilled <<
G4endl;
136 G4double geometryStepLength, newSafety ;
137 fParticleIsLooping = false ;
162 G4ThreeVector OriginShift = startPosition - fPreviousSftOrigin ;
164 if( MagSqShift >=
sqr(fPreviousSafety) )
166 currentSafety = 0.0 ;
170 currentSafety = fPreviousSafety - std::sqrt(MagSqShift) ;
178 fGeometryLimitedStep = false ;
188 G4bool fieldExertsForce = false ;
190 if( (particleMagneticCharge != 0.0) )
210 if( !fieldExertsForce )
213 if( fShortStepOptimisation && (currentMinimumStep <= currentSafety) )
217 geometryStepLength = currentMinimumStep ;
218 fGeometryLimitedStep = false ;
224 linearStepLength = fLinearNavigator->
ComputeStep( startPosition,
230 fPreviousSftOrigin = startPosition ;
231 fPreviousSafety = newSafety ;
236 currentSafety = newSafety ;
238 fGeometryLimitedStep= (linearStepLength <= currentMinimumStep);
239 if( fGeometryLimitedStep )
242 geometryStepLength = linearStepLength ;
247 geometryStepLength = currentMinimumStep ;
250 endpointDistance = geometryStepLength ;
254 fTransportEndPosition = startPosition+geometryStepLength*startMomentumDir ;
258 fTransportEndMomentumDir = startMomentumDir ;
261 fParticleIsLooping = false ;
262 fMomentumChanged = false ;
263 fEndGlobalTimeComputed = false ;
273 particleElectricCharge,
290 if( currentMinimumStep > 0 )
294 lengthAlongCurve = fFieldPropagator->
ComputeStep( aFieldTrack,
298 fGeometryLimitedStep= lengthAlongCurve < currentMinimumStep;
299 if( fGeometryLimitedStep ) {
300 geometryStepLength = lengthAlongCurve ;
302 geometryStepLength = currentMinimumStep ;
307 geometryStepLength = lengthAlongCurve= 0.0 ;
308 fGeometryLimitedStep = false ;
313 fPreviousSftOrigin = startPosition ;
314 fPreviousSafety = currentSafety ;
319 fTransportEndPosition = aFieldTrack.
GetPosition() ;
323 fMomentumChanged = true ;
329 fEndGlobalTimeComputed =
true;
331 fTransportEndSpin = aFieldTrack.
GetSpin();
333 endpointDistance = (fTransportEndPosition - startPosition).mag() ;
339 if( currentMinimumStep == 0.0 )
341 if( currentSafety == 0.0 ) fGeometryLimitedStep = true ;
347 if( currentSafety < endpointDistance )
352 if( particleMagneticCharge != 0.0 ) {
356 currentSafety = endSafety ;
357 fPreviousSftOrigin = fTransportEndPosition ;
358 fPreviousSafety = currentSafety ;
364 currentSafety += endpointDistance ;
366 #ifdef G4DEBUG_TRANSPORT
368 G4cout <<
"***G4MonopoleTransportation::AlongStepGPIL ** " <<
G4endl ;
369 G4cout <<
" Called Navigator->ComputeSafety at " << fTransportEndPosition
370 <<
" and it returned safety= " << endSafety <<
G4endl ;
371 G4cout <<
" Adding endpoint distance " << endpointDistance
372 <<
" to obtain pseudo-safety= " << currentSafety <<
G4endl ;
382 return geometryStepLength ;
393 static G4int noCalls=0;
418 if (!fEndGlobalTimeComputed)
432 deltaTime = stepLength/finalVelocity ;
434 else if (finalVelocity > 0.0)
438 meanInverseVelocity = 0.5
439 * ( 1.0 / initialVelocity + 1.0 / finalVelocity ) ;
440 deltaTime = stepLength * meanInverseVelocity ;
442 else if( initialVelocity > 0.0 )
444 deltaTime = stepLength/initialVelocity ;
446 fCandidateEndGlobalTime = startTime + deltaTime ;
450 deltaTime = fCandidateEndGlobalTime - startTime ;
467 if ( fParticleIsLooping )
469 G4double endEnergy= fTransportEndKineticEnergy;
471 if( (endEnergy < fThreshold_Important_Energy)
472 || (fNoLooperTrials >= fThresholdTrials ) ){
478 fSumEnergyKilled += endEnergy;
479 if( endEnergy > fMaxEnergyKilled) { fMaxEnergyKilled= endEnergy; }
482 if( (fVerboseLevel > 1) ||
483 ( endEnergy > fThreshold_Warning_Energy ) ) {
484 G4cout <<
" G4MonopoleTransportation is killing track that is looping or stuck "
487 <<
" MeV energy." <<
G4endl;
488 G4cout <<
" Number of trials = " << fNoLooperTrials
489 <<
" No of calls to AlongStepDoIt = " << noCalls
498 if( (fVerboseLevel > 2) ){
499 G4cout <<
" G4MonopoleTransportation::AlongStepDoIt(): Particle looping - "
500 <<
" Number of trials = " << fNoLooperTrials
501 <<
" No of calls to = " << noCalls
518 return &fParticleChange ;
552 if(fGeometryLimitedStep)
560 LocateGlobalPointAndUpdateTouchableHandle( track.
GetPosition(),
562 fCurrentTouchableHandle,
567 if( fCurrentTouchableHandle->
GetVolume() == 0 )
571 retCurrentTouchable = fCurrentTouchableHandle ;
611 if( pNewVol!=0 && pNewMaterialCutsCouple!=0 && pNewMaterialCutsCouple->
GetMaterial()!=pNewMaterial )
615 pNewMaterialCutsCouple =
630 return &fParticleChange ;
649 fPreviousSafety = 0.0 ;