Skip to content

JuliaHEP/LorentzVectorBase.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LorentzVectorBase.jl

Stable Documentation In development documentation Test workflow status Docs workflow Status Coverage

LorentzVectorBase.jl provides base interfaces for four-momenta in high-energy physics, facilitating standardized representations and operations on Lorentz vectors.

Installation

Install the package using Julia's package manager:

using Pkg
Pkg.add("LorentzVectorBase")

Alternatively, in the Julia REPL, enter pkg> mode by typing ], then

add LorentzVectorBase

Usage

This package defines abstract interfaces for Lorentz vectors. To utilize concrete implementations, consider packages like LorentzVectorHEP.jl or FourVectors.jl.

Example

The following example shows how to define a custom Lorentz vector type and implement the minimal set of interface functions required by LorentzVectorBase:

struct CustomLVector
    id::Int
    x::Float64
    y::Float64
    z::Float64
    t::Float64
end

LorentzVectorBase.coordinate_system(::CustomLVector) = LorentzVectorBase.XYZT()
LorentzVectorBase.x(lv::CustomLVector) = lv.x
LorentzVectorBase.y(lv::CustomLVector) = lv.y
LorentzVectorBase.z(lv::CustomLVector) = lv.z
LorentzVectorBase.t(lv::CustomLVector) = lv.t

Your custom type can include any additional fields or logic as needed. In this example, an extra id field is included alongside the four-vector components:

c = CustomLVector(rand(1:100), 1, 2, 3, 4)
@assert isapprox(LorentzVectorBase.spatial_magnitude(c), sqrt(1^2 + 2^2 + 3^2))

Code Formatting

To maintain code consistency, format your code with:

julia --project=.formatting -e 'using Pkg; Pkg.instantiate(); include(".formatting/format_all.jl")'

This ensures adherence to the project's formatting standards.

License

This project is licensed under the MIT License.

About

Base interfaces for four-momenta in high-energy physics.

Resources

License

Stars

Watchers

Forks

Contributors 9

Languages