Skip to content

Commit 1b245ba

Browse files
Small improvement to EDM4hep test script
1 parent 23e81fd commit 1b245ba

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

examples/EDM4hep/EDM4hepJets.jl

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ function parse_command_line(args)
1212
arg_type = Int
1313
default = 1
1414

15+
"--printjets"
16+
help = "Print reconstructed jets (selecting njets from the reconstructed event)"
17+
action = :store_true
18+
19+
"--njets"
20+
help = "Number of jets to output"
21+
arg_type = Int
22+
default = 2
23+
1524
"file"
1625
help = "EDM4hep events file to read"
1726
required = true
@@ -25,25 +34,39 @@ function main()
2534
global_logger(logger)
2635

2736
# Open input event file
37+
global_timer_start = time_ns()
2838
reader = RootIO.Reader(args[:file])
2939
events = RootIO.get(reader, "events")
3040

41+
total_time = 0.0
42+
count = 0
43+
3144
# Reconstruct each event
3245
for (ievt, evt) in enumerate(events)
46+
count += 1
3347
if args[:maxevents] > 0 && ievt > args[:maxevents]
3448
break
3549
end
3650
recps = RootIO.get(reader, evt, "ReconstructedParticles")
3751

52+
start_jet = time_ns()
3853
cs = jet_reconstruct(recps; algorithm = JetAlgorithm.Durham)
39-
@info begin
40-
jets = "Event $(ievt)\n"
41-
for jet in exclusive_jets(cs; njets = 2, T = EEjet)
42-
jets *= " $jet\n"
54+
end_jet = time_ns()
55+
total_time += end_jet - start_jet
56+
if args[:printjets]
57+
@info begin
58+
jets = "Event $(ievt)\n"
59+
for jet in exclusive_jets(cs; njets = args[:njets], T = EEjet)
60+
jets *= " $jet\n"
61+
end
62+
jets
4363
end
44-
jets
4564
end
4665
end
66+
global_timer_stop = time_ns()
67+
@info "Reconstructed $(count) events in $(total_time/1.0e9)s: rate = $((count * 1.0e9) / total_time)Hz"
68+
@info "Total time: $((global_timer_stop - global_timer_start)/1.0e9)s"
69+
count, total_time
4770
end
4871

4972
main()

0 commit comments

Comments
 (0)