Skip to content

Commit 7e30a8a

Browse files
Define eltype() for PseudoJet and EEjet
Returns the parametrised element type
1 parent 53a6a87 commit 7e30a8a

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

src/EEAlgorithm.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ function _ee_genkt_algorithm(; particles::Vector{EEjet{T}}, p = 1, R = 4.0,
275275
R2 = R^2
276276

277277
# Numerical type?
278-
ParticleType = typeof(particles[1].E)
278+
ParticleType = eltype(particles[1])
279279

280280
# Constant factor for the dij metric and the beam distance function
281281
if algorithm == JetAlgorithm.Durham

src/EEjet.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ mutable struct EEjet{T <: Real} <: FourMomentum
2727
_cluster_hist_index::Int
2828
end
2929

30+
31+
"""
32+
Base.eltype(::Type{EEjet{T}}) where T
33+
34+
Return the element type of the `EEjet` struct.
35+
"""
36+
Base.eltype(::Type{EEjet{T}}) where T = T
37+
3038
function EEjet(px::T, py::T, pz::T, E::T, _cluster_hist_index::Integer) where {T <: Real}
3139
@muladd p2 = px * px + py * py + pz * pz
3240
inv_p = @fastmath 1.0 / sqrt(p2)

src/PlainAlgo.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ function _plain_jet_reconstruct(; particles::Vector{PseudoJet{T}}, p = -1, R = 1
287287
# Parameters
288288
R2 = R^2
289289

290-
# Numerical type?
291-
ParticleType = typeof(particles[1].E)
290+
# Numerical type for this reconstruction
291+
ParticleType = eltype(particles[1])
292292

293293
# Optimised compact arrays for determining the next merge step
294294
# We make sure these arrays are type stable - have seen issues where, depending on the values

src/Pseudojet.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ mutable struct PseudoJet{T <: Real} <: FourMomentum
4949
_phi::T
5050
end
5151

52+
"""
53+
Base.eltype(::Type{PseudoJet{T}}) where T
54+
55+
Return the element type of the `PseudoJet` struct.
56+
"""
57+
Base.eltype(::Type{PseudoJet{T}}) where T = T
58+
5259
"""
5360
PseudoJet(px::T, py::T, pz::T, E::T,
5461
_cluster_hist_index::Int,

src/TiledAlgoLL.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ function _tiled_jet_reconstruct(particles::Vector{PseudoJet{T}}; p::Real = -1, R
440440
R2::Float64 = R * R
441441
p = (round(p) == p) ? Int(p) : p # integer p if possible
442442

443-
# Numerical type?
444-
ParticleType = typeof(particles[1].E)
443+
# Numerical type for this reconstruction
444+
ParticleType = eltype(particles[1])
445445

446446
# This will be used quite deep inside loops, so declare it here so that
447447
# memory (de)allocation gets done only once

0 commit comments

Comments
 (0)