scikit-hep / scikit-hep/vector

`v.perp(direction)` should compute 2D magnitude along an alternate 3D longitudinal axis direction (both are at least 3D)

Open
#141 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
99
Forks
42
Avg merge
1d 13h
Merged PRs (30d)
6

Description

From ROOT's TLorentzVector:

>>> import ROOT

>>> v = ROOT.TLorentzVector(1.1, 2.2, 3.3, 4.4)
>>> direction = ROOT.TVector3(3, 2, 1)

>>> v.Perp(direction)
2.880476151115099

We want the same thing in a convenient method: v.perp(direction)

>>> import awkward as ak
>>> import numpy as np
>>> import vector
>>> vector.register_awkward()

>>> v = ak.Array([
...     [{"x": 1.1, "y": 2.2, "z": 3.3}], [], [{"x": 1.1, "y": 2.2, "z": 3.3}]
... ], with_name="Vector3D")

>>> direction = ak.Array([
...     [{"x": 3, "y": 2, "z": 1}], [], [{"x": 3, "y": 2, "z": 1}]
... ], with_name="Vector3D")

>>> v.mag * np.sin(v.deltaangle(direction))
<Array [[2.88], [], [2.88]] type='3 * var * float64'>

New "compute" modules are not needed; just compute this as a convenience method from the existing ones.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the existing perp, mag, and deltaangle implementations and follow how Vector3D arrays and empty elements are handled. Add the convenience behavior for v.perp(direction) without a new compute module, matching ROOT's result for the shown 3D inputs and preserving the demonstrated awkward-array structure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.