Skip to content

Fix triangle loop detection in v1 Particle combiner

Alex Pearce requested to merge apearce-moore-300 into master

The ThOr combiners detect whether or not consecutive containers are 'identical' (contain the same particles in the same order) in order to be able to activate the 'triangle loop'. The triangle loop allows us to skip combinations which contain particles which have already entered the combination.

The v2 triangle loop detection just checks for input container pointer equality.

The v1 detection cannot do this because the v1 inputs are Gaudi::NamedRange_, which are instantiated on-the-fly from container inputs (liked KeyedContainer or std::vector). Because two identical containers are wrapped as two different NamedRange_ instances, and we cannot access the underlying container, we cannot use 'range pointer' equality (we have two instances).

The current v1 detection just checks whether the first element of the two ranges is the same. This is can be trivially wrong, of course, and can result in segfaults (see Moore#300 (closed)).

This MR replaces the v1 detection logic with a simple Gaudi::NamedRange_::operator== call. This is slower than a container-pointer equality check (O(n) vs. O(1)) but is robust, at least. Because we hope to replace all v1 combiners with v2 equivalents this is something we can likely live with for now.

Edited by Alex Pearce

Merge request reports

Loading