Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent unphysical number of phi bins (#1161) #1167

Merged
merged 2 commits into from
Feb 22, 2022

Conversation

stephenswat
Copy link
Member

The bug described in issue #1161 is caused by the creation of negative or (near) infinite number of phi bins, which cause the internal mechanisms of std::vector to crash. This effect is caused by the fact that the number of phi neighbours is not properly initialized, causing it to take on uninitialized values.

This commit does two things to prevent this issue. First of all, it adds a sensible default value for the number of phi neighbours, ensuring that it never takes on uninitialized values. Secondly, a sanity check is added to the space point grid to ensure that the phi delta value has a physically meaningful value; if this is not the case, an exception is thrown.

Resolves #1161.

@stephenswat stephenswat added Bug Something isn't working Component - Core Affects the Core module Impact - Minor Nuissance bug and/or affects only a single module labels Feb 16, 2022
@stephenswat stephenswat added this to the next milestone Feb 16, 2022
@paulgessinger
Copy link
Member

Looks fine from here, @LuisFelipeCoelho can you review this PR?

@LuisFelipeCoelho
Copy link
Member

Looks fine to me. Thanks for finding the problem and fixing it!

@codecov
Copy link

codecov bot commented Feb 16, 2022

Codecov Report

Merging #1167 (20d8b7a) into main (b7d2de0) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1167      +/-   ##
==========================================
- Coverage   47.84%   47.84%   -0.01%     
==========================================
  Files         360      360              
  Lines       18523    18525       +2     
  Branches     8737     8739       +2     
==========================================
  Hits         8863     8863              
- Misses       3624     3626       +2     
  Partials     6036     6036              
Impacted Files Coverage Δ
Core/include/Acts/Seeding/SpacePointGrid.hpp 0.00% <ø> (ø)
Core/include/Acts/Seeding/SpacePointGrid.ipp 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b7d2de0...20d8b7a. Read the comment docs.

@stephenswat
Copy link
Member Author

Hmm, it looks like some of the tests fail.

@stephenswat
Copy link
Member Author

Okay, so one of the Python tests appears to be losing tracks. I would suspect then, that one phi bin neighbour is not enough. Does anyone have a suggestion for a better default value? Otherwise, we might want to look into a mechanism that can ensure that this value is set.

@robertlangenberg
Copy link
Contributor

robertlangenberg commented Feb 21, 2022

This may be related to #1172 as the size of the phi bins reduced. In principle a single phi bin should cover the maximum deflection in phi such that looking at a single neighbor should be enough as long as numPhiNeighbors is 1. This didn't change, right @noemina @LuisFelipeCoelho ?

@noemina
Copy link
Contributor

noemina commented Feb 21, 2022

This may be related to #1172 as the size of the phi bins reduced. In principle a single phi bin should cover the maximum deflection in phi such that looking at a single neighbor should be enough as long as numPhiNeighbors is 1. This didn't change, right @noemina @LuisFelipeCoelho ?

That's exactly what it does. We didn't change the logic there.

@stephenswat
Copy link
Member Author

From the discussion in #1172 I gather that 0 is probably a better default value than 1 in this case.

The bug described in issue acts-project#1161 is caused by the creation of negative
or (near) infinite number of phi bins, which cause the internal
mechanisms of `std::vector` to crash. This effect is caused by the fact
that the number of phi neighbours is not properly initialized, causing
it to take on uninitialized values.

This commit does two things to prevent this issue. First of all, it adds
a sensible default value for the number of phi neighbours, ensuring that
it never takes on uninitialized values. Secondly, a sanity check is
added to the space point grid to ensure that the phi delta value has a
physically meaningful value; if this is not the case, an exception is
thrown.

Resolves acts-project#1161.
@robertlangenberg
Copy link
Contributor

I just had a quick chat with Noemi, and I think I understand the issue. There are configuration parameters called numPhiNeighbors for Grid and BinFinder which don't mean the same. The numPhiNeighbors for the Grid means "how many phiBin neighbors (plus the current bin) should cover the full deflection of a minimum pT particle". Setting this to zero means "no phi bin neighbors needed to cover the full deflection", i.e. 1 phi-bin covers the full deflection.

What has been newly added is the consideration of the max impact parameters, which increases the size of the bins a bit and is probably uncontroversial, but may slightly change results.

I think this should be renamed and even numbers of phiBins should be allowed to cover the full deflection.

The numPhiNeighbors parameter of the BinFinder sets how many neighboring phi bins (plus the current one) are returned for each call to "findBins" (which I think is aptly named).

To get the behavior the seeding test expects, (assuming the newly added d_ZERO doesn't change the results as well), the numPhiNeighbors of the Grid has to be set to zero, while the numPhiNeighbors of the BinFinder must be set to 1.

@robertlangenberg
Copy link
Contributor

The reason this was changed like this is because for ATLAS at µ=60 the configuration with numPhiNeighbors=1 for both Grid and BinFinder has shown to give acceptable results and reduces CPU usage (due to the reduced combinatorics, this corresponds to a 66% reduction of the phi-range).

@kodiakhq kodiakhq bot merged commit c0aea9f into acts-project:main Feb 22, 2022
@paulgessinger paulgessinger modified the milestones: next, v18.0.0 Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Bug Something isn't working Component - Core Affects the Core module Impact - Minor Nuissance bug and/or affects only a single module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Seed finding C++ example throws exceptions
5 participants