Skip to content

Draft: Change to re-id'ing of vertices and particles after remove

Christian Holm Christensen requested to merge cholmcc_remove_reindex into master

The original code in GenEvent::remove_particle and GenEvent::remove_vertex for reassigning IDs are broken. Seems to happen when an event does not necessarily have strict ordering of vertices. I.e., a vertex with a numerically low (less negative) ID refers back to some other vertex with a numerically larger (more negative) ID. Then, the original reordering brings the index and ID out of sync, sometimes leading to negative or positive IDs of particles and vertices, respectively.

In this new code, what we do is reassign the ID based on the vertex's actual position in the container, as calculated by std::distance. The calculation of the index is done only for the first particle or vertex to be reassigned a new ID, and then the indexes are incremented or decremented.

That means, we need to reassign attributes here, too. Note that there is no check of attributes are already assigned to the new ID.

A bit more can be found in this MR

Yours, Christian

Merge request reports