Skip to content

Commit 19d690d

Browse files
Fix types for EE reco
Ensure that types are stable for EEReco, meaning that they are EEjet{T} for a specific T, not just generic EEjet
1 parent 8b3f1f4 commit 19d690d

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/ClusterSequence.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ ClusterSequence(algorithm::JetAlgorithm.Algorithm, p::Real, R::Float64, strategy
148148
Qtot)
149149
end
150150

151+
ClusterSequence{T}(algorithm::JetAlgorithm.Algorithm, p::Real, R::Float64, strategy::RecoStrategy.Strategy, jets::Vector{T}, history, Qtot) where {T <: FourMomentum} = begin
152+
ClusterSequence{T}(algorithm, Float64(p), R, strategy, jets, length(jets), history,
153+
Qtot)
154+
end
155+
156+
151157
"""
152158
add_step_to_history!(clusterseq::ClusterSequence, parent1, parent2, jetp_index, dij)
153159

src/EEAlgorithm.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
const large_distance = 16.0 # = 4^2
44
const large_dij = 1.0e6
55

6+
using Infiltrator
7+
68
"""
79
angular_distance(eereco, i, j) -> Float64
810
@@ -242,11 +244,12 @@ function ee_genkt_algorithm(particles::AbstractArray{T, 1}; p = 1, R = 4.0,
242244
recombination_particles = copy(particles)
243245
sizehint!(recombination_particles, length(particles) * 2)
244246
else
245-
recombination_particles = EEjet[]
247+
ParticleType = typeof(px(particles[1]))
248+
recombination_particles = EEjet{ParticleType}[]
246249
sizehint!(recombination_particles, length(particles) * 2)
247250
for i in eachindex(particles)
248251
push!(recombination_particles,
249-
EEjet(px(particles[i]), py(particles[i]), pz(particles[i]),
252+
EEjet{ParticleType}(px(particles[i]), py(particles[i]), pz(particles[i]),
250253
energy(particles[i])))
251254
end
252255
end
@@ -264,9 +267,9 @@ end
264267
265268
This function is the actual implementation of the e+e- jet clustering algorithm.
266269
"""
267-
function _ee_genkt_algorithm(; particles::Vector{EEjet}, p = 1, R = 4.0,
270+
function _ee_genkt_algorithm(; particles::Vector{EEjet{T}}, p = 1, R = 4.0,
268271
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.Durham,
269-
recombine = +)
272+
recombine = +) where {T <: Real}
270273
# Bounds
271274
N::Int = length(particles)
272275

@@ -298,7 +301,7 @@ function _ee_genkt_algorithm(; particles::Vector{EEjet}, p = 1, R = 4.0,
298301
# Setup the initial history and get the total energy
299302
history, Qtot = initial_history(particles)
300303

301-
clusterseq = ClusterSequence(algorithm, p, R, RecoStrategy.N2Plain, particles, history,
304+
clusterseq = ClusterSequence{EEjet{ParticleType}}(algorithm, p, R, RecoStrategy.N2Plain, particles, history,
302305
Qtot)
303306

304307
# Run over initial pairs of jets to find nearest neighbours
@@ -307,6 +310,8 @@ function _ee_genkt_algorithm(; particles::Vector{EEjet}, p = 1, R = 4.0,
307310
# Only for debugging purposes...
308311
# ee_check_consistency(clusterseq, clusterseq_index, N, nndist, nndij, nni, "Start")
309312

313+
#@infiltrate
314+
310315
# Now we can start the main loop
311316
iter = 0
312317
while N != 0

src/EEjet.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function EEjet(px::T, py::T, pz::T, E::T, _cluster_hist_index::Integer) where {T
3434
end
3535

3636
EEjet(px::T, py::T, pz::T, E::T) where {T <: Real} = EEjet(px, py, pz, E, 0)
37+
EEjet{T}(px::T, py::T, pz::T, E::T) where {T <: Real} = EEjet(px, py, pz, E, 0)
3738

3839
EEjet(pj::PseudoJet) = EEjet(px(pj), py(pj), pz(pj), energy(pj), cluster_hist_index(pj))
3940

0 commit comments

Comments
 (0)