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

refactor: Refactor target direction logic in KF/CKF #2539

Merged
merged 5 commits into from
Oct 19, 2023

Conversation

andiwand
Copy link
Contributor

@andiwand andiwand commented Oct 12, 2023

Not sure what the use case for this was but to me it seems like the target propagation logic is flawed in KF/CKF. If we propagate to target from the last state the smoothing seems unnecessary. Also since the target surface is a perigee surface for us there are edge cases where the last state has a smaller "distance" to the perigee than the first one.

In general I'd say the user should take such a decision but this is too big of a change at the moment.

discovered with #2518

@andiwand andiwand added this to the next milestone Oct 12, 2023
@github-actions github-actions bot added Component - Core Affects the Core module Component - Examples Affects the Examples module Track Finding Track Fitting labels Oct 12, 2023
@Corentin-Allaire
Copy link
Contributor

Hello I am teaching this week, so I will look at this on Monday if it is fine

@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Merging #2539 (dc35499) into main (cc7857b) will decrease coverage by 0.05%.
Report is 1 commits behind head on main.
The diff coverage is 36.11%.

❗ Current head dc35499 differs from pull request most recent head 5c376e8. Consider uploading reports for the commit 5c376e8 to get more accurate results

@@            Coverage Diff             @@
##             main    #2539      +/-   ##
==========================================
- Coverage   49.79%   49.74%   -0.05%     
==========================================
  Files         466      466              
  Lines       26326    26354      +28     
  Branches    12095    12103       +8     
==========================================
+ Hits        13108    13111       +3     
- Misses       4615     4638      +23     
- Partials     8603     8605       +2     
Files Coverage Δ
Core/include/Acts/TrackFitting/KalmanFitter.hpp 42.39% <38.88%> (-0.75%) ⬇️
...de/Acts/TrackFinding/CombinatorialKalmanFilter.hpp 32.37% <33.33%> (-0.13%) ⬇️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Corentin-Allaire
Copy link
Contributor

Corentin-Allaire commented Oct 16, 2023

I will need to cross check but does the target surface has to be a perigee surface at the beamline can't it be any arbitrary surface ? Because I can see a few use case where you would want to have it behind the last measurements.

@andiwand
Copy link
Contributor Author

I will need to cross check but does the target surface has to be a perigee surface at the beamline can't it be any arbitrary surface ? Because I can see a few use case where you would want to have it behind the last measurements.

I agree, it might be generally useful but the current implementation is unstable for our usual setup with the perigee in front of the first sensitive.

If the target surface is behind the last sensitive smoothing should not be necessary but is currently coupled to the target propagation.

The problem I encounter is that the perigee surface might be "closer" to the last track state VS the first track state because we intersect with the PCA and not a plane surface in that case. Apart from that it is not clear what happens if we cannot reach the target source or if we are not in the bounds.

These details should be handled by the user IMO because it would be way to complicated to handle all of them in a core algorithm.

@andiwand
Copy link
Contributor Author

@paulgessinger @asalzburger @XiaocongAi is someone aware if users rely on this feature? @Corentin-Allaire is (rightfully) concerned that this will break user code

@Corentin-Allaire
Copy link
Contributor

Corentin-Allaire commented Oct 16, 2023

@paulgessinger @asalzburger @XiaocongAi is someone aware if users rely on this feature? @Corentin-Allaire is (rightfully) concerned that this will break user code

To be more precise i there any users for which the target surface is not before the first layer (the main thing that would come to mind for me is test beam setup or maybe fix target)

@paulgessinger
Copy link
Member

I believe @pbutti needs the last measurement surface, but I think he's picking it up manually anyway. Can you confirm?

@osbornjd
Copy link
Contributor

I may be misunderstanding the use case, but it sounds like this also might affect cosmic track fitting where a cosmic ray traverses your entire detector and you want to the track parameters determined at some target surface outside the detector at an arbitrary location.

@andiwand andiwand changed the title refactor: Remove target direction logic from KF/CKF refactor: Refactor target direction logic from KF/CKF Oct 18, 2023
@andiwand andiwand changed the title refactor: Refactor target direction logic from KF/CKF refactor: Refactor target direction logic in KF/CKF Oct 18, 2023
Copy link
Contributor

@Corentin-Allaire Corentin-Allaire left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your work andi ! I think for the time being this will work. I agree with you that in the futur having a separate module for the extrapolation is probably the way to go.

@kodiakhq kodiakhq bot merged commit fd80ca7 into acts-project:main Oct 19, 2023
@acts-project-service acts-project-service added the Fails Athena tests This PR causes a failure in the Athena tests label Oct 19, 2023
@andiwand andiwand deleted the refactor-ckf-target-direction branch October 19, 2023 15:28
@paulgessinger paulgessinger modified the milestones: next, v30.3.0 Oct 25, 2023
kodiakhq bot pushed a commit that referenced this pull request Mar 28, 2024
After #2539 I want to finally refactor the CKF and remove the smoothing and the reference surface targeting from the core algorithm in order to make it more composable and less complicated.

Before the CKF was basically only usable with smoothing turned on otherwise we would not receive any tracks. Now it always runs without smoothing and the user can decide what and how to smooth. Afterwards the user can decide which track state they want to extrapolate to a reference surface if necessary.

IMO this makes the algorithm flow much easier to comprehend and gives the user more flexibility. This also makes an implementation of a two way finding easier as discovered in #2717

blocked by
- #2723

---

Users can smooth and extrapolate tracks after the CKF returns them. Extrapolation can be achieved using the `Propagator` while smoothing can be done by the `GainMatrixSmoother`.

For convenience this PR also includes helper functions to smooth and extrapolate single tracks or a whole track container.

Example of smoothing and extrapolating tracks after the CKF

https://github.com/acts-project/acts/blob/98186891d4bdc5b211f6af3e96ca59ace7c315cc/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp#L172-L189
EleniXoch pushed a commit to EleniXoch/acts that referenced this pull request May 6, 2024
…ject#2722)

After acts-project#2539 I want to finally refactor the CKF and remove the smoothing and the reference surface targeting from the core algorithm in order to make it more composable and less complicated.

Before the CKF was basically only usable with smoothing turned on otherwise we would not receive any tracks. Now it always runs without smoothing and the user can decide what and how to smooth. Afterwards the user can decide which track state they want to extrapolate to a reference surface if necessary.

IMO this makes the algorithm flow much easier to comprehend and gives the user more flexibility. This also makes an implementation of a two way finding easier as discovered in acts-project#2717

blocked by
- acts-project#2723

---

Users can smooth and extrapolate tracks after the CKF returns them. Extrapolation can be achieved using the `Propagator` while smoothing can be done by the `GainMatrixSmoother`.

For convenience this PR also includes helper functions to smooth and extrapolate single tracks or a whole track container.

Example of smoothing and extrapolating tracks after the CKF

https://github.com/acts-project/acts/blob/98186891d4bdc5b211f6af3e96ca59ace7c315cc/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp#L172-L189
asalzburger pushed a commit to asalzburger/acts that referenced this pull request May 21, 2024
…ject#2722)

After acts-project#2539 I want to finally refactor the CKF and remove the smoothing and the reference surface targeting from the core algorithm in order to make it more composable and less complicated.

Before the CKF was basically only usable with smoothing turned on otherwise we would not receive any tracks. Now it always runs without smoothing and the user can decide what and how to smooth. Afterwards the user can decide which track state they want to extrapolate to a reference surface if necessary.

IMO this makes the algorithm flow much easier to comprehend and gives the user more flexibility. This also makes an implementation of a two way finding easier as discovered in acts-project#2717

blocked by
- acts-project#2723

---

Users can smooth and extrapolate tracks after the CKF returns them. Extrapolation can be achieved using the `Propagator` while smoothing can be done by the `GainMatrixSmoother`.

For convenience this PR also includes helper functions to smooth and extrapolate single tracks or a whole track container.

Example of smoothing and extrapolating tracks after the CKF

https://github.com/acts-project/acts/blob/98186891d4bdc5b211f6af3e96ca59ace7c315cc/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp#L172-L189
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Core Affects the Core module Component - Examples Affects the Examples module Fails Athena tests This PR causes a failure in the Athena tests Track Finding Track Fitting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants