@@ -45,7 +45,7 @@ a vector of `FinalJet` objects, e.g.,
4545selector = (cs) -> exclusive_jets(cs; njets = 2)
4646```
4747"""
48- struct ComparisonTest
48+ struct ComparisonTest{T <: Real }
4949 events_file:: AbstractString
5050 fastjet_outputs:: AbstractString
5151 algorithm:: JetAlgorithm.Algorithm
@@ -54,14 +54,24 @@ struct ComparisonTest
5454 R:: Real
5555 selector:: Any
5656 selector_name:: AbstractString
57+ numtype:: Type{T}
58+ end
59+
60+ " Define the element type based off the type parameter"
61+ Base. eltype (:: Type{ComparisonTest{T}} ) where {T} = T
62+
63+ """ Constructor where there is no type given"""
64+ function ComparisonTest (events_file, fastjet_outputs, algorithm, strategy, power, R,
65+ selector, selector_name)
66+ ComparisonTest (events_file, fastjet_outputs, algorithm, strategy, power, R, selector,
67+ selector_name, Float64)
5768end
5869
5970""" Constructor where there is no selector_name given"""
6071function ComparisonTest (events_file, fastjet_outputs, algorithm, strategy, power, R,
6172 selector)
62- selector_name = " "
6373 ComparisonTest (events_file, fastjet_outputs, algorithm, strategy, power, R, selector,
64- selector_name )
74+ " " , Float64 )
6575end
6676
6777""" Read JSON file with fastjet jets in it"""
94104
95105function run_reco_test (test:: ComparisonTest ; testname = nothing )
96106 # Read the input events
97- events = JetReconstruction. read_final_state_particles (test. events_file)
107+ if JetReconstruction. is_pp (test. algorithm)
108+ events = JetReconstruction. read_final_state_particles (test. events_file;
109+ T = PseudoJet{test. numtype})
110+ else
111+ events = JetReconstruction. read_final_state_particles (test. events_file;
112+ T = EEjet{test. numtype})
113+ end
98114 # Read the fastjet results
99115 fastjet_jets = read_fastjet_outputs (test. fastjet_outputs)
100116 sort_jets! (fastjet_jets)
@@ -117,6 +133,16 @@ function run_reco_test(test::ComparisonTest; testname = nothing)
117133 end
118134 end
119135
136+ # For Float64 we use a tolerance of 1e-6
137+ # For Float32 we use a tolerance of 1e-2, which is very low
138+ # but the problem is that we are comparing with FastJet in double
139+ # precision and in an iterative algorithm, this can lead to accumulating
140+ # differences that end up quite large
141+ tol = 1e-6
142+ if test. numtype == Float32
143+ tol = 1e-2
144+ end
145+
120146 @testset " $testname " begin
121147 # Test each event in turn...
122148 for (ievt, event) in enumerate (jet_collection)
@@ -131,9 +157,9 @@ function run_reco_test(test::ComparisonTest; testname = nothing)
131157 # the momentum
132158 # Sometimes phi could be in the range [-π, π], but FastJet always is [0, 2π]
133159 normalised_phi = jet. phi < 0.0 ? jet. phi + 2 π : jet. phi
134- @test jet. rap≈ fastjet_jets[ievt][" jets" ][ijet][" rap" ] atol = 1e-7
135- @test normalised_phi≈ fastjet_jets[ievt][" jets" ][ijet][" phi" ] atol = 1e-7
136- @test jet. pt≈ fastjet_jets[ievt][" jets" ][ijet][" pt" ] rtol= 1e-6
160+ @test jet. rap≈ fastjet_jets[ievt][" jets" ][ijet][" rap" ] rtol = tol
161+ @test normalised_phi≈ fastjet_jets[ievt][" jets" ][ijet][" phi" ] rtol = tol
162+ @test jet. pt≈ fastjet_jets[ievt][" jets" ][ijet][" pt" ] rtol= tol
137163 end
138164 end
139165 end
0 commit comments