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: Bug when sorting the SP in SeedFinder #1143

Merged
merged 28 commits into from
Mar 21, 2022

Conversation

LuisFelipeCoelho
Copy link
Member

In PR #1084 I mentioned that we were seeing a degradation in tracking efficiency when sorting the SP in cotangent of theta in the SeedFinder. However I realised that I was sorting only the linCircleVec vector in SeedFinder and the compatBottomSP and compatTopSP vectors should also be sorted.

This PR solves the bug and now the efficiency and the output should be the same as without the sorting.

@paulgessinger @robertlangenberg @noemina

@LuisFelipeCoelho LuisFelipeCoelho added the Bug Something isn't working label Jan 21, 2022
@paulgessinger
Copy link
Member

paulgessinger commented Jan 21, 2022

Fantastic!

Does that mean we could get rid of enableCutsForSortedSP again?

@paulgessinger paulgessinger added this to the next milestone Jan 21, 2022
@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #1143 (f02414d) into main (be5fec4) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

❗ Current head f02414d differs from pull request most recent head 4e99b14. Consider uploading reports for the commit 4e99b14 to get more accurate results

@@            Coverage Diff             @@
##             main    #1143      +/-   ##
==========================================
- Coverage   47.79%   47.77%   -0.03%     
==========================================
  Files         360      360              
  Lines       18600    18608       +8     
  Branches     8770     8770              
==========================================
  Hits         8890     8890              
- Misses       3658     3666       +8     
  Partials     6052     6052              
Impacted Files Coverage Δ
Core/include/Acts/Seeding/SeedFinderUtils.ipp 0.00% <0.00%> (ø)
Core/include/Acts/Seeding/InternalSpacePoint.hpp 0.00% <0.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@LuisFelipeCoelho
Copy link
Member Author

I realised that the output is still not the same, so I will have to investigate this a bit further before removing the enableCutsForSortedSP

@LuisFelipeCoelho
Copy link
Member Author

I believe that now we can get rid of enableCutsForSortedS, or we can keep it and add a python-level test that runs the seeding with the cotTheta sorting.

@LuisFelipeCoelho
Copy link
Member Author

One alternative would be to create an index vector and sort this vector based on cotTheta values from linCircleVec. Then create a new vector of pointers newVec, fill it with the new order from the index vector, and replace vec with the new one:

std::vector<size_t> idx(vec.size());
std::iota(idx.begin(), idx.end(), 0);

std::sort(idx.begin(), idx.end(),
	[&linCircleVec](size_t i1, size_t i2) {
	return linCircleVec[i1].cotTheta < linCircleVec[i2].cotTheta;
});

std::vector<const InternalSpacePoint<external_spacepoint_t>*> newVec;
for (size_t i = 0; i<vec.size();i++) {
	newVec.push_back(vec[idx[i]]);
}
vec = newVec;

@paulgessinger @robertlangenberg @noemina

@paulgessinger
Copy link
Member

Can't we just have transformCoordinates take the spacepoints as non-const?

Right now we have

template <typename external_spacepoint_t>
void transformCoordinates(
    std::vector<const InternalSpacePoint<external_spacepoint_t>*>& vec,
    const InternalSpacePoint<external_spacepoint_t>& spM, bool bottom,
bool enableCutsForSortedSP, std::vector<LinCircle>& linCircleVec);

Does transformCoordinates get executed on the same vec concurrently? Otherwise, maybe this could be changed to something like std::vector<InternalSpacePoint<external_spacepoint_t>*>&?

@noemina
Copy link
Contributor

noemina commented Feb 17, 2022

Does transformCoordinates get executed on the same vec concurrently? Otherwise, maybe this could be changed to something like std::vector<InternalSpacePoint<external_spacepoint_t>*>&?

I don't think this should happen. @robertlangenberg, can you please confirm it?

@LuisFelipeCoelho LuisFelipeCoelho removed this from the next milestone Mar 18, 2022
kodiakhq bot pushed a commit that referenced this pull request Mar 18, 2022
This PR tries to fix usage of mutable properties in #1168 and #1143.

Tagging: @paulgessinger @robertlangenberg @LuisFelipeCoelho 

BREAKING CHANGE: Remove assumption on constness of InternalSpacePoint. 
The need of this major change is to allow seed finding and filtering to evaluate and set properties of InternalSpacePoints as soon as they are candidates for triplet formation and seed quality evaluation.
@LuisFelipeCoelho LuisFelipeCoelho added this to the next milestone Mar 20, 2022
Copy link
Contributor

@noemina noemina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me. Approving.

@kodiakhq kodiakhq bot merged commit c30bcf8 into acts-project:main Mar 21, 2022
@LuisFelipeCoelho LuisFelipeCoelho deleted the itk-seeding-bug branch March 21, 2022 17:36
stephenswat added a commit to stephenswat/acts that referenced this pull request Mar 30, 2022
I've discovered that acts-project#1143 introduces a subtle but rather nefarious bug
in the seed finder utilities: the const qualifier on one of the types
was removed in the .ipp file, but not in the corresponding .hpp file.
This means that any code importing the .hpp will gladly compile the
code, but because a matching implementation is not present in the .ipp
file, it will rely on this implementation being made available at link
time. In this particular case, that never happens, and we run into
rather hard to debug linking errors. This commit resolves the issue by
making sure that the function signatures between the .hpp file and the
.ipp file are the same.
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants