Skip to content

Commit 16d3bf6

Browse files
Fastjet cmake and benchmark fixes (#13)
* Update fastjet-finder CMake CMakeLists file now is adapted for modern Fastjet versions that are built with CMake (>=3.5.0). Old FindFastJet.cmake is removed. * Fix argument name in README * Consistency update for fastjet-finder Align the arguments for fastjet-finder to be the same as those for the Julia test scripts, e.g., -m or --nsamples for the number of trial repeats. Ensure that algorithm and power values from benchmark.jl are correctly passed to fastjet-finder. It seems the algorithm setting was actually being _ignored_, meaning only pp-type algorithms actually got run. * Set fastjet output to "debug" * Update antikt-python to new tag
1 parent a0ee839 commit 16d3bf6

File tree

7 files changed

+22
-60
lines changed

7 files changed

+22
-60
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ The `benchmark.jl` script has quite a few options used for detailed control of
133133
the jobs it runs. The most important ones are:
134134

135135
```sh
136-
julia --project benchmark.jl --code CODE --algorithm ALG --strategy STRAT --trials TRIALS INPUT_FILE(S)
136+
julia --project benchmark.jl --code CODE --algorithm ALG --strategy STRAT --nsamples TRIALS INPUT_FILE(S)
137137
```
138138

139139
The `CODE` option selects the code implementation:

antikt-python

fastjet/CMakeLists.txt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# CMake file for fastjet codes used for benchmarks and validation
22
#
3-
# (C) CERN, 2024
3+
# (C) CERN, 2024-2025
44
# MIT License
55

66
cmake_minimum_required(VERSION 3.12)
77
project(FastJetBenchmarks)
88

9-
# Add package utilities to CMake path
10-
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
11-
129
find_package(HepMC3 REQUIRED)
13-
find_package(FastJet REQUIRED)
10+
find_package(fastjet REQUIRED)
11+
find_package(siscone REQUIRED)
1412

1513
set(CMAKE_CXX_STANDARD 17)
1614

@@ -21,11 +19,6 @@ add_executable(fastjet-finder
2119
src/fastjet-utils.cc
2220
)
2321

24-
target_include_directories(fastjet-finder PRIVATE
25-
${FASTJET_INCLUDE_DIRS}
26-
)
27-
2822
target_link_libraries(fastjet-finder
29-
HepMC3::HepMC3
30-
${FASTJET_LIBRARIES}
23+
HepMC3::HepMC3 fastjet::fastjet
3124
)

fastjet/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ algorithms.
77
The code requires the fastjet libraries (<https://fastjet.fr/>) as well as those
88
from HepMC3 (<https://gitlab.cern.ch/hepmc/HepMC3>).
99

10-
Depending on your system setup you make need to add the path to the HepMC3 CMake
11-
setup files to `CMAKE_PREFIX_PATH`.
10+
Depending on your system setup you make need to add the path to the HepMC3 and
11+
Fastjet CMake setup files to `CMAKE_PREFIX_PATH`. It may also be necessary to
12+
set `siscone_DIR`.
1213

1314
## Compilation
1415

@@ -32,10 +33,11 @@ jets. This is the standard executable used to benchmark fastjet.
3233

3334
Allowed options:
3435
-h, --help produce help message
35-
-m, --maxevents arg (=-1) Maximum events in file to process (-1 = all events)
36-
-n, --trials arg (=1) Number of repeated trials
36+
-n, --maxevents arg (=-1) Maximum events in file to process (-1 = all events)
37+
-m, --nsamples arg (=1) Number of repeated trials
3738
-s, --strategy arg (=Best) Valid values are 'Best' (default), 'N2Plain', 'N2Tiled'
38-
-p, --power arg (=-1) Algorithm p value: -1=antikt, 0=cambridge_aachen, 1=inclusive kt
39+
-A, --algorithm arg Valid values are 'AntiKt' 'CA' 'Kt' 'GenKt' 'EEKt' 'Durham'
40+
-p, --power arg Algorithm p value, only needed for 'GenKt' and 'EEKt'
3941
-R, --radius arg (=0.4) Algorithm R parameter
4042
--ptmin arg pt cut for inclusive jets
4143
--dijmax arg dijmax value for exclusive jets

fastjet/cmake/FindFastJet.cmake

Lines changed: 0 additions & 26 deletions
This file was deleted.

fastjet/src/fastjet-finder.cc

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ int main(int argc, char* argv[]) {
8787

8888
OptionParser opts("Allowed options");
8989
auto help_option = opts.add<Switch>("h", "help", "produce help message");
90-
auto max_events_option = opts.add<Value<int>>("m", "maxevents", "Maximum events in file to process (-1 = all events)", maxevents, &maxevents);
90+
auto max_events_option = opts.add<Value<int>>("n", "maxevents", "Maximum events in file to process (-1 = all events)", maxevents, &maxevents);
9191
auto skip_events_option = opts.add<Value<int>>("", "skipevents", "Number of events to skip over (0 = none)", skip_events, &skip_events);
92-
auto trials_option = opts.add<Value<int>>("n", "trials", "Number of repeated trials", trials, &trials);
92+
auto trials_option = opts.add<Value<int>>("m", "nsamples", "Number of repeated trials", trials, &trials);
9393
auto strategy_option = opts.add<Value<string>>("s", "strategy", "Valid values are 'Best' (default), 'N2Plain', 'N2Tiled'", mystrategy, &mystrategy);
94-
auto power_option = opts.add<Value<double>>("p", "power", "Algorithm p value: -1=antikt, 0=cambridge_aachen, 1=inclusive kt; otherwise generalised Kt", power, &power);
9594
auto alg_option = opts.add<Value<string>>("A", "algorithm", "Algorithm: AntiKt CA Kt GenKt EEKt Durham (overrides power)", alg, &alg);
95+
auto power_option = opts.add<Value<double>>("p", "power", "Algorithm p value, only used/needed for GenKt and EEKt", power, &power);
9696
auto radius_option = opts.add<Value<double>>("R", "radius", "Algorithm R parameter", R, &R);
9797
auto recombine_option = opts.add<Value<string>>("", "recombine", "Recombination scheme for jet merging", recombine, &recombine);
9898
auto ptmin_option = opts.add<Value<double>>("", "ptmin", "pt cut for inclusive jets");
@@ -163,16 +163,6 @@ int main(int argc, char* argv[]) {
163163
std::cout << "Unknown algorithm type: " << alg << std::endl;
164164
exit(1);
165165
}
166-
} else {
167-
if (power == -1.0) {
168-
algorithm = fastjet::antikt_algorithm;
169-
} else if (power == 0.0) {
170-
algorithm = fastjet::cambridge_aachen_algorithm;
171-
} else if (power == 1.0) {
172-
algorithm = fastjet::kt_algorithm;
173-
} else {
174-
algorithm = fastjet::genkt_algorithm;
175-
}
176166
}
177167

178168
auto recombine_scheme = fastjet::RecombinationScheme::E_scheme;

src/benchmark.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,20 @@ function fastjet_jet_process_avg_time(input_file::AbstractString;
157157
# Get consistent algorithm power
158158
p = JetReconstruction.get_algorithm_power(p = p, algorithm = algorithm)
159159

160-
# @warn "FastJet timing not implemented yet"
161160
fj_bin = joinpath(@__DIR__, "..", "fastjet", "build", "fastjet-finder")
162161
fj_args = String[]
163-
push!(fj_args, "-p", string(p))
162+
push!(fj_args, "-A", string(algorithm))
163+
if !isnothing(p)
164+
push!(fj_args, "-p", string(p))
165+
end
164166
push!(fj_args, "-s", string(strategy))
165167
push!(fj_args, "-R", string(radius))
166168
push!(fj_args, "--ptmin", string(ptmin))
167169

168-
push!(fj_args, "-n", string(nsamples))
170+
push!(fj_args, "-m", string(nsamples))
169171
@info "Fastjet command: $fj_bin $fj_args $input_file"
170172
fj_output = read(`$fj_bin $fj_args $input_file`, String)
173+
@debug "Fastjet output:\n$fj_output"
171174
min = tryparse(Float64, match(r"Lowest time per event ([\d\.]+) us", fj_output)[1])
172175
if isnothing(min)
173176
@error "Failed to parse output from FastJet script"

0 commit comments

Comments
 (0)