Skip to content

Commit

Permalink
fix: Update EventRecording to remove disconnected vertices and partic…
Browse files Browse the repository at this point in the history
…les (#912)

Fix related to #877
  • Loading branch information
andriish committed Sep 1, 2021
1 parent 6e25ee0 commit 43c4f42
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions Examples/Algorithms/Geant4HepMC/src/EventRecording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,28 @@ ActsExamples::ProcessCode ActsExamples::EventRecording::execute(
}
// Store the result
if (storeEvent) {
// Remove vertices without outgoing particles
for (auto it = event.vertices().crbegin();
it != event.vertices().crend(); it++) {
if ((*it)->particles_out().empty()) {
event.remove_vertex(*it);
// Remove vertices w/o outgoing particles and particles w/o production
// vertices
while (true) {
bool sane = true;
for (auto v : event.vertices()) {
if (!v)
continue;
if (v->particles_out().empty()) {
event.remove_vertex(v);
sane = false;
}
}
for (auto p : event.particles()) {
if (!p)
continue;
if (!p->production_vertex()) {
event.remove_particle(p);
sane = false;
}
}
if (sane)
break;
}
events.push_back(std::move(event));
}
Expand Down

0 comments on commit 43c4f42

Please sign in to comment.