Skip to content

fix(event-display): keep jivexml backward track theta and charge - #1041

Open
SajalDevX wants to merge 1 commit into
HSF:mainfrom
SajalDevX:fix/jivexml-backward-track-dparams
Open

SajalDevX wants to merge 1 commit into
HSF:mainfrom
SajalDevX:fix/jivexml-backward-track-dparams

Conversation

@SajalDevX

Copy link
Copy Markdown

JiveXML gives a track's polar angle as cotTheta, and JiveXMLLoader.getTracks turns it into theta with Math.atan(1 / cotTheta). For backward tracks (cotTheta < 0, eta < 0) that is negative, and the shift into (0, PI) only ran after track.dparams had been built. So every backward track was stored with:

  • a negative dparams[3] (e.g. -PI/4 instead of 3PI/4 for cotTheta = -1)
  • the sign of q/p in dparams[4] flipped, because |p| = pT / sin(theta) came out negative

track.eta was already right since it's computed after the shift.

JiveXML tracks don't carry a charge, so the q shown for a track, "Color by Charge" and the kinematics panel all read it from dparams[4] and showed the wrong charge for every backward track. The RK extrapolation for collections without polylines also takes its charge from dparams[4], so those tracks curved the wrong way.

This moves the theta < 0 shift to right after theta is computed, before momentum and dparams use it. I dropped the old "check if we need to flip phi" TODO with it: atan(1 / cotTheta) + PI is just the actual polar angle in (0, PI), so phi doesn't need to change.

Testing

Added src/tests/loaders/jivexml-loader.test.ts with one forward (cotTheta = 1) and one backward (cotTheta = -1) track, both with positive pt. It checks theta is PI/4 and 3PI/4, q/p is positive for both, and eta is +/-0.8814.

  • Before the fix: the theta and charge tests fail (-0.785 vs 2.356, and -7.07e-5 vs +7.07e-5). The eta test passes.
  • After the fix: all 3 pass. The rest of src/tests/loaders and src/tests/helpers still pass, including jivexml-menu-integration, rk-helper and phoenix-objects.
  • Prettier check passes on both files. I did not run ESLint or the full yarn test:ci, and atlasesd-loader / jsroot-event-loader did not run locally because I did not have jsroot installed. Neither of those touches this code.

JiveXML gives a track's polar angle as cotTheta, and the loader turns it
into theta with atan(1 / cotTheta). For a backward track (cotTheta < 0,
eta < 0) that is negative, and the shift into (0, PI) only happened after
dparams had already been built from it. So backward tracks were stored
with a negative theta in dparams[3] and, since |p| = pT / sin(theta)
came out negative, with the sign of q/p in dparams[4] flipped.

That gave every backward track the wrong charge wherever it is read from
dparams (the q shown for a track, "Color by Charge", the kinematics
panel), a wrong theta/angle, and made the Runge-Kutta extrapolation of
tracks without polylines bend the wrong way.

Shift theta into (0, PI) before dparams is built, and add tests for
forward and backward tracks.
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

🚀 Preview deployed: http://phoenix-pr-1041.surge.sh

Built from 90e6269.

This branch was successfully deployed

1 active deployment
pull-request — 90e6269f Deployed Oct 4, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant