16 if (lhe_event !=
nullptr) {
19 G4PrimaryVertex* vertex =
new G4PrimaryVertex();
20 vertex->SetPosition(lhe_event->getVertex()[0] +
vertex_[0],
21 lhe_event->getVertex()[1] +
vertex_[1],
22 lhe_event->getVertex()[2] +
vertex_[2]);
23 vertex->SetWeight(lhe_event->getEventWeight());
25 std::map<simcore::lhe::LHEParticle*, G4PrimaryParticle*> particle_map;
27 const auto& particles = lhe_event->getParticles();
28 for (
const auto& particle : particles) {
30 if (particle->getStatus() > 0) {
33 G4PrimaryParticle* primary =
new G4PrimaryParticle();
36 if (particle->getPdgId() == -623) {
37 G4ParticleDefinition* tungsten_ion_def =
38 G4IonTable::GetIonTable()->GetIon(74, 184, 0.);
39 if (tungsten_ion_def !=
nullptr) {
40 primary->SetParticleDefinition(tungsten_ion_def);
42 EXCEPTION_RAISE(
"EventGenerator",
43 "Failed to find particle definition for W ion.");
46 primary->SetPDGcode(particle->getPdgId());
50 primary->Set4Momentum(
51 particle->getMomentum(0) * GeV, particle->getMomentum(1) * GeV,
52 particle->getMomentum(2) * GeV, particle->getMomentum(3) * GeV);
53 primary->SetProperTime(particle->getLifetime() * nanosecond);
55 auto primary_info = std::make_unique<UserPrimaryParticleInformation>();
56 primary_info->setHepEvtStatus(particle->getStatus());
57 primary->SetUserInformation(primary_info.release());
59 particle_map[particle.get()] = primary;
65 if (particle->getMotherParticle(0) !=
nullptr &&
66 particle->getMotherParticle(0)->getStatus() > 0) {
67 G4PrimaryParticle* primary_mom =
68 particle_map[particle->getMotherParticle(0)];
69 if (primary_mom !=
nullptr) {
70 primary_mom->SetDaughter(primary);
73 vertex->SetPrimary(primary);
78 anEvent->AddPrimaryVertex(vertex);
81 ldmx_log(error) <<
"Ran out of input events so run will be aborted!";
82 G4RunManager::GetRunManager()->AbortRun(
true);
83 anEvent->SetEventAborted();