-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: introduce sorted index proxy to allow early break on neighbor se…
…arch (#1581) ### Briefly, what does this PR introduce? This PR originally intended to add hit sorting based on layer to achieve early breaks in the neighbor searching (i.e. if neighbors have to be at most two layers different in a ZDC-like detector, then in a sorted list we can stop evaluating for neighbors as soon as we encounter the first hit with more than two layers difference). This PR also makes several other changes to the topological clustering. - Hits are now referred to by an index proxy ordered set. This set (with ordering by layer and then index in collection) is modified as hits are assigned to clusters, such that only eligible hits remain in the set (once ordered, erasure does of course not affect ordering). The need for a separate vector which keeps track of already assigned hits is avoided. As more hits are assigned, the remaining search space is reduced, allowing for more efficient searching. - Clusters (groups) are now stored in a vector ordered by insertion sequence instead of a set (which is ordered but not in a useful way). This allows us to avoid rechecking already added hits for neighbors, and only check newly added hits for new neighbors to add. When modifying containers that we are iterating over, we have to make sure we do not invalidate iterators. Note https://en.cppreference.com/w/cpp/container#Iterator_invalidation. A vector container may change capacity, which invalidates all iterators. Iterators on a set are only invalidated when the element pointed to is erased. Erasure returns an iterator to the next element. Therefore, we postpone erasure of the starting hit of each group until after the entire group has been collected (and we have to make sure to avoid picking it again as a hit). If we erased the starting hit right away, the next iterator returned by the erase operation would likely become invalid when the hit is (likely, due to ordering) used in the cluster. ### What kind of change does this PR introduce? - [x] Bug fix (issue #1573) - [ ] New feature (issue #__) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No. ### Does this PR change default behavior? No.
- Loading branch information
Showing
3 changed files
with
103 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters