62 :
G4VProcess(G4String(
"MonopoleTransportation"), fTransportation),
67 fParticleIsLooping(false),
68 fPreviousSftOrigin(0., 0., 0.),
70 fThreshold_Warning_Energy(100 * MeV),
71 fThreshold_Important_Energy(250 * MeV),
75 fSumEnergyKilled(0.0),
76 fMaxEnergyKilled(0.0),
77 fShortStepOptimisation(false),
84 SetProcessSubType(TRANSPORTATION);
87 if (G4Threading::IsMasterThread() &&
88 G4Threading::IsMultithreadedApplication()) {
94 G4TransportationManager* transportMgr =
95 G4TransportationManager::GetTransportationManager();
136 const G4Track& track,
138 G4double currentMinimumStep, G4double& currentSafety,
139 G4GPILSelection* selection)
144 G4double geometryStepLength, newSafety;
156 *selection = CandidateForSelection;
160 const G4DynamicParticle* pParticle = track.GetDynamicParticle();
161 G4ThreeVector startMomentumDir = pParticle->GetMomentumDirection();
162 G4ThreeVector startPosition = track.GetPosition();
171 G4double MagSqShift = OriginShift.mag2();
182 G4double particleElectricCharge = pParticle->GetCharge();
193 G4FieldManager* fieldMgr = 0;
194 G4bool fieldExertsForce =
false;
196 if ((particleMagneticCharge != 0.0)) {
200 fieldMgr->ConfigureForTrack(&track);
206 fieldExertsForce = (fieldMgr->GetDetectorField() != 0);
215 if (!fieldExertsForce) {
216 G4double linearStepLength;
220 geometryStepLength = currentMinimumStep;
227 startPosition, startMomentumDir, currentMinimumStep, newSafety);
236 currentSafety = newSafety;
241 geometryStepLength = linearStepLength;
245 geometryStepLength = currentMinimumStep;
253 startPosition + geometryStepLength * startMomentumDir;
266 G4double momentumMagnitude = pParticle->GetTotalMomentum();
267 G4ThreeVector EndUnitMomentum;
268 G4double lengthAlongCurve;
271 G4ChargeState chargeState(particleElectricCharge,
275 particleMagneticCharge);
278 ->GetIntegrationDriver()
279 ->GetEquationOfMotion();
281 equationOfMotion->SetChargeMomentumMass(
282 chargeState, momentumMagnitude, restMass);
286 G4ThreeVector spin = track.GetPolarization();
287 G4FieldTrack aFieldTrack =
288 G4FieldTrack(startPosition, track.GetMomentumDirection(), 0.0,
289 track.GetKineticEnergy(), restMass, track.GetVelocity(),
290 track.GetGlobalTime(),
291 track.GetProperTime(),
293 if (currentMinimumStep > 0) {
297 aFieldTrack, currentMinimumStep, currentSafety, track.GetVolume());
300 geometryStepLength = lengthAlongCurve;
303 geometryStepLength = currentMinimumStep;
307 geometryStepLength = lengthAlongCurve = 0.0;
339 if (currentMinimumStep == 0.0) {
350 if (particleMagneticCharge != 0.0) {
354 currentSafety = endSafety;
364#ifdef G4DEBUG_TRANSPORT
365 G4cout.precision(12);
366 G4cout <<
"***G4MonopoleTransportation::AlongStepGPIL ** " << G4endl;
368 <<
" and it returned safety= " << endSafety << G4endl;
370 <<
" to obtain pseudo-safety= " << currentSafety << G4endl;
380 return geometryStepLength;
389 const G4Track& track,
const G4Step& stepData)
392 G4ParticleTable::GetParticleTable()->FindParticle(
"opticalphoton");
407 G4double deltaTime = 0.0;
411 G4double startTime = track.GetGlobalTime();
416 G4double finalVelocity = track.GetVelocity();
417 G4double initialVelocity = stepData.GetPreStepPoint()->GetVelocity();
418 G4double stepLength = track.GetStepLength();
421 const G4DynamicParticle* fpDynamicParticle = track.GetDynamicParticle();
422 if (fpDynamicParticle->GetDefinition() == fOpticalPhoton) {
425 deltaTime = stepLength / finalVelocity;
427 else if (finalVelocity > 0.0) {
428 G4double meanInverseVelocity;
430 meanInverseVelocity = 0.5 * (1.0 / initialVelocity + 1.0 / finalVelocity);
431 deltaTime = stepLength * meanInverseVelocity;
436 else if (initialVelocity > 0.0) {
437 deltaTime = stepLength / initialVelocity;
455 G4double restMass = track.GetDynamicParticle()->GetMass();
456 G4double deltaProperTime = deltaTime * (restMass / track.GetTotalEnergy());
458 fParticleChange.ProposeProperTime(track.GetProperTime() + deltaProperTime);
483 G4cout <<
" G4MonopoleTransportation is killing track "
484 <<
"that is looping or stuck " << G4endl <<
" This track has "
485 << track.GetKineticEnergy() / MeV <<
" MeV energy." << G4endl;
487 <<
" No of calls to AlongStepDoIt = " <<
noCalls << G4endl;
495 if ((verboseLevel > 2)) {
496 G4cout <<
" G4MonopoleTransportation::AlongStepDoIt(): "
497 <<
"Particle looping - "
499 <<
" No of calls to = " <<
noCalls << G4endl;
537 const G4Track& track,
const G4Step&)
539 G4TouchableHandle retCurrentTouchable;
557 track.GetPosition(), track.GetMomentumDirection(),
580 retCurrentTouchable = track.GetTouchableHandle();
583 const G4VPhysicalVolume* pNewVol = retCurrentTouchable->GetVolume();
584 const G4Material* pNewMaterial = 0;
587 pNewMaterial = pNewVol->GetLogicalVolume()->GetMaterial();
588 pNewSensitiveDetector = pNewVol->GetLogicalVolume()->GetSensitiveDetector();
598 const G4MaterialCutsCouple* pNewMaterialCutsCouple = 0;
600 pNewMaterialCutsCouple =
601 pNewVol->GetLogicalVolume()->GetMaterialCutsCouple();
604 if (pNewVol != 0 && pNewMaterialCutsCouple != 0 &&
605 pNewMaterialCutsCouple->GetMaterial() != pNewMaterial) {
608 pNewMaterialCutsCouple =
609 G4ProductionCutsTable::GetProductionCutsTable()->GetMaterialCutsCouple(
610 pNewMaterial, pNewMaterialCutsCouple->GetProductionCuts());
612 fParticleChange.SetMaterialCutsCoupleInTouchable(pNewMaterialCutsCouple);