Problem 1111 - incorrect tracking in local magnetic field
Summary: incorrect tracking in local magnetic field
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: geometry/navigation (show other problems)
Version: 9.3
Hardware: PC Linux
: P5 major
Assignee: John Apostolakis
URL:
Depends on:
Blocks:
 
Reported: 2010-03-12 19:40 CET by Anton Karneyeu
Modified: 2018-07-09 08:57 CEST (History)
0 users

See Also:


Attachments
test (1.72 KB, application/x-gzip)
2010-03-12 19:42 CET, Anton Karneyeu
Details
Revised DetectorConstrucion.cc file (2.50 KB, application/octet-stream)
2015-03-09 18:53 CET, John Apostolakis
Details

Note You need to log in before you can comment on or make changes to this problem.
Description Anton Karneyeu 2010-03-12 19:40:58 CET
Hello,

I have prepared small test program which shows problem of incorrect tracking in local magnetic field.

Configuration is following:
  world volume filled with G4_Vacuum
  beam of electrons directed along axis Z
  local magnetic field directed along axis Z

In this configuration the simulation run shows a deviation along axis X or Y, which should not be.

Here is a part of output:
--------------------------------------------------------------------------
Start Run processing.
=====================================
  G4EventManager::ProcessOneEvent()
=====================================
1 primaries are passed from G4EventTransformer.
!!!!!!! Now start processing an event !!!!!!!

*********************************************************************************************************
* G4Track Information:   Particle = e-,   Track ID = 1,   Parent ID = 0
*********************************************************************************************************

Step#    X(mm)    Y(mm)    Z(mm) KinE(MeV)  dE(MeV) StepLeng TrackLeng  NextVolume ProcName
    0        0        0        0         1        0        0         0       world initStep
    1   -0.248     10.6       60         1 1.69e-24     62.3      62.3  OutOfWorld Transportation
Track (trackID 1, parentID 0) is processed with stopping code 2
NULL returned from G4StackManager.
Terminate current event processing.
Run terminated. 
---------------------------------------------------------------------------

Anton
Comment 1 Anton Karneyeu 2010-03-12 19:42:11 CET
Created attachment 65 [details]
test
Comment 2 John Apostolakis 2015-03-09 18:48:17 CET
I have discovered the issue with the test program.

There is a mismatch between the Magnetic field created, and the electro-magnetic equation which was used. 

  // --- fields
  G4UniformMagField* elmagField = 
       new G4UniformMagField(G4ThreeVector(0., 0., 10.*gauss));
  G4EqMagElectricField* elmagEquation = 
      new G4EqMagElectricField(elmagField);

This was possible due to the existing inheritance between G4ElectroMagneticField (base class) and G4MagneticField (derived class).

If instead the equation of motion for the (pure) Magnetic field is used, the program exhibits the expected (correct) behaviour.  An excerpt of a program which does this and its results are below.

A revision which flags this problem when the user compile (or runs) the program should be considered.

// Revised source code
  G4MagIntegratorStepper* stepper= 0;
  G4Field* field= 0;
  G4double fieldValue= 10.0 * gauss;
  
  // --- fields
  
  //  Magnetic field only - Field defines only elements [0 to 2]
  G4UniformMagField* magField =
     new G4UniformMagField( G4ThreeVector(0., fieldValue, 0.) ); 

  //  Equation requires field                  elements [0 to 2]
  G4Mag_EqRhs* magEquation = new G4Mag_UsualEqRhs( magField );
  stepper = new G4ClassicalRK4(magEquation, 6);  //    x: 0-2, p: 3-5
  field= magField;
Comment 3 John Apostolakis 2015-03-09 18:50:53 CET
The missing output (using a revised G4SteppingVerbose with additional fields (momentum) and different precision is below.

"dir-X,Y and Z" are the momentum directions


*********************************************************************************************************
* G4Track Information:   Particle = e-,   Track ID = 1,   Parent ID = 0
*********************************************************************************************************

#Step#       X(mm)      Y(mm)      Z(mm)   dir-X   dir-Y   dir-Z Safety: Pre/Post (mm)KinE(MeV)  dE(MeV) StepLeng TrackLeng       StepStatus ProcName NextVolume Material: Current/Next 
 0           0          0          0       0       0       1        0    N/A           1        0        0         0 initStep       world G4_Galactic  Next:N/A  
#Step# 1/L      X(mm)      Y(mm)      Z(mm)   dir-X   dir-Y   dir-Z Safety: Pre/Post (mm)KinE(MeV)  dE(MeV) StepLeng TrackLeng       StepStatus ProcName NextVolume Material: Current/Next 
 1   0.3795          0         60  0.01265        0   0.9999        0        0         1 1.624e-24       60        60  Status= 0   World-Boundary Transportation  OutOfWorld   G4_Galactic
Comment 4 John Apostolakis 2015-03-09 18:53:34 CET
Created attachment 320 [details]
Revised DetectorConstrucion.cc file

Revised DetectorConstruction file for the test program.
Comment 5 John Apostolakis 2015-06-04 17:34:36 CEST
The test program points out a weakness / error in the design of the Geant4 field classes - the magnetic field derives from the electromagnetic field.

This allows the user to use an equation created for magnetic fields also for fields which have an electric component - which is incorrect and should result in a compilation error.

A fix will be prepared.
Comment 6 Gabriele Cosmo 2018-07-09 08:57:44 CEST
Fix included in 10.5-beta.