Skip to content

Commit

Permalink
indenting space 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikhasenko committed Dec 1, 2024
1 parent 0495354 commit 5680f08
Showing 1 changed file with 100 additions and 100 deletions.
200 changes: 100 additions & 100 deletions test/PxPyPzE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const ATOL = 1e-15
const RNG = MersenneTwister(137137)

struct CustomMom{T}
px::T
py::T
pz::T
E::T
px::T
py::T
pz::T
E::T
end

LorentzVectorBase.coordinate_system(::CustomMom) = LorentzVectorBase.PxPyPzE()
Expand All @@ -26,133 +26,133 @@ mom_zero = CustomMom(0.0, 0.0, 0.0, 0.0)
mom_offshell = CustomMom(0.0, 0.0, m, 0.0)

@testset "cooridnate names" begin
coordinate_names(LorentzVectorBase.PxPyPzE()) == (:px, :py, :pz, :E)
coordinate_names(LorentzVectorBase.PxPyPzE()) == (:px, :py, :pz, :E)
end

@testset "spatial_magnitude consistence" for mom in [mom_onshell, mom_offshell, mom_zero]
@test isapprox(
LorentzVectorBase.spatial_magnitude(mom),
sqrt(LorentzVectorBase.spatial_magnitude2(mom)),
)
@test isapprox(
LorentzVectorBase.spatial_magnitude(mom),
sqrt(LorentzVectorBase.spatial_magnitude2(mom)),
)
end

@testset "spatial_magnitude values" begin
@test isapprox(LorentzVectorBase.spatial_magnitude2(mom_onshell), px^2 + py^2 + pz^2)
@test isapprox(LorentzVectorBase.spatial_magnitude(mom_onshell), sqrt(px^2 + py^2 + pz^2))
@test isapprox(LorentzVectorBase.spatial_magnitude2(mom_onshell), px^2 + py^2 + pz^2)
@test isapprox(LorentzVectorBase.spatial_magnitude(mom_onshell), sqrt(px^2 + py^2 + pz^2))
end

@testset "mass consistence" for mom_on in [mom_onshell, mom_zero]
@test isapprox(LorentzVectorBase.mass(mom_on), sqrt(LorentzVectorBase.mass2(mom_on)))
@test LorentzVectorBase.invariant_mass2(mom_on) == LorentzVectorBase.mass2(mom_on)
@test LorentzVectorBase.invariant_mass(mom_on) == LorentzVectorBase.mass(mom_on)
@test isapprox(
LorentzVectorBase.invariant_mass(mom_on),
sqrt(LorentzVectorBase.invariant_mass2(mom_on)),
)
@test isapprox(LorentzVectorBase.mass(mom_on), sqrt(LorentzVectorBase.mass2(mom_on)))
@test LorentzVectorBase.invariant_mass2(mom_on) == LorentzVectorBase.mass2(mom_on)
@test LorentzVectorBase.invariant_mass(mom_on) == LorentzVectorBase.mass(mom_on)
@test isapprox(
LorentzVectorBase.invariant_mass(mom_on),
sqrt(LorentzVectorBase.invariant_mass2(mom_on)),
)
end

@testset "mass value" begin
@test isapprox(LorentzVectorBase.mass2(mom_onshell), E^2 - (px^2 + py^2 + pz^2))
@test isapprox(LorentzVectorBase.mass(mom_onshell), sqrt(E^2 - (px^2 + py^2 + pz^2)))
@test isapprox(LorentzVectorBase.mass2(mom_onshell), E^2 - (px^2 + py^2 + pz^2))
@test isapprox(LorentzVectorBase.mass(mom_onshell), sqrt(E^2 - (px^2 + py^2 + pz^2)))

@test isapprox(LorentzVectorBase.mass(mom_onshell), m)
@test isapprox(LorentzVectorBase.mass(mom_offshell), -m)
@test isapprox(LorentzVectorBase.mass(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.mass(mom_onshell), m)
@test isapprox(LorentzVectorBase.mass(mom_offshell), -m)
@test isapprox(LorentzVectorBase.mass(mom_zero), 0.0)
end

@testset "momentum components" begin
@test LorentzVectorBase.t(mom_onshell) == E
@test LorentzVectorBase.x(mom_onshell) == px
@test LorentzVectorBase.y(mom_onshell) == py
@test LorentzVectorBase.z(mom_onshell) == pz

@test LorentzVectorBase.E(mom_onshell) == E
@test LorentzVectorBase.E(LorentzVectorBase.PxPyPzE(), mom_onshell) == E
@test LorentzVectorBase.px(mom_onshell) == px
@test LorentzVectorBase.px(LorentzVectorBase.PxPyPzE(), mom_onshell) == px
@test LorentzVectorBase.py(mom_onshell) == py
@test LorentzVectorBase.py(LorentzVectorBase.PxPyPzE(), mom_onshell) == py
@test LorentzVectorBase.pz(mom_onshell) == pz
@test LorentzVectorBase.pz(LorentzVectorBase.PxPyPzE(), mom_onshell) == pz

@test isapprox(LorentzVectorBase.boost_beta(mom_onshell), sqrt(px^2 + py^2 + pz^2) / E)
@test isapprox(
LorentzVectorBase.boost_gamma(mom_onshell),
1 / sqrt(1.0 - LorentzVectorBase.boost_beta(mom_onshell)^2),
)

@test LorentzVectorBase.t(mom_zero) == 0.0
@test LorentzVectorBase.x(mom_zero) == 0.0
@test LorentzVectorBase.y(mom_zero) == 0.0
@test LorentzVectorBase.z(mom_zero) == 0.0
@test isapprox(LorentzVectorBase.boost_beta(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.boost_gamma(mom_zero), 1.0)
@test LorentzVectorBase.t(mom_onshell) == E
@test LorentzVectorBase.x(mom_onshell) == px
@test LorentzVectorBase.y(mom_onshell) == py
@test LorentzVectorBase.z(mom_onshell) == pz

@test LorentzVectorBase.E(mom_onshell) == E
@test LorentzVectorBase.E(LorentzVectorBase.PxPyPzE(), mom_onshell) == E
@test LorentzVectorBase.px(mom_onshell) == px
@test LorentzVectorBase.px(LorentzVectorBase.PxPyPzE(), mom_onshell) == px
@test LorentzVectorBase.py(mom_onshell) == py
@test LorentzVectorBase.py(LorentzVectorBase.PxPyPzE(), mom_onshell) == py
@test LorentzVectorBase.pz(mom_onshell) == pz
@test LorentzVectorBase.pz(LorentzVectorBase.PxPyPzE(), mom_onshell) == pz

@test isapprox(LorentzVectorBase.boost_beta(mom_onshell), sqrt(px^2 + py^2 + pz^2) / E)
@test isapprox(
LorentzVectorBase.boost_gamma(mom_onshell),
1 / sqrt(1.0 - LorentzVectorBase.boost_beta(mom_onshell)^2),
)

@test LorentzVectorBase.t(mom_zero) == 0.0
@test LorentzVectorBase.x(mom_zero) == 0.0
@test LorentzVectorBase.y(mom_zero) == 0.0
@test LorentzVectorBase.z(mom_zero) == 0.0
@test isapprox(LorentzVectorBase.boost_beta(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.boost_gamma(mom_zero), 1.0)
end

@testset "transverse coordiantes value" begin
@test isapprox(LorentzVectorBase.pt2(mom_onshell), px^2 + py^2)
@test isapprox(LorentzVectorBase.pt(mom_onshell), sqrt(px^2 + py^2))
@test isapprox(LorentzVectorBase.mt2(mom_onshell), E^2 - pz^2)
@test isapprox(LorentzVectorBase.mt(mom_onshell), sqrt(E^2 - pz^2))
@test isapprox(LorentzVectorBase.mt(mom_offshell), -m)

@test isapprox(LorentzVectorBase.rapidity(mom_onshell), 0.5 * log((E + pz) / (E - pz)))

@test isapprox(LorentzVectorBase.pt2(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.pt(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.mt2(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.mt(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.pt2(mom_onshell), px^2 + py^2)
@test isapprox(LorentzVectorBase.pt(mom_onshell), sqrt(px^2 + py^2))
@test isapprox(LorentzVectorBase.mt2(mom_onshell), E^2 - pz^2)
@test isapprox(LorentzVectorBase.mt(mom_onshell), sqrt(E^2 - pz^2))
@test isapprox(LorentzVectorBase.mt(mom_offshell), -m)

@test isapprox(LorentzVectorBase.rapidity(mom_onshell), 0.5 * log((E + pz) / (E - pz)))

@test isapprox(LorentzVectorBase.pt2(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.pt(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.mt2(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.mt(mom_zero), 0.0)
end

@testset "spherical coordiantes consistence" for mom_on in [mom_onshell, mom_zero]
@test isapprox(
LorentzVectorBase.cos_theta(mom_on), cos(LorentzVectorBase.polar_angle(mom_on)),
)
@test isapprox(LorentzVectorBase.cos_phi(mom_on), cos(LorentzVectorBase.phi(mom_on)))
@test isapprox(LorentzVectorBase.sin_phi(mom_on), sin(LorentzVectorBase.phi(mom_on)))
@test isapprox(
LorentzVectorBase.cos_theta(mom_on), cos(LorentzVectorBase.polar_angle(mom_on))
)
@test isapprox(LorentzVectorBase.cos_phi(mom_on), cos(LorentzVectorBase.phi(mom_on)))
@test isapprox(LorentzVectorBase.sin_phi(mom_on), sin(LorentzVectorBase.phi(mom_on)))
end

@testset "Ranges for angles: (θ,ϕ) ∈ [0,π] x [-π,π]" begin
p = CustomMom(1.0, sqrt(3), 1.0, 8.0)
θ = acos(1 / sqrt(5))
ϕ = π / 3
#
@test LorentzVectorBase.polar_angle(p) θ
@test LorentzVectorBase.azimuthal_angle(p) ϕ

p = CustomMom(1.0, sqrt(3), -1.0, 8.0)
@test LorentzVectorBase.polar_angle(p) π - θ
@test LorentzVectorBase.azimuthal_angle(p) ϕ

p = CustomMom(-1.0, sqrt(3), 1.0, 8.0)
@test LorentzVectorBase.polar_angle(p) θ
@test LorentzVectorBase.azimuthal_angle(p) π - ϕ

p = CustomMom(-1.0, sqrt(3), -1.0, 8.0)
@test LorentzVectorBase.polar_angle(p) π - θ
@test LorentzVectorBase.azimuthal_angle(p) π - ϕ
#
p = CustomMom(-1.0, -sqrt(3), -1.0, 8.0)
@test LorentzVectorBase.azimuthal_angle(p) -π + ϕ
#
p = CustomMom(1.0, -sqrt(3), -1.0, 8.0)
@test LorentzVectorBase.azimuthal_angle(p) -ϕ
p = CustomMom(1.0, sqrt(3), 1.0, 8.0)
θ = acos(1 / sqrt(5))
ϕ = π / 3
#
@test LorentzVectorBase.polar_angle(p) θ
@test LorentzVectorBase.azimuthal_angle(p) ϕ

p = CustomMom(1.0, sqrt(3), -1.0, 8.0)
@test LorentzVectorBase.polar_angle(p) π - θ
@test LorentzVectorBase.azimuthal_angle(p) ϕ

p = CustomMom(-1.0, sqrt(3), 1.0, 8.0)
@test LorentzVectorBase.polar_angle(p) θ
@test LorentzVectorBase.azimuthal_angle(p) π - ϕ

p = CustomMom(-1.0, sqrt(3), -1.0, 8.0)
@test LorentzVectorBase.polar_angle(p) π - θ
@test LorentzVectorBase.azimuthal_angle(p) π - ϕ
#
p = CustomMom(-1.0, -sqrt(3), -1.0, 8.0)
@test LorentzVectorBase.azimuthal_angle(p) -π + ϕ
#
p = CustomMom(1.0, -sqrt(3), -1.0, 8.0)
@test LorentzVectorBase.azimuthal_angle(p) -ϕ
end

@testset "spherical coordiantes values" begin
@test isapprox(
LorentzVectorBase.polar_angle(mom_onshell), atan(LorentzVectorBase.pt(mom_onshell), pz),
)
@test isapprox(LorentzVectorBase.polar_angle(mom_zero), 0.0)
@test isapprox(
LorentzVectorBase.polar_angle(mom_onshell), atan(LorentzVectorBase.pt(mom_onshell), pz)
)
@test isapprox(LorentzVectorBase.polar_angle(mom_zero), 0.0)

@test isapprox(LorentzVectorBase.phi(mom_onshell), atan(py, px))
@test isapprox(LorentzVectorBase.phi(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.phi(mom_onshell), atan(py, px))
@test isapprox(LorentzVectorBase.phi(mom_zero), 0.0)
end

@testset "light-cone coordiantes" begin
@test isapprox(LorentzVectorBase.plus_component(mom_onshell), 0.5 * (E + pz))
@test isapprox(LorentzVectorBase.minus_component(mom_onshell), 0.5 * (E - pz))
@test isapprox(LorentzVectorBase.plus_component(mom_onshell), 0.5 * (E + pz))
@test isapprox(LorentzVectorBase.minus_component(mom_onshell), 0.5 * (E - pz))

@test isapprox(LorentzVectorBase.plus_component(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.minus_component(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.plus_component(mom_zero), 0.0)
@test isapprox(LorentzVectorBase.minus_component(mom_zero), 0.0)
end

0 comments on commit 5680f08

Please sign in to comment.