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

Finalise summaryslice parsing

parent cca0b632
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ Base.getindex(c::EventContainer, idx::Integer) = DAQEvent(c.headers[idx], c.snap
Base.getindex(c::EventContainer, r::UnitRange) = [c[idx] for idx r]
Base.getindex(c::EventContainer, mask::BitArray) = [c[idx] for (idx, selected) enumerate(mask) if selected]
Base.length(c::EventContainer) = length(c.headers)
Base.eltype(c::EventContainer) = DAQEvent
Base.eltype(::EventContainer) = DAQEvent
function Base.iterate(c::EventContainer, state=1)
state > length(c) ? nothing : (DAQEvent(c.headers[state], c.snapshot_hits[state], c.triggered_hits[state]), state+1)
end
......@@ -76,7 +76,7 @@ function UnROOT.interped_data(rawdata, rawoffsets, ::Type{SummarysliceHeader}, :
UnROOT.splitup(rawdata, rawoffsets, SummarysliceHeader, jagged=false)
end
UnROOT.packedsizeof(::Type{SummaryFrame}) = 120 # incl. cnt and vers
UnROOT.packedsizeof(::Type{SummaryFrame}) = 79 # incl. cnt and vers
function UnROOT.readtype(io, T::Type{SummaryFrame})
dom_id = UnROOT.readtype(io, Int32)
dq_status = UnROOT.readtype(io, UInt32)
......@@ -92,12 +92,32 @@ end
function UnROOT.interped_data(rawdata, rawoffsets, ::Type{Vector{SummaryFrame}}, ::Type{T}) where {T <: UnROOT.JaggType}
UnROOT.splitup(rawdata, rawoffsets, SummaryFrame, skipbytes=10)
end
struct SummarysliceContainer
headers
summaryslices
end
struct Summaryslice
header::SummarysliceHeader
frames::Vector{SummaryFrame}
end
Base.getindex(c::SummarysliceContainer, idx::Integer) = Summaryslice(c.headers[idx], c.summaryslices[idx])
Base.getindex(c::SummarysliceContainer, r::UnitRange) = [c[idx] for idx r]
Base.getindex(c::SummarysliceContainer, mask::BitArray) = [c[idx] for (idx, selected) enumerate(mask) if selected]
Base.length(c::SummarysliceContainer) = length(c.headers)
Base.eltype(::SummarysliceContainer) = Summaryslice
function Base.iterate(c::SummarysliceContainer, state=1)
state > length(c) ? nothing : (c[state], state+1)
end
function Base.show(io::IO, c::SummarysliceContainer)
print(io, "$(typeof(c)) with $(length(c.headers)) summaryslices")
end
struct OnlineFile
_fobj::UnROOT.ROOTFile
events::EventContainer
summaryslices::SummarysliceContainer
function OnlineFile(filename::AbstractString)
customstructs = Dict(
......@@ -113,8 +133,13 @@ struct OnlineFile
EventContainer(
LazyBranch(fobj, "KM3NET_EVENT/KM3NET_EVENT/KM3NETDAQ::JDAQEventHeader"),
LazyBranch(fobj, "KM3NET_EVENT/KM3NET_EVENT/snapshotHits"),
LazyBranch(fobj, "KM3NET_EVENT/KM3NET_EVENT/triggeredHits"))
LazyBranch(fobj, "KM3NET_EVENT/KM3NET_EVENT/triggeredHits"),
),
SummarysliceContainer(
LazyBranch(fobj, "KM3NET_SUMMARYSLICE/KM3NET_SUMMARYSLICE/KM3NETDAQ::JDAQSummarysliceHeader"),
LazyBranch(fobj, "KM3NET_SUMMARYSLICE/KM3NET_SUMMARYSLICE/vector<KM3NETDAQ::JDAQSummaryFrame>")
)
)
end
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