Implement track cuts by distance of closest approach (DCA) and angle#951
Merged
Conversation
Member
|
This looks great - thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In certain experiments (such as LHCb), track collections are loaded containing only raw coordinate positions (pos) without track helix parameters (dparams). Because properties like$d_0$ , $z_0$ , $\phi$ , and $\eta$ were not explicitly provided, these track cuts were completely filtered out from the user interface, preventing users from cutting away background tracks or parallel noise.
Solution
This PR introduces dynamic calculation of all missing track properties directly from their coordinates (pos), enabling the existing track cuts globally for all loaded track formats. It also introduces two new dedicated cuts specifically for filtering out parallel and displaced tracks:
DCA (Distance of Closest Approach) to the beamline.$\vec{v} = (v_x, v_y, v_z)$ is calculated using the first segment of the track (positions[1] - positions[0]):
Angle of the track relative to the beamline.
Mathematical Calculations
For any track, the tangent vector
Azimuthal Angle ($\phi$ ): Computed using Math.atan2(v_y, v_x).$\eta$ ): Computed from the polar angle $\theta$ .$d_0$ ): Calculated as the 2D distance of closest approach to the z-axis (beamline) in the XY plane: $$d_0 = \frac{x_0 v_y - y_0 v_x}{\sqrt{v_x^2 + v_y^2}}$$ $z_0$ ): Calculated at the point of closest approach in the XY plane: $$z_0 = z_0 - v_z \frac{x_0 v_x + y_0 v_y}{v_x^2 + v_y^2}$$ $|d_0|$ .$$\theta = \arccos\left(\frac{v_z}{|\vec{v}|}\right) \times \frac{180}{\pi}$$ $\rightarrow$ 'DCA' and angle $\rightarrow$ 'Angle' in the pretty symbols registry.$d_0$ ), DCA, and polar angle.
Pseudorapidity (
Transverse Impact Parameter (
Longitudinal Impact Parameter (
DCA: Computed as
Angle: Computed as the polar angle relative to the z-axis in degrees:
Proposed Changes
packages/phoenix-event-display
src/loaders/objects/phoenix-objects.ts
Extracted track parameters logic into a reusable static method calculateTrackParams.
Integrated calculateTrackParams inside both getTrack and getTracks to automatically compute and assign dca, angle, d0, z0, phi, and eta from coordinate arrays if they are missing.
src/loaders/object-type-registry.ts
Registered the default dca (range 0 to 5000 mm) and angle (range 0 to 180 degrees) cuts in the track registry.
src/helpers/pretty-symbols.ts
Configured the mappings for dca
Verification & Testing
Unit Tests: Added a new test suite in phoenix-objects.test.ts verifying:
Exact property assignment of d0, z0, phi, eta, dca, and angle from track points.
Math correctness of signed transverse impact parameter (
Linting & Code Style: Clean ESLint check and auto-formatting applied. All 276 unit tests pass successfully.