-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.cc
More file actions
31 lines (24 loc) · 831 Bytes
/
generator.cc
File metadata and controls
31 lines (24 loc) · 831 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
#include "generator.hh"
#include "G4AnalysisManager.hh"
MyPrimaryGenerator::MyPrimaryGenerator()
{
fParticleGun = new G4ParticleGun(1);
}
MyPrimaryGenerator::~MyPrimaryGenerator()
{
delete fParticleGun;
}
void MyPrimaryGenerator::GeneratePrimaries(G4Event *anEvent)
{
G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
G4String particleName="test";
G4ParticleDefinition *particle = particleTable->FindParticle("proton");
G4ThreeVector pos(0.,0.,0.);
G4ThreeVector mom(0.,0.,1.);
fParticleGun->SetParticlePosition(pos);
fParticleGun->SetParticleMomentumDirection(mom);
//fParticleGun->SetParticleMomentum(1. *GeV);
fParticleGun->SetParticleEnergy(500. *MeV);
fParticleGun->SetParticleDefinition(particle);
fParticleGun->GeneratePrimaryVertex(anEvent);
}