From 906f4e42f05acb2d912631d793450ee148dae3fe Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Fri, 1 May 2026 17:11:03 +0200 Subject: [PATCH 1/2] change pseudorapidity limits to `Inf` --- src/coordinate_systems/XYZT.jl | 6 +++--- src/getter.jl | 6 +++++- test/XYZT.jl | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/coordinate_systems/XYZT.jl b/src/coordinate_systems/XYZT.jl index 8442e56..967ccb1 100644 --- a/src/coordinate_systems/XYZT.jl +++ b/src/coordinate_systems/XYZT.jl @@ -149,12 +149,12 @@ function eta(::XYZT, mom) return zero(zcomp) end - @warn "Pseudorapidity (η): transverse momentum is zero! return +/- 10e10" + @warn "Pseudorapidity (η): transverse momentum is zero! return ±Inf" if zcomp > zero(zcomp) - return 10e10 + return Inf end - return -10e10 + return -Inf end ####################### diff --git a/src/getter.jl b/src/getter.jl index 681ab48..b31543b 100644 --- a/src/getter.jl +++ b/src/getter.jl @@ -370,9 +370,13 @@ For a four-momentum `(px, py, pz, E)`, this function returns `log(tan(theta/2))` !!! warning If the transverse momentum (`pt`) is zero (i.e., the particle is aligned with the beam axis), - a warning is raised, and a large pseudorapidity value (±10e10) is returned as a convention. + a warning is raised, and `±Inf` (depending on the sign of the z-component) is returned as a convention. This occurs because the pseudorapidity is ill-defined when `pt = 0`. + For compatibility with other software, the returned values might be clamped. In particular: + - With ROOT legacy vectors ([TLorentzVector](https://root.cern.ch/doc/master/classTLorentzVector.html)), use `clamp(eta(lv), -1e11, 1e11)`. + - With ROOT [GenVector](https://root.cern/doc/master/group__GenVector.html) classes (`ROOT::Math::LorentzVector`, `ROOT::Math::XYZTVector`), use `clamp(eta(lv), z(lv) - 22756, z(lv) + 22756)`. + # Notes - Pseudorapidity is approximately equal to the rapidity ``y`` in the ultra-relativistic limit (when the particle's mass is negligible compared to its energy). diff --git a/test/XYZT.jl b/test/XYZT.jl index 8daef7f..cee5f53 100644 --- a/test/XYZT.jl +++ b/test/XYZT.jl @@ -113,8 +113,8 @@ end @test isapprox(LorentzVectorBase.eta(lvec_non_zero), 0.5 * log((1 + cth) / (1 - cth))) @test isapprox(LorentzVectorBase.eta(lvec_zero), 0.0) - @test isapprox(LorentzVectorBase.eta(CustomLVector(0.0, 0.0, 1.0, 0.0)), 10e10) - @test isapprox(LorentzVectorBase.eta(CustomLVector(0.0, 0.0, -1.0, 0.0)), -10e10) + @test LorentzVectorBase.eta(CustomLVector(0.0, 0.0, 1.0, 0.0)) == Inf + @test LorentzVectorBase.eta(CustomLVector(0.0, 0.0, -1.0, 0.0)) == -Inf end @testset "spherical coordinates consistence" for lvec in [lvec_non_zero, lvec_zero] From 299994a7ecea18251007bbabc6f69b980177bf7a Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Mon, 4 May 2026 09:04:54 +0200 Subject: [PATCH 2/2] return Inf of appropriate type --- src/coordinate_systems/XYZT.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coordinate_systems/XYZT.jl b/src/coordinate_systems/XYZT.jl index 967ccb1..3bdb4e1 100644 --- a/src/coordinate_systems/XYZT.jl +++ b/src/coordinate_systems/XYZT.jl @@ -151,10 +151,10 @@ function eta(::XYZT, mom) @warn "Pseudorapidity (η): transverse momentum is zero! return ±Inf" if zcomp > zero(zcomp) - return Inf + return oftype(zcomp, Inf) end - return -Inf + return oftype(zcomp, -Inf) end #######################