Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:29:49

0001 //
0002 // =======================================================================
0003 //
0004 // class G4MonopoleEquation
0005 //
0006 // Created:  30 April 2010, S. Burdin, B. Bozsogi
0007 //                       G4MonopoleEquation class for
0008 //                       Geant4 extended example "monopole"
0009 //
0010 // Adopted for CMSSW by V.Ivanchenko 30 April 2018
0011 //
0012 // =======================================================================
0013 //
0014 
0015 #include "CLHEP/Units/PhysicalConstants.h"
0016 #include "CLHEP/Units/SystemOfUnits.h"
0017 #include "SimG4Core/MagneticField/interface/MonopoleEquation.h"
0018 #include "globals.hh"
0019 #include <iomanip>
0020 
0021 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0022 
0023 MonopoleEquation::MonopoleEquation(G4MagneticField *emField) : G4EquationOfMotion(emField) {}
0024 
0025 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0026 
0027 MonopoleEquation::~MonopoleEquation() {}
0028 
0029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0030 
0031 void MonopoleEquation::SetChargeMomentumMass(G4ChargeState particleChargeState, G4double, G4double particleMass) {
0032   G4double particleMagneticCharge = particleChargeState.MagneticCharge();
0033   G4double particleElectricCharge = particleChargeState.GetCharge();
0034 
0035   fElCharge = CLHEP::eplus * particleElectricCharge * CLHEP::c_light;
0036 
0037   fMagCharge = CLHEP::eplus * particleMagneticCharge * CLHEP::c_light;
0038 
0039   // G4cout << " MonopoleEquation: ElectricCharge=" << particleElectricCharge
0040   //           << "; MagneticCharge=" << particleMagneticCharge
0041   //           << G4endl;
0042 
0043   fMassCof = particleMass * particleMass;
0044 }
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 void MonopoleEquation::EvaluateRhsGivenB(const G4double y[], const G4double Field[], G4double dydx[]) const {
0049   // Components of y:
0050   //    0-2 dr/ds,
0051   //    3-5 dp/ds - momentum derivatives
0052 
0053   G4double pSquared = y[3] * y[3] + y[4] * y[4] + y[5] * y[5];
0054 
0055   G4double Energy = std::sqrt(pSquared + fMassCof);
0056 
0057   G4double pModuleInverse = 1.0 / std::sqrt(pSquared);
0058 
0059   G4double inverse_velocity = Energy * pModuleInverse / CLHEP::c_light;
0060 
0061   G4double cofEl = fElCharge * pModuleInverse;
0062   G4double cofMag = fMagCharge * Energy * pModuleInverse;
0063 
0064   dydx[0] = y[3] * pModuleInverse;
0065   dydx[1] = y[4] * pModuleInverse;
0066   dydx[2] = y[5] * pModuleInverse;
0067 
0068   // G4double magCharge = twopi * hbar_Planck / (eplus * mu0);
0069   // magnetic charge in SI units A*m convention
0070   //  see http://en.wikipedia.org/wiki/Magnetic_monopole
0071   //   G4cout  << "Magnetic charge:  " << magCharge << G4endl;
0072   // dp/ds = dp/dt * dt/ds = dp/dt / v = Force / velocity
0073   // dydx[3] = fMagCharge * Field[0]  * inverse_velocity  * c_light;
0074   // multiplied by c_light to convert to MeV/mm
0075   //     dydx[4] = fMagCharge * Field[1]  * inverse_velocity  * c_light;
0076   //     dydx[5] = fMagCharge * Field[2]  * inverse_velocity  * c_light;
0077 
0078   dydx[3] = cofMag * Field[0] + cofEl * (y[4] * Field[2] - y[5] * Field[1]);
0079   dydx[4] = cofMag * Field[1] + cofEl * (y[5] * Field[0] - y[3] * Field[2]);
0080   dydx[5] = cofMag * Field[2] + cofEl * (y[3] * Field[1] - y[4] * Field[0]);
0081 
0082   //        G4cout << std::setprecision(5)<< "E=" << Energy
0083   //               << "; p="<< 1/pModuleInverse
0084   //               << "; mC="<< magCharge
0085   //               <<"; x=" << y[0]
0086   //               <<"; y=" << y[1]
0087   //               <<"; z=" << y[2]
0088   //               <<"; dydx[3]=" << dydx[3]
0089   //               <<"; dydx[4]=" << dydx[4]
0090   //               <<"; dydx[5]=" << dydx[5]
0091   //               << G4endl;
0092 
0093   dydx[6] = 0.;  // not used
0094 
0095   // Lab Time of flight
0096   dydx[7] = inverse_velocity;
0097   return;
0098 }
0099 
0100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......