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

Restructure tools

parent 394d9921
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,10 @@ include("daq.jl")
include("acoustics.jl")
include("calibration.jl")
include("tools.jl")
include("tools/general.jl")
include("tools/trigger.jl")
include("tools/reconstruction.jl")
include("physics.jl")
end # module
"""
Return `true` if the passed object (hit, event, ...) was triggered by any trigger algorithm.
"""
triggered(e) = e.trigger_mask > 0
"""
Return `true` if the n-th bit of `a` is set, `false` otherwise.
"""
nthbitset(n, a) = Bool((a >> n) & 1)
"""
$(METHODLIST)
Return `true` the 3D Muon trigger bit is set.
"""
is3dmuon(e::DAQEvent) = nthbitset(TRIGGER.JTRIGGER3DMUON, e.header.trigger_mask)
is3dmuon(x) = nthbitset(TRIGGER.JTRIGGER3DMUON, x)
"""
$(METHODLIST)
Return `true` if the 3D Shower trigger bit is set.
"""
is3dshower(e::DAQEvent) = nthbitset(TRIGGER.JTRIGGER3DSHOWER, e.header.trigger_mask)
is3dshower(x) = nthbitset(TRIGGER.JTRIGGER3DSHOWER, x)
"""
$(METHODLIST)
Return `true` if the MX Shower trigger bit is set.
"""
ismxshower(x) = nthbitset(TRIGGER.JTRIGGERMXSHOWER, x)
ismxshower(e::DAQEvent) = nthbitset(TRIGGER.JTRIGGERMXSHOWER, e.header.trigger_mask)
"""
$(METHODLIST)
Return `true` if the NanoBeacon trigger bit is set.
"""
isnb(x) = nthbitset(TRIGGER.JTRIGGERNB, x)
isnb(e::DAQEvent) = nthbitset(TRIGGER.JTRIGGERNB, e.header.trigger_mask)
"""
Return the most frequent value of a given iterable.
"""
......
"""
This struct is used to represent a range of reconstruction stages. These are
well-defined integers (see [KM3NeT
Dataformat](https://git.km3net.de/common/km3net-dataformat/-/blob/master/definitions/reconstruction.csv))
for each reconstruction algorithm and are stored in a vector named `rec_stages`
of each [`Trk`](@ref).
```jldoctest
julia> using KM3io
julia> rsr = RecStageRange(KM3io.RECONSTRUCTION.JMUONBEGIN, KM3io.RECONSTRUCTION.JMUONEND)
RecStageRange{Int64}(0, 99)
julia> KM3io.RECONSTRUCTION.JMUONSIMPLEX ∈ rsr
true
julia> KM3io.RECONSTRUCTION.AASHOWERFITPREFIT ∈ rsr
false
julia> 23 ∈ rsr
true
julia> 523 ∈ rsr
false
```
"""
struct RecStageRange{T<:Integer}
lower::T
upper::T
end
Base.in(rec_stage::T, rsr::RecStageRange) where T<:Integer = rsr.lower <= rec_stage <= rsr.upper
function hashistory(t::Trk, rec_type::Integer, rsr::RecStageRange)
rec_type != t.rec_type && return false
for rec_stage in t.rec_stages
!(rec_stage rsr) && return false
end
true
end
function hashistory(t::Trk, rec_type::Integer, rec_stage::Integer)
rec_type != t.rec_type && return false
rec_stage t.rec_stages
end
hasjppmuonprefit(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RECONSTRUCTION.JMUONPREFIT)
hasjppmuonsimplex(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RECONSTRUCTION.JMUONSIMPLEX)
hasjppmuongandalf(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RECONSTRUCTION.JMUONGANDALF)
hasjppmuonenergy(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RECONSTRUCTION.JMUONENERGY)
hasjppmuonstart(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RECONSTRUCTION.JMUONSTART)
hasjppmuonfit(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RecStageRange(RECONSTRUCTION.JMUONBEGIN, RECONSTRUCTION.JMUONEND))
hasshowerprefit(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RECONSTRUCTION.JSHOWERPREFIT)
hasshowerpositionfit(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RECONSTRUCTION.JSHOWERPOSITIONFIT)
hasshowercompletefit(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RECONSTRUCTION.JSHOWERCOMPLETEFIT)
hasshowerfit(t::Trk) = hashistory(t, RECONSTRUCTION.JPP_RECONSTRUCTION_TYPE, RecStageRange(RECONSTRUCTION.JSHOWERBEGIN, RECONSTRUCTION.JSHOWEREND))
hasaashowerfit(t::Trk) = hashistory(t, RECONSTRUCTION.AANET_RECONSTRUCTION_TYPE, RecStageRange(RECONSTRUCTION.AASHOWERBEGIN, RECONSTRUCTION.AASHOWEREND))
hasreconstructedjppmuon(e::Evt) = any(hasjppmuonfit, e.trks)
hasreconstructedjppshower(e::Evt) = any(hasshowerfit, e.trks)
hasreconstructedaashower(e::Evt) = any(hasaashowerfit, e.trks)
function besttrack(e::Evt, rsr::RecStageRange)
error("not implemented yet")
end
"""
Return `true` if the passed object (hit, event, ...) was triggered by any trigger algorithm.
"""
triggered(e) = e.trigger_mask > 0
"""
$(METHODLIST)
Return `true` the 3D Muon trigger bit is set.
"""
is3dmuon(e::DAQEvent) = nthbitset(TRIGGER.JTRIGGER3DMUON, e.header.trigger_mask)
is3dmuon(x) = nthbitset(TRIGGER.JTRIGGER3DMUON, x)
"""
$(METHODLIST)
Return `true` if the 3D Shower trigger bit is set.
"""
is3dshower(e::DAQEvent) = nthbitset(TRIGGER.JTRIGGER3DSHOWER, e.header.trigger_mask)
is3dshower(x) = nthbitset(TRIGGER.JTRIGGER3DSHOWER, x)
"""
$(METHODLIST)
Return `true` if the MX Shower trigger bit is set.
"""
ismxshower(x) = nthbitset(TRIGGER.JTRIGGERMXSHOWER, x)
ismxshower(e::DAQEvent) = nthbitset(TRIGGER.JTRIGGERMXSHOWER, e.header.trigger_mask)
"""
$(METHODLIST)
Return `true` if the NanoBeacon trigger bit is set.
"""
isnb(x) = nthbitset(TRIGGER.JTRIGGERNB, x)
isnb(e::DAQEvent) = nthbitset(TRIGGER.JTRIGGERNB, e.header.trigger_mask)
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