5 #include "G4IonTable.hh"
11 #include "G4SystemOfUnits.hh"
12 #include "G4PhysicalConstants.hh"
13 #include "G4RunManager.hh"
29 if (lheEvent != NULL) {
31 G4PrimaryVertex* vertex =
new G4PrimaryVertex();
32 vertex->SetPosition(0, 0, 0);
35 std::map<LHEParticle*, G4PrimaryParticle*> particleMap;
37 int particleIndex = 0;
38 const std::vector<LHEParticle*>& particles = lheEvent->
getParticles();
39 for (std::vector<LHEParticle*>::const_iterator it = particles.begin(); it != particles.end(); it++) {
45 G4PrimaryParticle* primary =
new G4PrimaryParticle();
46 if (particle->
getIDUP() == -623) {
47 G4ParticleDefinition* tungstenIonDef = G4IonTable::GetIonTable()->GetIon(74, 184, 0.);
48 if (tungstenIonDef != NULL) {
49 primary->SetParticleDefinition(tungstenIonDef);
51 G4Exception(
"LHEPrimaryGenerator::GeneratePrimaryVertex",
"EventGenerationError", FatalException,
"Failed to find particle definition for W ion.");
54 primary->SetPDGcode(particle->
getIDUP());
57 primary->Set4Momentum(particle->
getPUP(0) * GeV, particle->
getPUP(1) * GeV, particle->
getPUP(2) * GeV, particle->
getPUP(3) * GeV);
58 primary->SetProperTime(particle->
getVTIMUP() * nanosecond);
64 particleMap[particle] = primary;
70 G4PrimaryParticle* primaryMom = particleMap[particle->
getMother(0)];
71 if (primaryMom != NULL) {
72 primaryMom->SetDaughter(primary);
75 vertex->SetPrimary(primary);
89 anEvent->AddPrimaryVertex(vertex);
92 std::cout <<
"[ LHEPrimaryGenerator ] : Ran out of input events so run will be aborted!" <<
std::endl;
93 G4RunManager::GetRunManager()->AbortRun(
true);
94 anEvent->SetEventAborted();
LHE event with a list of particles and information from the header block.
const std::vector< LHEParticle * > & getParticles()
Single particle record in an LHE event.
LHEParticle * getMother(int) const
void GeneratePrimaryVertex(G4Event *anEvent)
virtual ~LHEPrimaryGenerator()
LHEPrimaryGenerator(LHEReader *reader)
Reads LHE event data into an LHEEvent object.
LHEEvent * readNextEvent()