CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
15 #include "CLHEP/Units/PhysicalConstants.h"
16 #include "CLHEP/Units/SystemOfUnits.h"
18 #include "globals.hh"
19 #include <iomanip>
20 
21 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
22 
23 MonopoleEquation::MonopoleEquation(G4MagneticField *emField) : G4EquationOfMotion(emField) {}
24 
25 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
26 
28 
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 
31 void MonopoleEquation::SetChargeMomentumMass(G4ChargeState particleChargeState, G4double, G4double particleMass) {
32  G4double particleMagneticCharge = particleChargeState.MagneticCharge();
33  G4double particleElectricCharge = particleChargeState.GetCharge();
34 
35  fElCharge = CLHEP::eplus * particleElectricCharge * CLHEP::c_light;
36 
37  fMagCharge = CLHEP::eplus * particleMagneticCharge * CLHEP::c_light;
38 
39  // G4cout << " MonopoleEquation: ElectricCharge=" << particleElectricCharge
40  // << "; MagneticCharge=" << particleMagneticCharge
41  // << G4endl;
42 
43  fMassCof = particleMass * particleMass;
44 }
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
48 void MonopoleEquation::EvaluateRhsGivenB(const G4double y[], const G4double Field[], G4double dydx[]) const {
49  // Components of y:
50  // 0-2 dr/ds,
51  // 3-5 dp/ds - momentum derivatives
52 
53  G4double pSquared = y[3] * y[3] + y[4] * y[4] + y[5] * y[5];
54 
55  G4double Energy = std::sqrt(pSquared + fMassCof);
56 
57  G4double pModuleInverse = 1.0 / std::sqrt(pSquared);
58 
59  G4double inverse_velocity = Energy * pModuleInverse / CLHEP::c_light;
60 
61  G4double cofEl = fElCharge * pModuleInverse;
62  G4double cofMag = fMagCharge * Energy * pModuleInverse;
63 
64  dydx[0] = y[3] * pModuleInverse;
65  dydx[1] = y[4] * pModuleInverse;
66  dydx[2] = y[5] * pModuleInverse;
67 
68  // G4double magCharge = twopi * hbar_Planck / (eplus * mu0);
69  // magnetic charge in SI units A*m convention
70  // see http://en.wikipedia.org/wiki/Magnetic_monopole
71  // G4cout << "Magnetic charge: " << magCharge << G4endl;
72  // dp/ds = dp/dt * dt/ds = dp/dt / v = Force / velocity
73  // dydx[3] = fMagCharge * Field[0] * inverse_velocity * c_light;
74  // multiplied by c_light to convert to MeV/mm
75  // dydx[4] = fMagCharge * Field[1] * inverse_velocity * c_light;
76  // dydx[5] = fMagCharge * Field[2] * inverse_velocity * c_light;
77 
78  dydx[3] = cofMag * Field[0] + cofEl * (y[4] * Field[2] - y[5] * Field[1]);
79  dydx[4] = cofMag * Field[1] + cofEl * (y[5] * Field[0] - y[3] * Field[2]);
80  dydx[5] = cofMag * Field[2] + cofEl * (y[3] * Field[1] - y[4] * Field[0]);
81 
82  // G4cout << std::setprecision(5)<< "E=" << Energy
83  // << "; p="<< 1/pModuleInverse
84  // << "; mC="<< magCharge
85  // <<"; x=" << y[0]
86  // <<"; y=" << y[1]
87  // <<"; z=" << y[2]
88  // <<"; dydx[3]=" << dydx[3]
89  // <<"; dydx[4]=" << dydx[4]
90  // <<"; dydx[5]=" << dydx[5]
91  // << G4endl;
92 
93  dydx[6] = 0.; // not used
94 
95  // Lab Time of flight
96  dydx[7] = inverse_velocity;
97  return;
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
~MonopoleEquation() override
void EvaluateRhsGivenB(const G4double y[], const G4double Field[], G4double dydx[]) const override
T sqrt(T t)
Definition: SSEVec.h:19
MonopoleEquation(G4MagneticField *emField)
void SetChargeMomentumMass(G4ChargeState particleChargeState, G4double momentum, G4double mass) override