35 #include "G4mplEqMagElectricField.hh"
41 #include "CLHEP/Units/PhysicalConstants.h"
45 #include "G4Version.hh"
47 G4mplEqMagElectricField::G4mplEqMagElectricField(G4MagneticField *emField )
48 : G4Mag_EqRhs( emField )
57 G4mplEqMagElectricField::SetChargeMomentumMass(G4ChargeState particleCharge,
59 G4double particleMass)
66 fMassCof = particleMass*particleMass ;
68 G4Mag_EqRhs::SetChargeMomentumMass(particleCharge, MomentumXc, particleMass);
73 G4mplEqMagElectricField::EvaluateRhsGivenB(
const G4double
y[],
74 const G4double Field[],
75 G4double dydx[] )
const
81 if (!
init)G4Exception(
"G4mplEqMagElectricField::EvaluateRhsGivenB",
"NotInitialized",FatalException,
"SetChargeMomentumMass has not been called");
83 const G4double pSquared =
y[3]*
y[3] +
y[4]*
y[4] +
y[5]*
y[5] ;
85 const G4double
Energy = std::sqrt( pSquared + fMassCof );
88 const G4double pModuleInverse = 1.0/std::sqrt(pSquared);
92 const G4double cofEl = fElCharge * pModuleInverse ;
93 const G4double cofMag = fMagCharge *
Energy * pModuleInverse;
96 dydx[0] =
y[3]*pModuleInverse ;
97 dydx[1] =
y[4]*pModuleInverse ;
98 dydx[2] =
y[5]*pModuleInverse ;
102 dydx[3] = cofMag * Field[0] + cofEl * (
y[4]*Field[2] -
y[5]*Field[1]);
103 dydx[4] = cofMag * Field[1] + cofEl * (
y[5]*Field[0] -
y[3]*Field[2]);
104 dydx[5] = cofMag * Field[2] + cofEl * (
y[3]*Field[1] -
y[4]*Field[0]);
111 dydx[7] = inverse_velocity;