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
faa7ece9
Verified
Commit
faa7ece9
authored
6 months ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Update docs
parent
a4ef3d6a
No related branches found
Branches containing commit
No related tags found
1 merge request
!40
Add Summaryslice interval iterator helper
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
docs/src/api.md
+1
-0
1 addition, 0 deletions
docs/src/api.md
src/exports.jl
+5
-2
5 additions, 2 deletions
src/exports.jl
src/root/online.jl
+3
-0
3 additions, 0 deletions
src/root/online.jl
src/tools/helpers.jl
+50
-0
50 additions, 0 deletions
src/tools/helpers.jl
with
59 additions
and
2 deletions
docs/src/api.md
+
1
−
0
View file @
faa7ece9
...
...
@@ -131,6 +131,7 @@ CHClient
### General tools
```
@docs
SummarysliceIntervalIterator
getevent
categorize
nthbitset
...
...
This diff is collapsed.
Click to expand it.
src/exports.jl
+
5
−
2
View file @
faa7ece9
...
...
@@ -110,8 +110,12 @@ hasshowerfit,
hasshowerpositionfit
,
hasshowerprefit
,
#
Uti
ls
#
Too
ls
MCEventMatcher
,
SummarysliceIntervalIterator
,
getevent
,
# Utils
categorize
,
is3dmuon
,
is3dshower
,
...
...
@@ -120,7 +124,6 @@ isnb,
most_frequent
,
nthbitset
,
triggered
,
getevent
,
# Physics and math helpers
CherenkovPhoton
,
...
...
This diff is collapsed.
Click to expand it.
src/root/online.jl
+
3
−
0
View file @
faa7ece9
...
...
@@ -113,6 +113,9 @@ struct Summaryslice
header
::
SummarysliceHeader
frames
::
Vector
{
SummaryFrame
}
end
function
Base.show
(
io
::
IO
,
s
::
Summaryslice
)
print
(
io
,
"Summaryslice(
$
(length(s.frames)) frames)"
)
end
struct
SummarysliceContainer
# For performance reasons we use directly the lazy types of UnROOT
# We could also parametrise it.
...
...
This diff is collapsed.
Click to expand it.
src/tools/helpers.jl
+
50
−
0
View file @
faa7ece9
...
...
@@ -58,3 +58,53 @@ function getevent(tree::T, frame_index, trigger_counter) where T<:Union{OnlineTr
end
getevent
(
tree
::
OfflineTree
,
idx
)
=
tree
[
idx
]
getevent
(
tree
::
OnlineTree
,
idx
)
=
tree
.
events
[
idx
]
"""
An iterator which yields a `Vector{Summaryslice}` containing summaryslices of a given
`time_interval` (in seconds). Useful when analysing summary data with fixed time intervals.
The returned summaryslices are also sorted in time.
"""
struct
SummarysliceIntervalIterator
sc
::
KM3io
.
SummarysliceContainer
time_interval
::
Int
# [s]
n_chunks
::
Int
timespan
::
Float64
indices
::
Vector
{
Int
}
function
SummarysliceIntervalIterator
(
f
::
ROOTFile
,
time_interval
)
ss
=
f
.
online
.
summaryslices
sorted_summaryslice_indices
=
sortperm
([
sh
.
frame_index
for
sh
in
ss
.
headers
])
timespan
=
ss
.
headers
[
sorted_summaryslice_indices
[
end
]]
.
frame_index
/
10
n_chunks
=
Int
(
ceil
(
timespan
/
time_interval
))
new
(
f
.
online
.
summaryslices
,
time_interval
,
n_chunks
,
timespan
,
sorted_summaryslice_indices
)
end
end
function
Base.show
(
io
::
IO
,
sii
::
SummarysliceIntervalIterator
)
print
(
io
,
"SummarysliceIntervalIterator (
$
(sii.timespan)s,
$
(sii.time_interval)s intervals,
$
(sii.n_chunks) chunks)"
)
end
Base
.
eltype
(
::
Type
{
SummarysliceIntervalIterator
})
=
Vector
{
KM3io
.
Summaryslice
}
Base
.
length
(
sii
::
SummarysliceIntervalIterator
)
=
sii
.
n_chunks
function
Base.iterate
(
sii
::
SummarysliceIntervalIterator
,
state
=
(
chunk_idx
=
1
,
s_idx
=
1
))
state
.
chunk_idx
>
sii
.
n_chunks
&&
return
nothing
out_size
=
sii
.
time_interval
*
10
out
=
empty!
(
Vector
{
KM3io
.
Summaryslice
}(
undef
,
out_size
))
frame_index_upper
=
state
.
chunk_idx
*
sii
.
time_interval
*
10
s_idx
=
state
.
s_idx
while
s_idx
<=
length
(
sii
.
indices
)
idx
=
sii
.
indices
[
s_idx
]
summaryslice
=
sii
.
sc
[
idx
]
if
summaryslice
.
header
.
frame_index
<
frame_index_upper
push!
(
out
,
summaryslice
)
s_idx
+=
1
else
break
end
end
return
(
out
,
(
chunk_idx
=
state
.
chunk_idx
+
1
,
s_idx
=
s_idx
))
end
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