37 if (lheEvent !=
nullptr) {
38 G4PrimaryVertex* vertex =
new G4PrimaryVertex();
43 std::map<simcore::lhe::LHEParticle*, G4PrimaryParticle*> particleMap;
45 const std::vector<simcore::lhe::LHEParticle*>& particles =
47 for (
auto* particle : particles) {
48 if (particle->getISTUP() > 0) {
49 G4PrimaryParticle* primary =
new G4PrimaryParticle();
50 if (particle->getIDUP() == -623) {
51 G4ParticleDefinition* tungstenIonDef =
52 G4IonTable::GetIonTable()->GetIon(74, 184, 0.);
53 if (tungstenIonDef !=
nullptr) {
54 primary->SetParticleDefinition(tungstenIonDef);
56 EXCEPTION_RAISE(
"EventGenerator",
57 "Failed to find particle definition for W ion.");
60 primary->SetPDGcode(particle->getIDUP());
63 primary->Set4Momentum(
64 particle->getPUP(0) * GeV, particle->getPUP(1) * GeV,
65 particle->getPUP(2) * GeV, particle->getPUP(3) * GeV);
66 primary->SetProperTime(particle->getVTIMUP() * nanosecond);
71 primary->SetUserInformation(primaryInfo);
73 particleMap[particle] = primary;
79 if (particle->getMother(0) !=
nullptr &&
80 particle->getMother(0)->getISTUP() > 0) {
81 G4PrimaryParticle* primaryMom = particleMap[particle->getMother(0)];
82 if (primaryMom !=
nullptr) {
83 primaryMom->SetDaughter(primary);
86 vertex->SetPrimary(primary);
91 anEvent->AddPrimaryVertex(vertex);
94 std::cout <<
"[ LHEPrimaryGenerator ] : Ran out of input events so run "
97 G4RunManager::GetRunManager()->AbortRun(
true);
98 anEvent->SetEventAborted();