Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented theta function #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/LorentzVectorHEP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ using LorentzVectors # provides x, y, z, t

export LorentzVectorCyl, LorentzVector

export px, py, pz, energy, fast_mass, pt, rapidity, eta, phi, mass
export deltaphi, deltar, deltaeta

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

include("cartesian.jl")
include("cylindrical.jl")

const Δϕ = deltaphi
const Δη = deltaeta
const ΔR = deltar
const Δθ = deltatheta

export ΔR, Δϕ, Δη, Δθ

# conversion
function LorentzVector(v::LorentzVectorCyl)
x = px(v)
Expand Down
8 changes: 8 additions & 0 deletions src/cartesian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ function phi02pi(lv::LorentzVector)
return phi(lv) < 0.0 ? phi(lv) + 2π : phi(lv)
end

function theta(lv::LorentzVector)
return lv.x == 0.0 && lv.y == 0.0 && lv.z == 0.0 ? 0.0 : atan2(pt(lv), lv.z)
end

function deltatheta(lv1::LorentzVector, lv2::LorentzVector)
return phi_mpi_pi(theta(lv1) - theta(lv2))
end

function phi_mpi_pi(x)
twopi = 2pi
while (x >= pi)
Expand Down
7 changes: 2 additions & 5 deletions src/cylindrical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,22 @@ end
dphi = dphi - 2*pi*(dphi > pi) + 2*pi*(dphi <= -pi)
return dphi
end
const Δϕ = deltaphi

@inline function deltaeta(v1::LorentzVectorCyl, v2::LorentzVectorCyl)
return v2.eta - v1.eta
end
const Δη = deltaeta

@inline function deltar2(v1::LorentzVectorCyl, v2::LorentzVectorCyl)
dphi = deltaphi(v1,v2)
deta = deltaeta(v1,v2)
return muladd(dphi, dphi, deta^2)
end
deltar(v1::LorentzVectorCyl, v2::LorentzVectorCyl) = sqrt(deltar2(v1, v2))
const ΔR = deltar

const ΔR = deltar

function fromPtEtaPhiE(pt, eta, phi, E)
m2 = E^2 - pt^2 - (sinh(eta) * pt)^2
m = sign(m2) * sqrt(abs(m2))
return LorentzVectorCyl(pt, eta, phi, m)
end

end
Loading