Skip to content

Commit 376d9f7

Browse files
Rename momentum fraction, generalise jet functions
Rename the transverse momentum fraction to pt_fraction Generalise a few methods of PseudoJet to work for all FourMomentum objects
1 parent 55d2fc1 commit 376d9f7

File tree

4 files changed

+54
-63
lines changed

4 files changed

+54
-63
lines changed

src/JetReconstruction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ energy(p::LorentzVectorCyl) = LorentzVectorHEP.energy(p)
4040
include("Pseudojet.jl")
4141
include("EEjet.jl")
4242
include("JetUtils.jl")
43-
export PseudoJet, EEjet, momentum_fraction, kt_scale, lorentzvector, lorentzvector_cyl
43+
export PseudoJet, EEjet, pt_fraction, kt_scale, lorentzvector, lorentzvector_cyl
4444

4545
# Jet reconstruction strategies and algorithms (enums!)
4646
include("AlgorithmStrategyEnums.jl")

src/JetUtils.jl

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,54 @@
11
# Generic utility functions for jet structs
22

3+
"""
4+
mag(jet::T) where {T <: FourMomentum}
5+
6+
Return the magnitude of the momentum of a `PseudoJet`, `|p|`.
7+
8+
# Returns
9+
The magnitude of the `PseudoJet` object.
10+
"""
11+
mag(jet::T) where {T <: FourMomentum} = sqrt(muladd(jet.px, jet.px, jet.py^2) + jet.pz^2)
12+
13+
"""
14+
CosTheta(jet::PseudoJet) where {T <: FourMomentum}
15+
16+
Compute the cosine of the angle between the momentum vector of `jet` and the z-axis.
17+
18+
# Returns
19+
- The cosine of the angle between `jet` and the z-axis.
20+
"""
21+
@inline function CosTheta(jet::T) where {T <: FourMomentum}
22+
fZ = jet.pz
23+
ptot = mag(jet)
24+
return ifelse(ptot == 0.0, 1.0, fZ / ptot)
25+
end
26+
27+
"""
28+
eta(jet::T) where {T <: FourMomentum}
29+
30+
Compute the pseudorapidity (η) of a jet.
31+
32+
# Returns
33+
- The pseudorapidity (η) of the PseudoJet.
34+
"""
35+
function eta(jet::T) where {T <: FourMomentum}
36+
cosTheta = CosTheta(jet)
37+
(cosTheta^2 < 1.0) && return -0.5 * log((1.0 - cosTheta) / (1.0 + cosTheta))
38+
fZ = jet.pz
39+
iszero(fZ) && return 0.0
40+
# Warning("PseudoRapidity","transverse momentum = 0! return +/- 10e10");
41+
fZ > 0.0 && return 10e10
42+
return -10e10
43+
end
44+
45+
"""
46+
const η = eta
47+
48+
Alias for the pseudorapidity function, `eta`.
49+
"""
50+
const η = eta
51+
352
"""
453
deltaR(jet1::T, jet2::T) where T <: FourMomentum
554
@@ -43,14 +92,14 @@ function deltar(jet1::T, jet2::T) where {T <: FourMomentum}
4392
end
4493

4594
"""
46-
pt_momentum_fraction(jet1::T, jet2::T) where T <: FourMomentum
95+
pt_fraction(jet1::T, jet2::T) where T <: FourMomentum
4796
4897
Computes the transverse momentum fraction of the softer of two jets.
4998
5099
# Returns
51100
- The transverse momentum fraction of the softer of the two jets.
52101
"""
53-
function pt_momentum_fraction(jet1::T, jet2::T) where {T <: FourMomentum}
102+
function pt_fraction(jet1::T, jet2::T) where {T <: FourMomentum}
54103
pt1 = JetReconstruction.pt(jet1)
55104
pt2 = JetReconstruction.pt(jet2)
56105
return min(pt1, pt2) / (pt1 + pt2)

src/Pseudojet.jl

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -276,64 +276,6 @@ Calculate the invariant mass squared (m^2) of a PseudoJet.
276276
"""
277277
m2(p::PseudoJet) = (p.E + p.pz) * (p.E - p.pz) - p._pt2
278278

279-
"""
280-
mag(p::PseudoJet)
281-
282-
Return the magnitude of the momentum of a `PseudoJet`, `|p|`.
283-
284-
# Arguments
285-
- `p::PseudoJet`: The `PseudoJet` object for which to compute the magnitude.
286-
287-
# Returns
288-
The magnitude of the `PseudoJet` object.
289-
"""
290-
mag(p::PseudoJet) = sqrt(muladd(p.px, p.px, p.py^2) + p.pz^2)
291-
292-
"""
293-
CosTheta(p::PseudoJet)
294-
295-
Compute the cosine of the angle between the momentum vector `p` and the z-axis.
296-
297-
# Arguments
298-
- `p::PseudoJet`: The PseudoJet object representing the momentum vector.
299-
300-
# Returns
301-
- The cosine of the angle between `p` and the z-axis.
302-
"""
303-
@inline function CosTheta(p::PseudoJet)
304-
fZ = p.pz
305-
ptot = mag(p)
306-
return ifelse(ptot == 0.0, 1.0, fZ / ptot)
307-
end
308-
309-
"""
310-
eta(p::PseudoJet)
311-
312-
Compute the pseudorapidity (η) of a PseudoJet.
313-
314-
# Arguments
315-
- `p::PseudoJet`: The PseudoJet object for which to compute the pseudorapidity.
316-
317-
# Returns
318-
- The pseudorapidity (η) of the PseudoJet.
319-
"""
320-
function eta(p::PseudoJet)
321-
cosTheta = CosTheta(p)
322-
(cosTheta^2 < 1.0) && return -0.5 * log((1.0 - cosTheta) / (1.0 + cosTheta))
323-
fZ = p.pz
324-
iszero(fZ) && return 0.0
325-
# Warning("PseudoRapidity","transverse momentum = 0! return +/- 10e10");
326-
fZ > 0.0 && return 10e10
327-
return -10e10
328-
end
329-
330-
"""
331-
const η = eta
332-
333-
Alias for the pseudorapidity function, `eta`.
334-
"""
335-
const η = eta
336-
337279
"""
338280
m(p::PseudoJet)
339281

test/test-jet-utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ eej1 = EEjet(1.0, 1.2, -2.2, 22.0)
99
eej2 = EEjet(-1.0, 3.2, -1.2, 39.0)
1010

1111
@testset "Common jet utilities" begin
12-
@test JetReconstruction.pt_momentum_fraction(pj1, pj2) 0.3889609897118418
13-
@test JetReconstruction.pt_momentum_fraction(eej1, eej2) 0.3178347357639779
12+
@test JetReconstruction.pt_fraction(pj1, pj2) 0.3889609897118418
13+
@test JetReconstruction.pt_fraction(eej1, eej2) 0.3178347357639779
1414

1515
jr_kt_scale = JetReconstruction.kt_scale(pj1, pj2)
1616
lvhep_kt_scale = min(JetReconstruction.pt(pj1), JetReconstruction.pt(pj2)) *

0 commit comments

Comments
 (0)