21 if (lhe_event !=
nullptr) {
24 G4PrimaryVertex* vertex =
new G4PrimaryVertex();
25 vertex->SetPosition(lhe_event->getVertex()[0] +
vertex_[0],
26 lhe_event->getVertex()[1] +
vertex_[1],
27 lhe_event->getVertex()[2] +
vertex_[2]);
28 vertex->SetWeight(lhe_event->getEventWeight());
30 std::map<simcore::lhe::LHEParticle*, G4PrimaryParticle*> particle_map;
32 const auto& particles = lhe_event->getParticles();
33 for (
const auto& particle : particles) {
35 if (particle->getStatus() > 0) {
38 G4PrimaryParticle* primary =
new G4PrimaryParticle();
41 if (particle->getPdgId() == -623) {
42 G4ParticleDefinition* tungsten_ion_def =
43 G4IonTable::GetIonTable()->GetIon(74, 184, 0.);
44 if (tungsten_ion_def !=
nullptr) {
45 primary->SetParticleDefinition(tungsten_ion_def);
47 EXCEPTION_RAISE(
"EventGenerator",
48 "Failed to find particle definition for W ion.");
51 primary->SetPDGcode(particle->getPdgId());
55 primary->Set4Momentum(
56 particle->getMomentum(0) * GeV, particle->getMomentum(1) * GeV,
57 particle->getMomentum(2) * GeV, particle->getMomentum(3) * GeV);
58 primary->SetProperTime(particle->getLifetime() * nanosecond);
60 auto primary_info = std::make_unique<UserPrimaryParticleInformation>();
61 primary_info->setHepEvtStatus(particle->getStatus());
62 primary->SetUserInformation(primary_info.release());
64 particle_map[particle.get()] = primary;
70 if (particle->getMotherParticle(0) !=
nullptr &&
71 particle->getMotherParticle(0)->getStatus() > 0) {
72 G4PrimaryParticle* primary_mom =
73 particle_map[particle->getMotherParticle(0)];
74 if (primary_mom !=
nullptr) {
75 primary_mom->SetDaughter(primary);
78 vertex->SetPrimary(primary);
83 anEvent->AddPrimaryVertex(vertex);
91 ldmx_log(error) <<
"Ran out of input events so run will be aborted!";
92 G4RunManager::GetRunManager()->AbortRun(
true);
93 anEvent->SetEventAborted();