Skip to content

Commit

Permalink
Make use of the known jet type parameter
Browse files Browse the repository at this point in the history
The particle type is know in the function signature of the underlying reconstruction
  • Loading branch information
graeme-a-stewart committed Dec 6, 2024
1 parent f52aa36 commit 5487316
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/EEAlgorithm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ function ee_genkt_algorithm(particles::AbstractArray{T, 1}; p = 1, R = 4.0,
recombination_particles = copy(particles)
sizehint!(recombination_particles, length(particles) * 2)
else
# We don't really know what element type we have here, so we need to
# drill down to a component to get that underlying type
ParticleType = typeof(px(particles[1]))
recombination_particles = EEjet{ParticleType}[]
sizehint!(recombination_particles, length(particles) * 2)
Expand Down Expand Up @@ -275,7 +277,7 @@ function _ee_genkt_algorithm(; particles::Vector{EEjet{T}}, p = 1, R = 4.0,
R2 = R^2

# Numerical type?
ParticleType = eltype(particles[1])
ParticleType = T

# Constant factor for the dij metric and the beam distance function
if algorithm == JetAlgorithm.Durham
Expand Down
4 changes: 3 additions & 1 deletion src/PlainAlgo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ function plain_jet_reconstruct(particles::AbstractArray{T, 1}; p::Union{Real, No
recombination_particles = copy(particles)
sizehint!(recombination_particles, length(particles) * 2)
else
# We don't really know what element type we have here, so we need to
# drill down to a component to get that underlying type
ParticleType = typeof(px(particles[1]))
recombination_particles = PseudoJet{ParticleType}[]
sizehint!(recombination_particles, length(particles) * 2)
Expand Down Expand Up @@ -288,7 +290,7 @@ function _plain_jet_reconstruct(; particles::Vector{PseudoJet{T}}, p = -1, R = 1
R2 = R^2

# Numerical type for this reconstruction
ParticleType = eltype(particles[1])
ParticleType = T

# Optimised compact arrays for determining the next merge step
# We make sure these arrays are type stable - have seen issues where, depending on the values
Expand Down
4 changes: 3 additions & 1 deletion src/TiledAlgoLL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ function tiled_jet_reconstruct(particles::AbstractArray{T, 1}; p::Union{Real, No
recombination_particles = copy(particles)
sizehint!(recombination_particles, length(particles) * 2)
else
# We don't really know what element type we have here, so we need to
# drill down to a component to get that underlying type
ParticleType = typeof(px(particles[1]))
recombination_particles = PseudoJet{ParticleType}[]
sizehint!(recombination_particles, length(particles) * 2)
Expand Down Expand Up @@ -442,7 +444,7 @@ function _tiled_jet_reconstruct(particles::Vector{PseudoJet{T}}; p::Real = -1, R
p = (round(p) == p) ? Int(p) : p # integer p if possible

# Numerical type for this reconstruction
ParticleType = eltype(particles[1])
ParticleType = T

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

0 comments on commit 5487316

Please sign in to comment.