@@ -16,7 +16,7 @@ using LorentzVectorHEP
1616using JetReconstruction
1717
1818# Backends for the jet reconstruction
19- @enumx T= Code Backends JetReconstruction Fastjet AkTPython AkTNumPy
19+ @enumx T= Code Backends JetReconstruction Fastjet AkTPython AkTNumPy CJetReconstruction
2020const AllCodeBackends = [String (Symbol (x)) for x in instances (Backends. Code)]
2121
2222# Parsing for Enum types
@@ -141,14 +141,15 @@ function julia_jet_process_avg_time(events::Vector{Vector{T}};
141141 lowest_time
142142end
143143
144- function fastjet_jet_process_avg_time (input_file:: AbstractString ;
145- ptmin:: Float64 = 5.0 ,
146- radius:: Float64 = 0.4 ,
147- p:: Union{Real, Nothing} = nothing ,
148- algorithm:: JetAlgorithm.Algorithm = JetAlgorithm. AntiKt,
149- strategy:: RecoStrategy.Strategy ,
150- nsamples:: Integer = 1 )
151-
144+ function external_benchmark_avg_time (input_file:: AbstractString ;
145+ ptmin:: Float64 = 5.0 ,
146+ radius:: Float64 = 0.4 ,
147+ p:: Union{Real, Nothing} = nothing ,
148+ algorithm:: JetAlgorithm.Algorithm = JetAlgorithm. AntiKt,
149+ strategy:: RecoStrategy.Strategy ,
150+ nsamples:: Integer = 1 ,
151+ backend:: Backends.Code = Backends. Fastjet)
152+
152153 # FastJet reader cannot handle gzipped files
153154 if endswith (input_file, " .gz" )
154155 input_file = hepmc3gunzip (input_file)
@@ -158,19 +159,29 @@ function fastjet_jet_process_avg_time(input_file::AbstractString;
158159 p = JetReconstruction. get_algorithm_power (p = p, algorithm = algorithm)
159160
160161 # @warn "FastJet timing not implemented yet"
161- fj_bin = joinpath (@__DIR__ , " .." , " fastjet" , " build" , " fastjet-finder" )
162- fj_args = String[]
163- push! (fj_args, " -p" , string (p))
164- push! (fj_args, " -s" , string (strategy))
165- push! (fj_args, " -R" , string (radius))
166- push! (fj_args, " --ptmin" , string (ptmin))
162+ if backend == Backends. Fastjet
163+ bench_dir = " fastjet"
164+ bench_name = " fastjet-finder"
165+ elseif backend == Backends. CJetReconstruction
166+ bench_dir = " cjetreconstruction"
167+ bench_name = " cjetreconstruction-finder"
168+ else
169+ @error " Unsupported backend for external benchmark: $backend "
170+ return 0.0
171+ end
172+ bench_bin = joinpath (@__DIR__ , " .." , bench_dir, " build" , bench_name)
173+ bench_args = String[]
174+ push! (bench_args, " -p" , string (p))
175+ push! (bench_args, " -s" , string (strategy))
176+ push! (bench_args, " -R" , string (radius))
177+ push! (bench_args, " --ptmin" , string (ptmin))
167178
168- push! (fj_args , " -n" , string (nsamples))
169- @info " Fastjet command: $fj_bin $fj_args $input_file "
170- fj_output = read (` $fj_bin $fj_args $input_file ` , String)
171- min = tryparse (Float64, match (r" Lowest time per event ([\d\. ]+) us" , fj_output )[1 ])
179+ push! (bench_args , " -n" , string (nsamples))
180+ @info " Benchmark command: $bench_bin $bench_args $input_file "
181+ bench_output = read (` $bench_bin $bench_args $input_file ` , String)
182+ min = tryparse (Float64, match (r" Lowest time per event ([\d\. ]+) us" , bench_output )[1 ])
172183 if isnothing (min)
173- @error " Failed to parse output from FastJet script"
184+ @error " Failed to parse output from external benchmark script"
174185 return 0.0
175186 end
176187 min
@@ -370,13 +381,14 @@ function main()
370381 p = args[:power ],
371382 strategy = args[:strategy ],
372383 nsamples = samples, repeats = args[:repeats ])
373- elseif args[:code ] == Backends. Fastjet
374- time_per_event = fastjet_jet_process_avg_time (event_file; ptmin = args[:ptmin ],
384+ elseif args[:code ] ∈ ( Backends. Fastjet, Backends . CJetReconstruction)
385+ time_per_event = external_benchmark_avg_time (event_file; ptmin = args[:ptmin ],
375386 radius = args[:radius ],
376387 algorithm = args[:algorithm ],
377388 p = args[:power ],
378389 strategy = args[:strategy ],
379- nsamples = samples)
390+ nsamples = samples,
391+ backend = args[:code ])
380392 elseif args[:code ] in (Backends. AkTPython, Backends. AkTNumPy)
381393 time_per_event = python_jet_process_avg_time (args[:code ], event_file; ptmin = args[:ptmin ],
382394 radius = args[:radius ],
0 commit comments