Skip to content

Commit

Permalink
add deltaphi
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf committed May 19, 2022
1 parent eae9a6b commit 9cb785e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LorentzVectorHEP"
uuid = "f612022c-142a-473f-8cfd-a09cf3793c6c"
authors = ["Jerry Ling <proton@jling.dev> and contributors"]
version = "0.1.0"
version = "0.1.1"

[deps]
LorentzVectors = "3f54b04b-17fc-5cd4-9758-90c048d965e3"
Expand Down
2 changes: 1 addition & 1 deletion src/LorentzVectorHEP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using LorentzVectors # provides x, y, z, t
export LorentzVectorCyl, LorentzVector

export px, py, pz, energy, fast_mass, pt, eta, phi, mass
export deltaphi, deltar
export deltaphi, deltar, deltaeta
export ΔR, Δϕ, Δη

include("cartesian.jl")
Expand Down
10 changes: 5 additions & 5 deletions src/cartesian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ function phi_mpi_pi(x)
return x
end

function deltaeta(lv1, lv2)
eta(lv1) - eta(lv2)
end
deltaeta(lv1, lv2) = eta(lv1) - eta(lv2)

deltaphi(lv1, lv2) = phi_mpi_pi(phi(lv1) - phi(lv2))

function deltar(lv1, lv2)
deta = eta(lv1) - eta(lv2)
dphi = phi_mpi_pi(phi(lv1) - phi(lv2))
return sqrt(deta * deta + dphi * dphi)
dphi = deltaphi(lv1 - lv2)
return sqrt(fma(deta, deta, dphi * dphi))
end
8 changes: 4 additions & 4 deletions src/cylindrical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Base.:+(v1::LorentzVectorCyl{T}, v2::LorentzVectorCyl{W}) where {T,W}
pt = sqrt(ptsq)
eta = asinh(sumpz/pt)
phi = atan(sumpy, sumpx)
mass = sqrt(max(muladd(m1, m1, m2^2) + 2*e1*e2 - 2*(muladd(px1, px2, py1*py2) + pz1*pz2), zero(v1.pt)))
mass = sqrt(max(fma(m1, m1, m2^2) + 2*e1*e2 - 2*(fma(px1, px2, py1*py2) + pz1*pz2), zero(v1.pt)))
return LorentzVectorCyl(pt,eta,phi,mass)
end

Expand All @@ -67,7 +67,7 @@ function fast_mass(v1::LorentzVectorCyl, v2::LorentzVectorCyl)
sinheta1 = sinh(eta1)
sinheta2 = sinh(eta2)
tpt12 = 2*pt1*pt2
return @fastmath sqrt(max(muladd(m1, m1, m2^2)
return @fastmath sqrt(max(fma(m1, m1, m2^2)
+ 2*sqrt((pt1^2*(1+sinheta1^2) + m1^2)*(pt2^2*(1+sinheta2^2) + m2^2))
- tpt12*sinheta1*sinheta2
- tpt12*cos(phi1-phi2), zero(pt1)))
Expand All @@ -90,7 +90,7 @@ const Δη = deltaeta
@inline function deltar2(v1::LorentzVectorCyl, v2::LorentzVectorCyl)
dphi = deltaphi(v1,v2)
deta = deltaeta(v1,v2)
return muladd(dphi, dphi, deta^2)
return fma(dphi, dphi, deta^2)
end
@inline deltar(v1::LorentzVectorCyl, v2::LorentzVectorCyl) = sqrt(deltar2(v1, v2))
deltar(v1::LorentzVectorCyl, v2::LorentzVectorCyl) = sqrt(deltar2(v1, v2))
const ΔR = deltar

2 comments on commit 9cb785e

@Moelf
Copy link
Member Author

@Moelf Moelf commented on 9cb785e May 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/60588

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.1 -m "<description of version>" 9cb785e35faeb4fb190fb4b1c27fe4ee0dfb7362
git push origin v0.1.1

Please sign in to comment.