-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.cc
61 lines (45 loc) · 2.17 KB
/
generator.cc
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "generator.hh"
MyPrimaryGenerator::MyPrimaryGenerator()
{
// ‘particle guns’ used for test-beam or fixed target simulations
// fParticleGun = new G4ParticleGun(1); //# of particles per event = 1
fParticleGun = new G4GeneralParticleSource(); // change particle gun by GPS everywhere
// Before this was in MyPrimaryGenerator::GeneratePrimaries(G4Event *anEvent)
// The idea now is that we can overwrite this "default" parameters with .mac
G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
// G4String particleName="proton";
// G4ParticleDefinition *particle = particleTable ->FindParticle("proton");
// G4String particleName="opticalphoton";
G4ParticleDefinition *particle = particleTable ->FindParticle("opticalphoton");
// G4String particleName="alpha";
// G4ParticleDefinition *particle = particleTable ->FindParticle("alpha");
//more generic particle --> placeholder without any properties
// G4ParticleDefinition *particle = particleTable ->FindParticle("geantino");
// G4ThreeVector pos(0., 0., 0.); // center of mother volume
G4ThreeVector pos(0*mm, 0*mm, -20*mm); // alpha source position -> center of our boxed detector face
G4ThreeVector mom(0., 0., 1.); // positive z direction
fParticleGun->SetParticlePosition(pos);
// fParticleGun->SetParticleMomentumDirection(mom);
// fParticleGun->SetParticleMomentum(100.*GeV);
fParticleGun->SetParticleDefinition(particle);
}
MyPrimaryGenerator::~MyPrimaryGenerator()
{
delete fParticleGun;
}
void MyPrimaryGenerator::GeneratePrimaries(G4Event *anEvent)
{
G4ParticleDefinition* particle = fParticleGun->GetParticleDefinition();
if(particle == G4Geantino::Geantino())
{
// Simulate the decay of the Am241 (check if coherent with activity 50-65 Bq)
G4int Z = 95;//
G4int A = 241; //
G4double charge = 1. * eplus;
G4double energy = 0. * keV;
G4ParticleDefinition *ion =G4IonTable::GetIonTable()->GetIon(Z,A,energy);
fParticleGun->SetParticleDefinition(ion);
fParticleGun->SetParticleCharge(charge);
}
fParticleGun->GeneratePrimaryVertex(anEvent);
}