Skip to content

Commit 6a3e3a1

Browse files
sattwamom-filagraeme-a-stewart
authored
Removed Jet Substructure Structs (#138)
* Removed Jet Substructure Structs Using separate structs for calling substructure functions seemed redundant. Removed the structs and incorporated their functionalities into the functions itself. * use local version of JetReconstruction in examples and docs (#142) * Jet utilities (#141) (#144) Add functions to calculate the momentum fraction and the kt scale for jets. - pt_fraction() for transverse momentum fraction - kt_scale() These are implemented generically for both jet types, though may be primary interesting for pp events (PseudoJet). deltar is added as a helper that returns the jet separation in pseudorapidity-phi. This is distinct from deltaR which operates in rapidity-phi space. These are probably not the greatest names, but are not in the public API. deltaR is moved to the new source file, JetUtils.jl. There is a small tidy up of the logic for calculating ϕ where the check for ϕ>2π can never be true. Added functions to convert jets to LorentzVector and LorentzVectorCyl. This required some initial refactoring of jet methods to be general, rather than PseudoJet specific, which will be continued. (cherry picked from commit c7cfa9e) * 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]> * Modified function signatures Modified the function signatures for `mass_drop`, `soft_drop`, `jet_filtering` and `jet_trimming` and updated documentations. Added `invalid_pseudojet` and `isvalid` and modified `test-substructure.jl`. * Better comparison against invalid_pseudojet Co-authored-by: Mateusz Jakub Fila <[email protected]> * Use invalid from Base; documentation improvements * Add type specifiers to docstrings --------- Co-authored-by: Mateusz Jakub Fila <[email protected]> Co-authored-by: Graeme A Stewart <[email protected]>
1 parent 3d70c47 commit 6a3e3a1

File tree

7 files changed

+111
-182
lines changed

7 files changed

+111
-182
lines changed

docs/src/substructure.md

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,64 @@
11
# Jet Substructure
22

3-
Jet substructure techniques provide powerful tools for analyzing and refining the properties of jets. Below are some of the key jet substructure functions, that are available.
3+
Jet substructure techniques provide powerful tools for analysing and refining the properties of jets. Below are some of the key jet substructure functions that are available.
44

55
### Mass Drop Tagging
66

77
```julia
8-
mass_drop(jet::PseudoJet, clusterseq::ClusterSequence, tag::MassDropTagger) -> PseudoJet
8+
mass_drop(jet::PseudoJet, clusterseq::ClusterSequence{PseudoJet}; mu::Float64, y::Float64) -> PseudoJet
99
```
1010

1111
The [mass_drop](@ref) function identifies subjets in a jet that pass the mass drop tagging condition. To use the `mass_drop` function:
1212

13-
- Configure the [MassDropTagger](@ref) with parameters tailored to the expected mass drop and distance thresholds for analysis.
14-
15-
```julia
16-
tagger = MassDropTagger(mu=0.67, y=0.09)
17-
```
18-
1913
- Apply the `mass_drop` function to the jet and its clustering sequence.
2014

2115
```julia
22-
tagged_jet = mass_drop(jet, clusterseq, tagger)
16+
tagger = (mu=0.67, y=0.09)
17+
tagged_jet = mass_drop(jet, clusterseq; tagger...)
2318
```
2419

25-
- If the jet is tagged successfully, the function returns the identified subjet. Else it returns `PseudoJet(0.0, 0.0, 0.0, 0.0)`.
20+
- If the jet is tagged successfully, the function returns the identified subjet. Else it returns the `invalid_pseudojet` object.
2621

2722
---
2823

2924
### Soft Drop Tagging
3025

3126
```julia
32-
soft_drop(jet::PseudoJet, clusterseq::ClusterSequence, tag::SoftDropTagger) -> PseudoJet
27+
soft_drop(jet::PseudoJet, clusterseq::ClusterSequence{PseudoJet}: zcut::Real, beta::Real) -> PseudoJet
3328
```
3429

3530
The [soft_drop](@ref) function applies soft-drop grooming to remove soft, wide-angle radiation from jets. It reclusters the jet with a specified radius and clustering method, iteratively checking the soft-drop condition on subjets. To use the `soft_drop` function:
3631

37-
- Construct the [SoftDropTagger](@ref) by defining the parameters for the grooming process, such as the energy fraction (`zcut`) and angular exponent (`b`)
38-
39-
```julia
40-
tagger = SoftDropTagger(zcut=0.1, b=2.0)
41-
```
42-
43-
By default, the reclustering radius is set to `1.0` which can be modified by defing the `tagger` object as
32+
- Apply the `soft_drop` function to the jet and its clustering sequence.
4433

4534
```julia
46-
tagger = SoftDropTagger(zcut=0.1, b=2.0, cluster_rad=0.4)
35+
tagger = (zcut = 0.1, beta = 2.0)
36+
tagged_jet = soft_drop(jet, clusterseq; tagger...)
4737
```
4838

49-
- Apply the `soft_drop` function to the jet and its clustering sequence.
50-
39+
By default, the reclustering radius is set to `1.0` which can be modified by the user as:
5140
```julia
52-
tagged_jet = soft_drop(jet, clusterseq, tagger)
41+
tagger = (zcut = 0.1, beta = 2.0, radius = 0.4)
42+
tagged_jet = soft_drop(jet, clusterseq; tagger...)
5343
```
5444

55-
- If the jet is tagged successfully, the function returns the identified subjet. Else it returns `nothing`.
45+
- If the jet is tagged successfully, the function returns the identified subjet. Else it returns the `invalid_pseudojet` object.
5646

5747
---
5848

5949
### Jet Filtering
6050

6151
```julia
62-
jet_filtering(jet::PseudoJet, clusterseq::ClusterSequence, filter::JetFilter) -> PseudoJet
52+
jet_filtering(jet::PseudoJet, clusterseq::ClusterSequence{PseudoJet}; radius::Real, hardest_jets::Integer) -> PseudoJet
6353
```
6454

6555
The [jet_filtering](@ref) function filters a jet to retain only the hardest subjets based on a specified radius and number. To use the function:
6656

67-
- Set the radius for subjet clustering and the number of hardest subjets to retain in a [JetFilter](@ref) method.
68-
69-
```julia
70-
filter = JetFilter(filter_radius=0.3, num_hardest_jets=3)
71-
```
72-
7357
- Apply the `jet_filtering` function to refine the jet.
7458

7559
```julia
76-
filtered_jet = jet_filtering(jet, clusterseq, filter)
60+
filter = (radius=0.3, hardest_jets=3)
61+
filtered_jet = jet_filtering(jet, clusterseq; filter...)
7762
```
7863

7964
- The function returns the filtered jet that retains only the most significant subjets, reducing noise.
@@ -83,26 +68,21 @@ filtered_jet = jet_filtering(jet, clusterseq, filter)
8368
### Jet Trimming
8469

8570
```julia
86-
jet_trimming(jet::PseudoJet, clusterseq::ClusterSequence, trim::JetTrim) -> PseudoJet
71+
jet_trimming(jet::PseudoJet, clusterseq::ClusterSequence{PseudoJet}; radius::Real, fraction::Real, recluster_method::JetAlgorithm.Algorithm) -> PseudoJet
8772
```
8873

8974
The [jet_trimming](@ref) function trims a jet by removing subjets with transverse momentum below a specified fraction of the main jet's momentum. This method cleans up jets by removing soft particles. To use this function:
9075

91-
- Configure the trimming radius and momentum fraction threshold in [JetTrim](@ref)
92-
93-
```julia
94-
trim = JetTrim(trim_radius=0.3, trim_fraction=0.3, recluster_method=JetAlgorithm.CA)
95-
```
96-
97-
It is to be noted that the `jet_trimming` function reclusters the constituents of the jet using either `C/A` or `kT ` algorithm, which needs to be specified.
98-
9976
- Apply the `jet_trimming` function to clean the jet.
10077

10178
```julia
102-
trimmed_jet = jet_trimming(jet, clusterseq, trim)
79+
trim = (radius=0.3, fraction=0.3, recluster_method=JetAlgorithm.CA)
80+
trimmed_jet = jet_trimming(jet, clusterseq; trim...)
10381
```
10482

105-
- The function returns the trimmed jet.
83+
- The function returns the trimmed jet if trimming is successful, or the `invalid_pseudojet` object.
84+
85+
It is to be noted that the `jet_trimming` function reclusters the constituents of the jet using either `C/A` or `kT ` algorithm, which needs to be specified.
10686

10787
---
10888

examples/substructure/jet-grooming.jl

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,21 @@ event_no = 1
1111
cluster_seq = jet_reconstruct(events[event_no], p = 0, R = 1.0)
1212
jets = inclusive_jets(cluster_seq; ptmin = 5.0, T = PseudoJet)
1313

14-
r = 0.3 # recluster radius
15-
n = 3 # number of hard jets to consider
14+
filter = (radius = 0.3, hardest_jets = 3)
1615

17-
filter = JetFilter(r, n)
18-
19-
@info "Jet Filtering: recluster radius = $r, hard subjets to consider = $n"
16+
@info "Jet Filtering: recluster radius = $(filter.radius), hard subjets to consider = $(filter.hardest_jets)"
2017
for jet in jets
21-
filtered = jet_filtering(jet, cluster_seq, filter)
18+
filtered = jet_filtering(jet, cluster_seq; filter...)
2219

2320
println("Original jet: pt = $(JetReconstruction.pt(jet)), rap = $(JetReconstruction.rapidity(jet)), phi = $(JetReconstruction.phi(jet)), E = $(jet.E)")
2421
println("Filtered jet: pt = $(JetReconstruction.pt(filtered)), rap = $(JetReconstruction.rapidity(filtered)), phi = $(JetReconstruction.phi(filtered)), E = $(filtered.E)\n")
2522
end
2623

27-
r = 0.3 # recluster radius
28-
f = 0.3 # trim fraction
29-
m = JetAlgorithm.CA # recluster method
30-
31-
trim = JetTrim(r, f, m)
24+
trim = (radius = 0.3, fraction = 0.3, recluster_method = JetAlgorithm.CA)
3225

33-
@info "Jet Trimming: recluster radius = $r, trim fraction = $f, recluster method = $m"
26+
@info "Jet Trimming: recluster radius = $(trim.radius), trim fraction = $(trim.fraction), recluster method = $(trim.recluster_method)"
3427
for jet in jets
35-
trimmed = jet_trimming(jet, cluster_seq, trim)
28+
trimmed = jet_trimming(jet, cluster_seq; trim...)
3629

3730
println("Original jet: pt = $(JetReconstruction.pt(jet)), rap = $(JetReconstruction.rapidity(jet)), phi = $(JetReconstruction.phi(jet)), E = $(jet.E)")
3831
println("Trimmed jet: pt = $(JetReconstruction.pt(trimmed)), rap = $(JetReconstruction.rapidity(trimmed)), phi = $(JetReconstruction.phi(trimmed)), E = $(trimmed.E)\n")

examples/substructure/jet-tagging.jl

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,20 @@ event_no = 1
1111
cluster_seq = jet_reconstruct(events[event_no], p = 0, R = 1.0)
1212
jets = inclusive_jets(cluster_seq; ptmin = 5.0, T = PseudoJet)
1313

14-
μ = 0.67 # jet mass ratio
15-
y = 0.09 # symmetry cut
14+
MDtagger = (mu = 0.67, y = 0.09)
1615

17-
MDtagger = MassDropTagger(μ, y)
18-
19-
@info "Mass Drop Tagging: μ = , y = $y"
16+
@info "Mass Drop Tagging: μ = $(MDtagger.mu), y = $(MDtagger.y)"
2017
for jet in jets
21-
tagged = mass_drop(jet, cluster_seq, MDtagger)
18+
tagged = mass_drop(jet, cluster_seq; MDtagger...)
2219
println("Original jet: pt = $(JetReconstruction.pt(jet)), rap = $(JetReconstruction.rapidity(jet)), phi = $(JetReconstruction.phi(jet)), E = $(jet.E)")
2320
println("Tagged jet: pt = $(JetReconstruction.pt(tagged)), rap = $(JetReconstruction.rapidity(tagged)), phi = $(JetReconstruction.phi(tagged)), E = $(tagged.E)\n")
2421
end
2522

26-
z = 0.1 # soft drop threshold
27-
b = 2.0 # angular exponent
28-
29-
SDtagger = SoftDropTagger(z, b)
23+
SDtagger = (zcut = 0.1, beta = 2.0)
3024

31-
@info "Soft Drop Tagging: recluster radius = $(SDtagger.cluster_rad), zcut = $z, b = $b"
25+
@info "Soft Drop Tagging: zcut = $(SDtagger.zcut), b = $(SDtagger.beta)"
3226
for jet in jets
33-
tagged = soft_drop(jet, cluster_seq, SDtagger)
27+
tagged = soft_drop(jet, cluster_seq; SDtagger...)
3428
println("Original jet: pt = $(JetReconstruction.pt(jet)), rap = $(JetReconstruction.rapidity(jet)), phi = $(JetReconstruction.phi(jet)), E = $(jet.E)")
3529
println("Tagged jet: pt = $(JetReconstruction.pt(tagged)), rap = $(JetReconstruction.rapidity(tagged)), phi = $(JetReconstruction.phi(tagged)), E = $(tagged.E)\n")
3630
end

src/JetReconstruction.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ export jet_reconstruct
7373

7474
## Substructure modules
7575
include("Substructure.jl")
76-
export MassDropTagger, SoftDropTagger, JetFilter, JetTrim, mass_drop, soft_drop,
77-
jet_filtering, jet_trimming
76+
export mass_drop, soft_drop, jet_filtering, jet_trimming
7877

7978
# Simple HepMC3 reader
8079
include("HepMC3.jl")

src/Pseudojet.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ A PseudoJet object.
9191
PseudoJet(px::Real, py::Real,
9292
pz::Real, E::Real) = PseudoJet(px, py, pz, E, 0, px^2 + py^2)
9393

94+
"""Used to mark an invalid result in case the corresponding substructure tagging fails."""
95+
const invalid_pseudojet = PseudoJet(0.0, 0.0, 0.0, 0.0)
96+
97+
import Base.isvalid
98+
"""
99+
isvalid(j::PseudoJet)
100+
101+
Function to check whether a given `PseudoJet` object is non-zero or not. Primarily to use for checking the validity of outputs of substructure tagging.
102+
103+
# Arguments
104+
- `j::PseudoJet`: The `PseudoJet` object to check.
105+
106+
# Returns
107+
- `Bool`: `true` if the `PseudoJet` object is non-zero, `false` otherwise.
108+
"""
109+
isvalid(j::PseudoJet) = !(j === invalid_pseudojet)
110+
94111
import Base.show
95112
"""
96113
show(io::IO, jet::PseudoJet)

0 commit comments

Comments
 (0)