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
0181fbf8
Verified
Commit
0181fbf8
authored
1 year ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Improve and extend detector indexing behaviour
parent
46dc002e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
docs/src/api.md
+2
-0
2 additions, 0 deletions
docs/src/api.md
src/KM3io.jl
+1
-1
1 addition, 1 deletion
src/KM3io.jl
src/hardware.jl
+31
-1
31 additions, 1 deletion
src/hardware.jl
test/hardware.jl
+29
-2
29 additions, 2 deletions
test/hardware.jl
with
63 additions
and
4 deletions
docs/src/api.md
+
2
−
0
View file @
0181fbf8
...
...
@@ -49,6 +49,8 @@ flush
PMT
DetectorModule
Detector
getmodule
modules
write(::AbstractString, ::Detector)
write(::IO, ::Detector)
Hydrophone
...
...
This diff is collapsed.
Click to expand it.
src/KM3io.jl
+
1
−
1
View file @
0181fbf8
...
...
@@ -21,7 +21,7 @@ export ROOTFile
export
H5File
,
H5CompoundDataset
,
create_dataset
,
addmeta
export
Direction
,
Position
,
UTMPosition
,
Location
,
Quaternion
,
Track
,
AbstractCalibratedHit
export
Detector
,
DetectorModule
,
PMT
,
Tripod
,
Hydrophone
,
center
,
isbasemodule
export
Detector
,
DetectorModule
,
PMT
,
Tripod
,
Hydrophone
,
center
,
isbasemodule
,
getmodule
,
modules
# Acoustics
export
Waveform
,
AcousticSignal
,
AcousticsTriggerParameter
,
piezoenabled
,
hydrophoneenabled
...
...
This diff is collapsed.
Click to expand it.
src/hardware.jl
+
31
−
1
View file @
0181fbf8
...
...
@@ -266,8 +266,38 @@ function Base.iterate(d::Detector, state=(Int[], 1))
end
(
d
.
modules
[
module_ids
[
count
]],
(
module_ids
,
count
+
1
))
end
Base
.
getindex
(
d
::
Detector
,
module_id
)
=
d
.
modules
[
module_id
]
Base
.
getindex
(
d
::
Detector
,
module_id
::
Integer
)
=
d
.
modules
[
module_id
]
Base
.
getindex
(
d
::
Detector
,
string
::
Integer
,
floor
::
Integer
)
=
d
.
locations
[
string
,
floor
]
"""
Return the detector module for a given string and floor.
"""
@inline
getmodule
(
d
::
Detector
,
string
::
Integer
,
floor
::
Integer
)
=
d
[
string
,
floor
]
"""
Return the detector module for a given string and floor (as `Tuple`).
"""
@inline
getmodule
(
d
::
Detector
,
loc
::
Tuple
{
T
,
T
})
where
T
<:
Integer
=
d
[
loc
...
]
"""
Return the detector module for a given location.
"""
@inline
getmodule
(
d
::
Detector
,
loc
::
Location
)
=
d
[
loc
.
string
,
loc
.
floor
]
Base
.
getindex
(
d
::
Detector
,
string
::
Int
,
::
Colon
)
=
sort!
(
filter
(
m
->
m
.
location
.
string
==
string
,
modules
(
d
)))
Base
.
getindex
(
d
::
Detector
,
string
::
Int
,
floors
::
T
)
where
T
<:
Union
{
AbstractArray
,
UnitRange
}
=
[
d
[
string
,
floor
]
for
floor
in
sort
(
floors
)]
Base
.
getindex
(
d
::
Detector
,
::
Colon
,
floor
::
Int
)
=
sort!
(
filter
(
m
->
m
.
location
.
floor
==
floor
,
modules
(
d
)))
"""
Return a vector of detector modules for a given range of floors on all strings.
This can be useful if specific detector module layers of the detector are needed, e.g.
the base modules (e.g. `detector[:, 0]`) or the top layer (e.g. `detector[:, 18]`).
"""
function
Base.getindex
(
d
::
Detector
,
::
Colon
,
floors
::
UnitRange
{
T
})
where
T
<:
Integer
modules
=
DetectorModule
[]
for
string
in
d
.
strings
for
floor
in
floors
push!
(
modules
,
d
[
string
,
floor
])
end
end
sort!
(
modules
)
end
"""
...
...
This diff is collapsed.
Click to expand it.
test/hardware.jl
+
29
−
2
View file @
0181fbf8
...
...
@@ -22,9 +22,11 @@ const SAMPLES_DIR = joinpath(@__DIR__, "samples")
# no base modules in DETX version <4
@test
342
==
length
(
d
)
@test
342
==
length
(
d
.
modules
)
@test
342
==
length
(
modules
(
d
))
@test
DetectorModule
==
eltype
(
d
)
else
@test
361
==
length
(
mods
)
@test
361
==
length
(
modules
(
d
))
@test
106.95
≈
d
.
modules
[
808469291
]
.
pos
.
y
# base module
@test
97.3720395
≈
d
.
modules
[
808974928
]
.
pos
.
z
# base module
@test
0.0
==
d
.
modules
[
808469291
]
.
t₀
# base module
...
...
@@ -35,8 +37,20 @@ const SAMPLES_DIR = joinpath(@__DIR__, "samples")
if
version
>
3
@test
Quaternion
(
1
,
0
,
0
,
0
)
≈
d
.
modules
[
808995481
]
.
q
@test
19
==
length
(
collect
(
m
for
m
∈
d
if
isbasemodule
(
m
)))
@test
19
==
length
(
d
[
:
,
0
])
@test
19
==
length
(
d
[
30
,
:
])
@test
5
==
length
(
d
[
30
,
0
:
4
])
for
m
in
d
[
30
,
0
:
4
]
@test
m
.
location
.
floor
in
0
:
4
end
else
@test
0
==
length
(
collect
(
m
for
m
∈
d
if
isbasemodule
(
m
)))
@test
0
==
length
(
d
[
:
,
0
])
@test
18
==
length
(
d
[
30
,
:
])
@test
4
==
length
(
d
[
30
,
1
:
4
])
for
m
in
d
[
30
,
1
:
4
]
@test
m
.
location
.
floor
in
1
:
4
end
end
if
version
>
4
...
...
@@ -51,8 +65,21 @@ const SAMPLES_DIR = joinpath(@__DIR__, "samples")
end
@test
31
==
d
.
modules
[
808992603
]
.
n_pmts
@test
30
≈
d
.
modules
[
817287557
]
.
location
.
string
@test
18
≈
d
.
modules
[
817287557
]
.
location
.
floor
@test
30
==
d
.
modules
[
817287557
]
.
location
.
string
@test
18
==
d
.
modules
[
817287557
]
.
location
.
floor
@test
Location
(
30
,
18
)
==
d
[
817287557
]
.
location
@test
817287557
==
d
[
30
,
18
]
.
id
@test
817287557
==
getmodule
(
d
,
30
,
18
)
.
id
@test
817287557
==
getmodule
(
d
,
(
30
,
18
))
.
id
@test
817287557
==
getmodule
(
d
,
Location
(
30
,
18
))
.
id
@test
19
==
length
(
d
[
:
,
18
])
for
m
in
d
[
:
,
17
]
@test
17
==
m
.
location
.
floor
end
for
m
in
d
[
:
,
1
:
4
]
@test
m
.
location
.
floor
in
1
:
4
end
@test
478392.31980645156
≈
d
.
modules
[
808992603
]
.
t₀
...
...
This diff is collapsed.
Click to expand it.
Tamas Gal
@tgal
mentioned in commit
3488897f
·
1 year ago
mentioned in commit
3488897f
mentioned in commit 3488897f1b50b51ea327ec28706e5152785368f0
Toggle commit list
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