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

Add summaryslice header readout and preliminary summaryframe parsing logic

parent 3bfdc9ad
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,40 @@ function Base.show(io::IO, e::EventContainer)
print(io, "$(typeof(e)) with $(length(e.headers)) events")
end
packedsizeof(::Type{SummarysliceHeader}) = 44
function UnROOT.readtype(io::IO, T::Type{SummarysliceHeader})
skip(io, 18)
detector_id = UnROOT.readtype(io, Int32)
run = UnROOT.readtype(io, Int32)
frame_index = UnROOT.readtype(io, Int32)
skip(io, 6)
UTC_seconds = UnROOT.readtype(io, UInt32)
UTC_16nanosecondcycles = UnROOT.readtype(io, UInt32)
T(detector_id, run, frame_index, UTCExtended(UTC_seconds, UTC_16nanosecondcycles))
end
function UnROOT.interped_data(rawdata, rawoffsets, ::Type{SummarysliceHeader}, ::Type{T}) where {T <: UnROOT.JaggType}
UnROOT.splitup(rawdata, rawoffsets, SummarysliceHeader, jagged=false)
end
UnROOT.packedsizeof(::Type{SummaryFrame}) = 120 # incl. cnt and vers
function UnROOT.readtype(io, T::Type{SummaryFrame})
dom_id = UnROOT.readtype(io, Int32)
dq_status = UnROOT.readtype(io, UInt32)
hrv = UnROOT.readtype(io, UInt32)
fifo = UnROOT.readtype(io, UInt32)
status3 = UnROOT.readtype(io, UInt32)
status4 = UnROOT.readtype(io, UInt32)
rates = [UnROOT.read(io, UInt8) for i 1:31]
# burn one byte
#read(io, UInt8)
T(dom_id, dq_status, hrv, fifo, status3, status4, rates)
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 OnlineFile
_fobj::UnROOT.ROOTFile
events::EventContainer
......@@ -61,7 +95,9 @@ struct OnlineFile
customstructs = Dict(
"KM3NETDAQ::JDAQEvent.snapshotHits" => Vector{SnapshotHit},
"KM3NETDAQ::JDAQEvent.triggeredHits" => Vector{TriggeredHit},
"KM3NETDAQ::JDAQEvent.KM3NETDAQ::JDAQEventHeader" => EventHeader
"KM3NETDAQ::JDAQEvent.KM3NETDAQ::JDAQEventHeader" => EventHeader,
"KM3NETDAQ::JDAQSummaryslice.KM3NETDAQ::JDAQSummarysliceHeader" => SummarysliceHeader,
"KM3NETDAQ::JDAQSummaryslice.vector<KM3NETDAQ::JDAQSummaryFrame>" => Vector{SummaryFrame}
)
fobj = UnROOT.ROOTFile(filename, customstructs=customstructs)
......@@ -71,6 +107,7 @@ struct OnlineFile
LazyBranch(fobj, "KM3NET_EVENT/KM3NET_EVENT/snapshotHits"),
LazyBranch(fobj, "KM3NET_EVENT/KM3NET_EVENT/triggeredHits"))
)
end
end
Base.close(c::OnlineFile) = close(f._fobj)
......
......@@ -60,6 +60,23 @@ struct UTCExtended
end
end
struct SummaryFrame
dom_id::Int32
dq_status::UInt32
hrv::UInt32
fifo::UInt32
status3::UInt32
status4::UInt32
rates::Vector{UInt8}
end
struct SummarysliceHeader
detector_id::Int32
run::Int32
frame_index::Int32
t::UTCExtended
end
struct EventHeader
detector_id::Int32
run::Int32
......
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