Skip to content

Commit

Permalink
More robust specification of paths
Browse files Browse the repository at this point in the history
Use the @__DIR__ macro and the joinpath() function
  • Loading branch information
graeme-a-stewart committed Apr 17, 2024
1 parent 2e9c949 commit 8ff79d5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using LorentzVectorHEP
using Logging

"""Read JSON file with fastjet jets in it"""
function read_fastjet_outputs(; fname = "test/data/jet_collections_fastjet_akt.json")
function read_fastjet_outputs(fname)
f = open(fname)
JSON.parse(f)
end
Expand Down Expand Up @@ -35,13 +35,13 @@ function main()
algorithms = Dict(-1 => "Anti-kt",
0 => "Cambridge/Achen",
1 => "Inclusive-kt")
fastjet_alg_files = Dict(-1 => "test/data/jet_collections_fastjet_akt.json",
0 => "test/data/jet_collections_fastjet_ca.json",
1 => "test/data/jet_collections_fastjet_ikt.json")
fastjet_alg_files = Dict(-1 => joinpath(@__DIR__, "data", "jet_collections_fastjet_akt.json"),
0 => joinpath(@__DIR__, "data", "jet_collections_fastjet_ca.json"),
1 => joinpath(@__DIR__, "data", "jet_collections_fastjet_ikt.json"))

fastjet_data = Dict{Int, Vector{Any}}()
for (k, v) in pairs(fastjet_alg_files)
fastjet_jets = read_fastjet_outputs(fname = v)
fastjet_jets = read_fastjet_outputs(v)
sort_jets!(fastjet_jets)
fastjet_data[k] = fastjet_jets
end
Expand Down Expand Up @@ -76,7 +76,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("test/data/events.hepmc3")
events::Vector{Vector{PseudoJet}} = read_final_state_particles(joinpath(@__DIR__, "data", "events.hepmc3"))
jet_collection = FinalJets[]
for (ievt, event) in enumerate(events)
finaljets = final_jets(inclusive_jets(jet_reconstruction(event, R = distance, p = power), ptmin))
Expand Down Expand Up @@ -127,7 +127,7 @@ function do_test_compare_types(strategy::JetRecoStrategy.Strategy;

# Now run our jet reconstruction...
# From PseudoJets
events::Vector{Vector{PseudoJet}} = read_final_state_particles("test/data/events.hepmc3")
events::Vector{Vector{PseudoJet}} = read_final_state_particles(joinpath(@__DIR__, "data", "events.hepmc3"))
jet_collection = FinalJets[]
for (ievt, event) in enumerate(events)
finaljets = final_jets(inclusive_jets(jet_reconstruction(event, R = distance, p = power), ptmin))
Expand All @@ -136,7 +136,7 @@ function do_test_compare_types(strategy::JetRecoStrategy.Strategy;
end

# From LorentzVector
events_lv::Vector{Vector{LorentzVector}} = read_final_state_particles_lv("test/data/events.hepmc3")
events_lv::Vector{Vector{LorentzVector}} = read_final_state_particles_lv(joinpath(@__DIR__, "data", "events.hepmc3"))
jet_collection_lv = FinalJets[]
for (ievt, event) in enumerate(events_lv)
finaljets = final_jets(inclusive_jets(jet_reconstruction(event, R = distance, p = power), ptmin))
Expand Down

0 comments on commit 8ff79d5

Please sign in to comment.