Skip to content

Commit 28a3e0d

Browse files
m-filagraeme-a-stewartMoelf
authored
Make algorithm argument mandatory in jet_reconstruct (#161)
* make `algorithm` argument mandatory in `jet_reconstruct` * Small improvements to README --------- Co-authored-by: Graeme A Stewart <[email protected]> Co-authored-by: Jerry Ling <[email protected]>
1 parent 8a91752 commit 28a3e0d

21 files changed

+164
-269
lines changed

README.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,25 @@ algorithm and generalised $`k_\text{T}`$ for $`e^+e^-`$.
2727
The simplest interface is to call:
2828

2929
```julia
30-
cs = jet_reconstruct(particles::AbstractVector{T}; algorithm = JetAlgorithm.AntiKt, R = 1.0, [p = -1,] [strategy = RecoStrategy.Best])
30+
cs = jet_reconstruct(particles::AbstractVector{T}; algorithm = JetAlgorithm.AntiKt, R = 1.0)
3131
```
3232

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)`
3636
- 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)
38-
- `JetAlgorithm.AntiKt` anti-$`{k}_\text{T}`$ clustering (default)
38+
- `JetAlgorithm.AntiKt` anti-$`{k}_\text{T}`$ clustering
3939
- `JetAlgorithm.CA` Cambridge/Aachen clustering
4040
- `JetAlgorithm.Kt` inclusive $k_\text{T}$
4141
- `JetAlgorithm.GenKt` generalised $k_\text{T}$ (which also requires specification of `p`)
4242
- `JetAlgorithm.Durham` the $e^+e-$ $k_\text{T}$ algorithm, also known as the Durham algorithm
43-
- `JetAlgorithm.EEKt` the $e^+e-$ generalised $k_\text{T}$ algorithm
43+
- `JetAlgorithm.EEKt` the $e^+e-$ generalised $k_\text{T}$ algorithm (which also requires specification of `p`)
4444
- `R` - the cone size parameter; no particles more geometrically distance than `R` will be merged (default 1.0; note this parameter is ignored for the Durham algorithm)
45-
- `strategy` - the algorithm strategy to adopt, as described below (default `RecoStrategy.Best`)
4645

4746
The object returned is a `ClusterSequence`, which internally tracks all merge steps.
4847

49-
Alternatively, *for pp reconstruction*, one can swap the `algorithm=...`
50-
parameter for the value of `p`, the transverse momentum power used in the
51-
$d_{ij}$ metric for deciding on closest jets, as $k^{2p}_\text{T}$. Different
52-
values of $p$ then correspond to different reconstruction algorithms:
53-
54-
- `-1` gives anti-$`{k}_\text{T}`$ clustering (default)
55-
- `0` gives Cambridge/Aachen
56-
- `1` gives inclusive $k_\text{T}$
57-
58-
Note, for the `GenKt` and `EEKt` algorithms the `p` value *must* also be given to specify the algorithm fully.
48+
For a more complete description of all possible parameters please [refer to the documentation](https://juliahep.github.io/JetReconstruction.jl/stable/#Reconstruction-Interface).
5949

6050
To obtain the final inclusive jets, use the `inclusive_jets` method:
6151

docs/src/index.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ jet_reconstruct(particles; algorithm = JetAlgorithm.GenKt, R = 0.4,
3131
```
3232

3333
Where `particles` is a collection of 4-vector objects (see [Input Particle
34-
Types](@ref)) to reconstruct and the algorithm is either given explicitly or
35-
implied by the power value.
34+
Types](@ref)) to reconstruct and the algorithm is given explicitly.
3635

3736
For the case of generalised ``k_T`` (for ``pp`` and ``e^+e^-``) both the
3837
algorithm (`GenKt`, `EEKt`) and `p` are needed.
@@ -58,12 +57,6 @@ Each known algorithm is referenced using a `JetAlgorithm` scoped enum value.
5857
| ``e^+e-`` ``k_\text{T}`` / Durham | `JetAlgorithm.Durham` | `R` value ignored and can be omitted |
5958
| generalised ``e^+e-`` ``k_\text{T}`` | `JetAlgorithm.EEKt` | For ``e^+e^-``, value of `p` must also be specified |
6059

61-
#### ``pp`` Algorithms
62-
63-
For the three ``pp`` algorithms with fixed `p` values, the `p` value can be
64-
given instead of the algorithm name. However, this should be considered
65-
*deprecated* and will be removed in a future release.
66-
6760
### Strategy
6861

6962
Generally one does not need to manually specify a strategy, but [Algorithm

examples/constituents/jetreco-constituents-nb.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ md"Event to pick"
2626
event_no = 1
2727

2828
# ╔═╡ 2a899d67-71f3-4fe0-8104-7633a44a06a8
29-
cluster_seq = jet_reconstruct(events[event_no], p = 1, R = 1.0)
29+
cluster_seq = jet_reconstruct(events[event_no]; algorithm = JetAlgorithm.Kt, R = 1.0)
3030

3131
# ╔═╡ 043cc484-e537-409c-8aa2-e4904b5dc283
3232
md"Retrieve the exclusive pj_jets, but as `PseudoJet` types"

examples/constituents/jetreco-constituents.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ events = read_final_state_particles(input_file)
1515
# Event to pick
1616
event_no = 1
1717

18-
cluster_seq = jet_reconstruct(events[event_no], p = 1, R = 1.0)
18+
cluster_seq = jet_reconstruct(events[event_no]; algorithm = JetAlgorithm.Kt, R = 1.0)
1919

2020
# Retrieve the exclusive pj_jets, but as `PseudoJet` types
2121
pj_jets = inclusive_jets(cluster_seq; ptmin = 5.0, T = PseudoJet)

examples/instrumented-jetreco.jl

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,16 @@ function profile_code(events::Vector{Vector{T}}, profile, nsamples; R = 0.4, p =
7676
end
7777

7878
"""
79-
allocation_stats(events::Vector{Vector{T}}; distance::Real = 0.4,
80-
p::Union{Real, Nothing} = nothing,
81-
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
79+
allocation_stats(events::Vector{Vector{T}}; algorithm::JetAlgorithm.Algorithm,
80+
distance::Real = 0.4, p::Union{Real, Nothing} = nothing,
8281
strategy::RecoStrategy.Strategy,
82+
recombine = RecombinationMethods[RecombinationScheme.EScheme],
8383
ptmin::Real = 5.0) where {T <: JetReconstruction.FourMomentum}
84-
8584
Take a memory allocation profile of the jet reconstruction code, printing the
8685
output.
8786
"""
88-
function allocation_stats(events::Vector{Vector{T}}; distance::Real = 0.4,
89-
p::Union{Real, Nothing} = nothing,
90-
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
87+
function allocation_stats(events::Vector{Vector{T}}; algorithm::JetAlgorithm.Algorithm,
88+
distance::Real = 0.4, p::Union{Real, Nothing} = nothing,
9189
strategy::RecoStrategy.Strategy,
9290
recombine = RecombinationMethods[RecombinationScheme.EScheme],
9391
ptmin::Real = 5.0) where {T <: JetReconstruction.FourMomentum}
@@ -103,8 +101,8 @@ end
103101

104102
"""
105103
benchmark_jet_reco(events::Vector{Vector{T}};
104+
algorithm::JetAlgorithm.Algorithm,
106105
distance::Real = 0.4,
107-
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
108106
p::Union{Real, Nothing} = nothing,
109107
ptmin::Real = 5.0,
110108
dcut = nothing,
@@ -125,8 +123,8 @@ print summary statistics on the runtime.
125123
- `dump_cs`: If `true`, dump the cluster sequence for each event.
126124
"""
127125
function benchmark_jet_reco(events::Vector{Vector{T}};
126+
algorithm::JetAlgorithm.Algorithm,
128127
distance::Real = 0.4,
129-
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
130128
p::Union{Real, Nothing} = nothing,
131129
strategy::RecoStrategy.Strategy,
132130
recombine = RecombinationMethods[RecombinationScheme.EScheme],
@@ -143,9 +141,8 @@ function benchmark_jet_reco(events::Vector{Vector{T}};
143141
jet_collection = FinalJets[]
144142
end
145143

146-
# Set consistent algorithm and power
147-
(p, algorithm) = JetReconstruction.get_algorithm_power_consistency(p = p,
148-
algorithm = algorithm)
144+
# Set consistent algorithm power
145+
p = JetReconstruction.get_algorithm_power(p = p, algorithm = algorithm)
149146
@info "Jet reconstruction will use $(algorithm) with power $(p)"
150147

151148
# Now setup timers and run the loop

examples/jetreco.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ happens inside the JetReconstruction package itself.
2424
Final jets can be serialised if the "dump" option is given
2525
"""
2626
function jet_process(events::Vector{Vector{T}};
27+
algorithm::JetAlgorithm.Algorithm,
2728
distance::Real = 0.4,
28-
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
2929
p::Union{Real, Nothing} = nothing,
3030
ptmin::Real = 5.0,
3131
dcut = nothing,
@@ -34,9 +34,8 @@ function jet_process(events::Vector{Vector{T}};
3434
dump::Union{String, Nothing} = nothing) where {T <:
3535
JetReconstruction.FourMomentum}
3636

37-
# Set consistent algorithm and power
38-
(p, algorithm) = JetReconstruction.get_algorithm_power_consistency(p = p,
39-
algorithm = algorithm)
37+
# Set consistent algorithm power
38+
p = JetReconstruction.get_algorithm_power(p = p, algorithm = algorithm)
4039
@info "Jet reconstruction will use $(algorithm) with power $(p)"
4140

4241
# A friendly label for the algorithm and final jet selection

examples/substructure/jet-grooming.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ events = read_final_state_particles(input_file)
88
# Event to pick
99
event_no = 1
1010

11-
cluster_seq = jet_reconstruct(events[event_no], p = 0, R = 1.0)
11+
cluster_seq = jet_reconstruct(events[event_no]; algorithm = JetAlgorithm.CA, R = 1.0)
1212
jets = inclusive_jets(cluster_seq; ptmin = 5.0, T = PseudoJet)
1313

1414
filter = (radius = 0.3, hardest_jets = 3)

examples/substructure/jet-tagging.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ events = read_final_state_particles(input_file)
88
# Event to pick
99
event_no = 1
1010

11-
cluster_seq = jet_reconstruct(events[event_no], p = 0, R = 1.0)
11+
cluster_seq = jet_reconstruct(events[event_no]; algorithm = JetAlgorithm.CA, R = 1.0)
1212
jets = inclusive_jets(cluster_seq; ptmin = 5.0, T = PseudoJet)
1313

1414
MDtagger = (mu = 0.67, y = 0.09)

examples/visualisation/animate-reconstruction.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ function main()
5656
@warn "Neither algorithm nor power specified, defaulting to AntiKt"
5757
args[:algorithm] = JetAlgorithm.AntiKt
5858
end
59-
# Set consistent algorithm and power
60-
(p, algorithm) = JetReconstruction.get_algorithm_power_consistency(p = args[:power],
61-
algorithm = args[:algorithm])
62-
cs = jet_reconstruct(events[1], R = args[:distance], p = p, algorithm = algorithm,
59+
cs = jet_reconstruct(events[1], R = args[:distance], p = args[:power],
60+
algorithm = args[:algorithm],
6361
strategy = args[:strategy])
6462

6563
animatereco(cs, args[:output]; azimuth = (1.8, 3.0), elevation = 0.5,

examples/visualisation/visualise-jets-nb.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ md"""# Jet Reconstruction Visualisation
3030
3131
This Pluto script visualises the result of a jet reconstruction process.
3232
33-
Use the sliders below to change the reconstructed event, the algorithm and the jet radius parameter."""
33+
Use the sliders below to change the reconstructed event, the GenKt algorithm power and the jet radius parameter."""
3434

3535
# ╔═╡ 4e569f74-570b-4b30-9ea7-9cbc420f50f8
3636
md"Event number:"
@@ -60,7 +60,7 @@ events::Vector{Vector{PseudoJet}} = read_final_state_particles(input_file,
6060
skipevents = event_no);
6161

6262
# ╔═╡ 2a899d67-71f3-4fe0-8104-7633a44a06a8
63-
cs = jet_reconstruct(events[1], p = power, R = radius)
63+
cs = jet_reconstruct(events[1]; algorithm = JetAlgorithm.GenKt, p = power, R = radius)
6464

6565
# ╔═╡ b5fd4e96-d073-4e5f-8de1-41addaa0dc3d
6666
jetreco_vis = jetsplot(events[1], cs; Module = GLMakie)

0 commit comments

Comments
 (0)