Skip to content

Commit 62d7f8a

Browse files
author
Uwe Hernandez Acosta
committed
updated docstrings
1 parent 433031d commit 62d7f8a

File tree

4 files changed

+118
-18
lines changed

4 files changed

+118
-18
lines changed

src/LorentzVectorBase.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module LorentzVectorBase
22

33
export coordinate_system, coordinate_names
4+
export available_accessors
45

56
include("getter.jl")
67
include("interface.jl")
8+
include("utility.jl")
79
include("coordinate_systems/XYZT.jl")
810
include("coordinate_systems/PxPyPzE.jl")
911
include("coordinate_systems/PtEtaPhiM.jl")

src/coordinate_systems/PtEtaPhiM.jl

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
"""
2-
32
PtEtaPhiM <: AbstractCoordinateSystem
43
5-
Cylindrical coordinate system for four-momenta. Using this requires the implementation of the following interface functions:
4+
Represents the cylindrical coordinate system for four-momenta, commonly used in high-energy physics.
5+
This system expresses four-momentum components in terms of transverse momentum (`pt`), pseudorapidity (`eta`),
6+
azimuthal angle (`phi`), and mass (`mass`).
7+
8+
To use this coordinate system with a custom four-momentum type, you must implement the following interface methods:
69
710
```julia
8-
pt(::CustomFourMomentum)
9-
eta(::CustomFourMomentum)
10-
phi(::CustomFourMomentum)
11-
mass(::CustomFourMomentum)
11+
LorentzVectorBase.pt(::CustomFourMomentum) # Returns the transverse momentum
12+
LorentzVectorBase.eta(::CustomFourMomentum) # Returns the pseudorapidity
13+
LorentzVectorBase.phi(::CustomFourMomentum) # Returns the azimuthal angle
14+
LorentzVectorBase.mass(::CustomFourMomentum) # Returns the mass
15+
```
16+
17+
### Example
18+
19+
The following example demonstrates how to define a custom four-momentum type and implement the required interface:
20+
21+
```jldoctest
22+
julia> struct CustomFourMomentum
23+
pt
24+
eta
25+
phi
26+
mass
27+
end
28+
29+
julia> LorentzVectorBase.coordinate_system(::CustomFourMomentum) = LorentzVectorBase.PtEtaPhiM()
30+
31+
julia> LorentzVectorBase.pt(p::CustomFourMomentum) = p.pt
32+
33+
julia> LorentzVectorBase.eta(p::CustomFourMomentum) = p.eta
34+
35+
julia> LorentzVectorBase.phi(p::CustomFourMomentum) = p.phi
36+
37+
julia> LorentzVectorBase.mass(p::CustomFourMomentum) = p.mass
38+
39+
julia> p = CustomFourMomentum(10.0, 2.5, 1.57, 0.105)
40+
CustomFourMomentum(10.0, 2.5, 1.57, 0.105)
41+
42+
julia> isapprox(LorentzVectorBase.polar_angle(p), 2 * atan(exp(-2.5)))
43+
true
44+
1245
```
1346
47+
By implementing these methods, the custom type `CustomFourMomentum` becomes compatible with `LorentzVectorBase` operations in the `PtEtaPhiM` coordinate system.
1448
"""
1549
struct PtEtaPhiM <: AbstractCoordinateSystem end
1650
coordinate_names(::PtEtaPhiM) = (:pt, :eta, :phi, :mass)

src/coordinate_systems/PxPyPzE.jl

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,50 @@
11

22
"""
3-
43
PxPyPzE <: AbstractCoordinateSystem
54
6-
Cartesian coordinate system for four-momenta. Using this requires the implementation of the following interface functions:
5+
Represents the Cartesian coordinate system for four-momenta, where the components are labeled as (px, py, pz, E).
6+
This system is commonly used in high-energy physics to describe the momentum and energy of particles.
7+
8+
To use this coordinate system with a custom four-momentum type, you must implement the following interface methods:
79
810
```julia
9-
LorentzVectorBase.px(::CustomFourMomentum)
10-
LorentzVectorBase.py(::CustomFourMomentum)
11-
LorentzVectorBase.pz(::CustomFourMomentum)
12-
LorentzVectorBase.E(::CustomFourMomentum)
11+
LorentzVectorBase.px(::CustomFourMomentum) # Returns the x-component of momentum
12+
LorentzVectorBase.py(::CustomFourMomentum) # Returns the y-component of momentum
13+
LorentzVectorBase.pz(::CustomFourMomentum) # Returns the z-component of momentum
14+
LorentzVectorBase.E(::CustomFourMomentum) # Returns the energy component
15+
```
16+
17+
### Example
18+
19+
The following example demonstrates how to define a custom four-momentum type and implement the required interface:
20+
21+
```jldoctest
22+
julia> struct CustomFourMomentum
23+
px
24+
py
25+
pz
26+
E
27+
end
28+
29+
julia> LorentzVectorBase.coordinate_system(::CustomFourMomentum) = LorentzVectorBase.PxPyPzE()
30+
31+
julia> LorentzVectorBase.px(p::CustomFourMomentum) = p.px
32+
33+
julia> LorentzVectorBase.py(p::CustomFourMomentum) = p.py
34+
35+
julia> LorentzVectorBase.pz(p::CustomFourMomentum) = p.pz
36+
37+
julia> LorentzVectorBase.E(p::CustomFourMomentum) = p.E
38+
39+
julia> p = CustomFourMomentum(1.0, 2.0, 3.0, 4.0)
40+
CustomFourMomentum(1.0, 2.0, 3.0, 4.0)
41+
42+
julia> isapprox(LorentzVectorBase.spatial_magnitude(p), sqrt(1.0^2 + 2.0^2 + 3.0^2))
43+
true
44+
1345
```
1446
47+
By implementing these methods, the custom type `CustomFourMomentum` becomes compatible with `LorentzVectorBase` operations in the `PxPyPzE` coordinate system.
1548
"""
1649
struct PxPyPzE <: AbstractCoordinateSystem end
1750
coordinate_names(::PxPyPzE) = (:px, :py, :pz, :E)

src/coordinate_systems/XYZT.jl

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,47 @@
11
"""
2-
32
XYZT <: AbstractCoordinateSystem
43
5-
Cartesian coordinate system for four-vectors. Using this requires the implementation of the following interface functions:
4+
Represents the Cartesian coordinate system for four-vectors, where the components are labeled as (x, y, z, t).
5+
6+
To use this coordinate system with a custom four-vector type, you must implement the following interface methods:
67
78
```julia
8-
LorentzVectorBase.x(::CustomFourVector)
9-
LorentzVectorBase.y(::CustomFourVector)
10-
LorentzVectorBase.z(::CustomFourVector)
11-
LorentzVectorBase.t(::CustomFourVector)
9+
LorentzVectorBase.x(::CustomFourVector) # Returns the x-component
10+
LorentzVectorBase.y(::CustomFourVector) # Returns the y-component
11+
LorentzVectorBase.z(::CustomFourVector) # Returns the z-component
12+
LorentzVectorBase.t(::CustomFourVector) # Returns the time component
13+
```
14+
15+
### Example
16+
17+
The following example demonstrates how to define a custom four-vector type and implement the required interface:
18+
19+
```jldoctest
20+
julia> struct CustomLVector
21+
x
22+
y
23+
z
24+
t
25+
end
26+
27+
julia> LorentzVectorBase.coordinate_system(::CustomLVector) = LorentzVectorBase.XYZT()
28+
29+
julia> LorentzVectorBase.x(lv::CustomLVector) = lv.x
30+
31+
julia> LorentzVectorBase.y(lv::CustomLVector) = lv.y
32+
33+
julia> LorentzVectorBase.z(lv::CustomLVector) = lv.z
34+
35+
julia> LorentzVectorBase.t(lv::CustomLVector) = lv.t
36+
37+
julia> c = CustomLVector(1, 2, 3, 4)
38+
CustomLVector(1, 2, 3, 4)
39+
40+
julia> @assert isapprox(LorentzVectorBase.spatial_magnitude(c), sqrt(1^2 + 2^2 + 3^2))
41+
1242
```
1343
44+
By implementing these methods, the custom type `CustomLVector` becomes compatible with `LorentzVectorBase` operations in the `XYZT` coordinate system.
1445
"""
1546
struct XYZT <: AbstractCoordinateSystem end
1647
coordinate_names(::XYZT) = (:x, :y, :z, :t)

0 commit comments

Comments
 (0)