ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4EqEMFieldWithEDM.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4EqEMFieldWithEDM.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // G4EqEMFieldWithEDM implementation
27 //
28 // This is the standard right-hand side for equation of motion.
29 //
30 // Created: Kevin Lynch, 19.02.2009 - Based on G4EqEMFieldWithSpin
31 // Modified: Hiromi Iinuma, 06.11.2009 - see:
32 // http://hypernews.slac.stanford.edu/HyperNews/geant4/get/emfields/161.html
33 // -------------------------------------------------------------------
34 
35 #include "G4EqEMFieldWithEDM.hh"
37 #include "G4ThreeVector.hh"
38 #include "globals.hh"
39 #include "G4PhysicalConstants.hh"
40 #include "G4SystemOfUnits.hh"
41 
43  : G4EquationOfMotion( emField ), charge(0.), mass(0.), magMoment(0.),
44  spin(0.), fElectroMagCof(0.), fMassCof(0.), omegac(0.),
45  anomaly(0.0011659208), eta(0.), beta(0.), gamma(0.)
46 {
47 }
48 
50 {
51 }
52 
53 void
55  G4double MomentumXc,
56  G4double particleMass)
57 {
58  charge = particleCharge.GetCharge();
59  mass = particleMass;
60  magMoment = particleCharge.GetMagneticDipoleMoment();
61  spin = particleCharge.GetSpin();
62 
64  fMassCof = mass*mass;
65 
66  omegac = (eplus/mass)*c_light;
67 
68  G4double muB = 0.5*eplus*hbar_Planck/(mass/c_squared);
69 
70  G4double g_BMT;
71  if ( spin != 0. ) g_BMT = (std::abs(magMoment)/muB)/spin;
72  else g_BMT = 2.;
73 
74  anomaly = (g_BMT - 2.)/2.;
75 
76  G4double E = std::sqrt(sqr(MomentumXc)+sqr(mass));
77  beta = MomentumXc/E;
78  gamma = E/mass;
79 }
80 
81 void
83  const G4double Field[],
84  G4double dydx[] ) const
85 {
86 
87  // Components of y:
88  // 0-2 dr/ds,
89  // 3-5 dp/ds - momentum derivatives
90  // 9-11 dSpin/ds = (1/beta) dSpin/dt - spin derivatives
91 
92  // The BMT equation, following J.D.Jackson, Classical
93  // Electrodynamics, Second Edition, with additions for EDM
94  // evolution from
95  // M.Nowakowski, et.al. Eur.J.Phys.26, pp 545-560, (2005)
96  // or
97  // Silenko, Phys.Rev.ST Accel.Beams 9:034003, (2006)
98 
99  // dS/dt = (e/m) S \cross
100  // MDM: [ (g/2-1 +1/\gamma) B
101  // -(g/2-1)\gamma/(\gamma+1) (\beta \cdot B)\beta
102  // -(g/2-\gamma/(\gamma+1) \beta \cross E
103  //
104  // EDM: eta/2( E - gamma/(gamma+1) \beta (\beta \cdot E)
105  // + \beta \cross B ) ]
106  //
107  // where
108  // S = \vec{s}, where S^2 = 1
109  // B = \vec{B}
110  // \beta = \vec{\beta} = \beta \vec{u} with u^2 = 1
111  // E = \vec{E}
112 
113  G4double pSquared = y[3]*y[3] + y[4]*y[4] + y[5]*y[5] ;
114 
115  G4double Energy = std::sqrt( pSquared + fMassCof );
116  G4double cof2 = Energy/c_light ;
117 
118  G4double pModuleInverse = 1.0/std::sqrt(pSquared) ;
119 
120  G4double inverse_velocity = Energy * pModuleInverse / c_light;
121 
122  G4double cof1 = fElectroMagCof*pModuleInverse ;
123 
124  dydx[0] = y[3]*pModuleInverse ;
125  dydx[1] = y[4]*pModuleInverse ;
126  dydx[2] = y[5]*pModuleInverse ;
127 
128  dydx[3] = cof1*(cof2*Field[3] + (y[4]*Field[2] - y[5]*Field[1])) ;
129 
130  dydx[4] = cof1*(cof2*Field[4] + (y[5]*Field[0] - y[3]*Field[2])) ;
131 
132  dydx[5] = cof1*(cof2*Field[5] + (y[3]*Field[1] - y[4]*Field[0])) ;
133 
134  dydx[6] = dydx[8] = 0.;//not used
135 
136  // Lab Time of flight
137  dydx[7] = inverse_velocity;
138 
139  G4ThreeVector BField(Field[0],Field[1],Field[2]);
140  G4ThreeVector EField(Field[3],Field[4],Field[5]);
141 
142  EField /= c_light;
143 
144  G4ThreeVector u(y[3], y[4], y[5]);
145  u *= pModuleInverse;
146 
147  G4double udb = anomaly*beta*gamma/(1.+gamma) * (BField * u);
148  G4double ucb = (anomaly+1./gamma)/beta;
149  G4double uce = anomaly + 1./(gamma+1.);
150  G4double ude = beta*gamma/(1.+gamma)*(EField*u);
151 
152  G4ThreeVector Spin(y[9],y[10],y[11]);
153 
154  G4double pcharge;
155  if (charge == 0.) pcharge = 1.;
156  else pcharge = charge;
157 
158  G4ThreeVector dSpin(0.,0.,0.);
159  if (Spin.mag2() != 0.)
160  {
161  dSpin = pcharge*omegac*( ucb*(Spin.cross(BField))-udb*(Spin.cross(u))
162  // from Jackson
163  // -uce*Spin.cross(u.cross(EField)) )
164  // but this form has one less operation
165  - uce*(u*(Spin*EField) - EField*(Spin*u))
166  + eta/2.*(Spin.cross(EField) - ude*(Spin.cross(u))
167  // +Spin.cross(u.cross(Bfield))
168  + (u*(Spin*BField) - BField*(Spin*u)) ) );
169  }
170 
171  dydx[ 9] = dSpin.x();
172  dydx[10] = dSpin.y();
173  dydx[11] = dSpin.z();
174 
175  return;
176 }