Skip to content

Commit 25d206f

Browse files
Fix arguments in docstrings (#135)
* add missing algorithm prarameter and fix enum type in docstrings * constrain stategy argument type * fix dots, wrong parameters, missing types in substructure docs * fix documenting power as int!, add whitespaces in args docs * Update more docstrings Make sure the docstrings reflect the actual method signatures (particularly including type specifiers). Ensure that default values in docstring match those of the actual method. I reordered the named arguments in places to ensure that the more important parameters came first (p, algorithm) with optional ones later. For particle inputs, use Vector explicitly, instead of AbstractArray 1-D. --------- Co-authored-by: Graeme A Stewart <[email protected]>
1 parent 7a37cd8 commit 25d206f

File tree

7 files changed

+88
-70
lines changed

7 files changed

+88
-70
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ algorithm and generalised $`k_\text{T}`$ for $`e^+e^-`$.
2727
The simplest interface is to call:
2828

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

3333
- `particles` - a one dimensional array (vector) of input particles for the clustering

src/AlgorithmStrategyEnums.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The dictionary is created by iterating over the `power2algorithm` dictionary and
5858
const algorithm2power = Dict((i.second, i.first) for i in power2algorithm)
5959

6060
"""
61-
get_algorithm_power_consistency(; p::Union{Real, Nothing}, algorithm::Union{JetAlgorithm, Nothing})
61+
get_algorithm_power_consistency(; p::Union{Real, Nothing}, algorithm::Union{JetAlgorithm.Algorithm, Nothing})
6262
6363
Get the algorithm and power consistency correct
6464
@@ -70,7 +70,7 @@ the power parameter is specified, it throws an `ArgumentError`.
7070
7171
# Arguments
7272
- `p::Union{Real, Nothing}`: The power value.
73-
- `algorithm::Union{JetAlgorithm, Nothing}`: The algorithm.
73+
- `algorithm::Union{JetAlgorithm.Algorithm, Nothing}`: The algorithm.
7474
7575
# Returns
7676
A named tuple of the consistent power and algorithm values.

src/EEAlgorithm.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ If the algorithm is Durham, `p` is set to 1 and `R` is nominally set to 4.
221221
Note that unlike `pp` reconstruction the algorithm has to be specified
222222
explicitly.
223223
"""
224-
function ee_genkt_algorithm(particles::AbstractArray{T, 1}; p = 1, R = 4.0,
224+
function ee_genkt_algorithm(particles::Vector{T}; p = 1,
225225
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.Durham,
226-
recombine = +) where {T}
226+
R = 4.0, recombine = +) where {T}
227227

228228
# Check for consistency between algorithm and power
229229
(p, algorithm) = get_algorithm_power_consistency(p = p, algorithm = algorithm)

src/GenericAlgo.jl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
"""
2-
jet_reconstruct(particles; p = -1, algorithm = nothing, R = 1.0, recombine = +, strategy = RecoStrategy.Best)
2+
jet_reconstruct(particles; p::Union{Real, Nothing} = nothing,
3+
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
4+
R = 1.0, recombine = +,
5+
strategy::RecoStrategy.Strategy = RecoStrategy.Best)
36
47
Reconstructs jets from a collection of particles using a specified algorithm and
5-
strategy
8+
strategy.
69
710
# Arguments
811
- `particles`: A collection of particles used for jet reconstruction.
9-
- `p::Union{Real, Nothing} = -1`: The power value used for the distance measure
12+
- `p::Union{Real, Nothing} = nothing`: The power value used for the distance measure
1013
for generalised k_T, which maps to a particular reconstruction algorithm (-1 =
1114
AntiKt, 0 = Cambridge/Aachen, 1 = Kt).
1215
- `algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing`: The algorithm
1316
to use for jet reconstruction.
14-
- `R=1.0`: The jet radius parameter.
15-
- `recombine=+`: The recombination scheme used for combining particles.
16-
- `strategy=RecoStrategy.Best`: The jet reconstruction strategy to use.
17-
`RecoStrategy.Best` makes a dynamic decision based on the number of starting
18-
particles.
17+
- `R = 1.0`: The jet radius parameter.
18+
- `recombine = +`: The recombination scheme used for combining particles.
19+
- `strategy::RecoStrategy.Strategy = RecoStrategy.Best`: The jet reconstruction
20+
strategy to use. `RecoStrategy.Best` makes a dynamic decision based on the
21+
number of starting particles.
22+
23+
Note that one of `p` or `algorithm` must be specified, with `algorithm` preferred.
1924
2025
# Returns
2126
A cluster sequence object containing the reconstructed jets and the merging
@@ -52,10 +57,10 @@ jet_reconstruct(particles; algorithm = JetAlgorithm.Durham)
5257
jet_reconstruct(particles; algorithm = JetAlgorithm.GenKt, p = 0.5, R = 1.0)
5358
```
5459
"""
55-
function jet_reconstruct(particles; p::Union{Real, Nothing} = nothing, R = 1.0,
60+
function jet_reconstruct(particles; p::Union{Real, Nothing} = nothing,
5661
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
57-
recombine = +,
58-
strategy = RecoStrategy.Best)
62+
R = 1.0, recombine = +,
63+
strategy::RecoStrategy.Strategy = RecoStrategy.Best)
5964

6065
# Either map to the fixed algorithm corresponding to the strategy
6166
# or to an optimal choice based on the density of initial particles

src/PlainAlgo.jl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,21 @@ Base.@propagate_inbounds function upd_nn_step!(i, j, k, N, Nn, kt2_array, rapidi
187187
end
188188

189189
"""
190-
plain_jet_reconstruct(particles::Vector{T}; p = -1, R = 1.0, recombine = +) where T
190+
plain_jet_reconstruct(particles::Vector{T}; p::Union{Real, Nothing} = -1,
191+
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
192+
R = 1.0, recombine = +) where {T}
191193
192194
Perform pp jet reconstruction using the plain algorithm.
193195
194196
# Arguments
195197
- `particles::Vector{T}`: A vector of particles used for jet reconstruction, any
196198
array of particles, which supports suitable 4-vector methods, viz. pt2(),
197199
phi(), rapidity(), px(), py(), pz(), energy(), can be used. for each element.
200+
- `p::Union{Real, Nothing} = -1`: The power value used for jet reconstruction.
198201
- `algorithm::Union{JetAlgorithm, Nothing} = nothing`: The explicit jet
199202
algorithm to use.
200-
- `p::Int=-1`: The integer value used for jet reconstruction.
201-
- `R::Float64=1.0`: The radius parameter used for jet reconstruction.
202-
- `recombine::Function=+`: The recombination function used for jet
203+
- `R::Float64 = 1.0`: The radius parameter used for jet reconstruction.
204+
- `recombine::Function = +`: The recombination function used for jet
203205
reconstruction.
204206
205207
**Note** for the `particles` argument, the 4-vector methods need to exist in the
@@ -219,10 +221,9 @@ jets = plain_jet_reconstruct(particles; p = -1, R = 0.4)
219221
jets = plain_jet_reconstruct(particles; algorithm = JetAlgorithm.Kt, R = 1.0)
220222
```
221223
"""
222-
function plain_jet_reconstruct(particles::AbstractArray{T, 1}; p::Union{Real, Nothing} = -1,
223-
R = 1.0,
224+
function plain_jet_reconstruct(particles::Vector{T}; p::Union{Real, Nothing} = -1,
224225
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
225-
recombine = +) where {T}
226+
R = 1.0, recombine = +) where {T}
226227

227228
# Check for consistency between algorithm and power
228229
(p, algorithm) = get_algorithm_power_consistency(p = p, algorithm = algorithm)
@@ -252,7 +253,9 @@ function plain_jet_reconstruct(particles::AbstractArray{T, 1}; p::Union{Real, No
252253
end
253254

254255
"""
255-
_plain_jet_reconstruct(; particles::Vector{PseudoJet}, p = -1, R = 1.0, recombine = +)
256+
_plain_jet_reconstruct(; particles::Vector{PseudoJet}, p = -1,
257+
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.AntiKt,
258+
R = 1.0, recombine = +)
256259
257260
This is the internal implementation of jet reconstruction using the plain
258261
algorithm. It takes a vector of `particles` representing the input particles and
@@ -264,23 +267,26 @@ entry point to this jet reconstruction.
264267
265268
The power value maps to specific pp jet reconstruction algorithms: -1 = AntiKt,
266269
0 = Cambridge/Aachen, 1 = Inclusive Kt. Floating point values are allowed for
267-
generalised k_t algorithm.
270+
generalised k_t algorithm. The algorithm parameter must be consistent with the
271+
power parameter.
268272
269273
# Arguments
270274
- `particles`: A vector of `PseudoJet` objects representing the input particles.
271-
- `p=-1`: The power to which the transverse momentum (`pt`) of each particle is
275+
- `p = -1`: The power to which the transverse momentum (`pt`) of each particle is
272276
raised.
273-
- `R=1.0`: The jet radius parameter.
277+
- `R = 1.0`: The jet radius parameter.
278+
- `algorithm::JetAlgorithm.Algorithm = JetAlgorithm.AntiKt`: The jet reconstruction
279+
algorithm to use.
274280
- `recombine`: The recombination function used to merge two jets. Default is `+`
275281
(additive recombination).
276282
277283
# Returns
278284
- `clusterseq`: The resulting `ClusterSequence` object representing the
279285
reconstructed jets.
280286
"""
281-
function _plain_jet_reconstruct(; particles::Vector{PseudoJet}, p = -1, R = 1.0,
287+
function _plain_jet_reconstruct(; particles::Vector{PseudoJet}, p = -1,
282288
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.AntiKt,
283-
recombine = +)
289+
R = 1.0, recombine = +)
284290
# Bounds
285291
N::Int = length(particles)
286292
# Parameters

src/Substructure.jl

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ function deltaR(jet1::PseudoJet, jet2::PseudoJet)
2222
end
2323

2424
"""
25-
recluster(jet, clusterseq; R = rad, algorithm = mtd) -> ClusterSequence
25+
recluster(jet, clusterseq; R = 1.0, algorithm = JetAlgorithm.CA) -> ClusterSequence
2626
27-
Reclusters the constituents of a given jet `jet` with a different clustering method `mtd` and different jet radius `rad`.
27+
Reclusters the constituents of a given jet `jet` with a different clustering algorithm `algorithm` and different jet radius `R`.
2828
2929
# Arguments
3030
- `jet::PseudoJet`: The jet whose constituents are to be reclustered.
3131
- `clusterseq::ClusterSequence`: The cluster sequence from which the original jet is obtained.
32-
- `rad::Float64`: The new jet radius, by default set to 1.0
33-
- `mtd::JetAlgorithm.Algorithm`: The new clustering method, by default set to JetAlgorithm.CA
32+
- `R = 1.0`: The new jet radius.
33+
- `algorithm::JetAlgorithm.Algorithm = JetAlgorithm.CA`: The new clustering method.
3434
3535
# Returns
3636
- `ClusterSequence`: The new cluster sequence.
3737
"""
3838
function recluster(jet::PseudoJet, clusterseq::ClusterSequence; R = 1.0,
39-
algorithm = JetAlgorithm.CA)
39+
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.CA)
4040
cons = constituents(jet, clusterseq)
4141
new_clusterseq = jet_reconstruct(cons; p = nothing, R = R, algorithm = algorithm,
4242
strategy = RecoStrategy.Best)
@@ -50,8 +50,8 @@ end
5050
Used for tagging jets that undergo mass drop, a common technique in jet substructure.
5151
5252
# Fields:
53-
- `mu::Float64`: Maximum allowed mass ratio for a jet to pass tagging
54-
- `y::Float64`: Minimum kT distance threshold for parent separation
53+
- `mu::Float64`: Maximum allowed mass ratio for a jet to pass tagging.
54+
- `y::Float64`: Minimum kT distance threshold for parent separation.
5555
"""
5656
struct MassDropTagger
5757
mu::Float64
@@ -64,9 +64,10 @@ end
6464
Applies a soft-drop condition on jets, trimming away soft, wide-angle radiation.
6565
6666
# Fields:
67-
- `zcut::Float64`: Minimum allowed energy fraction for subjets
68-
- `b::Float64`: Angular exponent controlling soft radiation suppression
69-
- `cluster_rad::Float64`: The new radius that will be used to recluster the components of the jet, by default set to 1.0
67+
- `zcut::Float64`: Minimum allowed energy fraction for subjets.
68+
- `b::Float64`: Angular exponent controlling soft radiation suppression.
69+
- `cluster_rad::Float64`: The new radius that will be used to recluster the
70+
components of the jet, by default set to 1.0.
7071
"""
7172
struct SoftDropTagger
7273
zcut::Float64
@@ -82,8 +83,8 @@ SoftDropTagger(z::Float64, b::Float64) = SoftDropTagger(z, b, 1.0)
8283
Filters jets based on radius and number of hardest subjets, reducing contamination.
8384
8485
# Fields:
85-
- `filter_radius::Float64`: Radius parameter to recluster subjets
86-
- `num_hardest_jets::Int64`: Number of hardest jets to retain in the filtered result
86+
- `filter_radius::Float64`: Radius parameter to recluster subjets.
87+
- `num_hardest_jets::Int64`: Number of hardest jets to retain in the filtered result.
8788
"""
8889
struct JetFilter
8990
filter_radius::Float64
@@ -96,9 +97,9 @@ end
9697
Trims soft, large-angle components from jets based on fraction and radius.
9798
9899
# Fields:
99-
- `trim_radius::Float64`: Radius used for reclustering in trimming
100-
- `trim_fraction::Float64`: Minimum momentum fraction for retained subjets
101-
- `recluster_method::JetAlgorithm.Algorithm`: Method identifier for reclustering
100+
- `trim_radius::Float64`: Radius used for reclustering in trimming.
101+
- `trim_fraction::Float64`: Minimum momentum fraction for retained subjets.
102+
- `recluster_method::JetAlgorithm.Algorithm`: Method identifier for reclustering.
102103
"""
103104
struct JetTrim
104105
trim_radius::Float64
@@ -113,9 +114,9 @@ Identifies subjets in a jet that pass the mass drop tagging condition.
113114
The method stops at the first jet satisfying the mass and distance thresholds.
114115
115116
# Arguments:
116-
- `jet::PseudoJet`: PseudoJet instance representing the jet to tag
117-
- `clusterseq::ClusterSequence`: ClusterSequence with jet clustering history
118-
- `tag::MassDropTagger`: MassDropTagger instance providing mass drop parameters
117+
- `jet::PseudoJet`: PseudoJet instance representing the jet to tag.
118+
- `clusterseq::ClusterSequence`: ClusterSequence with jet clustering history.
119+
- `tag::MassDropTagger`: MassDropTagger instance providing mass drop parameters.
119120
120121
# Returns:
121122
- `PseudoJet`: The jet (or subjet) satisfying the mass drop conditions, if tagging is successful, otherwise a zero-momentum PseudoJet
@@ -155,12 +156,12 @@ Applies soft-drop grooming to remove soft, wide-angle radiation from jets.
155156
This function reclusters the jet and iteratively checks the soft-drop condition on subjets.
156157
157158
# Arguments:
158-
- `jet::PseudoJet`: PseudoJet instance to groom
159-
- `clusterseq::ClusterSequence`: ClusterSequence containing jet history
160-
- `tag::SoftDropTagger`: SoftDropTagger instance with soft-drop parameters
159+
- `jet::PseudoJet`: PseudoJet instance to groom.
160+
- `clusterseq::ClusterSequence`: ClusterSequence containing jet history.
161+
- `tag::SoftDropTagger`: SoftDropTagger instance with soft-drop parameters.
161162
162163
# Returns:
163-
- `PseudoJet`: Groomed jet or zero-momentum PseudoJet if grooming fails
164+
- `PseudoJet`: Groomed jet or zero-momentum PseudoJet if grooming fails.
164165
"""
165166
function soft_drop(jet::PseudoJet, clusterseq::ClusterSequence,
166167
tag::SoftDropTagger)
@@ -201,12 +202,12 @@ end
201202
Filters a jet to retain only the hardest subjets based on a specified radius and number.
202203
203204
# Arguments:
204-
- `jet::PseudoJet`: PseudoJet instance representing the jet to filter
205-
- `clusterseq::ClusterSequence`: ClusterSequence containing jet history
206-
- `filter::JetFilter`: Filter instance specifying radius and number of subjets
205+
- `jet::PseudoJet`: PseudoJet instance representing the jet to filter.
206+
- `clusterseq::ClusterSequence`: ClusterSequence containing jet history.
207+
- `filter::JetFilter`: Filter instance specifying radius and number of subjets.
207208
208209
# Returns:
209-
- `PseudoJet`: Filtered jet composed of the hardest subjets
210+
- `PseudoJet`: Filtered jet composed of the hardest subjets.
210211
"""
211212
function jet_filtering(jet::PseudoJet, clusterseq::ClusterSequence, filter::JetFilter)
212213
rad = filter.filter_radius
@@ -228,12 +229,12 @@ end
228229
Trims a jet by removing subjets with transverse momentum below a specified fraction.
229230
230231
# Arguments:
231-
- `jet::PseudoJet`: PseudoJet instance representing the jet to trim
232-
- `clusterseq::ClusterSequence`: ClusterSequence containing jet history
233-
- `trim::JetTrim`: Trim instance specifying trimming parameters
232+
- `jet::PseudoJet`: PseudoJet instance representing the jet to trim.
233+
- `clusterseq::ClusterSequence`: ClusterSequence containing jet history.
234+
- `trim::JetTrim`: Trim instance specifying trimming parameters.
234235
235236
# Returns:
236-
- `PseudoJet`: Trimmed jet composed of retained subjets
237+
- `PseudoJet`: Trimmed jet composed of retained subjets.
237238
"""
238239
function jet_trimming(jet::PseudoJet, clusterseq::ClusterSequence, trim::JetTrim)
239240
rad = trim.trim_radius

src/TiledAlgoLL.jl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ function find_tile_neighbours!(tile_union, jetA, jetB, oldB, tiling)
330330
end
331331

332332
"""
333-
tiled_jet_reconstruct(particles::Vector{T}; p = -1, R = 1.0, recombine = +) where {T}
333+
tiled_jet_reconstruct(particles::Vector{T}; p::Union{Real, Nothing} = -1,
334+
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
335+
R = 1.0, recombine = +) where {T}
334336
335337
Main jet reconstruction algorithm entry point for reconstructing jets using the
336338
tiled strategy for generic jet type T.
@@ -350,7 +352,7 @@ If both are given they must be consistent or an exception is thrown.
350352
JetReconstruction namespace)
351353
- `p::Union{Real, Nothing} = -1`: The power parameter for the jet reconstruction
352354
algorithm, thus switching between different algorithms.
353-
- `algorithm::Union{JetAlgorithm, Nothing} = nothing`: The explicit jet
355+
- `algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing`: The explicit jet
354356
algorithm to use.
355357
- `R::Float64 = 1.0`: The jet radius parameter for the jet reconstruction
356358
algorithm.
@@ -365,10 +367,9 @@ If both are given they must be consistent or an exception is thrown.
365367
tiled_jet_reconstruct(particles::Vector{LorentzVectorHEP}; p = -1, R = 0.4, recombine = +)
366368
```
367369
"""
368-
function tiled_jet_reconstruct(particles::AbstractArray{T, 1}; p::Union{Real, Nothing} = -1,
369-
R = 1.0,
370+
function tiled_jet_reconstruct(particles::Vector{T}; p::Union{Real, Nothing} = -1,
370371
algorithm::Union{JetAlgorithm.Algorithm, Nothing} = nothing,
371-
recombine = +) where {T}
372+
R = 1.0, recombine = +) where {T}
372373

373374
# Check for consistency between algorithm and power
374375
(p, algorithm) = get_algorithm_power_consistency(p = p, algorithm = algorithm)
@@ -398,18 +399,23 @@ Main jet reconstruction algorithm, using PseudoJet objects
398399
"""
399400

400401
"""
401-
_tiled_jet_reconstruct(particles::Vector{PseudoJet}; p = -1, R = 1.0, recombine = +) where {T}
402+
_tiled_jet_reconstruct(particles::Vector{PseudoJet}; p::Real = -1,
403+
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.AntiKt,
404+
R = 1.0, recombine = +)
402405
403406
Main jet reconstruction algorithm entry point for reconstructing jets once preprocessing
404-
of data types are done.
407+
of data types are done. The algorithm parameter must be consistent with the
408+
power parameter.
405409
406410
## Arguments
407411
- `particles::Vector{PseudoJet}`: A vector of `PseudoJet` particles used as input for jet
408412
reconstruction.
409-
- `p::Int = -1`: The power parameter for the jet reconstruction algorithm, thus
413+
- `p::Real = -1`: The power parameter for the jet reconstruction algorithm, thus
410414
switching between different algorithms.
411-
- `R::Float64 = 1.0`: The jet radius parameter for the jet reconstruction
415+
- `R = 1.0`: The jet radius parameter for the jet reconstruction
412416
algorithm.
417+
- `algorithm::JetAlgorithm.Algorithm = JetAlgorithm.AntiKt`: The jet reconstruction
418+
algorithm to use.
413419
- `recombine::Function = +`: The recombination function used for combining
414420
pseudojets.
415421
@@ -421,9 +427,9 @@ of data types are done.
421427
tiled_jet_reconstruct(particles::Vector{PseudoJet}; p = 1, R = 1.0, recombine = +)
422428
```
423429
"""
424-
function _tiled_jet_reconstruct(particles::Vector{PseudoJet}; p::Real = -1, R = 1.0,
430+
function _tiled_jet_reconstruct(particles::Vector{PseudoJet}; p::Real = -1,
425431
algorithm::JetAlgorithm.Algorithm = JetAlgorithm.AntiKt,
426-
recombine = +)
432+
R = 1.0, recombine = +)
427433
# Bounds
428434
N::Int = length(particles)
429435

0 commit comments

Comments
 (0)