Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 08:29:41

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file G4MonopoleEquation.cc
0027 /// \brief Implementation of the G4MonopoleEquation class
0028 
0029 // class G4MonopoleEquation
0030 //
0031 // Class description:
0032 //
0033 //
0034 //  This is the standard right-hand side for equation of motion.
0035 //
0036 //  The only case another is required is when using a moving reference
0037 //  frame ... or extending the class to include additional Forces,
0038 //  eg an electric field
0039 //
0040 //  10.11.98   V.Grichine
0041 //
0042 //  30.04.10   S.Burdin (modified to use for the monopole trajectories).
0043 //
0044 //  15.06.10   B.Bozsogi (replaced the hardcoded magnetic charge with
0045 //                        the one passed by G4MonopoleTransportation)
0046 //                       +workaround to pass the electric charge.
0047 //
0048 //  12.07.10  S.Burdin (added equations for the electric charges)
0049 // -------------------------------------------------------------------
0050 
0051 #include "G4MonopoleEquation.hh"
0052 
0053 #include "G4PhysicalConstants.hh"
0054 #include "G4SystemOfUnits.hh"
0055 #include "globals.hh"
0056 
0057 #include <iomanip>
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 G4MonopoleEquation::G4MonopoleEquation(G4MagneticField* emField) : G4EquationOfMotion(emField)
0062 {
0063   G4cout << "G4MonopoleEquation::G4MonopoleEquation" << G4endl;
0064 }
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 G4MonopoleEquation::~G4MonopoleEquation() {}
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 void G4MonopoleEquation::SetChargeMomentumMass(G4ChargeState particleChargeState,
0073                                                G4double,  // momentum,
0074                                                G4double particleMass)
0075 {
0076   G4double particleMagneticCharge = particleChargeState.MagneticCharge();
0077   G4double particleElectricCharge = particleChargeState.GetCharge();
0078 
0079   //   fElCharge = particleElectricCharge;
0080   fElCharge = eplus * particleElectricCharge * c_light;
0081 
0082   fMagCharge = eplus * particleMagneticCharge * c_light;
0083 
0084   // G4cout << " G4MonopoleEquation: ElectricCharge=" << particleElectricCharge
0085   //           << "; MagneticCharge=" << particleMagneticCharge
0086   //           << G4endl;
0087 
0088   fMassCof = particleMass * particleMass;
0089 }
0090 
0091 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0092 
0093 void G4MonopoleEquation::EvaluateRhsGivenB(const G4double y[], const G4double Field[],
0094                                            G4double dydx[]) const
0095 {
0096   // Components of y:
0097   //    0-2 dr/ds,
0098   //    3-5 dp/ds - momentum derivatives
0099 
0100   G4double pSquared = y[3] * y[3] + y[4] * y[4] + y[5] * y[5];
0101 
0102   G4double Energy = std::sqrt(pSquared + fMassCof);
0103 
0104   G4double pModuleInverse = 1.0 / std::sqrt(pSquared);
0105 
0106   G4double inverse_velocity = Energy * pModuleInverse / c_light;
0107 
0108   G4double cofEl = fElCharge * pModuleInverse;
0109   G4double cofMag = fMagCharge * Energy * pModuleInverse;
0110 
0111   dydx[0] = y[3] * pModuleInverse;
0112   dydx[1] = y[4] * pModuleInverse;
0113   dydx[2] = y[5] * pModuleInverse;
0114 
0115   // G4double magCharge = twopi * hbar_Planck / (eplus * mu0);
0116   // magnetic charge in SI units A*m convention
0117   //  see http://en.wikipedia.org/wiki/Magnetic_monopole
0118   //   G4cout  << "Magnetic charge:  " << magCharge << G4endl;
0119   // dp/ds = dp/dt * dt/ds = dp/dt / v = Force / velocity
0120   // dydx[3] = fMagCharge * Field[0]  * inverse_velocity  * c_light;
0121   // multiplied by c_light to convert to MeV/mm
0122   //     dydx[4] = fMagCharge * Field[1]  * inverse_velocity  * c_light;
0123   //     dydx[5] = fMagCharge * Field[2]  * inverse_velocity  * c_light;
0124 
0125   dydx[3] = cofMag * Field[0] + cofEl * (y[4] * Field[2] - y[5] * Field[1]);
0126   dydx[4] = cofMag * Field[1] + cofEl * (y[5] * Field[0] - y[3] * Field[2]);
0127   dydx[5] = cofMag * Field[2] + cofEl * (y[3] * Field[1] - y[4] * Field[0]);
0128 
0129   //        G4cout << std::setprecision(5)<< "E=" << Energy
0130   //               << "; p="<< 1/pModuleInverse
0131   //               << "; mC="<< magCharge
0132   //               <<"; x=" << y[0]
0133   //               <<"; y=" << y[1]
0134   //               <<"; z=" << y[2]
0135   //               <<"; dydx[3]=" << dydx[3]
0136   //               <<"; dydx[4]=" << dydx[4]
0137   //               <<"; dydx[5]=" << dydx[5]
0138   //               << G4endl;
0139 
0140   dydx[6] = 0.;  // not used
0141 
0142   // Lab Time of flight
0143   dydx[7] = inverse_velocity;
0144   return;
0145 }
0146 
0147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......