CMS 3D CMS Logo

MonopoleEquation.cc
Go to the documentation of this file.
1 //
2 // =======================================================================
3 //
4 // class G4MonopoleEquation
5 //
6 // Created: 30 April 2010, S. Burdin, B. Bozsogi
7 // G4MonopoleEquation class for
8 // Geant4 extended example "monopole"
9 //
10 // Adopted for CMSSW by V.Ivanchenko 30 April 2018
11 //
12 // =======================================================================
13 //
14 
16 #include "globals.hh"
17 #include "CLHEP/Units/PhysicalConstants.h"
18 #include "CLHEP/Units/SystemOfUnits.h"
19 #include <iomanip>
20 
21 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
22 
23 MonopoleEquation::MonopoleEquation(G4MagneticField *emField )
24  : G4EquationOfMotion( emField )
25 {}
26 
27 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
28 
30 {}
31 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 void
35 MonopoleEquation::SetChargeMomentumMass( G4ChargeState particleChargeState,
36  G4double,
37  G4double particleMass)
38 {
39  G4double particleMagneticCharge= particleChargeState.MagneticCharge();
40  G4double particleElectricCharge= particleChargeState.GetCharge();
41 
42  fElCharge = CLHEP::eplus*particleElectricCharge*CLHEP::c_light;
43 
44  fMagCharge = CLHEP::eplus*particleMagneticCharge*CLHEP::c_light;
45 
46  // G4cout << " MonopoleEquation: ElectricCharge=" << particleElectricCharge
47  // << "; MagneticCharge=" << particleMagneticCharge
48  // << G4endl;
49 
50  fMassCof = particleMass*particleMass ;
51 }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
55 void
57  const G4double Field[],
58  G4double dydx[] ) const
59 {
60  // Components of y:
61  // 0-2 dr/ds,
62  // 3-5 dp/ds - momentum derivatives
63 
64  G4double pSquared = y[3]*y[3] + y[4]*y[4] + y[5]*y[5] ;
65 
66  G4double Energy = std::sqrt( pSquared + fMassCof );
67 
68  G4double pModuleInverse = 1.0/std::sqrt(pSquared);
69 
70  G4double inverse_velocity = Energy * pModuleInverse / CLHEP::c_light;
71 
72  G4double cofEl = fElCharge * pModuleInverse ;
73  G4double cofMag = fMagCharge * Energy * pModuleInverse;
74 
75 
76  dydx[0] = y[3]*pModuleInverse ;
77  dydx[1] = y[4]*pModuleInverse ;
78  dydx[2] = y[5]*pModuleInverse ;
79 
80  // G4double magCharge = twopi * hbar_Planck / (eplus * mu0);
81  // magnetic charge in SI units A*m convention
82  // see http://en.wikipedia.org/wiki/Magnetic_monopole
83  // G4cout << "Magnetic charge: " << magCharge << G4endl;
84  // dp/ds = dp/dt * dt/ds = dp/dt / v = Force / velocity
85  // dydx[3] = fMagCharge * Field[0] * inverse_velocity * c_light;
86  // multiplied by c_light to convert to MeV/mm
87  // dydx[4] = fMagCharge * Field[1] * inverse_velocity * c_light;
88  // dydx[5] = fMagCharge * Field[2] * inverse_velocity * c_light;
89 
90  dydx[3] = cofMag * Field[0] + cofEl * (y[4]*Field[2] - y[5]*Field[1]);
91  dydx[4] = cofMag * Field[1] + cofEl * (y[5]*Field[0] - y[3]*Field[2]);
92  dydx[5] = cofMag * Field[2] + cofEl * (y[3]*Field[1] - y[4]*Field[0]);
93 
94  // G4cout << std::setprecision(5)<< "E=" << Energy
95  // << "; p="<< 1/pModuleInverse
96  // << "; mC="<< magCharge
97  // <<"; x=" << y[0]
98  // <<"; y=" << y[1]
99  // <<"; z=" << y[2]
100  // <<"; dydx[3]=" << dydx[3]
101  // <<"; dydx[4]=" << dydx[4]
102  // <<"; dydx[5]=" << dydx[5]
103  // << G4endl;
104 
105  dydx[6] = 0.;//not used
106 
107  // Lab Time of flight
108  dydx[7] = inverse_velocity;
109  return;
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
~MonopoleEquation() override
T sqrt(T t)
Definition: SSEVec.h:18
MonopoleEquation(G4MagneticField *emField)
void EvaluateRhsGivenB(const G4double y[], const G4double Field[], G4double dydx[]) const override
void SetChargeMomentumMass(G4ChargeState particleChargeState, G4double momentum, G4double mass) override