Skip to content

Commit c4ad094

Browse files
authored
Fix type instability when passing type to a function, concretize default types (#187)
* fix type instability in inclusive and exclusive jets * fix type instability in read_final_state_particles * concretize default vector types * use same convention in recombination schemes, fix docstrings and return type
1 parent 2463114 commit c4ad094

24 files changed

+75
-65
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ To obtain the final inclusive jets, use the `inclusive_jets` method:
5353
final_jets = inclusive_jets(cs::ClusterSequence; ptmin=0.0)
5454
```
5555

56-
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`).
56+
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., `inclusive_jets(cs::ClusterSequence, EEJet; ptmin=0.0)`).
5757

5858
#### Sorting
5959

docs/src/softkiller.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ A typical workflow using SoftKiller is:
3333
using JetReconstruction
3434

3535
# Read event particles (see examples/softkiller/softkiller_plots.jl)
36-
particles = read_final_state_particles("event.hepmc3", T=PseudoJet)[1]
36+
particles = read_final_state_particles("event.hepmc3", PseudoJet)[1]
3737

3838
# Set up SoftKiller
3939
sk = SoftKiller(rapmax=5.0, grid_size=0.4)

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, EEJet; njets = args[:njets])
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, EEJet; njets = 2)
1818
for jet in dijets
1919
println(jet)
2020
end

examples/constituents/jetreco-constituents-nb.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ cluster_seq = jet_reconstruct(events[event_no]; algorithm = JetAlgorithm.Kt, R =
3232
md"Retrieve the exclusive pj_jets, but as `PseudoJet` types"
3333

3434
# ╔═╡ 0d8d4664-915f-4f28-9d5a-6e03cb8d7d8b
35-
pj_jets = inclusive_jets(cluster_seq; ptmin = 5.0, T = PseudoJet)
35+
pj_jets = inclusive_jets(cluster_seq, PseudoJet; ptmin = 5.0)
3636

3737
# ╔═╡ 0bd764f9-d427-43fc-8342-603b6759ec8f
3838
md"Get the constituents of the first jet"

examples/constituents/jetreco-constituents.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ event_no = 1
1818
cluster_seq = jet_reconstruct(events[event_no]; algorithm = JetAlgorithm.Kt, R = 1.0)
1919

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

2323
# Get the constituents of the first jet
2424
my_constituents = JetReconstruction.constituents(pj_jets[1], cluster_seq)

examples/instrumented-jetreco.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,9 @@ function main()
341341
else
342342
jet_type = PseudoJet
343343
end
344-
events::Vector{Vector{jet_type}} = read_final_state_particles(args[:file],
344+
events::Vector{Vector{jet_type}} = read_final_state_particles(args[:file], jet_type;
345345
maxevents = args[:maxevents],
346-
skipevents = args[:skip],
347-
T = jet_type)
346+
skipevents = args[:skip])
348347

349348
# Major switch between modes of running
350349
if args[:alloc]

examples/jetreco.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,9 @@ function main()
149149
else
150150
jet_type = PseudoJet
151151
end
152-
events::Vector{Vector{jet_type}} = read_final_state_particles(args[:file],
152+
events::Vector{Vector{jet_type}} = read_final_state_particles(args[:file], jet_type;
153153
maxevents = args[:maxevents],
154-
skipevents = args[:skip],
155-
T = jet_type)
154+
skipevents = args[:skip])
156155
if isnothing(args[:algorithm]) && isnothing(args[:power])
157156
@warn "Neither algorithm nor power specified, defaulting to AntiKt"
158157
args[:algorithm] = JetAlgorithm.AntiKt

examples/softkiller/softkiller_plots.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,13 @@ function main()
165165
args[:hard_file] = normpath(joinpath(@__DIR__, args[:hard_file]))
166166

167167
# Reading pileup and hard event files
168-
events = read_final_state_particles(args[:pileup_file],
168+
events = read_final_state_particles(args[:pileup_file], jet_type;
169169
maxevents = args[:maxevents],
170-
skipevents = args[:skip],
171-
T = jet_type)
170+
skipevents = args[:skip])
172171

173-
h_events = read_final_state_particles(args[:hard_file],
172+
h_events = read_final_state_particles(args[:hard_file], jet_type;
174173
maxevents = args[:maxevents],
175-
skipevents = args[:skip],
176-
T = jet_type)
174+
skipevents = args[:skip])
177175

178176
# Set up SoftKiller grid and rapidity range
179177
rapmax = 5.0

examples/softkiller/softkiller_runtime.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,13 @@ function main()
8686
args[:hard_file] = normpath(joinpath(@__DIR__, args[:hard_file]))
8787

8888
# Reading pileup and hard event files
89-
events = read_final_state_particles(args[:pileup_file],
89+
events = read_final_state_particles(args[:pileup_file], jet_type;
9090
maxevents = args[:maxevents],
91-
skipevents = args[:skip],
92-
T = jet_type)
91+
skipevents = args[:skip])
9392

94-
h_events = read_final_state_particles(args[:hard_file],
93+
h_events = read_final_state_particles(args[:hard_file], jet_type;
9594
maxevents = args[:maxevents],
96-
skipevents = args[:skip],
97-
T = jet_type)
95+
skipevents = args[:skip])
9896

9997
# Set up SoftKiller grid and rapidity range
10098
rapmax = 5.0

0 commit comments

Comments
 (0)