Skip to content

Commit 2727c4d

Browse files
Fixes for type variation from CLI
Allow instrumented-jetreco to have a type argument that makes the particle collection have that specific type, allowing for switches to different Floats N.B, Currently Float32 is slower than Float64
1 parent 19d690d commit 2727c4d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

examples/instrumented-jetreco.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ function parse_command_line(args)
273273
arg_type = RecoStrategy.Strategy
274274
default = RecoStrategy.Best
275275

276+
"--type", "-T"
277+
help = """Numerical type to use for the reconstruction (Float32, Float64)"""
278+
arg_type = Symbol
279+
default = :Float64
280+
276281
"--nsamples", "-m"
277282
help = "Number of measurement points to acquire."
278283
arg_type = Int
@@ -331,9 +336,9 @@ function main()
331336

332337
# Try to read events into the correct type!
333338
if JetReconstruction.is_ee(args[:algorithm])
334-
jet_type = EEjet
339+
jet_type = EEjet{eval(args[:type])}
335340
else
336-
jet_type = PseudoJet
341+
jet_type = PseudoJet{eval(args[:type])}
337342
end
338343
events::Vector{Vector{jet_type}} = read_final_state_particles(args[:file],
339344
maxevents = args[:maxevents],

src/EEjet.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ function EEjet(px::T, py::T, pz::T, E::T, _cluster_hist_index::Integer) where {T
3333
EEjet{T}(px, py, pz, E, p2, inv_p, _cluster_hist_index)
3434
end
3535

36+
# Constructor with type T passes through without history index
3637
EEjet(px::T, py::T, pz::T, E::T) where {T <: Real} = EEjet(px, py, pz, E, 0)
37-
EEjet{T}(px::T, py::T, pz::T, E::T) where {T <: Real} = EEjet(px, py, pz, E, 0)
38+
39+
# Constructor with type U does type conversion before initialising
40+
EEjet{U}(px::T, py::T, pz::T, E::T) where {T <: Real, U <: Real} = EEjet(U(px), U(py), U(pz), U(E), 0)
3841

3942
EEjet(pj::PseudoJet) = EEjet(px(pj), py(pj), pz(pj), energy(pj), cluster_hist_index(pj))
4043

0 commit comments

Comments
 (0)