Message: Sudden Changes in Particle Position using G4VProcess Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Sudden Changes in Particle Position using G4VProcess 

Forum: Event and Track Management
Date: 25 Apr, 2018
From: Greg Christian <Greg Christian>


I am trying to incorporate a RAYTRACE calculation of propagation of a particle through a magnetic field into a GEANT4 simulation. The integration of the RAYTRACE code into my simulation is not a problem, what I am asking about is the issue of integrating this into my event processing. Right now, I do this by defining a new G4VProcess and calling the magnetic field calculation in PostStepDoIt().

G4VParticleChange* RaytracePhysicalProcess::PostStepDoIt(
  const G4Track& aTrack, const G4Step&)
  const G4ParticleDefinition* particle =

  const G4StepPoint* preStep = aTrack.GetStep()->GetPreStepPoint();
  const G4StepPoint* postStep = aTrack.GetStep()->GetPostStepPoint();

  // Read kinetic information of track
  const G4double Ekin = preStep->GetKineticEnergy(); // MeV
  const G4double Mass = particle->GetPDGMass();    // MeV/c^2
  const G4int Charge  = particle->GetPDGCharge();  // e
  const G4ThreeVector& Pos = postStep->GetPosition(); // mm
  const G4ThreeVector& Mom = preStep->GetMomentumDirection();

  // Snipped code to call external RAYTRACE library and calculate
  // new values of Momentum direction and Position.
  G4ThreeVector PosOut = GetPosOut();
  G4ThreeVector MomOut = GetMomOut();

  // Change the position and direction of the particle (Ekin does not change)

  return &aParticleChange;

I also define a new "RAYTRACE" material and define the interaction length in this material using to be very small (1 nm). For all other materials I make the interaction length "infinity" (DBL_MAX). I do this using RaytracePhysicalProcess::PostStepGetPhysicalInteractionLength(). All other virtual functions I give null implementations.

Using this technique, I can make the calculation apply to charged particles passing through a region of space simply by placing a section of my RAYTRACE material (1nm thick) in the correct position in my detector construction. As far as I can tell, everything works fine, however I get the following errors on every event:

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomNav1002
      issued by : G4Navigator::ComputeStep()
Accuracy error or slightly inaccurate position shift.
     The Step's starting point has moved 9.50573 mm
     since the last call to a Locate method.
     This has resulted in moving 9.50573 mm  from the last point at which the safety      was calculated
     which is more than the computed safety= 7.04303e-11 mm  at that point.
     This difference is 9.50573 mm.
     The tolerated accuracy is 1e-06 mm.

  *** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomNav1002
      issued by : G4Navigator::ComputeStep()
May lead to a crash or unreliable results.
        Position has shifted considerably without notifying the navigator !
        Tolerated safety: 1.00007e-06
        Computed shift  : 90.3589
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

Presumably this is because of the sudden change in particle position (and momentum direction?).

My questions are as follows:

1. Are there any potential problems with the technique I am using.

2. Assuming the answer to (1) is yes, is there any way to suppress the warning messages?

Thank you for the help.

Best, Greg

PS - I am aware that magnetic field calculations with GEANT4 are possible, but I prefer to use the long-standing and well-tested RAYTRACE code instead.

 Add Message Add Message
to: "Sudden Changes in Particle Position using G4VProcess"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]