Skip to content

Commit

Permalink
Formatting!
Browse files Browse the repository at this point in the history
  • Loading branch information
graeme-a-stewart committed Nov 26, 2024
1 parent 53ca16b commit 3bbe3fb
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 29 deletions.
5 changes: 3 additions & 2 deletions src/ClusterSequence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,13 @@ ClusterSequence(algorithm::JetAlgorithm.Algorithm, p::Real, R::Float64, strategy
Qtot)
end

ClusterSequence{T}(algorithm::JetAlgorithm.Algorithm, p::Real, R::Float64, strategy::RecoStrategy.Strategy, jets::Vector{T}, history, Qtot) where {T <: FourMomentum} = begin
function ClusterSequence{T}(algorithm::JetAlgorithm.Algorithm, p::Real, R::Float64,
strategy::RecoStrategy.Strategy, jets::Vector{T}, history,
Qtot) where {T <: FourMomentum}
ClusterSequence{T}(algorithm, Float64(p), R, strategy, jets, length(jets), history,
Qtot)
end


"""
add_step_to_history!(clusterseq::ClusterSequence, parent1, parent2, jetp_index, dij)
Expand Down
7 changes: 4 additions & 3 deletions src/EEAlgorithm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function ee_genkt_algorithm(particles::AbstractArray{T, 1}; p = 1, R = 4.0,
for i in eachindex(particles)
push!(recombination_particles,
EEjet{ParticleType}(px(particles[i]), py(particles[i]), pz(particles[i]),
energy(particles[i])))
energy(particles[i])))
end
end

Expand Down Expand Up @@ -299,8 +299,9 @@ function _ee_genkt_algorithm(; particles::Vector{EEjet{T}}, p = 1, R = 4.0,
# Setup the initial history and get the total energy
history, Qtot = initial_history(particles)

clusterseq = ClusterSequence{EEjet{ParticleType}}(algorithm, p, R, RecoStrategy.N2Plain, particles, history,
Qtot)
clusterseq = ClusterSequence{EEjet{ParticleType}}(algorithm, p, R, RecoStrategy.N2Plain,
particles, history,
Qtot)

# Run over initial pairs of jets to find nearest neighbours
get_angular_nearest_neighbours!(eereco, algorithm, dij_factor)
Expand Down
9 changes: 3 additions & 6 deletions src/EEjet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ mutable struct EEjet{T <: Real} <: FourMomentum
_cluster_hist_index::Int
end


"""
Base.eltype(::Type{EEjet{T}}) where T
Return the element type of the `EEjet` struct.
"""
Base.eltype(::Type{EEjet{T}}) where T = T

Base.eltype(::Type{EEjet{T}}) where {T} = T

"""
EEjet(px::T, py::T, pz::T, E::T, _cluster_hist_index::Integer) where {T <: Real}
Expand Down Expand Up @@ -106,8 +104,8 @@ Constructs an `EEjet` object with conversion of the given momentum components
An `EEjet` object with the momentum components and energy parametrised to type
`U`.
"""
EEjet{U}(px::T, py::T, pz::T, E::T) where {T <: Real, U <: Real} = EEjet(U(px), U(py), U(pz), U(E), 0)

EEjet{U}(px::T, py::T, pz::T, E::T) where {T <: Real, U <: Real} = EEjet(U(px), U(py),
U(pz), U(E), 0)

"""
EEjet(pj::PseudoJet) -> EEjet
Expand All @@ -122,7 +120,6 @@ Constructs an `EEjet` object from a given `PseudoJet` object `pj`.
"""
EEjet(pj::PseudoJet) = EEjet(px(pj), py(pj), pz(pj), energy(pj), cluster_hist_index(pj))


p2(eej::EEjet) = eej._p2
pt2(eej::EEjet) = eej.px^2 + eej.py^2
const kt2 = pt2
Expand Down
8 changes: 5 additions & 3 deletions src/PlainAlgo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ generalised k_t algorithm.
"""
function _plain_jet_reconstruct(; particles::Vector{PseudoJet{T}}, p = -1, R = 1.0,
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.AntiKt,
recombine = +) where T <: Real
recombine = +) where {T <: Real}
# Bounds
N::Int = length(particles)
# Parameters
Expand All @@ -308,8 +308,10 @@ function _plain_jet_reconstruct(; particles::Vector{PseudoJet{T}}, p = -1, R = 1
# Current implementation mutates the particles vector, so need to copy it
# for the cluster sequence (there is too much copying happening, so this
# needs to be rethought and reoptimised)
clusterseq = ClusterSequence{PseudoJet{ParticleType}}(algorithm, p, R, RecoStrategy.N2Plain, particles, history,
Qtot)
clusterseq = ClusterSequence{PseudoJet{ParticleType}}(algorithm, p, R,
RecoStrategy.N2Plain, particles,
history,
Qtot)

# Initialize nearest neighbours
@simd for i in 1:N
Expand Down
26 changes: 15 additions & 11 deletions src/Pseudojet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end
Return the element type of the `PseudoJet` struct.
"""
Base.eltype(::Type{PseudoJet{T}}) where T = T
Base.eltype(::Type{PseudoJet{T}}) where {T} = T

"""
PseudoJet(px::T, py::T, pz::T, E::T,
Expand All @@ -75,10 +75,10 @@ history index.
A `PseudoJet` object.
"""
PseudoJet(px::T, py::T, pz::T, E::T,
_cluster_hist_index::Int,
pt2::T) where {T <: Real} = PseudoJet{T}(px,
py, pz, E, _cluster_hist_index,
pt2, 1.0 / pt2, _invalid_rap, _invalid_phi)
_cluster_hist_index::Int,
pt2::T) where {T <: Real} = PseudoJet{T}(px,
py, pz, E, _cluster_hist_index,
pt2, 1.0 / pt2, _invalid_rap, _invalid_phi)

"""
PseudoJet{T}(px::T, py::T, pz::T, E::T,
Expand All @@ -100,10 +100,10 @@ and energy and history index.
A `PseudoJet` object.
"""
PseudoJet{T}(px::T, py::T, pz::T, E::T,
_cluster_hist_index::Int,
pt2::T) where {T <: Real} = PseudoJet{T}(px,
py, pz, E, _cluster_hist_index,
pt2, 1.0 / pt2, _invalid_rap, _invalid_phi)
_cluster_hist_index::Int,
pt2::T) where {T <: Real} = PseudoJet{T}(px,
py, pz, E, _cluster_hist_index,
pt2, 1.0 / pt2, _invalid_rap, _invalid_phi)

"""
PseudoJet(px::T, py::T, pz::T, E::T) where T <: Real
Expand All @@ -125,8 +125,12 @@ pz::T, E::T) where {T <: Real} = PseudoJet(px, py, pz, E, 0, px^2 + py^2)
"""
PseudoJet{U}(px::T, py::T, pz::T, E::T) where T <: Real, U <: Real
"""
PseudoJet{U}(px::T, py::T, pz::T, E::T) where {T <: Real, U <: Real} = PseudoJet{U}(U(px), U(py), U(pz), U(E), 0, U(px^2 + py^2))

PseudoJet{U}(px::T, py::T, pz::T, E::T) where {T <: Real, U <: Real} = PseudoJet{U}(U(px),
U(py),
U(pz),
U(E), 0,
U(px^2 +
py^2))

import Base.show
"""
Expand Down
11 changes: 7 additions & 4 deletions src/TiledAlgoLL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,9 @@ function tiled_jet_reconstruct(particles::AbstractArray{T, 1}; p::Union{Real, No
sizehint!(recombination_particles, length(particles) * 2)
for i in eachindex(particles)
push!(recombination_particles,
PseudoJet{ParticleType}(px(particles[i]), py(particles[i]), pz(particles[i]),
energy(particles[i])))
PseudoJet{ParticleType}(px(particles[i]), py(particles[i]),
pz(particles[i]),
energy(particles[i])))
end
end

Expand Down Expand Up @@ -424,7 +425,7 @@ tiled_jet_reconstruct(particles::Vector{PseudoJet}; p = 1, R = 1.0, recombine =
"""
function _tiled_jet_reconstruct(particles::Vector{PseudoJet{T}}; p::Real = -1, R = 1.0,
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.AntiKt,
recombine = +) where T <: Real
recombine = +) where {T <: Real}
# Bounds
N::Int = length(particles)

Expand Down Expand Up @@ -468,7 +469,9 @@ function _tiled_jet_reconstruct(particles::Vector{PseudoJet{T}}; p::Real = -1, R
tiling = Tiling(setup_tiling(_eta, R))

# ClusterSequence is the struct that holds the state of the reconstruction
clusterseq = ClusterSequence{PseudoJet{ParticleType}}(algorithm, p, R, RecoStrategy.N2Tiled, jets, history, Qtot)
clusterseq = ClusterSequence{PseudoJet{ParticleType}}(algorithm, p, R,
RecoStrategy.N2Tiled, jets,
history, Qtot)

# Tiled jets is a structure that has additional variables for tracking which tile a jet is in
tiledjets = similar(clusterseq.jets, TiledJet)
Expand Down

0 comments on commit 3bbe3fb

Please sign in to comment.