-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.cpp
More file actions
34 lines (27 loc) · 899 Bytes
/
Copy pathgenerator.cpp
File metadata and controls
34 lines (27 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "generator.hh"
PrimaryGenerator::PrimaryGenerator()
{
// 1 as in the number of events
fParticleGun = new G4ParticleGun(1);
}
PrimaryGenerator::~PrimaryGenerator()
{
delete fParticleGun;
}
void PrimaryGenerator::GeneratePrimaries(G4Event *event)
{
// where particle information is stored
G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
G4String particleName = "mu+";
G4ParticleDefinition *particle = particleTable -> FindParticle(particleName);
// position and momentum vectors
G4ThreeVector pos(0.,0.,-1*m);
G4ThreeVector mom(0.,0.,1.);
// generate the particle
fParticleGun -> SetParticlePosition(pos);
fParticleGun -> SetParticleMomentumDirection(mom);
fParticleGun -> SetParticleEnergy(4.*GeV);
fParticleGun -> SetParticleMomentum(500.*MeV);
fParticleGun -> SetParticleDefinition(particle);
fParticleGun -> GeneratePrimaryVertex(event);
}