Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Asa found that the true position at the start of the TMS and position at the start of the track are wrong. Here green are start positions while black are true hits.
Turns out the GetPositionAtZ funciton wasn't working well, and neither was GetMomentumAtZ. It seems like it's returning the start position each time, and adjusting z to match the requested z. That's why the black line is pointing to x and y in the x vs y plot.
Here are some x,y,z,t times for BirthPosition, RecoTrackPrimaryParticleTruePositionStart, PositionTMSStart, RecoTrackPrimaryParticleTruePositionTrackStart, RecoTrackPrimaryParticleTruePositionTrackEnd and RecoTrackPrimaryParticleTruePositionEnd.
Of these, RecoTrackPrimaryParticleTruePositionStart, RecoTrackPrimaryParticleTruePositionTrackStart, RecoTrackPrimaryParticleTruePositionTrackEnd all use GetPositionAtZ. We can see they're all the birth position except that z was adjusted to match the requested z position. RecoTrackPrimaryParticleTruePositionEnd uses GetDeathPosition, and PositionTMSStart uses GetPositionEnteringTMS.
Fix
I replaced GetPositionAtZ and GetMomentumAtZ with an improved version. This improved version does a linear interpolation between the two nearest points to try to get the most exact value for a given value of z. If z is outside the range of the particle, but within max_z_dist, then it returns the start/end position/momentum. This was always on my todo list but given this bug, I went ahead and did it
This also fixes the issue:
I made some test files using the validation technique . I tagged with
kleykamp_2024-08-27
and stored them in/exp/dune/data/users/kleykamp/dune-tms/simple_processing_test/kleykamp_2024-08-27