File indexing completed on 2025-01-31 09:22:03
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 "FlashPrimaryGeneratorAction.hh"
0030 #include "G4SystemOfUnits.hh"
0031
0032 #include "G4Event.hh"
0033 #include "G4GeneralParticleSource.hh"
0034 #include "G4ParticleDefinition.hh"
0035 #include "G4ParticleGun.hh"
0036 #include "G4ParticleTable.hh"
0037 #include "Randomize.hh"
0038 #include "globals.hh"
0039
0040 FlashPrimaryGeneratorAction::FlashPrimaryGeneratorAction() {
0041
0042 particleGun = new G4GeneralParticleSource();
0043
0044 SetDefaultPrimaryParticle();
0045 }
0046
0047 FlashPrimaryGeneratorAction::~FlashPrimaryGeneratorAction() {
0048 delete particleGun;
0049 }
0050
0051 void FlashPrimaryGeneratorAction::SetDefaultPrimaryParticle() {
0052
0053 G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
0054 G4ParticleDefinition *particle = particleTable->FindParticle("e-");
0055 particleGun->SetParticleDefinition(particle);
0056
0057
0058 G4double defaultX0 = -113 * cm;
0059
0060 X0 = defaultX0;
0061
0062 G4double defaultY0 = 0.0 * mm;
0063 Y0 = defaultY0;
0064
0065 G4double defaultZ0 = 0.0 * mm;
0066 Z0 = defaultZ0;
0067
0068 G4double defaultsigmaY = 2.5*mm;
0069
0070 sigmaY = defaultsigmaY;
0071
0072 G4double defaultsigmaZ = 2.5*mm;
0073
0074 sigmaZ = defaultsigmaZ;
0075
0076 G4double defaultTheta = 2 * deg;
0077
0078 Theta = defaultTheta;
0079 }
0080
0081 void FlashPrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent) {
0082
0083
0084
0085 G4double x = X0;
0086 G4double y = Y0;
0087 G4double z = Z0;
0088
0089 if (sigmaY > 0.0) {
0090 y += G4RandGauss::shoot(Y0, sigmaY);
0091 }
0092
0093 if (sigmaZ > 0.0) {
0094 z += G4RandGauss::shoot(Z0, sigmaZ);
0095 }
0096
0097 particleGun->GetCurrentSource()->GetPosDist()->SetCentreCoords(G4ThreeVector(x, y, z));
0098
0099 particleGun->GetCurrentSource()->GetAngDist()->SetAngDistType("beam2d");
0100 particleGun->GetCurrentSource()->GetAngDist()->DefineAngRefAxes("angref1", G4ThreeVector( 0, 0,1.));
0101
0102 particleGun->GetCurrentSource()->GetAngDist()->SetBeamSigmaInAngX(Theta);
0103 particleGun->GetCurrentSource()->GetAngDist()->SetBeamSigmaInAngY(Theta);
0104 particleGun->GetCurrentSource()->GetAngDist()->SetParticleMomentumDirection(G4ThreeVector(1,0,0));
0105
0106 particleGun->GeneratePrimaryVertex(anEvent);
0107 }