Skip to content

Commit 16b2767

Browse files
m-filagraeme-a-stewart
authored andcommitted
fix dump in jetreco and instrumented-jetreco examples (JuliaHEP#182)
* fix dump in jetreco and instrumented-jetreco examples * Refactor fixed dump option Rename the jets selected as "selectedjets" to avoid confusion with too many "final jets". Add a test of this option to the example testing script "test.sh" --------- Co-authored-by: Graeme A Stewart <[email protected]>
1 parent 14bd9d9 commit 16b2767

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

examples/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
profile/*
77
# Playground for development scripts and notebooks
88
playground/*
9+
# Ignore outputs from tests
10+
test-output*

examples/instrumented-jetreco.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,24 +159,24 @@ function benchmark_jet_reco(events::Vector{Vector{T}};
159159
cs = jet_reconstruct(event; R = distance, p = p, algorithm = algorithm,
160160
strategy = strategy, recombine...)
161161
if !isnothing(njets)
162-
finaljets = exclusive_jets(cs; njets = njets)
162+
selectedjets = exclusive_jets(cs; njets = njets)
163163
elseif !isnothing(dcut)
164-
finaljets = exclusive_jets(cs; dcut = dcut)
164+
selectedjets = exclusive_jets(cs; dcut = dcut)
165165
else
166-
finaljets = inclusive_jets(cs; ptmin = ptmin)
166+
selectedjets = inclusive_jets(cs; ptmin = ptmin)
167167
end
168168
# Only print the jet content once
169169
if irun == 0 || nsamples == 1
170170
@info begin
171171
jet_output = "Event $(ievt)\n"
172-
sort!(finaljets, by = x -> pt(x), rev = true)
173-
for (ijet, jet) in enumerate(finaljets)
172+
sort!(selectedjets, by = x -> pt(x), rev = true)
173+
for (ijet, jet) in enumerate(selectedjets)
174174
jet_output *= " $(ijet) - $(jet)\n"
175175
end
176176
"$(jet_output)"
177177
end
178178
if !isnothing(dump)
179-
push!(jet_collection, FinalJets(ievt, finaljets))
179+
push!(jet_collection, FinalJets(ievt, final_jets(selectedjets)))
180180
end
181181
if dump_cs
182182
println("Cluster sequence for event $(ievt)")

examples/jetreco.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ function jet_process(events::Vector{Vector{T}};
3434
dump::Union{String, Nothing} = nothing) where {T <:
3535
JetReconstruction.FourMomentum}
3636

37+
# If we are dumping the results, setup the JSON structure
38+
if !isnothing(dump)
39+
jet_collection = FinalJets[]
40+
end
41+
3742
# Set consistent algorithm power
3843
p = JetReconstruction.get_algorithm_power(p = p, algorithm = algorithm)
3944
@info "Jet reconstruction will use $(algorithm) with power $(p)"
@@ -54,22 +59,22 @@ function jet_process(events::Vector{Vector{T}};
5459
strategy = strategy)
5560
# Now select jets, with inclusive or exclusive parameters
5661
if !isnothing(njets)
57-
finaljets = exclusive_jets(cluster_seq; njets = njets)
62+
selectedjets = exclusive_jets(cluster_seq; njets = njets)
5863
elseif !isnothing(dcut)
59-
finaljets = exclusive_jets(cluster_seq; dcut = dcut)
64+
selectedjets = exclusive_jets(cluster_seq; dcut = dcut)
6065
else
61-
finaljets = inclusive_jets(cluster_seq; ptmin = ptmin)
66+
selectedjets = inclusive_jets(cluster_seq; ptmin = ptmin)
6267
end
6368
@info begin
6469
jet_output = "Event $(ievt)\n"
65-
sort!(finaljets, by = x -> pt(x), rev = true)
66-
for (ijet, jet) in enumerate(finaljets)
70+
sort!(selectedjets, by = x -> pt(x), rev = true)
71+
for (ijet, jet) in enumerate(selectedjets)
6772
jet_output *= " $(ijet) - $(jet)\n"
6873
end
6974
"$(jet_output)"
7075
end
7176
if !isnothing(dump)
72-
push!(jet_collection, FinalJets(ievt, finaljets))
77+
push!(jet_collection, FinalJets(ievt, final_jets(selectedjets)))
7378
end
7479
end
7580

examples/test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ julia --project instrumented-jetreco.jl --algorithm=CA -R 1.0 ../test/data/event
1212
echo "pp 14TeV Kt"
1313
julia --project instrumented-jetreco.jl --algorithm=Kt -R 1.0 ../test/data/events.pp13TeV.hepmc3.zst
1414

15+
echo "pp 14TeV Kt with dump option"
16+
julia --project instrumented-jetreco.jl --algorithm=Kt -R 1.0 ../test/data/events.pp13TeV.hepmc3.zst --dump test-output-pp.csv
17+
1518
echo "ee H Durham allocation test"
1619
julia --project instrumented-jetreco.jl --algorithm=Durham --alloc ../test/data/events.eeH.hepmc3.zst
1720

@@ -21,3 +24,5 @@ julia --project jetreco.jl --algorithm=CA -R 1.0 ../test/data/events.pp13TeV.hep
2124
echo "ee basic reco test"
2225
julia --project jetreco.jl --algorithm=EEKt -R 1.0 -p -1.0 ../test/data/events.eeH.hepmc3.zst
2326

27+
echo "ee basic reco test with dump"
28+
julia --project jetreco.jl --algorithm=EEKt -R 1.0 -p -1.0 ../test/data/events.eeH.hepmc3.zst --dump test-output-ee.csv

0 commit comments

Comments
 (0)