Skip to content

Commit cf892a6

Browse files
authored
Tests for range of the spherical angle (#22)
1 parent 46d7df1 commit cf892a6

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

test/PxPyPzE.jl

+32-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ using LorentzVectorBase
55
const ATOL = 1e-15
66
const RNG = MersenneTwister(137137)
77

8-
struct CustomMom
9-
px
10-
py
11-
pz
12-
E
8+
struct CustomMom{T}
9+
px::T
10+
py::T
11+
pz::T
12+
E::T
1313
end
1414

1515
LorentzVectorBase.coordinate_system(::CustomMom) = LorentzVectorBase.PxPyPzE()
@@ -112,6 +112,33 @@ end
112112
@test isapprox(LorentzVectorBase.sin_phi(mom_on), sin(LorentzVectorBase.phi(mom_on)))
113113
end
114114

115+
@testset "Ranges for angles: (θ,ϕ) ∈ [0,π] x [-π,π]" begin
116+
p = CustomMom(1.0, sqrt(3), 1.0, 8.0)
117+
θ = acos(1 / sqrt(5))
118+
ϕ = π / 3
119+
#
120+
@test LorentzVectorBase.polar_angle(p) θ
121+
@test LorentzVectorBase.azimuthal_angle(p) ϕ
122+
123+
p = CustomMom(1.0, sqrt(3), -1.0, 8.0)
124+
@test LorentzVectorBase.polar_angle(p) π - θ
125+
@test LorentzVectorBase.azimuthal_angle(p) ϕ
126+
127+
p = CustomMom(-1.0, sqrt(3), 1.0, 8.0)
128+
@test LorentzVectorBase.polar_angle(p) θ
129+
@test LorentzVectorBase.azimuthal_angle(p) π - ϕ
130+
131+
p = CustomMom(-1.0, sqrt(3), -1.0, 8.0)
132+
@test LorentzVectorBase.polar_angle(p) π - θ
133+
@test LorentzVectorBase.azimuthal_angle(p) π - ϕ
134+
#
135+
p = CustomMom(-1.0, -sqrt(3), -1.0, 8.0)
136+
@test LorentzVectorBase.azimuthal_angle(p) -π + ϕ
137+
#
138+
p = CustomMom(1.0, -sqrt(3), -1.0, 8.0)
139+
@test LorentzVectorBase.azimuthal_angle(p) -ϕ
140+
end
141+
115142
@testset "spherical coordiantes values" begin
116143
@test isapprox(
117144
LorentzVectorBase.polar_angle(mom_onshell), atan(LorentzVectorBase.pt(mom_onshell), pz)

0 commit comments

Comments
 (0)