Geant4-11
G4Transportation.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28// ------------------------------------------------------------
29// GEANT 4 include file implementation
30//
31// ------------------------------------------------------------
32//
33// This class is a process responsible for the transportation of
34// a particle, ie the geometrical propagation that encounters the
35// geometrical sub-volumes of the detectors.
36//
37// It is also tasked with the key role of proposing the "isotropic safety",
38// which will be used to update the post-step point's safety.
39//
40// =======================================================================
41// Created: 19 March 1997, J. Apostolakis
42// =======================================================================
43
44#include "G4Transportation.hh"
47
49#include "G4SystemOfUnits.hh"
51#include "G4ParticleTable.hh"
52
53#include "G4ChargeState.hh"
54#include "G4EquationOfMotion.hh"
55
58
60
64
66//
67// Constructor
68
70 : G4VProcess( G4String("Transportation"), fTransportation ),
71 fFieldExertedForce( false ),
72 fPreviousSftOrigin( 0.,0.,0. ),
73 fPreviousSafety( 0.0 ),
74 fEndPointDistance( -1.0 ),
75 fShortStepOptimisation( false ) // Old default: true (=fast short steps)
76{
78 pParticleChange= &fParticleChange; // Required to conform to G4VProcess
79 SetVerboseLevel(verbosity);
80
81 G4TransportationManager* transportMgr ;
82
84
85 fLinearNavigator = transportMgr->GetNavigatorForTracking() ;
86
87 fFieldPropagator = transportMgr->GetPropagatorInField() ;
88
89 fpSafetyHelper = transportMgr->GetSafetyHelper(); // New
90
91 fpLogger = new G4TransportationLogger("G4Transportation", verbosity);
92
94 // Use the old defaults: Warning = 100 MeV, Important = 250 MeV, No Trials = 10;
95
97 // Should be done by Set methods in SetHighLooperThresholds -- making sure
98
99 // Cannot determine whether a field exists here, as it would
100 // depend on the relative order of creating the detector's
101 // field and this process. That order is not guaranted.
103 // This value must be updated using DoesAnyFieldExist() at least at the
104 // start of each Run -- for now this is at the Start of every Track. TODO
105
106 static G4ThreadLocal G4TouchableHandle* pNullTouchableHandle = 0;
107 if ( !pNullTouchableHandle)
108 {
109 pNullTouchableHandle = new G4TouchableHandle;
110 }
111 fCurrentTouchableHandle = *pNullTouchableHandle;
112 // Points to (G4VTouchable*) 0
113
114
115#ifdef G4VERBOSE
116 if( verboseLevel > 0)
117 {
118 G4cout << " G4Transportation constructor> set fShortStepOptimisation to ";
119 if ( fShortStepOptimisation ) { G4cout << "true" << G4endl; }
120 else { G4cout << "false" << G4endl; }
121 }
122#endif
123}
124
126
128{
129 if( fSumEnergyKilled > 0.0 )
130 {
132 }
133 delete fpLogger;
134}
135
137
138void
139G4Transportation::PrintStatistics( std::ostream& outStr) const
140{
141 outStr << " G4Transportation: Statistics for looping particles " << G4endl;
142 if( fSumEnergyKilled > 0.0 || fNumLoopersKilled > 0 )
143 {
144 outStr << " Sum of energy of looping tracks killed: "
145 << fSumEnergyKilled / CLHEP::MeV << " MeV "
146 << " from " << fNumLoopersKilled << " tracks " << G4endl
147 << " Sum of energy of non-electrons : "
149 << " from " << fNumLoopersKilled_NonElectron << " tracks "
150 << G4endl;
151 outStr << " Max energy of *any type* looper killed: " << fMaxEnergyKilled
152 << " its PDG was " << fMaxEnergyKilledPDG << G4endl;
154 {
155 outStr << " Max energy of non-electron looper killed: "
157 << " its PDG was " << fMaxEnergyKilled_NonElecPDG << G4endl;
158 }
159 if( fMaxEnergySaved > 0.0 )
160 {
161 outStr << " Max energy of loopers 'saved': " << fMaxEnergySaved << G4endl;
162 outStr << " Sum of energy of loopers 'saved': "
164 outStr << " Sum of energy of unstable loopers 'saved': "
166 }
167 }
168 else
169 {
170 outStr << " No looping tracks found or killed. " << G4endl;
171 }
172}
173
175//
176// Responsibilities:
177// Find whether the geometry limits the Step, and to what length
178// Calculate the new value of the safety and return it.
179// Store the final time, position and momentum.
180
182 const G4Track& track,
183 G4double, // previousStepSize
184 G4double currentMinimumStep, G4double& currentSafety,
185 G4GPILSelection* selection)
186{
187 // Initial actions moved to StartTrack()
188 // --------------------------------------
189 // Note: in case another process changes touchable handle
190 // it will be necessary to add here (for all steps)
191 // fCurrentTouchableHandle = aTrack->GetTouchableHandle();
192
193 // GPILSelection is set to defaule value of CandidateForSelection
194 // It is a return value
195 //
196 *selection = CandidateForSelection;
197
198 // Get initial Energy/Momentum of the track
199 //
200 const G4ThreeVector startPosition = track.GetPosition();
201 const G4ThreeVector startMomentumDir = track.GetMomentumDirection();
202
203 // The Step Point safety can be limited by other geometries and/or the
204 // assumptions of any process - it's not always the geometrical safety.
205 // We calculate the starting point's isotropic safety here.
206 {
207 const G4double MagSqShift = (startPosition - fPreviousSftOrigin).mag2();
208
209 if(MagSqShift >= sqr(fPreviousSafety))
210 currentSafety = 0.0;
211 else
212 currentSafety = fPreviousSafety - std::sqrt(MagSqShift);
213 }
214
215 // Is the particle charged or has it a magnetic moment?
216 //
217 const G4DynamicParticle* pParticle = track.GetDynamicParticle();
218
219 const G4double particleMass = pParticle->GetMass();
220 const G4double particleCharge = pParticle->GetCharge();
221 const G4double kineticEnergy = pParticle->GetKineticEnergy();
222
223 const G4double magneticMoment = pParticle->GetMagneticMoment();
224 const G4ThreeVector particleSpin = pParticle->GetPolarization();
225
226 // There is no need to locate the current volume. It is Done elsewhere:
227 // On track construction
228 // By the tracking, after all AlongStepDoIts, in "Relocation"
229
230 // Check if the particle has a force, EM or gravitational, exerted on it
231 //
232
233 G4bool eligibleEM =
234 (particleCharge != 0.0) || ((magneticMoment != 0.0) && fUseMagneticMoment);
235 G4bool eligibleGrav = (particleMass != 0.0) && fUseGravity;
236
237 fFieldExertedForce = false;
238
239 if(eligibleEM || eligibleGrav)
240 {
241 if(G4FieldManager* fieldMgr =
243 {
244 // User can configure the field Manager for this track
245 fieldMgr->ConfigureForTrack(&track);
246 // Called here to allow a transition from no-field pointer
247 // to finite field (non-zero pointer).
248
249 // If the field manager has no field ptr, the field is zero
250 // by definition ( = there is no field ! )
251 if(const G4Field* ptrField = fieldMgr->GetDetectorField())
253 eligibleEM || (eligibleGrav && ptrField->IsGravityActive());
254 }
255 }
256
257 G4double geometryStepLength = currentMinimumStep;
258
259 if(currentMinimumStep == 0.0)
260 {
261 fEndPointDistance = 0.0;
262 // flag step as geometry limited if current safety is also zero
263 fGeometryLimitedStep = (currentSafety == 0.0);
264
265 fMomentumChanged = false;
266 fParticleIsLooping = false;
268 fTransportEndPosition = startPosition;
269 fTransportEndMomentumDir = startMomentumDir;
270 fTransportEndKineticEnergy = kineticEnergy;
271 fTransportEndSpin = particleSpin;
272 }
273 else if(!fFieldExertedForce)
274 {
275 fGeometryLimitedStep = false;
276 if(geometryStepLength > currentSafety || !fShortStepOptimisation)
277 {
278 const G4double linearStepLength = fLinearNavigator->ComputeStep(
279 startPosition, startMomentumDir, currentMinimumStep, currentSafety);
280
281 if(linearStepLength <= currentMinimumStep)
282 {
283 geometryStepLength = linearStepLength;
285 }
286 // Remember last safety origin & value.
287 //
288 fPreviousSftOrigin = startPosition;
289 fPreviousSafety = currentSafety;
290 fpSafetyHelper->SetCurrentSafety(currentSafety, startPosition);
291 }
292
293 fEndPointDistance = geometryStepLength;
294
295 fMomentumChanged = false;
296 fParticleIsLooping = false;
299 startPosition + geometryStepLength * startMomentumDir;
300 fTransportEndMomentumDir = startMomentumDir;
301 fTransportEndKineticEnergy = kineticEnergy;
302 fTransportEndSpin = particleSpin;
303 }
304 else // A field exerts force
305 {
306 const auto pParticleDef = pParticle->GetDefinition();
307 const auto particlePDGSpin = pParticleDef->GetPDGSpin();
308 const auto particlePDGMagM = pParticleDef->GetPDGMagneticMoment();
309
310 auto equationOfMotion = fFieldPropagator->GetCurrentEquationOfMotion();
311
312 // The charge can change (dynamic), therefore the use of G4ChargeState
313 //
314 equationOfMotion->SetChargeMomentumMass(
315 G4ChargeState(particleCharge, magneticMoment, particlePDGSpin),
316 pParticle->GetTotalMomentum(), particleMass);
317
318 G4FieldTrack aFieldTrack(startPosition,
319 track.GetGlobalTime(), // Lab.
320 startMomentumDir, kineticEnergy, particleMass,
321 particleCharge, particleSpin, particlePDGMagM,
322 0.0, // Length along track
323 particlePDGSpin);
324
325 // Do the Transport in the field (non recti-linear)
326 //
327 const G4double lengthAlongCurve = fFieldPropagator->ComputeStep(
328 aFieldTrack, currentMinimumStep, currentSafety, track.GetVolume(),
329 kineticEnergy < fThreshold_Important_Energy);
330
331 if(lengthAlongCurve < geometryStepLength)
332 geometryStepLength = lengthAlongCurve;
333
334 // Remember last safety origin & value.
335 //
336 fPreviousSftOrigin = startPosition;
337 fPreviousSafety = currentSafety;
338 fpSafetyHelper->SetCurrentSafety(currentSafety, startPosition);
339
341 //
342 // It is possible that step was reduced in PropagatorInField due to
343 // previous zero steps. To cope with case that reduced step is taken
344 // in full, we must rely on PiF to obtain this value
345
346 G4bool changesEnergy =
348
349 fMomentumChanged = true;
351
352 fEndGlobalTimeComputed = changesEnergy;
353 fTransportEndPosition = aFieldTrack.GetPosition();
355
356 fEndPointDistance = (fTransportEndPosition - startPosition).mag();
357
358 // Ignore change in energy for fields that conserve energy
359 // This hides the integration error, but gives a better physical answer
361 changesEnergy ? aFieldTrack.GetKineticEnergy() : kineticEnergy;
362 fTransportEndSpin = aFieldTrack.GetSpin();
363
365 {
366 // If the field can change energy, then the time must be integrated
367 // - so this should have been updated
368 //
370
371 // was ( fCandidateEndGlobalTime != track.GetGlobalTime() );
372 // a cleaner way is to have FieldTrack knowing whether time is updated.
373 }
374#if defined(G4VERBOSE) || defined(G4DEBUG_TRANSPORT)
375 else
376 {
377 // The energy should be unchanged by field transport,
378 // - so the time changed will be calculated elsewhere
379 //
380 // Check that the integration preserved the energy
381 // - and if not correct this!
382 G4double startEnergy = kineticEnergy;
384
385 static G4ThreadLocal G4int no_inexact_steps = 0, no_large_ediff;
386 G4double absEdiff = std::fabs(startEnergy - endEnergy);
387 if(absEdiff > perMillion * endEnergy)
388 {
389 no_inexact_steps++;
390 // Possible statistics keeping here ...
391 }
392 if(verboseLevel > 1)
393 {
394 if(std::fabs(startEnergy - endEnergy) > perThousand * endEnergy)
395 {
396 static G4ThreadLocal G4int no_warnings = 0, warnModulo = 1,
397 moduloFactor = 10;
398 no_large_ediff++;
399 if((no_large_ediff % warnModulo) == 0)
400 {
401 no_warnings++;
402 std::ostringstream message;
403 message << "Energy change in Step is above 1^-3 relative value. "
404 << G4endl << " Relative change in 'tracking' step = "
405 << std::setw(15) << (endEnergy - startEnergy) / startEnergy
406 << G4endl << " Starting E= " << std::setw(12)
407 << startEnergy / MeV << " MeV " << G4endl
408 << " Ending E= " << std::setw(12) << endEnergy / MeV
409 << " MeV " << G4endl
410 << "Energy has been corrected -- however, review"
411 << " field propagation parameters for accuracy." << G4endl;
412 if((verboseLevel > 2) || (no_warnings < 4) ||
413 (no_large_ediff == warnModulo * moduloFactor))
414 {
415 message << "These include EpsilonStepMax(/Min) in G4FieldManager "
416 << G4endl
417 << "which determine fractional error per step for "
418 "integrated quantities. "
419 << G4endl
420 << "Note also the influence of the permitted number of "
421 "integration steps."
422 << G4endl;
423 }
424 message << "Bad 'endpoint'. Energy change detected and corrected."
425 << G4endl << "Has occurred already " << no_large_ediff
426 << " times.";
427 G4Exception("G4Transportation::AlongStepGetPIL()", "EnergyChange",
428 JustWarning, message);
429 if(no_large_ediff == warnModulo * moduloFactor)
430 {
431 warnModulo *= moduloFactor;
432 }
433 }
434 }
435 } // end of if (verboseLevel)
436 }
437#endif
438 }
439
440 // Update the safety starting from the end-point,
441 // if it will become negative at the end-point.
442 //
443 if(currentSafety < fEndPointDistance)
444 {
445 if(particleCharge != 0.0)
446 {
447 G4double endSafety =
449 currentSafety = endSafety;
451 fPreviousSafety = currentSafety;
453
454 // Because the Stepping Manager assumes it is from the start point,
455 // add the StepLength
456 //
457 currentSafety += fEndPointDistance;
458
459#ifdef G4DEBUG_TRANSPORT
460 G4cout.precision(12);
461 G4cout << "***G4Transportation::AlongStepGPIL ** " << G4endl;
462 G4cout << " Called Navigator->ComputeSafety at " << fTransportEndPosition
463 << " and it returned safety= " << endSafety << G4endl;
464 G4cout << " Adding endpoint distance " << fEndPointDistance
465 << " to obtain pseudo-safety= " << currentSafety << G4endl;
466 }
467 else
468 {
469 G4cout << "***G4Transportation::AlongStepGPIL ** " << G4endl;
470 G4cout << " Avoiding call to ComputeSafety : " << G4endl;
471 G4cout << " charge = " << particleCharge << G4endl;
472 G4cout << " mag moment = " << magneticMoment << G4endl;
473#endif
474 }
475 }
476
478 fLastStepInVolume = false;
479 fNewTrack = false;
480
482 fParticleChange.ProposeTrueStepLength(geometryStepLength);
483
484 return geometryStepLength;
485}
486
488//
489// Initialize ParticleChange (by setting all its members equal
490// to corresponding members in G4Track)
491
493 const G4Step& stepData )
494{
495#if defined(G4VERBOSE) || defined(G4DEBUG_TRANSPORT)
497 noCallsASDI++;
498#else
499 #define noCallsASDI 0
500#endif
501
503
504 // Code for specific process
505 //
510
512
513 G4double deltaTime = 0.0 ;
514
515 // Calculate Lab Time of Flight (ONLY if field Equations used it!)
516 // G4double endTime = fCandidateEndGlobalTime;
517 // G4double delta_time = endTime - startTime;
518
519 G4double startTime = track.GetGlobalTime() ;
520
522 {
523 // The time was not integrated .. make the best estimate possible
524 //
525 G4double initialVelocity = stepData.GetPreStepPoint()->GetVelocity();
526 G4double stepLength = track.GetStepLength();
527
528 deltaTime= 0.0; // in case initialVelocity = 0
529 if ( initialVelocity > 0.0 ) { deltaTime = stepLength/initialVelocity; }
530
531 fCandidateEndGlobalTime = startTime + deltaTime ;
532 fParticleChange.ProposeLocalTime( track.GetLocalTime() + deltaTime) ;
533 }
534 else
535 {
536 deltaTime = fCandidateEndGlobalTime - startTime ;
538 }
539
540
541 // Now Correct by Lorentz factor to get delta "proper" Time
542
543 G4double restMass = track.GetDynamicParticle()->GetMass() ;
544 G4double deltaProperTime = deltaTime*( restMass/track.GetTotalEnergy() ) ;
545
546 fParticleChange.ProposeProperTime(track.GetProperTime() + deltaProperTime) ;
547 //fParticleChange.ProposeTrueStepLength( track.GetStepLength() ) ;
548
549 // If the particle is caught looping or is stuck (in very difficult
550 // boundaries) in a magnetic field (doing many steps) THEN can kill it ...
551 //
552 if ( fParticleIsLooping )
553 {
555 fNoLooperTrials ++;
556 auto particleType= track.GetDynamicParticle()->GetParticleDefinition();
557
558 G4bool stable = particleType->GetPDGStable();
559 G4bool candidateForEnd = (endEnergy < fThreshold_Important_Energy)
561 G4bool unstableAndKillable = !stable && ( fAbandonUnstableTrials != 0);
562 G4bool unstableForEnd = (endEnergy < fThreshold_Important_Energy)
564 if( (candidateForEnd && stable) || (unstableAndKillable && unstableForEnd) )
565 {
566 // Kill the looping particle
567 //
569 G4int particlePDG= particleType->GetPDGEncoding();
570 const G4int electronPDG= 11; // G4Electron::G4Electron()->GetPDGEncoding();
571
572 // Simple statistics
573 fSumEnergyKilled += endEnergy;
574 fSumEnerSqKilled = endEnergy * endEnergy;
576
577 if( endEnergy > fMaxEnergyKilled ) {
578 fMaxEnergyKilled = endEnergy;
579 fMaxEnergyKilledPDG = particlePDG;
580 }
581 if( particleType->GetPDGEncoding() != electronPDG )
582 {
583 fSumEnergyKilled_NonElectron += endEnergy;
584 fSumEnerSqKilled_NonElectron += endEnergy * endEnergy;
586
587 if( endEnergy > fMaxEnergyKilled_NonElectron )
588 {
590 fMaxEnergyKilled_NonElecPDG = particlePDG;
591 }
592 }
593
595 {
597 noCallsASDI, __func__ );
598 }
600 }
601 else
602 {
604 if( fNoLooperTrials == 1 ) {
605 fSumEnergySaved += endEnergy;
606 if ( !stable )
607 fSumEnergyUnstableSaved += endEnergy;
608 }
609#ifdef G4VERBOSE
611 {
612 G4cout << " " << __func__
613 << " Particle is looping but is saved ..." << G4endl
614 << " Number of trials = " << fNoLooperTrials << G4endl
615 << " No of calls to = " << noCallsASDI << G4endl;
616 }
617#endif
618 }
619 }
620 else
621 {
623 }
624
625 // Another (sometimes better way) is to use a user-limit maximum Step size
626 // to alleviate this problem ..
627
628 // Introduce smooth curved trajectories to particle-change
629 //
632
633 return &fParticleChange ;
634}
635
637//
638// This ensures that the PostStep action is always called,
639// so that it can do the relocation if it is needed.
640//
641
644 G4double, // previousStepSize
645 G4ForceCondition* pForceCond )
646{
647 fFieldExertedForce = false; // Not known
648 *pForceCond = Forced ;
649 return DBL_MAX ; // was kInfinity ; but convention now is DBL_MAX
650}
651
653//
654
656 const G4Step& )
657{
658 G4TouchableHandle retCurrentTouchable ; // The one to return
659 G4bool isLastStep= false;
660
661 // Initialize ParticleChange (by setting all its members equal
662 // to corresponding members in G4Track)
663 // fParticleChange.Initialize(track) ; // To initialise TouchableChange
664
666
667 // If the Step was determined by the volume boundary,
668 // logically relocate the particle
669
671 {
672 // fCurrentTouchable will now become the previous touchable,
673 // and what was the previous will be freed.
674 // (Needed because the preStepPoint can point to the previous touchable)
675
678 LocateGlobalPointAndUpdateTouchableHandle( track.GetPosition(),
679 track.GetMomentumDirection(),
681 true ) ;
682 // Check whether the particle is out of the world volume
683 // If so it has exited and must be killed.
684 //
686 {
688 }
689 retCurrentTouchable = fCurrentTouchableHandle ;
691
692 // Update the Step flag which identifies the Last Step in a volume
693 if( !fFieldExertedForce )
694 isLastStep = fLinearNavigator->ExitedMotherVolume()
696 else
697 isLastStep = fFieldPropagator->IsLastStepInVolume();
698 }
699 else // fGeometryLimitedStep is false
700 {
701 // This serves only to move the Navigator's location
702 //
704
705 // The value of the track's current Touchable is retained.
706 // (and it must be correct because we must use it below to
707 // overwrite the (unset) one in particle change)
708 // It must be fCurrentTouchable too ??
709 //
711 retCurrentTouchable = track.GetTouchableHandle() ;
712
713 isLastStep= false;
714 } // endif ( fGeometryLimitedStep )
715 fLastStepInVolume= isLastStep;
716
719
720 const G4VPhysicalVolume* pNewVol = retCurrentTouchable->GetVolume() ;
721 const G4Material* pNewMaterial = 0 ;
722 const G4VSensitiveDetector* pNewSensitiveDetector = 0 ;
723
724 if( pNewVol != 0 )
725 {
726 pNewMaterial= pNewVol->GetLogicalVolume()->GetMaterial();
727 pNewSensitiveDetector= pNewVol->GetLogicalVolume()->GetSensitiveDetector();
728 }
729
732
733 const G4MaterialCutsCouple* pNewMaterialCutsCouple = 0;
734 if( pNewVol != 0 )
735 {
736 pNewMaterialCutsCouple=pNewVol->GetLogicalVolume()->GetMaterialCutsCouple();
737 }
738
739 if ( pNewVol!=0 && pNewMaterialCutsCouple!=0
740 && pNewMaterialCutsCouple->GetMaterial()!=pNewMaterial )
741 {
742 // for parametrized volume
743 //
744 pNewMaterialCutsCouple =
746 ->GetMaterialCutsCouple(pNewMaterial,
747 pNewMaterialCutsCouple->GetProductionCuts());
748 }
749 fParticleChange.SetMaterialCutsCoupleInTouchable( pNewMaterialCutsCouple );
750
751 // temporarily until Get/Set Material of ParticleChange,
752 // and StepPoint can be made const.
753 // Set the touchable in ParticleChange
754 // this must always be done because the particle change always
755 // uses this value to overwrite the current touchable pointer.
756 //
757 fParticleChange.SetTouchableHandle(retCurrentTouchable) ;
758
759 return &fParticleChange ;
760}
761
763// New method takes over the responsibility to reset the state of
764// G4Transportation object at the start of a new track or the resumption
765// of a suspended track.
766//
767
768void
770{
772 fNewTrack= true;
773 fFirstStepInVolume= true;
774 fLastStepInVolume= false;
775
776 // The actions here are those that were taken in AlongStepGPIL
777 // when track.GetCurrentStepNumber()==1
778
779 // Whether field exists should be determined at run level -- TODO
781
782 // reset safety value and center
783 //
784 fPreviousSafety = 0.0 ;
786
787 // reset looping counter -- for motion in field
788 fNoLooperTrials= 0;
789 // Must clear this state .. else it depends on last track's value
790 // --> a better solution would set this from state of suspended track TODO ?
791 // Was if( aTrack->GetCurrentStepNumber()==1 ) { .. }
792
793 // ChordFinder reset internal state
794 //
796 {
798 // Resets all state of field propagator class (ONLY) including safety
799 // values (in case of overlaps and to wipe for first track).
800 }
801
802 // Make sure to clear the chord finders of all fields (i.e. managers)
803 //
805 fieldMgrStore->ClearAllChordFindersState();
806
807 // Update the current touchable handle (from the track's)
808 //
810
811 // Inform field propagator of new track
812 //
814}
815
817//
818
820{
821 G4bool lastValue= fUseMagneticMoment;
822 fUseMagneticMoment= useMoment;
824 return lastValue;
825}
826
828//
829
831{
832 G4bool lastValue= fUseGravity;
833 fUseGravity= useGravity;
835 return lastValue;
836}
837
839//
840// Supress (or not) warnings about 'looping' particles
841
843{
844 fSilenceLooperWarnings= val; // Flag to *Supress* all 'looper' warnings
845 // G4CoupledTransportation::fSilenceLooperWarnings= val;
846}
847
849//
851{
853}
854
855
857//
859{
860 // Restores the old high values -- potentially appropriate for energy-frontier
861 // HEP experiments.
862 // Caution: All tracks with E < 100 MeV that are found to loop are
863 SetThresholdWarningEnergy( 100.0 * CLHEP::MeV ); // Warn above this energy
864 SetThresholdImportantEnergy( 250.0 * CLHEP::MeV ); // Extra trial above this En
865
866 G4int maxTrials = 10;
867 SetThresholdTrials( maxTrials );
868
869 PushThresholdsToLogger(); // Again, to be sure
871}
872
874void G4Transportation::SetLowLooperThresholds() // Values for low-E applications
875{
876 // These values were the default in Geant4 10.5 - beta
877 SetThresholdWarningEnergy( 1.0 * CLHEP::keV ); // Warn above this En
878 SetThresholdImportantEnergy( 1.0 * CLHEP::MeV ); // Extra trials above it
879
880 G4int maxTrials = 30; // A new value - was 10
881 SetThresholdTrials( maxTrials );
882
883 PushThresholdsToLogger(); // Again, to be sure
885}
886
888//
889void
891{
892 const char* message= "Logger object missing from G4Transportation object";
893 G4String classAndMethod= G4String("G4Transportation") + G4String( methodName );
894 G4Exception(classAndMethod, "Missing Logger", JustWarning, message);
895}
896
897
899//
900void
902{
903 PushThresholdsToLogger(); // To be absolutely certain they are in sync
904 fpLogger->ReportLooperThresholds("G4Transportation");
905}
906
908//
909void G4Transportation::ProcessDescription(std::ostream& outStr) const
910
911// StreamInfo(std::ostream& out, const G4ParticleDefinition& part, G4bool rst) const
912
913{
914 G4String indent = " "; // : "");
915 G4int oldPrec= outStr.precision(6);
916 // outStr << std::setprecision(6);
917 outStr << G4endl << indent << GetProcessName() << ": ";
918
919 outStr << " Parameters for looping particles: " << G4endl
920 << " warning-E = " << fThreshold_Warning_Energy / CLHEP::MeV << " MeV " << G4endl
921 << " important E = " << fThreshold_Important_Energy / CLHEP::MeV << " MeV " << G4endl
922 << " thresholdTrials " << fThresholdTrials << G4endl;
923 outStr.precision(oldPrec);
924}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
G4ForceCondition
@ Forced
G4GPILSelection
@ CandidateForSelection
#define fPreviousSftOrigin
#define fPreviousSafety
#define fFieldExertedForce
@ fTransportation
static constexpr double perMillion
Definition: G4SIunits.hh:327
static constexpr double MeV
Definition: G4SIunits.hh:200
static constexpr double perThousand
Definition: G4SIunits.hh:326
CLHEP::Hep3Vector G4ThreeVector
G4ReferenceCountedHandle< G4VTouchable > G4TouchableHandle
@ fStopAndKill
#define noCallsASDI
double G4double
Definition: G4Types.hh:83
long G4long
Definition: G4Types.hh:87
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4double GetMass() const
G4double GetCharge() const
const G4ParticleDefinition * GetParticleDefinition() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
G4double GetMagneticMoment() const
G4double GetTotalMomentum() const
const G4ThreeVector & GetPolarization() const
virtual void SetChargeMomentumMass(G4ChargeState particleCharge, G4double MomentumXc, G4double MassXc2)=0
static G4FieldManagerStore * GetInstance()
G4bool DoesFieldChangeEnergy() const
const G4ThreeVector & GetMomentumDir() const
G4double GetKineticEnergy() const
G4ThreeVector GetPosition() const
G4ThreeVector GetSpin() const
G4double GetLabTimeOfFlight() const
G4VSensitiveDetector * GetSensitiveDetector() const
G4Material * GetMaterial() const
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
const G4Material * GetMaterial() const
G4ProductionCuts * GetProductionCuts() const
void SetGeometricallyLimitedStep()
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
Definition: G4Navigator.cc:614
virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
Definition: G4Navigator.cc:770
G4bool EnteredDaughterVolume() const
G4bool ExitedMotherVolume() const
void SetPointerToVectorOfAuxiliaryPoints(std::vector< G4ThreeVector > *vec)
void SetMaterialInTouchable(G4Material *fMaterial)
void SetTouchableHandle(const G4TouchableHandle &fTouchable)
void SetMaterialCutsCoupleInTouchable(const G4MaterialCutsCouple *fMaterialCutsCouple)
virtual void Initialize(const G4Track &)
void SetSensitiveDetectorInTouchable(G4VSensitiveDetector *fSensitiveDetector)
void SetMomentumChanged(G4bool b)
void ProposePolarization(G4double Px, G4double Py, G4double Pz)
void ProposePosition(G4double x, G4double y, G4double z)
void ProposeLocalTime(G4double t)
void ProposeProperTime(G4double finalProperTime)
void ProposeEnergy(G4double finalEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
void ProposeGlobalTime(G4double t)
G4bool GetPDGStable() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
static G4ProductionCutsTable * GetProductionCutsTable()
G4FieldManager * FindAndSetFieldManager(G4VPhysicalVolume *pCurrentPhysVol)
G4FieldManager * GetCurrentFieldManager()
G4bool IsLastStepInVolume()
G4bool IsParticleLooping() const
G4EquationOfMotion * GetCurrentEquationOfMotion()
std::vector< G4ThreeVector > * GimmeTrajectoryVectorAndForgetIt() const
G4double ComputeStep(G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=nullptr, G4bool canRelaxDeltaChord=false)
void SetCurrentSafety(G4double val, const G4ThreeVector &pos)
G4double GetVelocity() const
Definition: G4Step.hh:62
G4StepPoint * GetPreStepPoint() const
G4TrackStatus GetTrackStatus() const
G4VPhysicalVolume * GetVolume() const
const G4ThreeVector & GetPosition() const
G4double GetGlobalTime() const
G4double GetProperTime() const
G4double GetLocalTime() const
const G4DynamicParticle * GetDynamicParticle() const
const G4TouchableHandle & GetTouchableHandle() const
const G4ThreeVector & GetMomentumDirection() const
G4double GetStepLength() const
G4double GetTotalEnergy() const
void ReportLoopingTrack(const G4Track &track, const G4Step &stepInfo, G4int numTrials, G4long noCalls, const char *methodName) const
void ReportLooperThresholds(const char *className)
static G4TransportationManager * GetTransportationManager()
G4PropagatorInField * GetPropagatorInField() const
G4SafetyHelper * GetSafetyHelper() const
G4Navigator * GetNavigatorForTracking() const
void SetThresholdImportantEnergy(G4double newEnImp)
G4ThreeVector fPreviousSftOrigin
static void SetSilenceLooperWarnings(G4bool val)
G4double fThreshold_Important_Energy
G4double fMaxEnergyKilled_NonElectron
G4ThreeVector fTransportEndSpin
G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &currentSafety, G4GPILSelection *selection)
static G4bool EnableGravity(G4bool useGravity=true)
G4double fTransportEndKineticEnergy
void PushThresholdsToLogger()
void PrintStatistics(std::ostream &outStr) const
unsigned long fNumLoopersKilled_NonElectron
static G4bool fSilenceLooperWarnings
G4PropagatorInField * fFieldPropagator
G4ThreeVector fTransportEndPosition
G4double fThreshold_Warning_Energy
G4double fSumEnerSqKilled_NonElectron
G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData)
void SetThresholdTrials(G4int newMaxTrials)
G4ParticleChangeForTransport fParticleChange
G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &stepData)
G4double PostStepGetPhysicalInteractionLength(const G4Track &, G4double previousStepSize, G4ForceCondition *pForceCond)
G4double fSumEnergyUnstableSaved
static G4bool EnableMagneticMoment(G4bool useMoment=true)
G4TouchableHandle fCurrentTouchableHandle
void StartTracking(G4Track *aTrack)
G4Transportation(G4int verbosityLevel=1)
static G4bool fUseGravity
G4Navigator * fLinearNavigator
G4TransportationLogger * fpLogger
G4bool DoesAnyFieldExist()
static G4bool fUseMagneticMoment
void SetThresholdWarningEnergy(G4double newEnWarn)
G4double fSumEnergyKilled_NonElectron
static G4bool GetSilenceLooperWarnings()
void ReportMissingLogger(const char *methodName)
G4ThreeVector fTransportEndMomentumDir
unsigned long fNumLoopersKilled
G4SafetyHelper * fpSafetyHelper
G4double fCandidateEndGlobalTime
virtual void ProcessDescription(std::ostream &outFile) const
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLastStepInVolume(G4bool flag)
void ProposeFirstStepInVolume(G4bool flag)
void ProposeTrueStepLength(G4double truePathLength)
G4LogicalVolume * GetLogicalVolume() const
void SetVerboseLevel(G4int value)
Definition: G4VProcess.hh:412
G4int verboseLevel
Definition: G4VProcess.hh:356
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:406
virtual void StartTracking(G4Track *)
Definition: G4VProcess.cc:87
G4VParticleChange * pParticleChange
Definition: G4VProcess.hh:321
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:34
static constexpr double keV
static constexpr double MeV
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T sqr(const T &x)
Definition: templates.hh:128
#define DBL_MAX
Definition: templates.hh:62
#define G4ThreadLocal
Definition: tls.hh:77