Skip to content

Commit 29432d3

Browse files
committed
xyze rename
1 parent c16a41c commit 29432d3

File tree

3 files changed

+47
-47
lines changed

3 files changed

+47
-47
lines changed

src/LorentzVectorBase.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module LorentzVectorBase
33
export coordinate_system, coordinate_names
44

55
include("interface.jl")
6-
include("coordinate_systems/exyz.jl")
6+
include("coordinate_systems/xyze.jl")
77
include("coordinate_systems/PtEtaPhiM.jl")
88

99
end

src/coordinate_systems/exyz.jl renamed to src/coordinate_systems/xyze.jl

+42-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
3-
EXYZ <: AbstractCoordinateSystem
3+
XYZE <: AbstractCoordinateSystem
44
55
Cartesian coordinate system for four-momenta. Using this requires the implementation of the following interface functions:
66
@@ -12,8 +12,8 @@ energy(::CustomFourMomentum)
1212
```
1313
1414
"""
15-
struct EXYZ <: AbstractCoordinateSystem end
16-
coordinate_names(::EXYZ) = (:px, :py, :pz, :energy)
15+
struct XYZE <: AbstractCoordinateSystem end
16+
coordinate_names(::XYZE) = (:px, :py, :pz, :energy)
1717

1818
####
1919
# Interface functions
@@ -53,7 +53,7 @@ function pz end
5353

5454
"""
5555
56-
spatial_magnitude2(::EXYZ, mom)
56+
spatial_magnitude2(::XYZE, mom)
5757
5858
Return the square of the spatial_magnitude of a given four-momentum, i.e. the sum of the squared spatial components.
5959
@@ -67,13 +67,13 @@ Return the square of the spatial_magnitude of a given four-momentum, i.e. the su
6767
This function differs from a similar function for the `TLorentzVector` used in the famous `ROOT` library.
6868
6969
"""
70-
@inline function spatial_magnitude2(::EXYZ, mom)
70+
@inline function spatial_magnitude2(::XYZE, mom)
7171
return px(mom)^2 + py(mom)^2 + pz(mom)^2
7272
end
7373

7474
"""
7575
76-
spatial_magnitude(::EXYZ,mom)
76+
spatial_magnitude(::XYZE,mom)
7777
7878
Return the spatial_magnitude of a given four-momentum, i.e. the euklidian norm spatial components.
7979
@@ -87,13 +87,13 @@ Return the spatial_magnitude of a given four-momentum, i.e. the euklidian norm s
8787
This function differs from a similar function for the `TLorentzVector` used in the famous `ROOT` library.
8888
8989
"""
90-
@inline function spatial_magnitude(cs::EXYZ, mom)
90+
@inline function spatial_magnitude(cs::XYZE, mom)
9191
return sqrt(spatial_magnitude2(mom))
9292
end
9393

9494
"""
9595
96-
mass2(::EXYZ,mom)
96+
mass2(::XYZE,mom)
9797
9898
Return the squared invariant mass of a given four-momentum, i.e. the minkowski dot with itself.
9999
@@ -103,13 +103,13 @@ Return the squared invariant mass of a given four-momentum, i.e. the minkowski d
103103
104104
105105
"""
106-
@inline function mass2(::EXYZ, mom)
106+
@inline function mass2(::XYZE, mom)
107107
return energy(mom)^2 - px(mom)^2 - py(mom)^2 - pz(mom)^2
108108
end
109109

110110
"""
111111
112-
mass(::EXYZ,mom)
112+
mass(::XYZE,mom)
113113
114114
Return the the invariant mass of a given four-momentum, i.e. the square root of the minkowski dot with itself.
115115
@@ -123,7 +123,7 @@ Return the the invariant mass of a given four-momentum, i.e. the square root of
123123
If the squared invariant mass `m2` is negative, `-sqrt(-m2)` is returned.
124124
125125
"""
126-
@inline function mass(::EXYZ, mom)
126+
@inline function mass(::XYZE, mom)
127127
m2 = mass2(mom)
128128
if m2 < zero(m2)
129129
# Think about including this waring, maybe optional with a global PRINT_WARINGS switch.
@@ -136,7 +136,7 @@ end
136136

137137
"""
138138
139-
boost_beta(::EXYZ, mom )
139+
boost_beta(::XYZE, mom )
140140
141141
Return spatial_magnitude of the beta vector for a given four-momentum, i.e. the spatial_magnitude of the four-momentum divided by its 0-component.
142142
@@ -145,7 +145,7 @@ Return spatial_magnitude of the beta vector for a given four-momentum, i.e. the
145145
If `(E,px,py,pz)` is a four-momentum, this is equivalent to `sqrt(px^2 + py^2 + pz^2)/E`.
146146
147147
"""
148-
@inline function boost_beta(::EXYZ, mom)
148+
@inline function boost_beta(::XYZE, mom)
149149
en = energy(mom)
150150
rho = spatial_magnitude(mom)
151151
if !iszero(en)
@@ -163,7 +163,7 @@ end
163163

164164
"""
165165
166-
boost_gamma(::EXYZ,mom)
166+
boost_gamma(::XYZE,mom)
167167
168168
Return the relativistic gamma factor for a given four-momentum, i.e. the inverse square root of one minus the beta vector squared.
169169
@@ -172,7 +172,7 @@ Return the relativistic gamma factor for a given four-momentum, i.e. the inverse
172172
If `(E,px,py,pz)` is a four-momentum with beta vector `β`, this is equivalent to `1/sqrt(1- β^2)`.
173173
174174
"""
175-
@inline function boost_gamma(::EXYZ, mom)
175+
@inline function boost_gamma(::XYZE, mom)
176176
return inv(sqrt(one(energy(mom)) - boost_beta(mom)^2))
177177
end
178178

@@ -181,7 +181,7 @@ end
181181
########################
182182
"""
183183
184-
pt2(::EXYZ,mom)
184+
pt2(::XYZE,mom)
185185
186186
Return the squared transverse momentum for a given four-momentum, i.e. the sum of its squared 1- and 2-component.
187187
@@ -194,13 +194,13 @@ Return the squared transverse momentum for a given four-momentum, i.e. the sum o
194194
The transverse components are defined w.r.t. to the 3-axis.
195195
196196
"""
197-
@inline function pt2(::EXYZ, mom)
197+
@inline function pt2(::XYZE, mom)
198198
return px(mom)^2 + py(mom)^2
199199
end
200200

201201
"""
202202
203-
pt(::EXYZ, mom)
203+
pt(::XYZE, mom)
204204
205205
Return the transverse momentum for a given four-momentum, i.e. the spatial_magnitude of its transverse components.
206206
@@ -214,13 +214,13 @@ Return the transverse momentum for a given four-momentum, i.e. the spatial_magni
214214
The transverse components are defined w.r.t. to the 3-axis.
215215
216216
"""
217-
@inline function pt(::EXYZ, mom)
217+
@inline function pt(::XYZE, mom)
218218
return sqrt(pt2(mom))
219219
end
220220

221221
"""
222222
223-
mt2(::EXYZ, mom)
223+
mt2(::XYZE, mom)
224224
225225
Return the squared transverse mass for a given four-momentum, i.e. the difference of its squared 0- and 3-component.
226226
@@ -235,13 +235,13 @@ Return the squared transverse mass for a given four-momentum, i.e. the differenc
235235
236236
237237
"""
238-
@inline function mt2(::EXYZ, mom)
238+
@inline function mt2(::XYZE, mom)
239239
return energy(mom)^2 - pz(mom)^2
240240
end
241241

242242
"""
243243
244-
mt(::EXYZ,mom)
244+
mt(::XYZE,mom)
245245
246246
Return the transverse momentum for a given four-momentum, i.e. the square root of its squared transverse mass.
247247
@@ -259,7 +259,7 @@ Return the transverse momentum for a given four-momentum, i.e. the square root o
259259
If the squared transverse mass `mt2` is negative, `-sqrt(-mt2)` is returned.
260260
261261
"""
262-
function mt(::EXYZ, mom)
262+
function mt(::XYZE, mom)
263263
mT2 = mt2(mom)
264264
if mT2 < zero(mT2)
265265
# add optional waring: negative transverse mass -> -sqrt(-mT2) is returned.
@@ -271,7 +271,7 @@ end
271271

272272
"""
273273
274-
rapidity(::EXYZ, mom)
274+
rapidity(::XYZE, mom)
275275
276276
Return the [rapidity](https://en.wikipedia.org/wiki/Rapidity) for a given four-momentum.
277277
@@ -285,18 +285,18 @@ Return the [rapidity](https://en.wikipedia.org/wiki/Rapidity) for a given four-m
285285
The transverse components are defined w.r.t. to the 3-axis.
286286
287287
"""
288-
@inline function rapidity(::EXYZ, mom)
288+
@inline function rapidity(::XYZE, mom)
289289
en = energy(mom)
290290
zcomp = pz(mom)
291291
return 0.5 * log((en + zcomp) / (en - zcomp))
292292
end
293293

294294
"""
295-
eta(::EXYZ, mom)
295+
eta(::XYZE, mom)
296296
297297
TBW
298298
"""
299-
function eta(::EXYZ, mom)
299+
function eta(::XYZE, mom)
300300
cth = cos_theta(mom)
301301

302302
if cth^2 < one(cth)
@@ -321,7 +321,7 @@ end
321321
#######################
322322
"""
323323
324-
polar_angle(::EXYZ,mom)
324+
polar_angle(::XYZE,mom)
325325
326326
Return the theta angle for a given four-momentum, i.e. the polar angle of its spatial components in [spherical coordinates](https://en.wikipedia.org/wiki/Spherical_coordinate_system).
327327
@@ -334,7 +334,7 @@ Return the theta angle for a given four-momentum, i.e. the polar angle of its sp
334334
The [spherical coordinates](https://en.wikipedia.org/wiki/Spherical_coordinate_system) are defined w.r.t. to the 3-axis.
335335
336336
"""
337-
@inline function polar_angle(::EXYZ, mom)
337+
@inline function polar_angle(::XYZE, mom)
338338
xcomp = px(mom)
339339
ycomp = py(mom)
340340
zcomp = pz(mom)
@@ -348,23 +348,23 @@ end
348348

349349
"""
350350
351-
cos_theta(::EXYZ, mom)
351+
cos_theta(::XYZE, mom)
352352
353353
Return the cosine of the theta angle for a given four-momentum.
354354
355355
!!! note
356356
357-
This is an equivalent but faster version of `cos(polar_angle(::EXYZ, mom))`; see [`polar_angle`](@ref).
357+
This is an equivalent but faster version of `cos(polar_angle(::XYZE, mom))`; see [`polar_angle`](@ref).
358358
359359
"""
360-
@inline function cos_theta(::EXYZ, mom)
360+
@inline function cos_theta(::XYZE, mom)
361361
r = spatial_magnitude(mom)
362362
return iszero(r) ? one(px(mom)) : pz(mom) / r
363363
end
364364

365365
"""
366366
367-
phi(::EXYZ, mom)
367+
phi(::XYZE, mom)
368368
369369
Return the phi angle for a given four-momentum, i.e. the azimuthal angle of its spatial components in [spherical coordinates](https://en.wikipedia.org/wiki/Spherical_coordinate_system).
370370
@@ -377,15 +377,15 @@ Return the phi angle for a given four-momentum, i.e. the azimuthal angle of its
377377
The [spherical coordinates](https://en.wikipedia.org/wiki/Spherical_coordinate_system) are defined w.r.t. to the 3-axis.
378378
379379
"""
380-
function phi(::EXYZ, mom)
380+
function phi(::XYZE, mom)
381381
xcomp = px(mom)
382382
ycomp = py(mom)
383383
return iszero(xcomp) && iszero(ycomp) ? zero(xcomp) : atan(ycomp, xcomp)
384384
end
385385

386386
"""
387387
388-
cos_phi(::EXYZ, mom)
388+
cos_phi(::XYZE, mom)
389389
390390
Return the cosine of the azimuthal angle for a given four-momentum.
391391
@@ -394,14 +394,14 @@ Return the cosine of the azimuthal angle for a given four-momentum.
394394
This is an equivalent but faster version of `cos(azimuthal_angle(mom))`; see [`azimuthal_angle`](@ref).
395395
396396
"""
397-
function cos_phi(::EXYZ, mom)
397+
function cos_phi(::XYZE, mom)
398398
pT = transverse_momentum(mom)
399399
return iszero(pT) ? one(pT) : px(mom) / pT
400400
end
401401

402402
"""
403403
404-
sin_phi(::EXYZ,mom)
404+
sin_phi(::XYZE,mom)
405405
406406
Return the sine of the azimuthal angle for a given four-momentum.
407407
@@ -410,7 +410,7 @@ Return the sine of the azimuthal angle for a given four-momentum.
410410
This is an equivalent but faster version of `sin(azimuthal_angle(mom))`; see [`azimuthal_angle`](@ref).
411411
412412
"""
413-
function sin_phi(::EXYZ, mom)
413+
function sin_phi(::XYZE, mom)
414414
pT = transverse_momentum(mom)
415415
return iszero(pT) ? zero(pT) : py(mom) / pT
416416
end
@@ -420,7 +420,7 @@ end
420420
########################
421421
"""
422422
423-
plus_component(::EXYZ, mom)
423+
plus_component(::XYZE, mom)
424424
425425
Return the plus component for a given four-momentum in [light-cone coordinates](https://en.wikipedia.org/wiki/Light-cone_coordinates).
426426
@@ -437,13 +437,13 @@ Return the plus component for a given four-momentum in [light-cone coordinates](
437437
The definition ``p^+ := (E + p_z)/2` differs from the usual definition of [light-cone coordinates](https://en.wikipedia.org/wiki/Light-cone_coordinates) in general relativity.
438438
439439
"""
440-
@inline function plus_component(::EXYZ, mom)
440+
@inline function plus_component(::XYZE, mom)
441441
return 0.5 * (energy(mom) + pz(mom))
442442
end
443443

444444
"""
445445
446-
minus_component(::EXYZ, mom)
446+
minus_component(::XYZE, mom)
447447
448448
Return the minus component for a given four-momentum in [light-cone coordinates](https://en.wikipedia.org/wiki/Light-cone_coordinates).
449449
@@ -460,6 +460,6 @@ Return the minus component for a given four-momentum in [light-cone coordinates]
460460
The definition ``p^- := (E - p_z)/2` differs from the usual definition of [light-cone coordinates](https://en.wikipedia.org/wiki/Light-cone_coordinates) in general relativity.
461461
462462
"""
463-
@inline function minus_component(::EXYZ, mom)
463+
@inline function minus_component(::XYZE, mom)
464464
return 0.5 * (energy(mom) - pz(mom))
465465
end

test/xyze.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const ATOL = 1e-15
66
const RNG = MersenneTwister(137137)
77

88
struct CustomMom
9-
e
109
x
1110
y
1211
z
12+
e
1313
end
1414

15-
LorentzVectorBase.coordinate_system(::CustomMom) = LorentzVectorBase.EXYZ()
15+
LorentzVectorBase.coordinate_system(::CustomMom) = LorentzVectorBase.XYZE()
1616
LorentzVectorBase.px(mom::CustomMom) = mom.x
1717
LorentzVectorBase.py(mom::CustomMom) = mom.y
1818
LorentzVectorBase.pz(mom::CustomMom) = mom.z
@@ -21,9 +21,9 @@ LorentzVectorBase.energy(mom::CustomMom) = mom.e
2121
x, y, z = rand(RNG, 3)
2222
m = rand(RNG)
2323
E = sqrt(x^2 + y^2 + z^2 + m^2)
24-
mom_onshell = CustomMom(E, x, y, z)
24+
mom_onshell = CustomMom(x, y, z, E)
2525
mom_zero = CustomMom(0.0, 0.0, 0.0, 0.0)
26-
mom_offshell = CustomMom(0.0, 0.0, 0.0, m)
26+
mom_offshell = CustomMom(0.0, 0.0, m, 0.0)
2727

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

0 commit comments

Comments
 (0)