Index: trunk/source/geometry/magneticfield/History
===================================================================
--- trunk/source/geometry/magneticfield/History	(revision 850)
+++ trunk/source/geometry/magneticfield/History	(revision 921)
@@ -1,3 +1,3 @@
-$Id: History,v 1.130 2008/04/24 12:40:50 gcosmo Exp $
+$Id: History,v 1.135 2008/11/21 21:16:11 gum Exp $
 -------------------------------------------------------------------
 
@@ -17,4 +17,33 @@
      * Reverse chronological order (last date on top), please *
      ----------------------------------------------------------
+
+November, 19th, 2008  P.Gumplinger - field-V09-01-05
+- renormalize the spin to ONE in G4EqEMFieldWithSpin.cc and G4Mag_SpinEqRhs.cc
+
+November, 7th, 2008   P.Gumplinger - field-V09-01-04
+----------------------------------
+- Added SetAnomaly() and GetAnomaly() accessors to G4EqEMFieldWithSpin.
+
+October, 28th, 2008   T.Nikitina - field-V09-01-03
+--------------------------------
+- Added 'ApproxCurveV' to method G4ChordFinder::ApproxCurvePointS() in 
+  order to better calculate the curve length.
+- Some code cleanup.
+
+September, 18th, 2008   T.Nikitina
+----------------------------------
+- Added new stepper class G4ConstRK4, performing integration of one step
+  with error calculation in constant magnetic field; implementation derived
+  from G4ClassicalRK4.
+
+July, 15th, 2008   J.Apostolakis - field-V09-01-02
+--------------------------------
+- Revised signature of G4ChordFinder::FinderNextChord(), making 'FieldTrack'
+  argument passed a reference.
+
+May, 28th, 2008   T.Nikitina
+----------------------------
+- G4ChordFinder: added new method ApproxCurvePointS() using Brent second order
+  location mechanism.
 
 April 24th, 2008   T.Nikitina - field-V09-01-01
Index: trunk/source/geometry/magneticfield/include/G4CashKarpRKF45.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4CashKarpRKF45.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4CashKarpRKF45.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4CashKarpRKF45.hh,v 1.11 2008/01/11 15:23:54 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4ChordFinder.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ChordFinder.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ChordFinder.hh	(revision 921)
@@ -25,11 +25,11 @@
 //
 //
-// $Id: G4ChordFinder.hh,v 1.19 2008/07/15 14:02:06 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// $Id: G4ChordFinder.hh,v 1.21 2008/10/29 14:17:42 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // 
-// class G4ChordFinder
-//
-// Class description:
+// Class G4ChordFinder
+//
+// class description:
 //
 // A class that provides RK integration of motion ODE  (as does g4magtr)
@@ -38,6 +38,5 @@
 
 // History:
-// - 25.02.97 John Apostolakis,  design and implementation 
-// - 05.03.97 V. Grichine , makeup to G4 'standard'
+// - 25.02.97 - John Apostolakis - Design and implementation 
 // -------------------------------------------------------------------
 
@@ -62,5 +61,4 @@
       
       virtual ~G4ChordFinder();
-
 
       G4double    AdvanceChordLimited( G4FieldTrack& yCurrent,
@@ -73,19 +71,20 @@
         // -> Returns Length of Step taken.
      
-      G4FieldTrack ApproxCurvePointS(const  G4FieldTrack&  curveAPointVelocity,
-                                      const  G4FieldTrack&  curveBPointVelocity,
-                                      const  G4ThreeVector& currentEPoint,
-                                      const  G4ThreeVector& currentFPoint,
-                                      const  G4ThreeVector& PointG,
-                                             G4bool first,G4double      epsStep);
+      G4FieldTrack ApproxCurvePointS( const G4FieldTrack&  curveAPointVelocity,
+                                      const G4FieldTrack&  curveBPointVelocity,
+                                      const G4FieldTrack&  ApproxCurveV,
+                                      const G4ThreeVector& currentEPoint,
+                                      const G4ThreeVector& currentFPoint,
+                                      const G4ThreeVector& PointG,
+                                            G4bool first,  G4double epsStep);
  
-      G4FieldTrack ApproxCurvePointV(const  G4FieldTrack&  curveAPointVelocity,
-                                     const  G4FieldTrack&  curveBPointVelocity,
-                                     const  G4ThreeVector& currentEPoint,
-                                            G4double      epsStep);
+      G4FieldTrack ApproxCurvePointV( const G4FieldTrack&  curveAPointVelocity,
+                                      const G4FieldTrack&  curveBPointVelocity,
+                                      const G4ThreeVector& currentEPoint,
+                                            G4double       epsStep);
 
       inline G4double InvParabolic( const G4double xa, const G4double ya,
-				    const G4double xb, const G4double yb,
-			     const G4double xc, const G4double yc );
+                                    const G4double xb, const G4double yb,
+                                    const G4double xc, const G4double yc );
 
       inline G4double  GetDeltaChord() const;
@@ -112,5 +111,27 @@
         // A report with the above -- and possibly other stats
       inline G4int SetVerbose( G4int newvalue=1); 
-       // Set verbosity and return old value
+        // Set verbosity and return old value
+
+      void SetFractions_Last_Next( G4double fractLast= 0.90, 
+                                   G4double fractNext= 0.95 ); 
+        // Parameters for  performance ... change with great care
+
+      inline void SetFirstFraction(G4double fractFirst);
+        // Parameter for  performance ... change with great care
+
+   public:  // without description
+
+      void     TestChordPrint( G4int    noTrials, 
+                               G4int    lastStepTrial, 
+                               G4double dChordStep, 
+                               G4double nextStepTrial );
+
+        //   Printing for monitoring ...
+ 
+      inline   G4double GetFirstFraction();         // Originally 0.999
+      inline   G4double GetFractionLast();          // Originally 1.000
+      inline   G4double GetFractionNextEstimate();  // Originally 0.980
+      inline   G4double GetMultipleRadius();        // No original value
+        //  Parameters for adapting performance ... use with great care
 
    protected:   // .........................................................
@@ -140,26 +161,5 @@
                                 G4double  oldStepTrial, 
                                 G4double  dChordStep);
-  public:  // no description 
-      void     TestChordPrint( G4int    noTrials, 
-                               G4int    lastStepTrial, 
-                               G4double dChordStep, 
-                               G4double nextStepTrial );
-        //   Printing for monitoring ...
- 
-      inline   G4double GetFirstFraction();         // Originally 0.999
-      inline   G4double GetFractionLast();          // Originally 1.000
-      inline   G4double GetFractionNextEstimate();  // Originally 0.980
-      inline   G4double GetMultipleRadius();        // No original value
-       //  Parameters for adapting performance ... use with great care
-
-   public:  // with description 
-      void     SetFractions_Last_Next( G4double fractLast= 0.90, 
-				       G4double fractNext= 0.95 ); 
-      //  Parameters for  performance ... change with great care
-
-      inline   void     SetFirstFraction(G4double fractFirst);
-      //  Parameter for  performance ... change with great care
-
-   protected:
+
       inline G4double GetLastStepEstimateUnc(); 
       inline void     SetLastStepEstimateUnc( G4double stepEst ); 
@@ -172,13 +172,16 @@
 
    private:  // ............................................................
-                                            // G4int    nOK, nBAD;
+                                          // G4int    nOK, nBAD;
       G4MagInt_Driver* fIntgrDriver;
 
       const G4double fDefaultDeltaChord;  // SET in G4ChordFinder.cc = 0.25 mm
 
-      G4double fDeltaChord;                        //  Maximum miss distance 
-
-      G4double    fLastStepEstimate_Unconstrained; //  State information for efficiency
+      G4double fDeltaChord;               //  Maximum miss distance 
+
+      G4double    fLastStepEstimate_Unconstrained;
+        //  State information for efficiency
+
       //  Variables used in construction/destruction
+
       G4bool fAllocatedStepper;
       G4EquationOfMotion* fEquation; 
Index: trunk/source/geometry/magneticfield/include/G4ChordFinder.icc
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ChordFinder.icc	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ChordFinder.icc	(revision 921)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4ChordFinder.icc,v 1.13 2008/05/28 09:20:03 tnikitin Exp $
-// GEANT4 tag $Name: HEAD $
+// $Id: G4ChordFinder.icc,v 1.14 2008/10/29 14:34:35 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // G4ChordFinder inline implementations
@@ -134,5 +134,5 @@
 		       T = ya/yc;
         const G4double Q = (T-1)*(R-1)*(S-1);
-	if (fabs(Q) <DBL_MIN ) return  DBL_MAX;
+	if (std::fabs(Q) <DBL_MIN ) return  DBL_MAX;
 	
 	const G4double P = S*(T*(R-T)*(xc-xb) - (1-R)*(xb-xa));
Index: trunk/source/geometry/magneticfield/include/G4ChordFinderSaf.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ChordFinderSaf.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ChordFinderSaf.hh	(revision 921)
@@ -24,6 +24,6 @@
 // ********************************************************************
 //
-// $Id: G4ChordFinderSaf.hh,v 1.3 2006/06/29 18:21:52 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// $Id: G4ChordFinderSaf.hh,v 1.4 2008/09/12 16:12:18 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // 
@@ -53,5 +53,5 @@
   ~G4ChordFinderSaf(); 
 
-  G4double FindNextChord( const  G4FieldTrack  yStart,
+  G4double FindNextChord( const  G4FieldTrack&  yStart,
 			  G4double     stepMax,
 			  G4FieldTrack&   yEnd,  // Endpoint
Index: trunk/source/geometry/magneticfield/include/G4ClassicalRK4.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ClassicalRK4.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ClassicalRK4.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ClassicalRK4.hh,v 1.10 2006/06/29 18:21:55 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4DELPHIMagField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4DELPHIMagField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4DELPHIMagField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4DELPHIMagField.hh,v 1.4 2006/06/29 18:21:57 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4ElectricField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ElectricField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ElectricField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ElectricField.hh,v 1.2 2006/06/29 18:21:59 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4ElectroMagneticField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ElectroMagneticField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ElectroMagneticField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ElectroMagneticField.hh,v 1.11 2006/06/29 18:22:01 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4EqEMFieldWithSpin.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4EqEMFieldWithSpin.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4EqEMFieldWithSpin.hh	(revision 921)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4EqEMFieldWithSpin.hh,v 1.1 2007/08/30 23:34:01 gum Exp $
-// GEANT4 tag $Name: HEAD $
+// $Id: G4EqEMFieldWithSpin.hh,v 1.3 2008/11/14 13:37:09 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
@@ -44,5 +44,6 @@
 
 #include "G4EquationOfMotion.hh"
-#include "G4ElectroMagneticField.hh"
+
+class G4ElectroMagneticField;
 
 class G4EqEMFieldWithSpin : public G4EquationOfMotion
@@ -52,5 +53,5 @@
     G4EqEMFieldWithSpin(G4ElectroMagneticField *emField );
 
-    ~G4EqEMFieldWithSpin() {;} 
+    ~G4EqEMFieldWithSpin();
 
     void  SetChargeMomentumMass(G4double particleCharge, // in e+ units
@@ -64,8 +65,12 @@
       // calculates the value of the derivative dydx.
 
+    inline void SetAnomaly(G4double a) { anomaly = a; }
+    inline G4double GetAnomaly() const { return anomaly; }
+      // set/get magnetic anomaly
+
   private:
 
-    G4double        fElectroMagCof ;
-    G4double        fMassCof;
+    G4double fElectroMagCof ;
+    G4double fMassCof;
 
     G4double omegac;
@@ -78,3 +83,3 @@
 };
 
-#endif
+#endif /* G4EQEMFIELDWITHSPIN */
Index: trunk/source/geometry/magneticfield/include/G4EqMagElectricField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4EqMagElectricField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4EqMagElectricField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4EqMagElectricField.hh,v 1.9 2006/06/29 18:22:03 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4EquationOfMotion.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4EquationOfMotion.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4EquationOfMotion.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4EquationOfMotion.hh,v 1.10 2006/06/29 18:22:05 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4EquationOfMotion.icc
===================================================================
--- trunk/source/geometry/magneticfield/include/G4EquationOfMotion.icc	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4EquationOfMotion.icc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4EquationOfMotion.icc,v 1.9 2006/06/29 18:22:07 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4ErrorMag_UsualEqRhs.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ErrorMag_UsualEqRhs.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ErrorMag_UsualEqRhs.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ErrorMag_UsualEqRhs.hh,v 1.1 2007/05/16 12:54:02 gcosmo Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4ExactHelixStepper.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ExactHelixStepper.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ExactHelixStepper.hh	(revision 921)
@@ -25,5 +25,5 @@
 //
 // $Id: G4ExactHelixStepper.hh,v 1.5 2007/05/18 12:50:31 tnikitin Exp $ 
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4ExplicitEuler.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ExplicitEuler.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ExplicitEuler.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ExplicitEuler.hh,v 1.9 2006/06/29 18:22:11 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4Field.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4Field.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4Field.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4Field.hh,v 1.10 2006/06/29 18:22:13 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4FieldManager.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4FieldManager.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4FieldManager.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4FieldManager.hh,v 1.16 2006/06/29 18:22:15 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //  
Index: trunk/source/geometry/magneticfield/include/G4FieldManager.icc
===================================================================
--- trunk/source/geometry/magneticfield/include/G4FieldManager.icc	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4FieldManager.icc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4FieldManager.icc,v 1.12 2006/06/29 18:22:18 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4FieldManagerStore.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4FieldManagerStore.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4FieldManagerStore.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4FieldManagerStore.hh,v 1.3 2008/01/17 09:39:08 gcosmo Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // class G4FieldManagerStore
Index: trunk/source/geometry/magneticfield/include/G4FieldTrack.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4FieldTrack.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4FieldTrack.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4FieldTrack.hh,v 1.21 2006/11/13 18:24:35 gcosmo Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4FieldTrack.icc
===================================================================
--- trunk/source/geometry/magneticfield/include/G4FieldTrack.icc	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4FieldTrack.icc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4FieldTrack.icc,v 1.21 2006/11/13 18:24:35 gcosmo Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // -------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/include/G4HarmonicPolMagField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4HarmonicPolMagField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4HarmonicPolMagField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HarmonicPolMagField.hh,v 1.4 2006/06/29 18:22:24 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // class G4HarmonicPolMagField
Index: trunk/source/geometry/magneticfield/include/G4HelixExplicitEuler.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4HelixExplicitEuler.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4HelixExplicitEuler.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HelixExplicitEuler.hh,v 1.9 2007/08/21 08:52:00 tnikitin Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4HelixHeum.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4HelixHeum.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4HelixHeum.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HelixHeum.hh,v 1.8 2006/06/29 18:22:36 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4HelixImplicitEuler.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4HelixImplicitEuler.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4HelixImplicitEuler.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HelixImplicitEuler.hh,v 1.8 2006/06/29 18:22:38 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4HelixSimpleRunge.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4HelixSimpleRunge.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4HelixSimpleRunge.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HelixSimpleRunge.hh,v 1.7 2006/06/29 18:22:41 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4ImplicitEuler.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4ImplicitEuler.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4ImplicitEuler.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ImplicitEuler.hh,v 1.8 2006/06/29 18:22:44 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4LineCurrentMagField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4LineCurrentMagField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4LineCurrentMagField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4LineCurrentMagField.hh,v 1.4 2006/06/29 18:22:46 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4LineSection.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4LineSection.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4LineSection.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4LineSection.hh,v 1.9 2006/06/29 18:22:48 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4MagErrorStepper.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4MagErrorStepper.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4MagErrorStepper.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagErrorStepper.hh,v 1.11 2006/06/29 18:22:50 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4MagErrorStepper.icc
===================================================================
--- trunk/source/geometry/magneticfield/include/G4MagErrorStepper.icc	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4MagErrorStepper.icc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagErrorStepper.icc,v 1.13 2006/06/29 18:22:52 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // --------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/include/G4MagHelicalStepper.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4MagHelicalStepper.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4MagHelicalStepper.hh	(revision 921)
@@ -27,5 +27,5 @@
 //
 // $Id: G4MagHelicalStepper.hh,v 1.15 2007/08/21 08:48:28 tnikitin Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4MagHelicalStepper.icc
===================================================================
--- trunk/source/geometry/magneticfield/include/G4MagHelicalStepper.icc	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4MagHelicalStepper.icc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagHelicalStepper.icc,v 1.13 2007/05/18 15:45:15 tnikitin Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // Linear Step in regions of no field
Index: trunk/source/geometry/magneticfield/include/G4MagIntegratorDriver.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4MagIntegratorDriver.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4MagIntegratorDriver.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagIntegratorDriver.hh,v 1.20 2007/05/10 10:10:05 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4MagIntegratorDriver.icc
===================================================================
--- trunk/source/geometry/magneticfield/include/G4MagIntegratorDriver.icc	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4MagIntegratorDriver.icc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagIntegratorDriver.icc,v 1.13 2007/05/10 10:10:48 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // --------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/include/G4MagIntegratorStepper.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4MagIntegratorStepper.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4MagIntegratorStepper.hh	(revision 921)
@@ -25,5 +25,5 @@
 //
 // $Id: G4MagIntegratorStepper.hh,v 1.12 2006/09/20 09:31:01 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4MagIntegratorStepper.icc
===================================================================
--- trunk/source/geometry/magneticfield/include/G4MagIntegratorStepper.icc	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4MagIntegratorStepper.icc	(revision 921)
@@ -25,5 +25,5 @@
 //
 // $Id: G4MagIntegratorStepper.icc,v 1.10 2006/09/20 09:31:46 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 
Index: trunk/source/geometry/magneticfield/include/G4Mag_EqRhs.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4Mag_EqRhs.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4Mag_EqRhs.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4Mag_EqRhs.hh,v 1.9 2006/06/29 18:23:07 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4Mag_SpinEqRhs.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4Mag_SpinEqRhs.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4Mag_SpinEqRhs.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4Mag_SpinEqRhs.hh,v 1.11 2006/06/29 18:23:09 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4Mag_UsualEqRhs.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4Mag_UsualEqRhs.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4Mag_UsualEqRhs.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4Mag_UsualEqRhs.hh,v 1.7 2006/06/29 18:23:12 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4MagneticField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4MagneticField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4MagneticField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagneticField.hh,v 1.14 2006/06/29 18:23:14 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4QuadrupoleMagField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4QuadrupoleMagField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4QuadrupoleMagField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4QuadrupoleMagField.hh,v 1.4 2006/06/29 18:23:16 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4RKG3_Stepper.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4RKG3_Stepper.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4RKG3_Stepper.hh	(revision 921)
@@ -27,5 +27,5 @@
 //
 // $Id: G4RKG3_Stepper.hh,v 1.13 2007/05/18 12:44:02 tnikitin Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4SimpleHeum.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4SimpleHeum.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4SimpleHeum.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4SimpleHeum.hh,v 1.8 2006/06/29 18:23:20 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4SimpleRunge.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4SimpleRunge.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4SimpleRunge.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4SimpleRunge.hh,v 1.8 2006/06/29 18:23:23 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/include/G4UniformElectricField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4UniformElectricField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4UniformElectricField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4UniformElectricField.hh,v 1.9 2006/06/29 18:23:25 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // 
Index: trunk/source/geometry/magneticfield/include/G4UniformMagField.hh
===================================================================
--- trunk/source/geometry/magneticfield/include/G4UniformMagField.hh	(revision 850)
+++ trunk/source/geometry/magneticfield/include/G4UniformMagField.hh	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4UniformMagField.hh,v 1.9 2006/06/29 18:23:27 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // 
Index: trunk/source/geometry/magneticfield/src/G4CashKarpRKF45.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4CashKarpRKF45.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4CashKarpRKF45.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4CashKarpRKF45.cc,v 1.15 2008/01/11 18:11:44 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // The Cash-Karp Runge-Kutta-Fehlberg 4/5 method is an embedded fourth
Index: trunk/source/geometry/magneticfield/src/G4ChordFinder.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4ChordFinder.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4ChordFinder.cc	(revision 921)
@@ -25,11 +25,12 @@
 //
 //
-// $Id: G4ChordFinder.cc,v 1.49 2008/07/15 14:02:06 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// $Id: G4ChordFinder.cc,v 1.51 2008/10/29 14:17:42 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
-// 25.02.97 John Apostolakis,  design and implimentation 
-// 05.03.97 V. Grichine , style modification
+// 25.02.97 - John Apostolakis - Design and implementation 
 // -------------------------------------------------------------------
+
+#include <iomanip>
 
 #include "G4ChordFinder.hh"
@@ -38,5 +39,4 @@
 #include "G4ClassicalRK4.hh"
 
-#include <iomanip>
 
 // ..........................................................................
@@ -54,5 +54,5 @@
 {
   // Simple constructor which does not create equation, ..
-      // fDeltaChord= fDefaultDeltaChord; 
+
   fIntgrDriver= pIntegrationDriver;
   fAllocatedStepper= false;
@@ -62,4 +62,5 @@
     // check the values and set the other parameters
 }
+
 
 // ..........................................................................
@@ -80,4 +81,5 @@
   //  Construct the Chord Finder
   //  by creating in inverse order the  Driver, the Stepper and EqRhs ...
+
   G4Mag_EqRhs *pEquation = new G4Mag_UsualEqRhs(theMagField);
   fEquation = pEquation;                            
@@ -103,4 +105,20 @@
                                      pItsStepper->GetNumberOfVariables() );
 }
+
+
+// ......................................................................
+
+G4ChordFinder::~G4ChordFinder()
+{
+  delete   fEquation; // fIntgrDriver->pIntStepper->theEquation_Rhs;
+  if( fAllocatedStepper)
+  { 
+     delete fDriversStepper; 
+  }
+  delete   fIntgrDriver; 
+
+  if( fStatsVerbose ) { PrintStatistics(); }
+}
+
 
 // ......................................................................
@@ -113,43 +131,493 @@
   if( fractNext == -1.0 )   fractNext = 0.98;  // 0.9; 
 
-  // fFirstFraction  = 0.999;  // Orig 0.999 A safe value,  range: ~ 0.95 - 0.999 
-  // fMultipleRadius = 15.0;   // For later use, range: ~  2 - 20 
-
-  if( fStatsVerbose ) { 
+  // fFirstFraction  = 0.999; // Orig 0.999 A safe value, range: ~ 0.95 - 0.999
+  // fMultipleRadius = 15.0;  // For later use, range: ~  2 - 20 
+
+  if( fStatsVerbose )
+  { 
     G4cout << " ChordFnd> Trying to set fractions: "
-	   << " first " << fFirstFraction
-	   << " last " <<  fractLast
-	   << " next " <<  fractNext
-	   << " and multiple " << fMultipleRadius
-	   << G4endl;
+           << " first " << fFirstFraction
+           << " last " <<  fractLast
+           << " next " <<  fractNext
+           << " and multiple " << fMultipleRadius
+           << G4endl;
   } 
 
   if( (fractLast > 0.0) && (fractLast <=1.0) ) 
-    { fFractionLast= fractLast; }
-  else
+  {
+    fFractionLast= fractLast;
+  }
+  else
+  {
+    G4cerr << "G4ChordFinder::SetFractions_Last_Next: Invalid "
+           << " fraction Last = " << fractLast
+           << " must be  0 <  fractionLast <= 1 " << G4endl;
+  }
+  if( (fractNext > 0.0) && (fractNext <1.0) )
+  {
+    fFractionNextEstimate = fractNext;
+  }
+  else
+  {
     G4cerr << "G4ChordFinder:: SetFractions_Last_Next: Invalid "
-	   << " fraction Last = " << fractLast
-	   << " must be  0 <  fractionLast <= 1 " << G4endl;
-  if( (fractNext > 0.0) && (fractNext <1.0) )
-    { fFractionNextEstimate = fractNext; }
-  else
-    G4cerr << "G4ChordFinder:: SetFractions_Last_Next: Invalid "
-	   << " fraction Next = " << fractNext
-	   << " must be  0 <  fractionNext < 1 " << G4endl;
-}
+           << " fraction Next = " << fractNext
+           << " must be  0 <  fractionNext < 1 " << G4endl;
+  }
+}
+
 
 // ......................................................................
 
-G4ChordFinder::~G4ChordFinder()
-{
-  delete   fEquation; // fIntgrDriver->pIntStepper->theEquation_Rhs;
-  if( fAllocatedStepper)
+G4double 
+G4ChordFinder::AdvanceChordLimited( G4FieldTrack& yCurrent,
+                                    G4double      stepMax,
+                                    G4double      epsStep,
+                                    const G4ThreeVector latestSafetyOrigin,
+                                    G4double       latestSafetyRadius )
+{
+  G4double stepPossible;
+  G4double dyErr;
+  G4FieldTrack yEnd( yCurrent);
+  G4double  startCurveLen= yCurrent.GetCurveLength();
+  G4double nextStep;
+  //            *************
+  stepPossible= FindNextChord(yCurrent, stepMax, yEnd, dyErr, epsStep,
+                              &nextStep, latestSafetyOrigin, latestSafetyRadius
+                             );
+  //            *************
+
+  G4bool good_advance;
+
+  if ( dyErr < epsStep * stepPossible )
+  {
+     // Accept this accuracy.
+
+     yCurrent = yEnd;
+     good_advance = true; 
+  }
+  else
+  {  
+     // Advance more accurately to "end of chord"
+     //                           ***************
+     good_advance = fIntgrDriver->AccurateAdvance(yCurrent, stepPossible,
+                                                  epsStep, nextStep);
+     if ( ! good_advance )
+     { 
+       // In this case the driver could not do the full distance
+       stepPossible= yCurrent.GetCurveLength()-startCurveLen;
+     }
+  }
+  return stepPossible;
+}
+
+
+// ............................................................................
+
+G4double
+G4ChordFinder::FindNextChord( const  G4FieldTrack& yStart,
+                                     G4double     stepMax,
+                                     G4FieldTrack&   yEnd, // Endpoint
+                                     G4double&   dyErrPos, // Error of endpoint
+                                     G4double    epsStep,
+                                     G4double*  pStepForAccuracy, 
+                              const  G4ThreeVector, //  latestSafetyOrigin,
+                                     G4double       //  latestSafetyRadius 
+                                        )
+{
+  // Returns Length of Step taken
+
+  G4FieldTrack yCurrent=  yStart;  
+  G4double    stepTrial, stepForAccuracy;
+  G4double    dydx[G4FieldTrack::ncompSVEC]; 
+
+  //  1.)  Try to "leap" to end of interval
+  //  2.)  Evaluate if resulting chord gives d_chord that is good enough.
+  // 2a.)  If d_chord is not good enough, find one that is.
+  
+  G4bool    validEndPoint= false;
+  G4double  dChordStep, lastStepLength; //  stepOfLastGoodChord;
+
+  fIntgrDriver-> GetDerivatives( yCurrent, dydx );
+
+  G4int     noTrials=0;
+  const G4double safetyFactor= fFirstFraction; //  0.975 or 0.99 ? was 0.999
+
+  stepTrial = std::min( stepMax, safetyFactor*fLastStepEstimate_Unconstrained );
+
+  G4double newStepEst_Uncons= 0.0; 
+  do
   { 
-     delete fDriversStepper; 
-  }                                //  fIntgrDriver->pIntStepper;}
-  delete   fIntgrDriver; 
-
-  if( fStatsVerbose ) { PrintStatistics();  }
-}
+     G4double stepForChord;  
+     yCurrent = yStart;    // Always start from initial point
+    
+     //            ************
+     fIntgrDriver->QuickAdvance( yCurrent, dydx, stepTrial, 
+                                 dChordStep, dyErrPos);
+     //            ************
+     
+     //  We check whether the criterion is met here.
+     validEndPoint = AcceptableMissDist(dChordStep);
+
+     lastStepLength = stepTrial; 
+
+     // This method estimates to step size for a good chord.
+     stepForChord = NewStep(stepTrial, dChordStep, newStepEst_Uncons );
+
+     if( ! validEndPoint )
+     {
+        if( stepTrial<=0.0 )
+        {
+          stepTrial = stepForChord;
+        }
+        else if (stepForChord <= stepTrial)
+        {
+          // Reduce by a fraction, possibly up to 20% 
+          stepTrial = std::min( stepForChord, fFractionLast * stepTrial);
+        }
+        else
+        {
+          stepTrial *= 0.1;
+        }
+     }
+     noTrials++; 
+  }
+  while( ! validEndPoint );   // End of do-while  RKD 
+
+  if( newStepEst_Uncons > 0.0  )
+  {
+     fLastStepEstimate_Unconstrained= newStepEst_Uncons;
+  }
+
+  AccumulateStatistics( noTrials );
+
+  if( pStepForAccuracy )
+  { 
+     // Calculate the step size required for accuracy, if it is needed
+     //
+     G4double dyErr_relative = dyErrPos/(epsStep*lastStepLength);
+     if( dyErr_relative > 1.0 )
+     {
+        stepForAccuracy = fIntgrDriver->ComputeNewStepSize( dyErr_relative,
+                                                            lastStepLength );
+     }
+     else
+     {
+        stepForAccuracy = 0.0;   // Convention to show step was ok 
+     }
+     *pStepForAccuracy = stepForAccuracy;
+  }
+
+#ifdef  TEST_CHORD_PRINT
+  static int dbg=0;
+  if( dbg )
+  {
+    G4cout << "ChordF/FindNextChord:  NoTrials= " << noTrials 
+           << " StepForGoodChord=" << std::setw(10) << stepTrial << G4endl;
+  }
+#endif
+  yEnd=  yCurrent;  
+  return stepTrial; 
+}
+
+
+// ...........................................................................
+
+G4double G4ChordFinder::NewStep(G4double  stepTrialOld, 
+                                G4double  dChordStep, // Curr. dchord achieved
+                                G4double& stepEstimate_Unconstrained )  
+{
+  // Is called to estimate the next step size, even for successful steps,
+  // in order to predict an accurate 'chord-sensitive' first step
+  // which is likely to assist in more performant 'stepping'.
+
+  G4double stepTrial;
+  static G4double lastStepTrial = 1.,  lastDchordStep= 1.;
+
+#if 1
+
+  if (dChordStep > 0.0)
+  {
+    stepEstimate_Unconstrained =
+                 stepTrialOld*std::sqrt( fDeltaChord / dChordStep );
+    stepTrial =  fFractionNextEstimate * stepEstimate_Unconstrained;
+  }
+  else
+  {
+    // Should not update the Unconstrained Step estimate: incorrect!
+    stepTrial =  stepTrialOld * 2.; 
+  }
+
+  if( stepTrial <= 0.001 * stepTrialOld)
+  {
+     if ( dChordStep > 1000.0 * fDeltaChord )
+     {
+        stepTrial= stepTrialOld * 0.03;   
+     }
+     else
+     {
+        if ( dChordStep > 100. * fDeltaChord )
+        {
+          stepTrial= stepTrialOld * 0.1;   
+        }
+        else   // Try halving the length until dChordStep OK
+        {
+          stepTrial= stepTrialOld * 0.5;   
+        }
+     }
+  }
+  else if (stepTrial > 1000.0 * stepTrialOld)
+  {
+     stepTrial= 1000.0 * stepTrialOld;
+  }
+
+  if( stepTrial == 0.0 )
+  {
+     stepTrial= 0.000001;
+  }
+
+  lastStepTrial = stepTrialOld; 
+  lastDchordStep= dChordStep;
+
+#else
+
+  if ( dChordStep > 1000. * fDeltaChord )
+  {
+        stepTrial= stepTrialOld * 0.03;   
+  }
+  else
+  {
+     if ( dChordStep > 100. * fDeltaChord )
+     {
+        stepTrial= stepTrialOld * 0.1;   
+     }
+     else  // Keep halving the length until dChordStep OK
+     {
+        stepTrial= stepTrialOld * 0.5;   
+     }
+  }
+
+#endif 
+
+  // A more sophisticated chord-finder could figure out a better
+  // stepTrial, from dChordStep and the required d_geometry
+  //   e.g.
+  //      Calculate R, r_helix (eg at orig point)
+  //      if( stepTrial < 2 pi  R )
+  //          stepTrial = R arc_cos( 1 - fDeltaChord / r_helix )
+  //      else    
+  //          ??
+
+  return stepTrial;
+}
+
+
+// ...........................................................................
+
+G4FieldTrack
+G4ChordFinder::ApproxCurvePointS( const G4FieldTrack&  CurveA_PointVelocity, 
+                                  const G4FieldTrack&  CurveB_PointVelocity, 
+                                  const G4FieldTrack&  ApproxCurveV,
+                                  const G4ThreeVector& CurrentE_Point,
+                                  const G4ThreeVector& CurrentF_Point,
+                                  const G4ThreeVector& PointG,
+                                       G4bool first, G4double eps_step)
+{
+  // ApproxCurvePointS is 2nd implementation of ApproxCurvePoint.
+  // Use Brent Algorithm (or InvParabolic) when possible.
+  // Given a starting curve point A (CurveA_PointVelocity), curve point B
+  // (CurveB_PointVelocity), a point E which is (generally) not on the curve
+  // and  a point F which is on the curve (first approximation), find new
+  // point S on the curve closer to point E. 
+  // While advancing towards S utilise 'eps_step' as a measure of the
+  // relative accuracy of each Step.
+
+  G4FieldTrack EndPoint( CurveA_PointVelocity);
+  G4ThreeVector Point_A=CurveA_PointVelocity.GetPosition();
+  G4ThreeVector Point_B=CurveB_PointVelocity.GetPosition();
+  G4double xa,xb,xc,ya,yb,yc;
+ 
+  // InverseParabolic. AF Intersects (First Part of Curve) 
+
+  if(first)
+  {
+      xa=0.;
+      ya=(PointG-Point_A).mag();
+      xb=(Point_A-CurrentF_Point).mag();
+      yb=-(PointG-CurrentF_Point).mag();
+      xc=(Point_A-Point_B).mag();
+      yc=-(CurrentE_Point-Point_B).mag();
+  }    
+  else
+  {
+     xa=0.;
+     ya=(Point_A-PointG).mag();
+     xb=(Point_B-Point_A).mag();
+     yb=-(PointG-Point_B).mag();
+     xc=-(Point_A-CurrentF_Point).mag();
+     yc=-(Point_A-CurrentE_Point).mag();
+    
+  }
+  const G4double tolerance= 1.e-12;
+  if(ya<=tolerance||std::abs(yc)<=tolerance)
+  {
+    ; // What to do for the moment: return the same point as at start
+      // then PropagatorInField will take care
+  }
+  else
+  {
+    G4double test_step = InvParabolic(xa,ya,xb,yb,xc,yc);
+    G4double curve;
+    if(first)
+    {
+      curve=std::abs(EndPoint.GetCurveLength()
+                    -ApproxCurveV.GetCurveLength());
+    }
+    else
+    {
+      curve=std::abs(EndPoint.GetCurveLength()
+                    -CurveB_PointVelocity.GetCurveLength());
+    }
+      
+    if(test_step<=0)    { test_step=0.1*xb; }
+    if(test_step>=xb)   { test_step=0.5*xb; }
+    if(test_step>=curve){ test_step=0.5*curve; } 
+
+    if(curve*(1.+eps_step)<xb) // Similar to ReEstimate Step from
+    {                          // G4VIntersectionLocator
+      test_step=0.5*curve;
+    }
+
+    G4bool goodAdvance;
+    goodAdvance = fIntgrDriver->AccurateAdvance(EndPoint,test_step, eps_step);
+      
+#ifdef G4DEBUG_FIELD
+    // Printing Brent and Linear Approximation
+    //
+    G4cout << "G4ChordFinder::ApproxCurvePointS() - test-step ShF = "
+           << test_step << "  EndPoint = " << EndPoint << G4endl;
+
+    //  Test Track
+    //
+    G4FieldTrack TestTrack( CurveA_PointVelocity);
+    TestTrack = ApproxCurvePointV( CurveA_PointVelocity, 
+                                   CurveB_PointVelocity, 
+                                   CurrentE_Point, eps_step );
+    G4cout.precision(14);
+    G4cout << "G4ChordFinder::BrentApprox = " << EndPoint  << G4endl;
+    G4cout << "G4ChordFinder::LinearApprox= " << TestTrack << G4endl; 
+#endif
+  }
+  return EndPoint;
+}
+
+
+// ...........................................................................
+
+G4FieldTrack G4ChordFinder::
+ApproxCurvePointV( const G4FieldTrack& CurveA_PointVelocity, 
+                   const G4FieldTrack& CurveB_PointVelocity, 
+                   const G4ThreeVector& CurrentE_Point,
+                         G4double eps_step)
+{
+  // If r=|AE|/|AB|, and s=true path lenght (AB)
+  // return the point that is r*s along the curve!
+ 
+  G4FieldTrack   Current_PointVelocity = CurveA_PointVelocity; 
+
+  G4ThreeVector  CurveA_Point= CurveA_PointVelocity.GetPosition();
+  G4ThreeVector  CurveB_Point= CurveB_PointVelocity.GetPosition();
+
+  G4ThreeVector  ChordAB_Vector= CurveB_Point   - CurveA_Point;
+  G4ThreeVector  ChordAE_Vector= CurrentE_Point - CurveA_Point;
+
+  G4double       ABdist= ChordAB_Vector.mag();
+  G4double  curve_length;  //  A curve length  of AB
+  G4double  AE_fraction; 
+  
+  curve_length= CurveB_PointVelocity.GetCurveLength()
+              - CurveA_PointVelocity.GetCurveLength();  
+ 
+  G4double  integrationInaccuracyLimit= std::max( perMillion, 0.5*eps_step ); 
+  if( curve_length < ABdist * (1. - integrationInaccuracyLimit) )
+  { 
+#ifdef G4DEBUG_FIELD
+    G4cerr << " Warning in G4ChordFinder::ApproxCurvePoint: "
+           << G4endl
+           << " The two points are further apart than the curve length "
+           << G4endl
+           << " Dist = "         << ABdist
+           << " curve length = " << curve_length 
+           << " relativeDiff = " << (curve_length-ABdist)/ABdist 
+           << G4endl;
+    if( curve_length < ABdist * (1. - 10*eps_step) )
+    {
+      G4cerr << " ERROR: the size of the above difference"
+             << " exceeds allowed limits.  Aborting." << G4endl;
+      G4Exception("G4ChordFinder::ApproxCurvePointV()", "PrecisionError",
+                  FatalException, "Unphysical curve length.");
+    }
+#endif
+    // Take default corrective action: adjust the maximum curve length. 
+    // NOTE: this case only happens for relatively straight paths.
+    // curve_length = ABdist; 
+  }
+
+  G4double  new_st_length; 
+
+  if ( ABdist > 0.0 )
+  {
+     AE_fraction = ChordAE_Vector.mag() / ABdist;
+  }
+  else
+  {
+     AE_fraction = 0.5;                         // Guess .. ?; 
+#ifdef G4DEBUG_FIELD
+     G4cout << "Warning in G4ChordFinder::ApproxCurvePointV():"
+            << " A and B are the same point!" << G4endl
+            << " Chord AB length = " << ChordAE_Vector.mag() << G4endl
+            << G4endl;
+#endif
+  }
+  
+  if( (AE_fraction> 1.0 + perMillion) || (AE_fraction< 0.) )
+  {
+#ifdef G4DEBUG_FIELD
+    G4cerr << " G4ChordFinder::ApproxCurvePointV() - Warning:"
+           << " Anomalous condition:AE > AB or AE/AB <= 0 " << G4endl
+           << "   AE_fraction = " <<  AE_fraction << G4endl
+           << "   Chord AE length = " << ChordAE_Vector.mag() << G4endl
+           << "   Chord AB length = " << ABdist << G4endl << G4endl;
+    G4cerr << " OK if this condition occurs after a recalculation of 'B'"
+           << G4endl << " Otherwise it is an error. " << G4endl ; 
+#endif
+     // This course can now result if B has been re-evaluated, 
+     // without E being recomputed (1 July 99).
+     // In this case this is not a "real error" - but it is undesired
+     // and we cope with it by a default corrective action ...
+     //
+     AE_fraction = 0.5;                         // Default value
+  }
+
+  new_st_length= AE_fraction * curve_length; 
+
+  G4bool good_advance;
+  if ( AE_fraction > 0.0 )
+  { 
+     good_advance = fIntgrDriver->AccurateAdvance(Current_PointVelocity, 
+                                                  new_st_length, eps_step );
+     //
+     // In this case it does not matter if it cannot advance the full distance
+  }
+
+  // If there was a memory of the step_length actually required at the start 
+  // of the integration Step, this could be re-used ...
+
+  G4cout.precision(14);
+
+  return Current_PointVelocity;
+}
+
+
+// ......................................................................
 
 void
@@ -157,4 +625,5 @@
 {
   // Print Statistics
+
   G4cout << "G4ChordFinder statistics report: " << G4endl;
   G4cout 
@@ -171,465 +640,24 @@
 }
 
-// ......................................................................
-
-G4double 
-G4ChordFinder::AdvanceChordLimited( G4FieldTrack& yCurrent,
-                                    G4double      stepMax,
-                                    G4double      epsStep,
-				    const G4ThreeVector latestSafetyOrigin,
-				    G4double       latestSafetyRadius
-				    )
-{
-  G4double stepPossible;
-  G4double dyErr;
-  G4FieldTrack yEnd( yCurrent);
-  G4double  startCurveLen= yCurrent.GetCurveLength();
-  G4double nextStep;
-  //            *************
-  stepPossible= FindNextChord(yCurrent, stepMax, yEnd, dyErr, epsStep, &nextStep
-                              , latestSafetyOrigin, latestSafetyRadius
-                             );
-  //            *************
-  //  G4cout<<"Exit Find Next Chord Err= "<<dyErr<<" eps=  "<<epsStep<<"stepPos=  "<<stepPossible<<G4endl;
-  G4bool good_advance;
-
-  if ( dyErr < epsStep * stepPossible )
- 
-      {   //G4cout<<"err comparison = "<<dyErr<<" eps=  "<<epsStep<<G4endl;
-     // Accept this accuracy.
-     yCurrent = yEnd;
-     good_advance = true; 
-  }
-  else
-  {  
-    // G4cout<<"Entering Accurate Advance"<<G4endl;
-     // Advance more accurately to "end of chord"
-     //                           ***************
-     good_advance = fIntgrDriver->AccurateAdvance(yCurrent, stepPossible, epsStep, nextStep);
-     //                           ***************
-     if ( ! good_advance ){ 
-       // In this case the driver could not do the full distance
-       stepPossible= yCurrent.GetCurveLength()-startCurveLen;
-     }
-  }
-
-#ifdef G4DEBUG_FIELD
-  //G4cout << "Exiting FindNextChord Limited with:" << G4endl
-  //       << "   yCurrent: " << yCurrent<< G4endl; 
-#endif
-
-  return stepPossible;
-}
-
-// #define  TEST_CHORD_PRINT  1
-
-// ............................................................................
-
-G4double
-G4ChordFinder::FindNextChord( const  G4FieldTrack& yStart,
-                                     G4double     stepMax,
-                                     G4FieldTrack&   yEnd, // Endpoint
-                                     G4double&   dyErrPos, // Error of endpoint
-                                     G4double    epsStep,
-                                     G4double*  pStepForAccuracy, 
-			      const  G4ThreeVector, //  latestSafetyOrigin,
-			             G4double       //  latestSafetyRadius 
-					)
-  // Returns Length of Step taken
-{
-  //G4cout<<"Inter Find Next Chord with step="<<stepMax<<G4endl;  
-  // G4int       stepRKnumber=0;
-  G4FieldTrack yCurrent=  yStart;  
-  G4double    stepTrial, stepForAccuracy;
-  G4double    dydx[G4FieldTrack::ncompSVEC]; 
-
-  //  1.)  Try to "leap" to end of interval
-  //  2.)  Evaluate if resulting chord gives d_chord that is good enough.
-  //     2a.)  If d_chord is not good enough, find one that is.
-  
-  G4bool    validEndPoint= false;
-  G4double  dChordStep, lastStepLength; //  stepOfLastGoodChord;
-
-  fIntgrDriver-> GetDerivatives( yCurrent, dydx )  ;
-  //for (G4int i=0;i<G4FieldTrack::ncompSVEC;i++){
-  //  dydx[i]=0.;
-  //}
-  G4int     noTrials=0;
-  const G4double safetyFactor= fFirstFraction; //  0.975 or 0.99 ? was 0.999
-
-  stepTrial = std::min( stepMax, 
-                          safetyFactor * fLastStepEstimate_Unconstrained );
-
-  G4double newStepEst_Uncons= 0.0; 
-  do
-  { 
-     G4double stepForChord;  
-     yCurrent = yStart;    // Always start from initial point
-    
-     //            ************
-     fIntgrDriver->QuickAdvance( yCurrent, dydx, stepTrial, 
-				 dChordStep, dyErrPos);
-     //            ************
-
-     // G4cout<<"AfterQuickAdv step="<<stepTrial<<"  dC="<<dChordStep<<" yErr="<<dyErrPos<<G4endl;
-     
-      //  We check whether the criterion is met here.
-     validEndPoint = AcceptableMissDist(dChordStep);
-     // if(validEndPoint){G4cout<<"validEndPoint"<<fDeltaChord<<G4endl;} 
-     // else{G4cout<<"No__validEndPoint"<<G4endl;}
-
-
-     //&& (dyErrPos < eps) ;
-     //   validEndPoint = AcceptableMissDist(dChordStep) && (dyErrPos < epsStep) ;
-
-     lastStepLength = stepTrial; 
-
-     // This method estimates to step size for a good chord.
-     stepForChord = NewStep(stepTrial, dChordStep, newStepEst_Uncons );
-
-     if( ! validEndPoint ) {
-        if( stepTrial<=0.0 )
-	  stepTrial = stepForChord; 
-        else if (stepForChord <= stepTrial) 
-	  // Reduce by a fraction, possibly up to 20% 
-	  stepTrial = std::min( stepForChord, 
-	             		fFractionLast * stepTrial); 
-        else
-          stepTrial *= 0.1;
-
-        // if(dbg) G4cerr<<"Dchord too big. Try new hstep="<<stepTrial<<G4endl;
-     }
-     // #ifdef  TEST_CHORD_PRINT
-     // TestChordPrint( noTrials, lastStepLength, dChordStep, stepTrial );
-     // #endif
-
-     noTrials++; 
-  }
-  while( ! validEndPoint );   // End of do-while  RKD 
-
-  if( newStepEst_Uncons > 0.0  ){ 
-    fLastStepEstimate_Unconstrained= newStepEst_Uncons;
-  }
-
-  AccumulateStatistics( noTrials );
-
-  // stepOfLastGoodChord = stepTrial;
-
-  if( pStepForAccuracy ){ 
-     // Calculate the step size required for accuracy, if it is needed
-     G4double dyErr_relative = dyErrPos/(epsStep*lastStepLength);
-     if( dyErr_relative > 1.0 ) {
-        stepForAccuracy =
-	   fIntgrDriver->ComputeNewStepSize( dyErr_relative,
-					     lastStepLength );
-     }else{
-        stepForAccuracy = 0.0;   // Convention to show step was ok 
-     }
-     *pStepForAccuracy = stepForAccuracy;
-  }
-
-#ifdef  TEST_CHORD_PRINT
-  static int dbg=0;
-  if( dbg ) 
-    G4cout << "ChordF/FindNextChord:  NoTrials= " << noTrials 
-           << " StepForGoodChord=" << std::setw(10) << stepTrial << G4endl;
-#endif
-  //G4cout << "ChordF/FindNextChord:  NoTrials= " << noTrials 
-  //         << " StepForGoodChord=" << std::setw(10) << stepTrial << G4endl;
-  yEnd=  yCurrent;  
-  return stepTrial; 
-}
-
-// ----------------------------------------------------------------------------
-#if 0          
-//   #ifdef G4VERBOSE
-if( dbg ) {
-   G4cerr << "Returned from QuickAdvance with: yCur=" << yCurrent <<G4endl;
-   G4cerr << " dChordStep= "<< dChordStep <<" dyErr=" << dyErr << G4endl; 
-}
-#endif
-// ----------------------------------------------------------------------------
 
 // ...........................................................................
 
-G4double G4ChordFinder::NewStep(G4double  stepTrialOld, 
-                                G4double  dChordStep, // Curr. dchord achieved
-                                G4double& stepEstimate_Unconstrained )  
-//
-// Is called to estimate the next step size, even for successful steps,
-// in order to predict an accurate 'chord-sensitive' first step
-// which is likely to assist in more performant 'stepping'.
-//
-       
-{
-  G4double stepTrial;
-  static G4double lastStepTrial = 1.,  lastDchordStep= 1.;
-
-#if 1 
-  // const G4double  threshold = 1.21, multiplier = 0.9;
-  //  0.9 < 1 / std::sqrt(1.21)
-
-  if (dChordStep > 0.0)
-  {
-    stepEstimate_Unconstrained = stepTrialOld*std::sqrt( fDeltaChord / dChordStep );
-    // stepTrial =  0.98 * stepEstimate_Unconstrained;
-    stepTrial =  fFractionNextEstimate * stepEstimate_Unconstrained;
-  }
-  else
-  {
-    // Should not update the Unconstrained Step estimate: incorrect!
-    stepTrial =  stepTrialOld * 2.; 
-  }
-
-  // if ( dChordStep < threshold * fDeltaChord ){
-  //    stepTrial= stepTrialOld *  multiplier;    
-  // }
-  if( stepTrial <= 0.001 * stepTrialOld)
-  {
-     if ( dChordStep > 1000.0 * fDeltaChord ){
-        stepTrial= stepTrialOld * 0.03;   
-     }else{
-        if ( dChordStep > 100. * fDeltaChord ){
-          stepTrial= stepTrialOld * 0.1;   
-        }else{
-    // Try halving the length until dChordStep OK
-          stepTrial= stepTrialOld * 0.5;   
-        }
-     }
-  }else if (stepTrial > 1000.0 * stepTrialOld)
-  {
-     stepTrial= 1000.0 * stepTrialOld;
-  }
-
-  if( stepTrial == 0.0 ){
-     stepTrial= 0.000001;
-  }
-
-  lastStepTrial = stepTrialOld; 
-  lastDchordStep= dChordStep;
-#else
-  if ( dChordStep > 1000. * fDeltaChord ){
-        stepTrial= stepTrialOld * 0.03;   
-  }else{
-     if ( dChordStep > 100. * fDeltaChord ){
-        stepTrial= stepTrialOld * 0.1;   
-     }else{
-        // Keep halving the length until dChordStep OK
-        stepTrial= stepTrialOld * 0.5;   
-     }
-  }
-#endif 
-
-  // A more sophisticated chord-finder could figure out a better
-  //   stepTrial, from dChordStep and the required d_geometry
-  //   eg
-  //      Calculate R, r_helix (eg at orig point)
-  //      if( stepTrial < 2 pi  R )
-  //          stepTrial = R arc_cos( 1 - fDeltaChord / r_helix )
-  //      else    
-  //          ??
-
-  return stepTrial;
-}
-
-//  ApproxCurvePointS is 2nd implementation of ApproxCurvePoint.
-//  Use Brent Algorithm(or InvParabolic) when it possible.
-//  Given a starting curve point A (CurveA_PointVelocity),  
-//  curve point B (CurveB_PointVelocity), a point E which is (generally)
-//  not on the curve  and  a point F which is on the curve(first approximation)
-//  From this information find new point S on the curve closer to point E. 
-//  While advancing towards S utilise eps_step 
-//  as a measure of the relative accuracy of each Step.
-G4FieldTrack
-G4ChordFinder::ApproxCurvePointS( const G4FieldTrack& CurveA_PointVelocity, 
-                                  const G4FieldTrack& CurveB_PointVelocity, 
-                                  const G4ThreeVector& CurrentE_Point,
-                                  const G4ThreeVector& CurrentF_Point,
-                                  const G4ThreeVector& PointG,
-                                       G4bool first, G4double eps_step)
-{
-
- 
-  G4FieldTrack EndPoint( CurveA_PointVelocity);
-  G4ThreeVector Point_A=CurveA_PointVelocity.GetPosition();
-  G4ThreeVector Point_B=CurveB_PointVelocity.GetPosition();
-  G4double xa,xb,xc,ya,yb,yc;
- 
-//InverseParabolic
-//AF Intersects (First Part of Curve) 
-  if(first){
-      xa=0.;
-      ya=(PointG-Point_A).mag();
-      xb=(Point_A-CurrentF_Point).mag();
-      yb=-(PointG-CurrentF_Point).mag();
-      xc=(Point_A-Point_B).mag();
-      yc=-(CurrentE_Point-Point_B).mag();
-  }    
-  else{
-     xa=0.;
-     ya=(Point_A-PointG).mag();
-     xb=(Point_B-Point_A).mag();
-     yb=-(PointG-Point_B).mag();
-     xc=-(Point_A-CurrentF_Point).mag();
-     yc=-(Point_A-CurrentE_Point).mag();
-    
-  }
-  const G4double tolerance= 1.e-12;
-  if(ya<=tolerance||std::abs(yc)<=tolerance){
-    ; //What to do for the moment return the same point as in begin
-     //Then PropagatorInField will take care
-   }
-   else{
-         
-      G4double test_step  =InvParabolic(xa,ya,xb,yb,xc,yc);
-      G4double curve=std::abs(EndPoint.GetCurveLength()-CurveB_PointVelocity.GetCurveLength());
-      G4double dist= (EndPoint.GetPosition()-Point_B).mag();
-      if(test_step<=0) { test_step=0.1*xb;}
-      if(test_step>=xb){ test_step=0.5*xb;}
-       
-
-      if(curve*(1.+eps_step)<dist){
-	test_step=0.5*dist;
-       }
-
-       G4bool goodAdvance;
-       goodAdvance= 
-             fIntgrDriver->AccurateAdvance(EndPoint,test_step, eps_step);
-            //            ***************
-      
-       #ifdef G4DEBUG_FIELD
-        G4cout<<"G4ChordFinder:: test-step ShF="<<test_step<<"  EndPoint="<<EndPoint<<G4endl;
-      //    Test Track
-       G4FieldTrack TestTrack( CurveA_PointVelocity);
-       TestTrack = ApproxCurvePointV( CurveA_PointVelocity, 
-                                                  CurveB_PointVelocity, 
-                                                  CurrentE_Point,
-                                                  eps_step );
-       G4cout.precision(14);
-       G4cout<<"G4ChordFinder:: BrentApprox="<<EndPoint<<G4endl;
-       G4cout<<"G4ChordFinder::LinearApprox="<<TestTrack<<G4endl; 
-       #endif
-  }
-return EndPoint;
-}  
-
-G4FieldTrack
-G4ChordFinder::ApproxCurvePointV( const G4FieldTrack& CurveA_PointVelocity, 
-                                  const G4FieldTrack& CurveB_PointVelocity, 
-                                  const G4ThreeVector& CurrentE_Point,
-                                        G4double eps_step)
-{
-  // 1st implementation:
-  //    if r=|AE|/|AB|, and s=true path lenght (AB)
-  //    return the point that is r*s along the curve!
-  /////////////////////////////
-  //
-  //2st implementation : Inverse Parabolic Extrapolation by D.C.Williams
-  //
-  //    Uses InvParabolic (xa,ya,xb,yb,xc,yc)
-
-  G4FieldTrack    Current_PointVelocity = CurveA_PointVelocity; 
-
-  G4ThreeVector  CurveA_Point= CurveA_PointVelocity.GetPosition();
-  G4ThreeVector  CurveB_Point= CurveB_PointVelocity.GetPosition();
-
-  G4ThreeVector  ChordAB_Vector= CurveB_Point   - CurveA_Point;
-  G4ThreeVector  ChordAE_Vector= CurrentE_Point - CurveA_Point;
-
-  G4double       ABdist= ChordAB_Vector.mag();
-  G4double  curve_length;  //  A curve length  of AB
-  G4double  AE_fraction; 
-  
-  curve_length= CurveB_PointVelocity.GetCurveLength()
-              - CurveA_PointVelocity.GetCurveLength();  
-
-  // const 
-  G4double  integrationInaccuracyLimit= std::max( perMillion, 0.5*eps_step ); 
-  if( curve_length < ABdist * (1. - integrationInaccuracyLimit) ){ 
-#ifdef G4DEBUG_FIELD
-    G4cerr << " Warning in G4ChordFinder::ApproxCurvePoint: "
-           << G4endl
-           << " The two points are further apart than the curve length "
-           << G4endl
-           << " Dist = "         << ABdist
-           << " curve length = " << curve_length 
-           << " relativeDiff = " << (curve_length-ABdist)/ABdist 
-           << G4endl;
-    if( curve_length < ABdist * (1. - 10*eps_step) ) {
-      G4cerr << " ERROR: the size of the above difference"
-             << " exceeds allowed limits.  Aborting." << G4endl;
-      G4Exception("G4ChordFinder::ApproxCurvePointV()", "PrecisionError",
-                  FatalException, "Unphysical curve length.");
-    }
-#endif
-    // Take default corrective action: 
-    //    -->  adjust the maximum curve length. 
-    //  NOTE: this case only happens for relatively straight paths.
-    curve_length = ABdist; 
-  }
-
-  G4double  new_st_length; 
-
-  if ( ABdist > 0.0 ){
-     AE_fraction = ChordAE_Vector.mag() / ABdist;
-  }else{
-     AE_fraction = 0.5;                         // Guess .. ?; 
-#ifdef G4DEBUG_FIELD
-     G4cout << "Warning in G4ChordFinder::ApproxCurvePoint:"
-            << " A and B are the same point!" << G4endl
-            << " Chord AB length = " << ChordAE_Vector.mag() << G4endl
-            << G4endl;
-#endif
-  }
-  
-  if( (AE_fraction> 1.0 + perMillion) || (AE_fraction< 0.) ){
-#ifdef G4DEBUG_FIELD
-    G4cerr << " G4ChordFinder::ApproxCurvePointV - Warning:"
-           << " Anomalous condition:AE > AB or AE/AB <= 0 " << G4endl
-           << "   AE_fraction = " <<  AE_fraction << G4endl
-           << "   Chord AE length = " << ChordAE_Vector.mag() << G4endl
-           << "   Chord AB length = " << ABdist << G4endl << G4endl;
-    G4cerr << " OK if this condition occurs after a recalculation of 'B'"
-           << G4endl << " Otherwise it is an error. " << G4endl ; 
-#endif
-     // This course can now result if B has been re-evaluated, 
-     //   without E being recomputed   (1 July 99)
-     //  In this case this is not a "real error" - but it undesired
-     //   and we cope with it by a default corrective action ...
-     AE_fraction = 0.5;                         // Default value
-  }
-
-  new_st_length= AE_fraction * curve_length; 
-
-  G4bool good_advance;
-  if ( AE_fraction > 0.0 ) { 
-     good_advance = 
-      fIntgrDriver->AccurateAdvance(Current_PointVelocity, 
-                                    new_st_length,
-                                    eps_step ); // Relative accuracy
-     // In this case it does not matter if it cannot advance the full distance
-  }
-
-  // If there was a memory of the step_length actually require at the start 
-  // of the integration Step, this could be re-used ...
-   G4cout.precision(14);
-      
-   //     G4cout<<"G4ChordFinder::LinearApprox="<<Current_PointVelocity<<G4endl; 
-  return Current_PointVelocity;
-}
-
-void
-G4ChordFinder::TestChordPrint( G4int    noTrials, 
-			       G4int    lastStepTrial, 
-			       G4double dChordStep, 
-			       G4double nextStepTrial )
+void G4ChordFinder::TestChordPrint( G4int    noTrials, 
+                                    G4int    lastStepTrial, 
+                                    G4double dChordStep, 
+                                    G4double nextStepTrial )
 {
      G4int oldprec= G4cout.precision(5);
      G4cout << " ChF/fnc: notrial " << std::setw( 3) << noTrials 
             << " this_step= "       << std::setw(10) << lastStepTrial;
-     if( std::fabs( (dChordStep / fDeltaChord) - 1.0 ) < 0.001 ){
-             G4cout.precision(8);
-     }else{  G4cout.precision(6); }
-     G4cout << " dChordStep=  "     << std::setw(12) << dChordStep;
+     if( std::fabs( (dChordStep / fDeltaChord) - 1.0 ) < 0.001 )
+     {
+       G4cout.precision(8);
+     }
+     else
+     {
+       G4cout.precision(6);
+     }
+     G4cout << " dChordStep=  " << std::setw(12) << dChordStep;
      if( dChordStep > fDeltaChord ) { G4cout << " d+"; }
      else                           { G4cout << " d-"; }
Index: trunk/source/geometry/magneticfield/src/G4ChordFinderSaf.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4ChordFinderSaf.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4ChordFinderSaf.cc	(revision 921)
@@ -116,5 +116,5 @@
 
 G4double
-G4ChordFinderSaf::FindNextChord( const  G4FieldTrack  yStart,
+G4ChordFinderSaf::FindNextChord( const  G4FieldTrack&  yStart,
                                      G4double     stepMax,
                                      G4FieldTrack&   yEnd, // Endpoint
Index: trunk/source/geometry/magneticfield/src/G4ClassicalRK4.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4ClassicalRK4.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4ClassicalRK4.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ClassicalRK4.cc,v 1.12 2006/06/29 18:23:37 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // -------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4DELPHIMagField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4DELPHIMagField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4DELPHIMagField.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4DELPHIMagField.cc,v 1.6 2006/06/29 18:23:39 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 // -------------------------------------------------------------------
 
Index: trunk/source/geometry/magneticfield/src/G4ElectricField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4ElectricField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4ElectricField.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ElectricField.cc,v 1.2 2006/06/29 18:23:42 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // --------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4ElectroMagneticField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4ElectroMagneticField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4ElectroMagneticField.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ElectroMagneticField.cc,v 1.3 2006/06/29 18:23:44 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // --------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4EqEMFieldWithSpin.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4EqEMFieldWithSpin.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4EqEMFieldWithSpin.cc	(revision 921)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4EqEMFieldWithSpin.cc,v 1.2 2008/04/24 12:33:08 tnikitin Exp $
-// GEANT4 tag $Name: HEAD $
+// $Id: G4EqEMFieldWithSpin.cc,v 1.4 2008/11/21 21:17:03 gum Exp $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
@@ -40,13 +40,21 @@
 
 #include "G4EqEMFieldWithSpin.hh"
+#include "G4ElectroMagneticField.hh"
 #include "G4ThreeVector.hh"
 #include "globals.hh"
 
 G4EqEMFieldWithSpin::G4EqEMFieldWithSpin(G4ElectroMagneticField *emField )
-      : G4EquationOfMotion( emField ) { anomaly = 1.165923e-3; }
+      : G4EquationOfMotion( emField )
+{ 
+  anomaly = 0.0011659208;
+}
+
+G4EqEMFieldWithSpin::~G4EqEMFieldWithSpin()
+{
+} 
 
 void  
 G4EqEMFieldWithSpin::SetChargeMomentumMass(G4double particleCharge, // e+ units
-		                            G4double MomentumXc,
+                                            G4double MomentumXc,
                                             G4double particleMass)
 {
@@ -61,12 +69,11 @@
    beta  = MomentumXc/E;
    gamma = E/particleMass;
+
 }
-
-
 
 void
 G4EqEMFieldWithSpin::EvaluateRhsGivenB(const G4double y[],
-			                const G4double Field[],
-				              G4double dydx[] ) const
+                                       const G4double Field[],
+                                             G4double dydx[] ) const
 {
 
@@ -114,4 +121,7 @@
 
    G4ThreeVector Spin(y[9],y[10],y[11]);
+
+   if (Spin.mag() > 0.) Spin = Spin.unit();
+
    G4ThreeVector dSpin;
 
Index: trunk/source/geometry/magneticfield/src/G4EqMagElectricField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4EqMagElectricField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4EqMagElectricField.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4EqMagElectricField.cc,v 1.14 2008/04/24 12:33:35 tnikitin Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/src/G4EquationOfMotion.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4EquationOfMotion.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4EquationOfMotion.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4EquationOfMotion.cc,v 1.9 2006/06/29 18:23:48 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // -------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4ErrorMag_UsualEqRhs.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4ErrorMag_UsualEqRhs.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4ErrorMag_UsualEqRhs.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ErrorMag_UsualEqRhs.cc,v 1.1 2007/05/16 12:54:02 gcosmo Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/src/G4ExactHelixStepper.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4ExactHelixStepper.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4ExactHelixStepper.cc	(revision 921)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4ExactHelixStepper.cc,v 1.8 2007/12/10 16:29:47 gunter Exp $ 
-// GEANT4 tag $Name: HEAD $
+// $Id: G4ExactHelixStepper.cc,v 1.9 2008/10/29 14:34:35 gcosmo Exp $ 
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //  Helix a-la-Explicity Euler: x_1 = x_0 + helix(h)
@@ -112,5 +112,5 @@
 {
   // Implementation : must check whether h/R >  pi  !!
-  //   If( h/R <  pi)   DistChord=h/2*tan(Ang_curve/4)
+  //   If( h/R <  pi)   DistChord=h/2*std::tan(Ang_curve/4)
   //   Else             DistChord=R_helix
   //
Index: trunk/source/geometry/magneticfield/src/G4ExplicitEuler.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4ExplicitEuler.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4ExplicitEuler.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ExplicitEuler.cc,v 1.8 2006/06/29 18:23:53 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/src/G4FieldManager.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4FieldManager.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4FieldManager.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4FieldManager.cc,v 1.15 2007/12/07 15:34:10 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // -------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4FieldManagerStore.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4FieldManagerStore.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4FieldManagerStore.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4FieldManagerStore.cc,v 1.4 2008/01/17 10:56:23 gcosmo Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // G4FieldManagerStore
Index: trunk/source/geometry/magneticfield/src/G4FieldTrack.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4FieldTrack.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4FieldTrack.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4FieldTrack.cc,v 1.14 2007/10/03 15:34:42 japost Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // -------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4HarmonicPolMagField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4HarmonicPolMagField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4HarmonicPolMagField.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HarmonicPolMagField.cc,v 1.6 2006/06/29 18:24:00 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // -------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4HelixExplicitEuler.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4HelixExplicitEuler.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4HelixExplicitEuler.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HelixExplicitEuler.cc,v 1.8 2007/12/10 16:29:49 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/src/G4HelixHeum.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4HelixHeum.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4HelixHeum.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HelixHeum.cc,v 1.6 2006/06/29 18:24:04 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/src/G4HelixImplicitEuler.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4HelixImplicitEuler.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4HelixImplicitEuler.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HelixImplicitEuler.cc,v 1.6 2006/06/29 18:24:06 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/src/G4HelixSimpleRunge.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4HelixSimpleRunge.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4HelixSimpleRunge.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4HelixSimpleRunge.cc,v 1.7 2006/06/29 18:24:08 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/src/G4ImplicitEuler.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4ImplicitEuler.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4ImplicitEuler.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ImplicitEuler.cc,v 1.9 2006/06/29 18:24:11 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/src/G4LineCurrentMagField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4LineCurrentMagField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4LineCurrentMagField.cc	(revision 921)
@@ -25,5 +25,5 @@
 //
 // $Id: G4LineCurrentMagField.cc,v 1.6 2006/06/29 18:24:13 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 // -------------------------------------------------------------------
 
Index: trunk/source/geometry/magneticfield/src/G4LineSection.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4LineSection.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4LineSection.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4LineSection.cc,v 1.10 2006/06/29 18:24:16 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // --------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4MagErrorStepper.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4MagErrorStepper.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4MagErrorStepper.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagErrorStepper.cc,v 1.13 2006/06/29 18:24:18 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // --------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4MagHelicalStepper.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4MagHelicalStepper.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4MagHelicalStepper.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagHelicalStepper.cc,v 1.23 2007/09/05 12:20:17 gcosmo Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // --------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4MagIntegratorDriver.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4MagIntegratorDriver.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4MagIntegratorDriver.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagIntegratorDriver.cc,v 1.49 2007/08/17 12:30:33 gcosmo Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // 
Index: trunk/source/geometry/magneticfield/src/G4MagIntegratorStepper.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4MagIntegratorStepper.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4MagIntegratorStepper.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagIntegratorStepper.cc,v 1.11 2006/06/29 18:24:34 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // --------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4Mag_EqRhs.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4Mag_EqRhs.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4Mag_EqRhs.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4Mag_EqRhs.cc,v 1.11 2006/06/29 18:24:36 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //  This is the standard right-hand side for equation of motion  
Index: trunk/source/geometry/magneticfield/src/G4Mag_SpinEqRhs.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4Mag_SpinEqRhs.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4Mag_SpinEqRhs.cc	(revision 921)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4Mag_SpinEqRhs.cc,v 1.12 2006/06/29 18:24:39 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// $Id: G4Mag_SpinEqRhs.cc,v 1.13 2008/11/21 21:18:26 gum Exp $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // This is the standard right-hand side for equation of motion.
@@ -45,5 +45,5 @@
   : G4Mag_EqRhs( MagField ) 
 {
-   anomaly = 1.165923e-3;
+   anomaly = 0.0011659208;
 }
 
@@ -53,16 +53,16 @@
 G4Mag_SpinEqRhs::SetChargeMomentumMass(G4double particleCharge, // in e+ units
                                        G4double MomentumXc,
-                                       G4double mass)
+                                       G4double particleMass)
 {
    //  To set fCof_val 
-   G4Mag_EqRhs::SetChargeMomentumMass(particleCharge, MomentumXc, mass);
+   G4Mag_EqRhs::SetChargeMomentumMass(particleCharge, MomentumXc, particleMass);
 
-   omegac = 0.105658387*GeV/mass * 2.837374841e-3*(rad/cm/kilogauss);
+   omegac = 0.105658387*GeV/particleMass * 2.837374841e-3*(rad/cm/kilogauss);
 
    ParticleCharge = particleCharge;
 
-   E = std::sqrt(sqr(MomentumXc)+sqr(mass));
+   E = std::sqrt(sqr(MomentumXc)+sqr(particleMass));
    beta  = MomentumXc/E;
-   gamma = E/mass;
+   gamma = E/particleMass;
 
 }
@@ -96,4 +96,7 @@
 
    G4ThreeVector Spin(y[9],y[10],y[11]);
+
+   if (Spin.mag() > 0.) Spin = Spin.unit();
+
    G4ThreeVector dSpin;
 
Index: trunk/source/geometry/magneticfield/src/G4Mag_UsualEqRhs.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4Mag_UsualEqRhs.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4Mag_UsualEqRhs.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4Mag_UsualEqRhs.cc,v 1.12 2006/06/29 18:24:42 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
Index: trunk/source/geometry/magneticfield/src/G4MagneticField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4MagneticField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4MagneticField.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MagneticField.cc,v 1.3 2006/06/29 18:24:44 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // --------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4QuadrupoleMagField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4QuadrupoleMagField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4QuadrupoleMagField.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4QuadrupoleMagField.cc,v 1.4 2006/06/29 18:24:46 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // -------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4RKG3_Stepper.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4RKG3_Stepper.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4RKG3_Stepper.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4RKG3_Stepper.cc,v 1.15 2007/08/21 10:17:41 tnikitin Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // -------------------------------------------------------------------
Index: trunk/source/geometry/magneticfield/src/G4SimpleHeum.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4SimpleHeum.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4SimpleHeum.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4SimpleHeum.cc,v 1.8 2006/06/29 18:24:51 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //  Simple Heum:
Index: trunk/source/geometry/magneticfield/src/G4SimpleRunge.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4SimpleRunge.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4SimpleRunge.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4SimpleRunge.cc,v 1.10 2006/06/29 18:24:53 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //  Simple Runge:
Index: trunk/source/geometry/magneticfield/src/G4UniformElectricField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4UniformElectricField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4UniformElectricField.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4UniformElectricField.cc,v 1.12 2006/06/29 18:24:56 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 // 
Index: trunk/source/geometry/magneticfield/src/G4UniformMagField.cc
===================================================================
--- trunk/source/geometry/magneticfield/src/G4UniformMagField.cc	(revision 850)
+++ trunk/source/geometry/magneticfield/src/G4UniformMagField.cc	(revision 921)
@@ -26,5 +26,5 @@
 //
 // $Id: G4UniformMagField.cc,v 1.11 2006/06/29 18:24:58 gunter Exp $
-// GEANT4 tag $Name: HEAD $
+// GEANT4 tag $Name: geant4-09-02-cand-01 $
 //
 //
