Skip to content

Commit 3d70c47

Browse files
Rename EEjet to EEJet (#137)
* Rename EEjet to EEJet Follow Julia standard capitalisation more closely * Rename source file * Update struct name Co-authored-by: Mateusz Jakub Fila <[email protected]> * Add basic unit tests for jet types This improves test coverage * Fixup a few old struct name references --------- Co-authored-by: Mateusz Jakub Fila <[email protected]>
1 parent 24a35e5 commit 3d70c47

15 files changed

+92
-51
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cs = jet_reconstruct(particles::Vector{T}; algorithm = JetAlgorithm.AntiKt, R =
3333
- `particles` - a one dimensional array (vector) of input particles for the clustering
3434
- Any type that supplies the methods `pt2()`, `phi()`, `rapidity()`, `px()`, `py()`, `pz()`, `energy()` can be used
3535
- These methods have to be defined in the namespace of this package, i.e., `JetReconstruction.pt2(::T)`
36-
- The `PseudoJet` or `EEjet` types from this package, a 4-vector from `LorentzVectorHEP`, or a `ReconstructedParticle` from [EDM4hep](https://github.com/peremato/EDM4hep.jl) are suitable (and have the appropriate definitions)
36+
- The `PseudoJet` or `EEJet` types from this package, a 4-vector from `LorentzVectorHEP`, or a `ReconstructedParticle` from [EDM4hep](https://github.com/peremato/EDM4hep.jl) are suitable (and have the appropriate definitions)
3737
- `algorithm` is the name of the jet algorithm to be used (from the `JetAlgorithm` enum)
3838
- `JetAlgorithm.AntiKt` anti-$`{k}_\text{T}`$ clustering (default)
3939
- `JetAlgorithm.CA` Cambridge/Aachen clustering
@@ -64,7 +64,7 @@ To obtain the final inclusive jets, use the `inclusive_jets` method:
6464
final_jets = inclusive_jets(cs::ClusterSequence; ptmin=0.0)
6565
```
6666

67-
Only jets passing the cut $p_T > p_{Tmin}$ will be returned. The result is returned as a `Vector{LorentzVectorHEP}`, but different return types can be specified (e.g., `T = EEjet`).
67+
Only jets passing the cut $p_T > p_{Tmin}$ will be returned. The result is returned as a `Vector{LorentzVectorHEP}`, but different return types can be specified (e.g., `T = EEJet`).
6868

6969
#### Sorting
7070

docs/src/particles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ to extract the 4-vector components, viz, the following are required:
1111

1212
Currently built-in supported types are
1313
[`LorentzVectorHEP`](https://github.com/JuliaHEP/LorentzVectorHEP.jl), the
14-
`PseudoJet` and `EEjet`s from this package, and `ReconstructedParticles` from
14+
`PseudoJet` and `EEJet`s from this package, and `ReconstructedParticles` from
1515
[EDM4hep Inputs](@ref).
1616

1717
If you require support for a different input collection type then ensure you

examples/EDM4hep/EDM4hepJets.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function main()
5656
if args[:printjets]
5757
@info begin
5858
jets = "Event $(ievt)\n"
59-
for jet in exclusive_jets(cs; njets = args[:njets], T = EEjet)
59+
for jet in exclusive_jets(cs; njets = args[:njets], T = EEJet)
6060
jets *= " $jet\n"
6161
end
6262
jets

examples/EDM4hep/SimpleRecoEDM4hep.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ recps = RootIO.get(reader, evt, "ReconstructedParticles")
1414

1515
# Reconstruct and print the jets
1616
cs = jet_reconstruct(recps; algorithm = JetAlgorithm.Durham)
17-
dijets = exclusive_jets(cs; njets = 2, T = EEjet)
17+
dijets = exclusive_jets(cs; njets = 2, T = EEJet)
1818
for jet in dijets
1919
println(jet)
2020
end

examples/instrumented-jetreco.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ function main()
331331

332332
# Try to read events into the correct type!
333333
if JetReconstruction.is_ee(args[:algorithm])
334-
jet_type = EEjet
334+
jet_type = EEJet
335335
else
336336
jet_type = PseudoJet
337337
end

examples/jetreco.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function main()
141141
global_logger(logger)
142142
# Try to read events into the correct type!
143143
if JetReconstruction.is_ee(args[:algorithm])
144-
jet_type = EEjet
144+
jet_type = EEJet
145145
else
146146
jet_type = PseudoJet
147147
end

ext/EDM4hepJets.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ Return the energy component of a ReconstructedParticle's four vector.
3434
JetReconstruction.energy(recoparticle::ReconstructedParticle) = recoparticle.energy
3535

3636
"""
37-
JetReconstruction.EEjet(recoparticle::ReconstructedParticle)
37+
JetReconstruction.EEJet(recoparticle::ReconstructedParticle)
3838
39-
Construct an EEjet from a ReconstructedParticle.
39+
Construct an EEJet from a ReconstructedParticle.
4040
"""
41-
function JetReconstruction.EEjet(recoparticle::ReconstructedParticle)
42-
EEjet(JetReconstruction.px(recoparticle), JetReconstruction.py(recoparticle),
41+
function JetReconstruction.EEJet(recoparticle::ReconstructedParticle)
42+
EEJet(JetReconstruction.px(recoparticle), JetReconstruction.py(recoparticle),
4343
JetReconstruction.pz(recoparticle), JetReconstruction.energy(recoparticle))
4444
end
4545

src/ClusterSequence.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ each parent jet. If the transverse momentum is greater than or equal to `ptmin`,
236236
the jet is added to the array of inclusive jets.
237237
238238
Valid return types are `LorentzVectorCyl` and the jet type of the input `clusterseq`
239-
(`U` - either `PseudoJet` or `EEjet` depending which algorithm was used)
239+
(`U` - either `PseudoJet` or `EEJet` depending which algorithm was used)
240240
(N.B. this will evolve in the future to be any subtype of `FourMomentumBase`;
241241
currently unrecognised types will return `LorentzVectorCyl`).
242242
@@ -294,7 +294,7 @@ jets or a cut on the maximum distance parameter.
294294
- An array of `T` objects representing the exclusive jets.
295295
296296
Valid return types are `LorentzVectorCyl` and the jet type of the input `clusterseq`
297-
(`U` - either `PseudoJet` or `EEjet` depending which algorithm was used)
297+
(`U` - either `PseudoJet` or `EEJet` depending which algorithm was used)
298298
(N.B. this will evolve in the future to be any subtype of `FourMomentumBase`;
299299
currently unrecognised types will return `LorentzVectorCyl`).
300300

src/EEAlgorithm.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,17 @@ function ee_genkt_algorithm(particles::Vector{T}; p = 1,
236236
R = 4.0
237237
end
238238

239-
if T == EEjet
239+
if T == EEJet
240240
# recombination_particles will become part of the cluster sequence, so size it for
241241
# the starting particles and all N recombinations
242242
recombination_particles = copy(particles)
243243
sizehint!(recombination_particles, length(particles) * 2)
244244
else
245-
recombination_particles = EEjet[]
245+
recombination_particles = EEJet[]
246246
sizehint!(recombination_particles, length(particles) * 2)
247247
for i in eachindex(particles)
248248
push!(recombination_particles,
249-
EEjet(px(particles[i]), py(particles[i]), pz(particles[i]),
249+
EEJet(px(particles[i]), py(particles[i]), pz(particles[i]),
250250
energy(particles[i])))
251251
end
252252
end
@@ -258,13 +258,13 @@ function ee_genkt_algorithm(particles::Vector{T}; p = 1,
258258
end
259259

260260
"""
261-
_ee_genkt_algorithm(; particles::Vector{EEjet}, p = 1, R = 4.0,
261+
_ee_genkt_algorithm(; particles::Vector{EEJet}, p = 1, R = 4.0,
262262
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.Durham,
263263
recombine = +)
264264
265265
This function is the actual implementation of the e+e- jet clustering algorithm.
266266
"""
267-
function _ee_genkt_algorithm(; particles::Vector{EEjet}, p = 1, R = 4.0,
267+
function _ee_genkt_algorithm(; particles::Vector{EEJet}, p = 1, R = 4.0,
268268
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.Durham,
269269
recombine = +)
270270
# Bounds

src/EEjet.jl renamed to src/EEJet.jl

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
mutable struct EEjet
2+
mutable struct EEJet
33
4-
The `EEjet` struct is a 4-momentum object used for the e+e jet reconstruction routines.
4+
The `EEJet` struct is a 4-momentum object used for the e+e jet reconstruction routines.
55
66
# Fields
77
- `px::Float64`: The x-component of the jet momentum.
@@ -12,7 +12,7 @@ The `EEjet` struct is a 4-momentum object used for the e+e jet reconstruction ro
1212
- `_p2::Float64`: The squared momentum of the jet.
1313
- `_inv_p::Float64`: The inverse momentum of the jet.
1414
"""
15-
mutable struct EEjet <: FourMomentum
15+
mutable struct EEJet <: FourMomentum
1616
px::Float64
1717
py::Float64
1818
pz::Float64
@@ -22,41 +22,41 @@ mutable struct EEjet <: FourMomentum
2222
_cluster_hist_index::Int
2323
end
2424

25-
function EEjet(px::Real, py::Real, pz::Real, E::Real, _cluster_hist_index::Int)
25+
function EEJet(px::Real, py::Real, pz::Real, E::Real, _cluster_hist_index::Int)
2626
@muladd p2 = px * px + py * py + pz * pz
2727
inv_p = @fastmath 1.0 / sqrt(p2)
28-
EEjet(px, py, pz, E, p2, inv_p, _cluster_hist_index)
28+
EEJet(px, py, pz, E, p2, inv_p, _cluster_hist_index)
2929
end
3030

31-
EEjet(px::Real, py::Real, pz::Real, E::Real) = EEjet(px, py, pz, E, 0)
31+
EEJet(px::Real, py::Real, pz::Real, E::Real) = EEJet(px, py, pz, E, 0)
3232

33-
EEjet(pj::PseudoJet) = EEjet(px(pj), py(pj), pz(pj), energy(pj), cluster_hist_index(pj))
33+
EEJet(pj::PseudoJet) = EEJet(px(pj), py(pj), pz(pj), energy(pj), cluster_hist_index(pj))
3434

35-
p2(eej::EEjet) = eej._p2
36-
pt2(eej::EEjet) = eej.px^2 + eej.py^2
35+
p2(eej::EEJet) = eej._p2
36+
pt2(eej::EEJet) = eej.px^2 + eej.py^2
3737
const kt2 = pt2
38-
pt(eej::EEjet) = sqrt(pt2(eej))
39-
energy(eej::EEjet) = eej.E
40-
px(eej::EEjet) = eej.px
41-
py(eej::EEjet) = eej.py
42-
pz(eej::EEjet) = eej.pz
43-
nx(eej::EEjet) = eej.px * eej._inv_p
44-
ny(eej::EEjet) = eej.py * eej._inv_p
45-
nz(eej::EEjet) = eej.pz * eej._inv_p
46-
cluster_hist_index(eej::EEjet) = eej._cluster_hist_index
38+
pt(eej::EEJet) = sqrt(pt2(eej))
39+
energy(eej::EEJet) = eej.E
40+
px(eej::EEJet) = eej.px
41+
py(eej::EEJet) = eej.py
42+
pz(eej::EEJet) = eej.pz
43+
nx(eej::EEJet) = eej.px * eej._inv_p
44+
ny(eej::EEJet) = eej.py * eej._inv_p
45+
nz(eej::EEJet) = eej.pz * eej._inv_p
46+
cluster_hist_index(eej::EEJet) = eej._cluster_hist_index
4747

48-
phi(eej::EEjet) = begin
48+
phi(eej::EEJet) = begin
4949
phi = pt2(eej) == 0.0 ? 0.0 : atan(eej.py, eej.px)
5050
if phi < 0.0
5151
phi += 2π
5252
end
5353
phi
5454
end
5555

56-
m2(eej::EEjet) = energy(eej)^2 - p2(eej)
57-
mass(eej::EEjet) = m2(eej) < 0.0 ? -sqrt(-m2(eej)) : sqrt(m2(eej))
56+
m2(eej::EEJet) = energy(eej)^2 - p2(eej)
57+
mass(eej::EEJet) = m2(eej) < 0.0 ? -sqrt(-m2(eej)) : sqrt(m2(eej))
5858

59-
function rapidity(eej::EEjet)
59+
function rapidity(eej::EEJet)
6060
if energy(eej) == abs(pz(eej)) && iszero(pt2(eej))
6161
MaxRapHere = _MaxRap + abs(pz(eej))
6262
rap = (pz(eej) >= 0.0) ? MaxRapHere : -MaxRapHere
@@ -75,13 +75,13 @@ function rapidity(eej::EEjet)
7575
end
7676

7777
import Base.+;
78-
function +(jet1::EEjet, jet2::EEjet)
79-
EEjet(jet1.px + jet2.px, jet1.py + jet2.py, jet1.pz + jet2.pz, jet1.E + jet2.E)
78+
function +(jet1::EEJet, jet2::EEJet)
79+
EEJet(jet1.px + jet2.px, jet1.py + jet2.py, jet1.pz + jet2.pz, jet1.E + jet2.E)
8080
end
8181

8282
import Base.show
83-
function show(io::IO, eej::EEjet)
84-
print(io, "EEjet(px: ", eej.px, " py: ", eej.py, " pz: ", eej.pz, " E: ", eej.E,
83+
function show(io::IO, eej::EEJet)
84+
print(io, "EEJet(px: ", eej.px, " py: ", eej.py, " pz: ", eej.pz, " E: ", eej.E,
8585
" cluster_hist_index: ", eej._cluster_hist_index, ")")
8686
end
8787

0 commit comments

Comments
 (0)