@@ -374,17 +374,18 @@ function tiled_jet_reconstruct(particles::AbstractArray{T, 1}; p::Union{Real, No
374374 (p, algorithm) = get_algorithm_power_consistency (p = p, algorithm = algorithm)
375375
376376 # If we have PseudoJets, we can just call the main algorithm...
377- if T == PseudoJet
377+ if T isa PseudoJet
378378 # recombination_particles will become part of the cluster sequence, so size it for
379379 # the starting particles and all N recombinations
380380 recombination_particles = copy (particles)
381381 sizehint! (recombination_particles, length (particles) * 2 )
382382 else
383- recombination_particles = PseudoJet[]
383+ ParticleType = typeof (px (particles[1 ]))
384+ recombination_particles = PseudoJet{ParticleType}[]
384385 sizehint! (recombination_particles, length (particles) * 2 )
385386 for i in eachindex (particles)
386387 push! (recombination_particles,
387- PseudoJet (px (particles[i]), py (particles[i]), pz (particles[i]),
388+ PseudoJet {ParticleType} (px (particles[i]), py (particles[i]), pz (particles[i]),
388389 energy (particles[i])))
389390 end
390391 end
@@ -421,9 +422,9 @@ of data types are done.
421422tiled_jet_reconstruct(particles::Vector{PseudoJet}; p = 1, R = 1.0, recombine = +)
422423```
423424"""
424- function _tiled_jet_reconstruct (particles:: Vector{PseudoJet} ; p:: Real = - 1 , R = 1.0 ,
425+ function _tiled_jet_reconstruct (particles:: Vector{PseudoJet{T} } ; p:: Real = - 1 , R = 1.0 ,
425426 algorithm:: JetAlgorithm.Algorithm = JetAlgorithm. AntiKt,
426- recombine = + )
427+ recombine = + ) where T <: Real
427428 # Bounds
428429 N:: Int = length (particles)
429430
@@ -439,13 +440,16 @@ function _tiled_jet_reconstruct(particles::Vector{PseudoJet}; p::Real = -1, R =
439440 R2:: Float64 = R * R
440441 p = (round (p) == p) ? Int (p) : p # integer p if possible
441442
443+ # Numerical type?
444+ ParticleType = typeof (particles[1 ]. E)
445+
442446 # This will be used quite deep inside loops, so declare it here so that
443447 # memory (de)allocation gets done only once
444448 tile_union = Vector {Int} (undef, 3 * _n_tile_neighbours)
445449
446450 # Container for pseudojets, sized for all initial particles, plus all of the
447451 # merged jets that can be created during reconstruction
448- jets = PseudoJet[]
452+ jets = PseudoJet{ParticleType} []
449453 sizehint! (jets, N * 2 )
450454 resize! (jets, N)
451455
@@ -456,15 +460,15 @@ function _tiled_jet_reconstruct(particles::Vector{PseudoJet}; p::Real = -1, R =
456460 history, Qtot = initial_history (jets)
457461
458462 # Now get the tiling setup
459- _eta = Vector {Float64 } (undef, length (particles))
463+ _eta = Vector {ParticleType } (undef, length (particles))
460464 for ijet in 1 : length (particles)
461465 _eta[ijet] = rapidity (particles[ijet])
462466 end
463467
464468 tiling = Tiling (setup_tiling (_eta, R))
465469
466470 # ClusterSequence is the struct that holds the state of the reconstruction
467- clusterseq = ClusterSequence (algorithm, p, R, RecoStrategy. N2Tiled, jets, history, Qtot)
471+ clusterseq = ClusterSequence {PseudoJet{ParticleType}} (algorithm, p, R, RecoStrategy. N2Tiled, jets, history, Qtot)
468472
469473 # Tiled jets is a structure that has additional variables for tracking which tile a jet is in
470474 tiledjets = similar (clusterseq. jets, TiledJet)
0 commit comments