Code Monkey home page Code Monkey logo

lvcyl.jl's Introduction

LVCyl.jl

This package is a minimal version of LorentzVectors.jl except using a cylindrical coordinate system (pT, eta, phi, mass) instead of cartesian (t, x, y, z).

The package is currently unregistered.

Usage

julia> using LVCyl

julia> v1 = LorentzVectorCyl(43.71242f0, 1.4733887f0, 1.6855469f0, 0.10571289f0)
julia> v2 = LorentzVectorCyl(36.994347f0, 0.38684082f0, -1.3935547f0, 0.10571289f0)

julia> v1+v2
LorentzVectorCyl{Float32}(pt=7.1725554, eta=3.3784156, phi=1.3575952, mass=92.55651)

julia> (v1+v2).mass
92.55651f0

If you only care about mass, it's much faster to compute.

julia> using BenchmarkTools

julia> @btime ($v1+$v2).mass
  85.620 ns (0 allocations: 0 bytes)
92.55651f0

julia> @btime fast_mass($v1,$v2)
  19.744 ns (0 allocations: 0 bytes)
92.55651f0

Broadcasting works as expected

julia> v1 .+ [v1, v2]
2-element Vector{LorentzVectorCyl{Float32}}:
 LorentzVectorCyl{Float32}(pt=87.42484, eta=1.4733886, phi=1.6855469, mass=0.20728905)
 LorentzVectorCyl{Float32}(pt=7.1725554, eta=3.3784156, phi=1.3575952, mass=92.55651)

julia> fast_mass.(v1, [v1, v2])
2-element Vector{Float32}:
  0.2104957
 92.55651

Some other helper functions. Note that "Δϕ" can be typed by \DeltaTAB\phiTAB in the julia REPL or a notebook.

julia> Δϕ(v1,v2)
-3.0791016f0

julia> Δη(v1,v2)
-1.0865479f0

julia> ΔR(v1,v2)
3.265188f0

# convert to and from cartesian `LorentzVector`
julia> using LorentzVectors

julia> tocartesian(v1)
(t = 100.38882f0, x = -5.0050235f0, y = 43.424942f0, z = 90.37216f0)

julia> v3 = LorentzVector(tocartesian(v1)...) 
LorentzVector{Float32}(100.38882f0, -5.0050235f0, 43.424942f0, 90.37216f0)

julia> fromcartesian(v3.t, v3.x, v3.y, v3.z)
LorentzVectorCyl{Float32}(pt=43.71242, eta=1.4733886, phi=1.6855469, mass=0.10597391)

lvcyl.jl's People

Contributors

aminnj avatar moelf avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.