Skip to content
Snippets Groups Projects
Verified Commit f985f64a authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Add utility functions

parent 0507f762
No related branches found
No related tags found
1 merge request!4Add utility functions
Pipeline #61188 failed
......@@ -14,11 +14,14 @@ using ColorSchemes
export update!, clearhits!, setfps!, add!, recolor!, describe!
export generate_colors, save_perspective, load_perspective
export global_scene
export select_first_hits, select_cherenkov_hits
include("params.jl")
include("core.jl")
include("interactivity.jl")
include("runtime.jl")
include("artists.jl")
include("utils.jl")
end # module
const _rba = RBA(Detector(joinpath(@__DIR__, "assets", "km3net_jul13_90m_r1494_corrected.detx")))
"""
global_scene()
Returns the GLMakie scene of the global RainbowAlga instance
"""
global_scene() = _rba.scene
"""
Select hits within a specific Cherenkov time window with respect to the given track.
"""
function select_cherenkov_hits(hits::T, track; mintot=20, maxtot=255, tmin=-50, tmax=500) where T
hits = filter(h -> mintot < h.tot < maxtot, hits)
out = T()
for hit in hits
chit = cherenkov(track, hit)
if tmin < chit.Δt < tmax
push!(out, hit)
end
end
sort(out; by=h->h.t)
end
"""
Select the first `n` hits on each PMT.
"""
function select_first_hits(hits::T; n=1, mintot=20, maxtot=255) where T
hits = filter(h -> mintot < h.tot < maxtot, hits)
out = T()
sort!(hits; by=h->h.t)
pmts = Dict{Tuple{Int, Int}, Int}()
for hit in hits
pmtkey = (hit.dom_id, hit.channel_id)
if !(pmtkey in keys(pmts))
pmts[pmtkey] = 1
end
pmts[pmtkey] > n && continue
pmts[pmtkey] += 1
push!(out, hit)
end
out
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment