21 #include "G4ProductionCutsTable.hh" 22 #include "G4ParticleTable.hh" 23 #include "G4ChordFinder.hh" 24 #include "G4SafetyHelper.hh" 25 #include "G4FieldManagerStore.hh" 26 #include "G4TransportationProcessType.hh" 27 #include "G4SystemOfUnits.hh" 29 class G4VSensitiveDetector;
34 : G4VProcess( G4String(
"MonopoleTransportation"), fTransportation ),
39 fParticleIsLooping(
false ),
40 fPreviousSftOrigin (0.,0.,0.),
41 fPreviousSafety ( 0.0 ),
42 fThreshold_Warning_Energy( 100 *
MeV ),
43 fThreshold_Important_Energy( 250 *
MeV ),
44 fThresholdTrials( 10 ),
46 fSumEnergyKilled( 0.0 ), fMaxEnergyKilled( 0.0 ),
47 fShortStepOptimisation(
false),
53 SetProcessSubType(TRANSPORTATION);
55 #ifdef G4MULTITHREADED 57 if (G4Threading::IsMasterThread())
63 G4TransportationManager* transportMgr =
64 G4TransportationManager::GetTransportationManager();
107 G4double currentMinimumStep,
108 G4double& currentSafety,
114 G4double geometryStepLength, newSafety ;
126 *selection = CandidateForSelection ;
130 const G4DynamicParticle* pParticle = track.GetDynamicParticle() ;
131 const G4ThreeVector& startMomentumDir = pParticle->GetMomentumDirection() ;
132 G4ThreeVector startPosition = track.GetPosition() ;
139 G4double MagSqShift = OriginShift.mag2() ;
142 currentSafety = 0.0 ;
152 G4double particleElectricCharge = pParticle->GetCharge();
161 G4bool fieldExertsForce =
false ;
171 fieldExertsForce = (
fieldMgrCMS->GetDetectorField() !=
nullptr);
179 if( !fieldExertsForce )
181 G4double linearStepLength ;
186 geometryStepLength = currentMinimumStep ;
199 fPreviousSftOrigin = startPosition ;
205 currentSafety = newSafety ;
211 geometryStepLength = linearStepLength ;
216 geometryStepLength = currentMinimumStep ;
236 G4double momentumMagnitude = pParticle->GetTotalMomentum() ;
237 G4ThreeVector EndUnitMomentum ;
238 G4double lengthAlongCurve ;
241 G4ChargeState chargeState(particleElectricCharge,
245 particleMagneticCharge );
247 G4EquationOfMotion* equationOfMotion =
248 fFieldPropagator->GetChordFinder()->GetIntegrationDriver()->GetEquationOfMotion();
251 ->SetChargeMomentumMass( chargeState,
256 G4ThreeVector
spin = track.GetPolarization() ;
257 G4FieldTrack aFieldTrack = G4FieldTrack( startPosition,
258 track.GetMomentumDirection(),
260 track.GetKineticEnergy(),
263 track.GetGlobalTime(),
264 track.GetProperTime(),
266 if( currentMinimumStep > 0 )
273 track.GetVolume() ) ;
276 geometryStepLength = lengthAlongCurve ;
278 geometryStepLength = currentMinimumStep ;
283 geometryStepLength = lengthAlongCurve= 0.0 ;
289 fPreviousSftOrigin = startPosition ;
315 if( currentMinimumStep == 0.0 )
325 if( particleMagneticCharge != 0.0 ) {
329 currentSafety = endSafety ;
339 #ifdef G4DEBUG_TRANSPORT 341 G4cout <<
"***MonopoleTransportation::AlongStepGPIL ** " << G4endl ;
343 <<
" and it returned safety= " << endSafety << G4endl ;
345 <<
" to obtain pseudo-safety= " << currentSafety << G4endl ;
352 return geometryStepLength ;
361 const G4Step& stepData )
374 G4double deltaTime = 0.0 ;
377 G4double startTime = track.GetGlobalTime() ;
383 G4double finalVelocity = track.GetVelocity() ;
384 G4double initialVelocity = stepData.GetPreStepPoint()->GetVelocity() ;
385 G4double stepLength = track.GetStepLength() ;
388 if (finalVelocity > 0.0)
390 G4double meanInverseVelocity ;
391 meanInverseVelocity = 0.5
392 * ( 1.0 / initialVelocity + 1.0 / finalVelocity ) ;
393 deltaTime = stepLength * meanInverseVelocity ;
395 else if( initialVelocity > 0.0 )
397 deltaTime = stepLength/initialVelocity ;
410 G4double restMass = track.GetDynamicParticle()->GetMass() ;
411 G4double deltaProperTime = deltaTime*( restMass/track.GetTotalEnergy() ) ;
413 fParticleChange.ProposeProperTime(track.GetProperTime() + deltaProperTime) ;
435 if( (verboseLevel > 1) ||
437 G4cout <<
" MonopoleTransportation is killing track that is looping or stuck " 439 <<
" This track has " << track.GetKineticEnergy() /
MeV 440 <<
" MeV energy." << G4endl;
442 <<
" No of calls to AlongStepDoIt = " << noCalls
451 if( (verboseLevel > 2) ){
452 G4cout <<
" MonopoleTransportation::AlongStepDoIt(): Particle looping - " 454 <<
" No of calls to = " << noCalls
483 G4ForceCondition* pForceCond )
485 *pForceCond = Forced ;
494 G4TouchableHandle retCurrentTouchable ;
509 LocateGlobalPointAndUpdateTouchableHandle( track.GetPosition(),
510 track.GetMomentumDirection(),
535 retCurrentTouchable = track.GetTouchableHandle() ;
538 const G4VPhysicalVolume* pNewVol = retCurrentTouchable->GetVolume() ;
539 const G4Material* pNewMaterial =
nullptr ;
540 const G4VSensitiveDetector* pNewSensitiveDetector =
nullptr ;
542 if( pNewVol !=
nullptr )
544 pNewMaterial= pNewVol->GetLogicalVolume()->GetMaterial();
545 pNewSensitiveDetector= pNewVol->GetLogicalVolume()->GetSensitiveDetector();
549 (G4Material *) pNewMaterial ) ;
551 (G4VSensitiveDetector *) pNewSensitiveDetector ) ;
553 const G4MaterialCutsCouple* pNewMaterialCutsCouple =
nullptr;
554 if( pNewVol !=
nullptr )
556 pNewMaterialCutsCouple=pNewVol->GetLogicalVolume()->GetMaterialCutsCouple();
559 if( pNewVol!=
nullptr && pNewMaterialCutsCouple!=
nullptr &&
560 pNewMaterialCutsCouple->GetMaterial()!=pNewMaterial )
564 pNewMaterialCutsCouple =
565 G4ProductionCutsTable::GetProductionCutsTable()
566 ->GetMaterialCutsCouple(pNewMaterial,
567 pNewMaterialCutsCouple->GetProductionCuts());
569 fParticleChange.SetMaterialCutsCoupleInTouchable( pNewMaterialCutsCouple );
596 G4FieldManager* fieldMgr =
601 G4VProcess::StartTracking(aTrack);
623 if( chordF ) chordF->ResetStepEstimate();
627 G4FieldManagerStore* fieldMgrStore= G4FieldManagerStore::GetInstance();
628 fieldMgrStore->ClearAllChordFindersState();
658 G4cout <<
" MonopoleTransportation: Statistics for looping particles " << G4endl;
G4double fThreshold_Warning_Energy
G4bool DoesGlobalFieldExist()
G4double fMaxEnergyKilled
G4double endpointDistance
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
void StartTracking(G4Track *aTrack) override
G4bool fGeometryLimitedStep
const Monopole * fParticleDef
void ResetKilledStatistics(G4int report=1)
G4double AtRestGetPhysicalInteractionLength(const G4Track &, G4ForceCondition *) override
G4double fCandidateEndGlobalTime
G4double fThreshold_Important_Energy
G4ThreeVector fTransportEndMomentumDir
G4ThreeVector fPreviousSftOrigin
G4bool fShortStepOptimisation
G4double fSumEnergyKilled
void ConfigureForTrack(const G4Track *) override
G4bool fEndGlobalTimeComputed
G4ThreeVector fTransportEndSpin
G4ParticleChangeForTransport fParticleChange
G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double ¤tSafety, G4GPILSelection *selection) override
G4Navigator * fLinearNavigator
G4double PostStepGetPhysicalInteractionLength(const G4Track &, G4double previousStepSize, G4ForceCondition *pForceCond) override
MonopoleTransportation(const Monopole *p, G4int verbosityLevel=1)
G4PropagatorInField * fFieldPropagator
G4VParticleChange * AtRestDoIt(const G4Track &, const G4Step &) override
G4SafetyHelper * fpSafetyHelper
G4TouchableHandle fCurrentTouchableHandle
G4double MagneticCharge() const
G4double fTransportEndKineticEnergy
G4bool fParticleIsLooping
Square< F >::type sqr(const F &f)
~MonopoleTransportation() override
G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &stepData) override
G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData) override
CMSFieldManager * fieldMgrCMS
void SetMonopoleTracking(G4bool)
G4ThreeVector fTransportEndPosition