Skip to content

Commit fa265fe

Browse files
Improved animation script (#189)
* Improved animation script Allow framerate, extra frames and title to be specified. Small patch to the HepMC3 summary script to print the particle density per event. * Add ancestors option
1 parent 1270f05 commit fa265fe

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

examples/visualisation/animate-reconstruction.jl

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function main()
2626
"--algorithm", "-A"
2727
help = """Algorithm to use for jet reconstruction: $(join(JetReconstruction.AllJetRecoAlgorithms, ", "))"""
2828
arg_type = JetAlgorithm.Algorithm
29+
default = JetAlgorithm.AntiKt
2930

3031
"--power", "-p"
3132
help = """Power value for jet reconstruction"""
@@ -36,6 +37,23 @@ function main()
3637
arg_type = RecoStrategy.Strategy
3738
default = RecoStrategy.Best
3839

40+
"--ancestors", "-a"
41+
help = """Show ancestors of jets in the animation"""
42+
action = :store_true
43+
44+
"--title", "-t"
45+
help = """Title for animation"""
46+
47+
"--framerate"
48+
help = """Framerate per second"""
49+
arg_type = Int
50+
default = 10
51+
52+
"--end-frames"
53+
help = """Number of end frames to pad animation with"""
54+
arg_type = Int
55+
default = 0
56+
3957
"file"
4058
help = "HepMC3 event file in HepMC3 to read"
4159
required = true
@@ -52,17 +70,14 @@ function main()
5270
events::Vector{Vector{PseudoJet}} = read_final_state_particles(args[:file],
5371
maxevents = args[:event],
5472
skipevents = args[:event])
55-
if isnothing(args[:algorithm]) && isnothing(args[:power])
56-
@warn "Neither algorithm nor power specified, defaulting to AntiKt"
57-
args[:algorithm] = JetAlgorithm.AntiKt
58-
end
5973
cs = jet_reconstruct(events[1], R = args[:distance], p = args[:power],
6074
algorithm = args[:algorithm],
6175
strategy = args[:strategy])
6276

6377
animatereco(cs, args[:output]; azimuth = (1.8, 3.0), elevation = 0.5,
64-
perspective = 0.5, framerate = 20, ancestors = true,
65-
barsize_phi = 0.1, barsize_y = 0.3)
78+
perspective = 0.5, ancestors = args[:ancestors],
79+
barsize_phi = 0.1, barsize_y = 0.3, title = args[:title],
80+
framerate = args[:framerate], end_frames = args[:end_frames])
6681

6782
@info "Saved jet reconstruction animation to $(args[:output])"
6883
end

test/data/hepmc32summary.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function parse_command_line(args)
2323
arg_type = Int
2424
default = 0
2525

26+
"--details"
27+
help = "Print per-event density"
28+
action = :store_true
29+
2630
"files"
2731
help = "The HepMC3 event files to read."
2832
required = true
@@ -43,6 +47,11 @@ function main()
4347
for e in events
4448
push!(n_particles, length(e))
4549
end
50+
if args[:details]
51+
for (i, n) in enumerate(n_particles)
52+
println("Event $i: $n")
53+
end
54+
end
4655
average_n = mean(n_particles)
4756
if args[:summary]
4857
println("$file,$average_n")

0 commit comments

Comments
 (0)