Skip to content

Commit

Permalink
Rename rap to rapidity
Browse files Browse the repository at this point in the history
This is the same method name as ScikitHEP's Vector package
Add a note that we adopt the ROOT convention of returning a negative
mass for space-like 4-vectors
  • Loading branch information
graeme-a-stewart committed Oct 13, 2023
1 parent 1672128 commit e69f963
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ you can also use `fromPtEtaPhiE(pt, eta, phi, energy) --> LorentzVectorCyl`.
and these functions for both of them:

```julia
px, py, pz, energy, pt, rap, eta, phi, mass
px, py, pz, energy, pt, rapidity, eta, phi, mass
```

as well as these utility functions:
Expand Down
3 changes: 2 additions & 1 deletion src/cartesian.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Base.zero(lv::T) where T<:LorentzVector = T(0,0,0,0)
mass2(lv::LorentzVector) = dot(lv, lv)
"""mass value - returns a negative number for spacelike 4-vectors"""
mass(lv::LorentzVector) = mass2(lv) < 0.0 ? sqrt(-mass2(lv)) : sqrt(mass2(lv))
pt2(lv::LorentzVector) = muladd(lv.x, lv.x, lv.y^2)
pt(lv::LorentzVector) = sqrt(pt2(lv))
Expand Down Expand Up @@ -30,7 +31,7 @@ end
const η = eta

"""Rapidity"""
function rap(lv::LorentzVector)
function rapidity(lv::LorentzVector)
pt_squared = pt2(lv)
abspz = abs(pz(lv))
if (energy(lv) == abspz) && (pt_squared == 0.0)
Expand Down
2 changes: 1 addition & 1 deletion src/cylindrical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function fast_mass(v1::LorentzVectorCyl, v2::LorentzVectorCyl)
end

"Rapidity"
function rap(lv::LorentzVectorCyl)
function rapidity(lv::LorentzVectorCyl)
num = sqrt(lv.mass^2 + lv.pt^2 * cosh(lv.eta)^2) + lv.pt * sinh(lv.eta)
den = sqrt(lv.mass^2 + lv.pt^2)
return log(num/den)
Expand Down

0 comments on commit e69f963

Please sign in to comment.