File indexing completed on 2025-02-23 09:21:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include "F06PrimaryGeneratorAction.hh"
0035
0036 #include "F06DetectorConstruction.hh"
0037
0038 #include "G4Event.hh"
0039 #include "G4ParticleDefinition.hh"
0040 #include "G4ParticleGun.hh"
0041 #include "G4ParticleTable.hh"
0042 #include "G4PhysicalConstants.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "Randomize.hh"
0045
0046
0047
0048 F06PrimaryGeneratorAction::F06PrimaryGeneratorAction()
0049 {
0050 G4int n_particle = 1;
0051 fParticleGun = new G4ParticleGun(n_particle);
0052
0053 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
0054
0055 G4ParticleDefinition* particle = particleTable->FindParticle("proton");
0056 G4double mass_proton = particle->GetPDGMass();
0057
0058 G4double muN = 0.5 * CLHEP::eplus * CLHEP::hbar_Planck / (mass_proton / CLHEP::c_squared);
0059
0060 G4cout << " *** Neutron *** " << G4endl;
0061
0062 particle = particleTable->FindParticle("neutron");
0063 G4double mass_neutron = particle->GetPDGMass();
0064
0065 G4double magneticMoment = particle->GetPDGMagneticMoment();
0066 G4cout << " magneticMoment: " << magneticMoment / muN << G4endl;
0067
0068
0069
0070 G4double g_factor = 2 * magneticMoment / muN;
0071 G4cout << " g_factor: " << g_factor << G4endl;
0072
0073 G4double charge = particle->GetPDGCharge();
0074 G4cout << " charge: " << charge << G4endl;
0075
0076 G4double anomaly = (g_factor - 2.) / 2.;
0077 G4cout << " anomaly: " << anomaly << G4endl;
0078
0079 anomaly = (g_factor * (mass_neutron / mass_proton) - 2.) / 2.;
0080 G4cout << " corrected anomaly: " << anomaly << G4endl;
0081
0082 muN = 0.5 * CLHEP::eplus * CLHEP::hbar_Planck / (mass_neutron / CLHEP::c_squared);
0083 g_factor = 2 * magneticMoment / muN;
0084
0085 anomaly = (g_factor - 2.) / 2.;
0086 G4cout << " *** anomaly: " << anomaly << G4endl;
0087
0088 G4cout << " *** MuonPlus *** " << G4endl;
0089
0090 particle = particleTable->FindParticle("mu+");
0091 G4double mass_muon = particle->GetPDGMass();
0092
0093 G4double muB = 0.5 * CLHEP::eplus * CLHEP::hbar_Planck / (mass_muon / CLHEP::c_squared);
0094
0095 magneticMoment = particle->GetPDGMagneticMoment();
0096 G4cout << " magneticMoment: " << magneticMoment / muB << G4endl;
0097
0098
0099
0100 g_factor = magneticMoment / muB;
0101 G4cout << " g_factor: " << g_factor << G4endl;
0102
0103 charge = particle->GetPDGCharge();
0104 G4cout << " charge: " << charge << G4endl;
0105
0106 anomaly = (g_factor - 2.) / 2.;
0107 G4cout << " anomaly: " << anomaly << G4endl;
0108
0109
0110
0111
0112 particle = particleTable->FindParticle("neutron");
0113 fParticleGun->SetParticleDefinition(particle);
0114 }
0115
0116
0117
0118 F06PrimaryGeneratorAction::~F06PrimaryGeneratorAction()
0119 {
0120 delete fParticleGun;
0121 }
0122
0123
0124
0125 void F06PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
0126 {
0127
0128
0129
0130 fParticleGun->SetParticlePosition(G4ThreeVector(0.0, 0.0, 0.0));
0131 fParticleGun->SetParticlePolarization(G4ThreeVector(0, 1, 0));
0132
0133 G4double particleEnergy = G4UniformRand() * 1e-7 * eV;
0134 fParticleGun->SetParticleEnergy(particleEnergy);
0135
0136 G4double theta = 2 * pi * G4UniformRand();
0137 G4double phi = std::acos(1 - 2 * G4UniformRand());
0138 if (phi > pi / 2 && phi < pi) phi = pi - phi;
0139
0140 G4double z = std::sin(phi) * std::cos(theta);
0141 G4double x = std::sin(phi) * std::sin(theta);
0142 G4double y = std::cos(phi);
0143
0144 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(x, y, z));
0145
0146 fParticleGun->GeneratePrimaryVertex(anEvent);
0147 }
0148
0149