diff --git a/src/Utils.jl b/src/Utils.jl index 9fe8a5b..62c71e4 100644 --- a/src/Utils.jl +++ b/src/Utils.jl @@ -20,6 +20,7 @@ function read_final_state_particles(fname; maxevents = -1, skipevents = 0) push!(events, input_particles) ipart += 1 end + close(f) @info "Total Events: $(length(events))" @debug events @@ -46,6 +47,7 @@ function read_final_state_particles_lv(fname; maxevents = -1, skipevents = 0) push!(events, input_particles) ipart += 1 end + close(f) @info "Total Events: $(length(events))" @debug events diff --git a/test/data/events.hepmc3.gz b/test/data/events.hepmc3.gz deleted file mode 100644 index fb9067f..0000000 Binary files a/test/data/events.hepmc3.gz and /dev/null differ diff --git a/test/data/events.hepmc3.xz b/test/data/events.hepmc3.xz new file mode 100644 index 0000000..c6b4841 Binary files /dev/null and b/test/data/events.hepmc3.xz differ diff --git a/test/runtests.jl b/test/runtests.jl index 78f91b7..acbcb73 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,6 +6,24 @@ using JSON using LorentzVectorHEP using Logging +const events_file = joinpath(@__DIR__, "data", "events.hepmc3") + +"""Decompress data file, if necessary""" +function unpack_events(file) + # File already there? + if isfile(file) + return true + end + # LZMA source? + file_compressed = joinpath(dirname(file), basename(file)*".xz") + if isfile(file_compressed) + @debug "Unpacking $(file_compressed)" + run(pipeline(`xzcat $file_compressed`, stdout=file)) + return true + end + false +end + """Read JSON file with fastjet jets in it""" function read_fastjet_outputs(fname) f = open(fname) @@ -31,6 +49,9 @@ function sort_jets!(jet_array::Vector{LorentzVectorCyl}) end function main() + # If necessary, unzip the events data file + unpack_events(events_file) + # Read our fastjet outputs (we read for anti-kt, cambridge/achen, inclusive-kt) algorithms = Dict(-1 => "Anti-kt", 0 => "Cambridge/Achen", @@ -76,7 +97,7 @@ function do_test_compare_to_fastjet(strategy::JetRecoStrategy.Strategy, fastjet_ # Now run our jet reconstruction... # From PseudoJets - events::Vector{Vector{PseudoJet}} = read_final_state_particles(joinpath(@__DIR__, "data", "events.hepmc3")) + events::Vector{Vector{PseudoJet}} = read_final_state_particles(events_file) jet_collection = FinalJets[] for (ievt, event) in enumerate(events) finaljets = final_jets(inclusive_jets(jet_reconstruction(event, R = distance, p = power), ptmin)) @@ -127,7 +148,7 @@ function do_test_compare_types(strategy::JetRecoStrategy.Strategy; # Now run our jet reconstruction... # From PseudoJets - events::Vector{Vector{PseudoJet}} = read_final_state_particles(joinpath(@__DIR__, "data", "events.hepmc3")) + events::Vector{Vector{PseudoJet}} = read_final_state_particles(events_file) jet_collection = FinalJets[] for (ievt, event) in enumerate(events) finaljets = final_jets(inclusive_jets(jet_reconstruction(event, R = distance, p = power), ptmin)) @@ -136,7 +157,7 @@ function do_test_compare_types(strategy::JetRecoStrategy.Strategy; end # From LorentzVector - events_lv::Vector{Vector{LorentzVector}} = read_final_state_particles_lv(joinpath(@__DIR__, "data", "events.hepmc3")) + events_lv::Vector{Vector{LorentzVector}} = read_final_state_particles_lv(events_file) jet_collection_lv = FinalJets[] for (ievt, event) in enumerate(events_lv) finaljets = final_jets(inclusive_jets(jet_reconstruction(event, R = distance, p = power), ptmin))