Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3io.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
common
KM3io.jl
Commits
ab1ed633
Verified
Commit
ab1ed633
authored
2 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
API clean up and restructure
parent
fadba84c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
API cleanup for online files reading
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/KM3io.jl
+4
-2
4 additions, 2 deletions
src/KM3io.jl
src/daq.jl
+10
-12
10 additions, 12 deletions
src/daq.jl
src/root/online.jl
+27
-15
27 additions, 15 deletions
src/root/online.jl
with
41 additions
and
29 deletions
src/KM3io.jl
+
4
−
2
View file @
ab1ed633
...
...
@@ -6,11 +6,13 @@ import Statistics: mean
using
Printf
:
@printf
using
Dates
:
DateTime
,
datetime2unix
,
unix2datetime
using
StaticArrays
:
FieldVector
import
UnROOT
using
UnROOT
export
OnlineFile
export
Position
,
UTMPosition
,
Location
,
Quaternion
export
Detector
,
DetectorModule
,
PMT
,
Tripod
,
Hydrophone
export
Waveform
,
AcousticsTriggerParameter
,
piezoenabled
,
hydrophoneenabled
export
is3dshower
,
ismxshower
,
is3dmuon
,
isnb
...
...
@@ -24,9 +26,9 @@ end
include
(
"types.jl"
)
include
(
"hardware.jl"
)
include
(
"daq.jl"
)
include
(
"root/online.jl"
)
include
(
"root/offline.jl"
)
include
(
"daq.jl"
)
include
(
"acoustics.jl"
)
include
(
"tools.jl"
)
...
...
This diff is collapsed.
Click to expand it.
src/daq.jl
+
10
−
12
View file @
ab1ed633
...
...
@@ -5,34 +5,35 @@ function Base.read(s::IO, ::Type{T}; legacy=false) where T<:DAQEvent
type
=
read
(
s
,
Int32
)
version
=
Int16
(
0
)
!
legacy
&&
(
version
=
read
(
s
,
Int16
))
det_id
=
read
(
s
,
Int32
)
run_id
=
read
(
s
,
Int32
)
timeslice_id
=
read
(
s
,
Int32
)
_timestamp_field
=
read
(
s
,
UInt32
)
whiterabbit_status
=
_timestamp_field
&
0x80000000
# most significant bit
timestamp
=
_timestamp_field
&
0x7FFFFFFF
# skipping the most significant bit
ticks
=
read
(
s
,
UInt32
)
ticks
=
read
(
s
,
UInt32
)
# 16ns ticks
trigger_counter
=
read
(
s
,
Int64
)
trigger_mask
=
read
(
s
,
Int64
)
overlays
=
read
(
s
,
Int32
)
header
=
KM3NETDAQEventHeader
(
det_id
,
run_id
,
timeslice_id
,
timestamp
,
ticks
,
trigger_counter
,
trigger_mask
,
overlays
)
n_triggered_hits
=
read
(
s
,
Int32
)
triggered_hits
=
Vector
{
TriggeredHit
}()
triggered_hits
=
Vector
{
KM3NETDAQ
TriggeredHit
}()
sizehint!
(
triggered_hits
,
n_triggered_hits
)
triggered_map
=
Dict
{
Tuple
{
Int32
,
UInt8
,
Int32
,
UInt8
},
Int64
}()
@inbounds
for
i
∈
1
:
n_triggered_hits
dom_id
=
read
(
s
,
Int32
)
channel_id
=
read
(
s
,
UInt8
)
time
=
bswap
(
read
(
s
,
Int32
))
tot
=
read
(
s
,
UInt8
)
trigger_mask
=
read
(
s
,
Int64
)
triggered_map
[(
dom_id
,
channel_id
,
time
,
tot
)]
=
trigger_mask
push!
(
triggered_hits
,
TriggeredHit
(
dom_id
,
channel_id
,
time
,
tot
,
trigger_mask
))
push!
(
triggered_hits
,
KM3NETDAQTriggeredHit
(
dom_id
,
channel_id
,
time
,
tot
,
trigger_mask
))
end
n_hits
=
read
(
s
,
Int32
)
hits
=
Vector
{
Hit
}()
sizehint!
(
hits
,
n_hits
)
snapshot_
hits
=
Vector
{
KM3NETDAQSnapshot
Hit
}()
sizehint!
(
snapshot_
hits
,
n_hits
)
@inbounds
for
i
∈
1
:
n_hits
dom_id
=
read
(
s
,
Int32
)
channel_id
=
read
(
s
,
UInt8
)
...
...
@@ -40,11 +41,8 @@ function Base.read(s::IO, ::Type{T}; legacy=false) where T<:DAQEvent
tot
=
read
(
s
,
UInt8
)
key
=
(
dom_id
,
channel_id
,
time
,
tot
)
triggered
=
false
if
haskey
(
triggered_map
,
key
)
triggered
=
true
end
push!
(
hits
,
Hit
(
channel_id
,
dom_id
,
time
,
tot
,
triggered
))
push!
(
snapshot_hits
,
KM3NETDAQSnapshotHit
(
dom_id
,
channel_id
,
time
,
tot
))
end
T
(
det_id
,
run_id
,
timeslice_id
,
whiterabbit_status
,
timestamp
,
ticks
,
trigger_counter
,
trigger_mask
,
overlays
,
n_triggered
_hits
,
triggered_
hits
,
n_hits
,
hits
)
T
(
header
,
snapshot
_hits
,
triggered_hits
)
end
This diff is collapsed.
Click to expand it.
src/root/online.jl
+
27
−
15
View file @
ab1ed633
...
...
@@ -7,7 +7,7 @@ end
function
UnROOT.readtype
(
io
,
T
::
Type
{
KM3NETDAQSnapshotHit
})
T
(
UnROOT
.
readtype
(
io
,
Int32
),
read
(
io
,
UInt8
),
read
(
io
,
Int32
),
read
(
io
,
UInt8
))
end
function
UnROOT.interped_data
(
rawdata
,
rawoffsets
,
::
Type
{
Vector
{
KM3NETDAQSnapshotHit
}},
::
Type
{
J
})
where
{
T
,
J
<:
UnROOT
.
JaggType
}
function
UnROOT.interped_data
(
rawdata
,
rawoffsets
,
::
Type
{
Vector
{
KM3NETDAQSnapshotHit
}},
::
Type
{
T
})
where
{
T
<:
UnROOT
.
JaggType
}
UnROOT
.
splitup
(
rawdata
,
rawoffsets
,
KM3NETDAQSnapshotHit
,
skipbytes
=
10
)
end
...
...
@@ -31,7 +31,7 @@ function UnROOT.readtype(io, T::Type{KM3NETDAQTriggeredHit})
T
(
dom_id
,
channel_id
,
tdc
,
tot
,
trigger_mask
)
end
function
UnROOT.interped_data
(
rawdata
,
rawoffsets
,
::
Type
{
Vector
{
KM3NETDAQTriggeredHit
}},
::
Type
{
J
})
where
{
T
,
J
<:
UnROOT
.
JaggType
}
function
UnROOT.interped_data
(
rawdata
,
rawoffsets
,
::
Type
{
Vector
{
KM3NETDAQTriggeredHit
}},
::
Type
{
T
})
where
{
T
<:
UnROOT
.
JaggType
}
UnROOT
.
splitup
(
rawdata
,
rawoffsets
,
KM3NETDAQTriggeredHit
,
skipbytes
=
10
)
end
...
...
@@ -62,21 +62,31 @@ function UnROOT.readtype(io::IO, T::Type{KM3NETDAQEventHeader})
overlays
=
UnROOT
.
readtype
(
io
,
UInt32
)
T
(
detector_id
,
run
,
frame_index
,
UTC_seconds
,
UTC_16nanosecondcycles
,
trigger_counter
,
trigger_mask
,
overlays
)
end
function
UnROOT.interped_data
(
rawdata
,
rawoffsets
,
::
Type
{
KM3NETDAQEventHeader
},
::
Type
{
J
})
where
{
T
,
J
<:
UnROOT
.
JaggType
}
function
UnROOT.interped_data
(
rawdata
,
rawoffsets
,
::
Type
{
KM3NETDAQEventHeader
},
::
Type
{
T
})
where
{
T
<:
UnROOT
.
JaggType
}
UnROOT
.
splitup
(
rawdata
,
rawoffsets
,
KM3NETDAQEventHeader
,
jagged
=
false
)
end
struct
Online
Event
struct
DAQ
Event
header
::
KM3NETDAQEventHeader
snapshot_hits
::
Vector
{
KM3NETDAQSnapshotHit
}
triggered_hits
::
Vector
{
KM3NETDAQTriggeredHit
}
end
function
Base.show
(
io
::
IO
,
e
::
DAQEvent
)
print
(
io
,
"
$
(typeof(e)) with
$
(length(e.snapshot_hits)) snapshot and
$
(length(e.triggered_hits)) triggered hits"
)
end
struct
OnlineFile
fobj
::
UnROOT
.
ROOTFile
headers
::
Vector
{
KM3NETDAQEventHeader
}
struct
EventContainer
headers
snapshot_hits
triggered_hits
end
function
Base.show
(
io
::
IO
,
e
::
EventContainer
)
print
(
io
,
"
$
(typeof(e)) with
$
(length(e.headers)) events"
)
end
struct
OnlineFile
_fobj
::
UnROOT
.
ROOTFile
events
::
EventContainer
function
OnlineFile
(
filename
::
AbstractString
)
customstructs
=
Dict
(
...
...
@@ -87,17 +97,19 @@ struct OnlineFile
fobj
=
UnROOT
.
ROOTFile
(
filename
,
customstructs
=
customstructs
)
new
(
fobj
,
fobj
[
"KM3NET_EVENT/KM3NET_EVENT/KM3NETDAQ::JDAQEventHeader"
],
fobj
[
"KM3NET_EVENT/KM3NET_EVENT/snapshotHits"
],
fobj
[
"KM3NET_EVENT/KM3NET_EVENT/triggeredHits"
])
EventContainer
(
LazyBranch
(
fobj
,
"KM3NET_EVENT/KM3NET_EVENT/KM3NETDAQ::JDAQEventHeader"
),
LazyBranch
(
fobj
,
"KM3NET_EVENT/KM3NET_EVENT/snapshotHits"
),
LazyBranch
(
fobj
,
"KM3NET_EVENT/KM3NET_EVENT/triggeredHits"
))
)
end
end
Base
.
getindex
(
f
::
OnlineFile
,
idx
::
Integer
)
=
OnlineEvent
(
f
.
headers
[
idx
],
f
.
snapshot_hits
[
idx
],
f
.
triggered_hits
[
idx
]
)
Base
.
length
(
f
::
OnlineFile
)
=
length
(
f
.
headers
)
Base
.
getindex
(
c
::
EventContainer
,
idx
::
Integer
)
=
DAQEvent
(
c
.
headers
[
idx
],
c
.
snapshot_hits
[
idx
],
c
.
triggered_hits
[
idx
])
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
.
close
(
f
::
OnlineFile
)
=
close
(
f
.
fobj
)
Base
.
length
(
c
::
EventContainer
)
=
length
(
f
.
headers
)
Base
.
close
(
c
::
OnlineFile
)
=
close
(
f
.
_fobj
)
function
read_headers
(
f
::
OnlineFile
)
data
,
offsets
=
UnROOT
.
array
(
f
.
fobj
,
"KM3NET_EVENT/KM3NET_EVENT/KM3NETDAQ::JDAQEventHeader"
;
raw
=
true
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment