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