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
3a40ce4c
Verified
Commit
3a40ce4c
authored
1 year ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Add more helpers to deal with modules
parent
626f05fc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!28
Add more helpers to deal with modules
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
docs/src/api.md
+4
-0
4 additions, 0 deletions
docs/src/api.md
src/KM3io.jl
+4
-1
4 additions, 1 deletion
src/KM3io.jl
src/hardware.jl
+19
-0
19 additions, 0 deletions
src/hardware.jl
src/tools/math.jl
+7
-0
7 additions, 0 deletions
src/tools/math.jl
with
34 additions
and
1 deletion
docs/src/api.md
+
4
−
0
View file @
3a40ce4c
...
...
@@ -52,6 +52,9 @@ Detector
modules
getmodule
getpmt
haslocation
isbasemodule
isopticalmodule
write(::AbstractString, ::Detector)
write(::IO, ::Detector)
Hydrophone
...
...
@@ -154,4 +157,5 @@ hashistory
### Math
```
@docs
angle
distance
```
This diff is collapsed.
Click to expand it.
src/KM3io.jl
+
4
−
1
View file @
3a40ce4c
...
...
@@ -27,7 +27,8 @@ export ROOTFile
export
H5File
,
H5CompoundDataset
,
create_dataset
,
addmeta
export
Direction
,
Position
,
UTMPosition
,
Location
,
Quaternion
,
Track
,
AbstractCalibratedHit
export
Detector
,
DetectorModule
,
PMT
,
Tripod
,
Hydrophone
,
StringMechanics
,
StringMechanicsParameters
,
center
,
isbasemodule
,
getmodule
,
modules
,
getpmt
,
getpmts
export
Detector
,
DetectorModule
,
PMT
,
Tripod
,
Hydrophone
,
StringMechanics
,
StringMechanicsParameters
,
center
,
isbasemodule
,
isopticalmodule
,
getmodule
,
modules
,
getpmt
,
getpmts
,
haslocation
# Acoustics
export
Waveform
,
AcousticSignal
,
AcousticsTriggerParameter
,
piezoenabled
,
hydrophoneenabled
...
...
@@ -60,6 +61,8 @@ export MCEventMatcher
export
CHClient
,
CHTag
,
subscribe
,
@ip_str
export
distance
@template
(
FUNCTIONS
,
METHODS
,
MACROS
)
=
"""
$(TYPEDSIGNATURES)
...
...
This diff is collapsed.
Click to expand it.
src/hardware.jl
+
19
−
0
View file @
3a40ce4c
...
...
@@ -81,7 +81,11 @@ end
The index in this context is the DAQ channel ID of the PMT, which is counting from 0.
"""
Base
.
getindex
(
d
::
DetectorModule
,
i
)
=
d
.
pmts
[
i
+
1
]
"""
Returns true if the module is a basemodule.
"""
isbasemodule
(
d
::
DetectorModule
)
=
d
.
location
.
floor
==
0
isopticalmodule
(
d
::
DetectorModule
)
=
d
.
n_pmts
>
0
getpmts
(
d
::
DetectorModule
)
=
d
.
pmts
"""
Get the PMT for a given DAQ channel ID (TDC)
...
...
@@ -294,6 +298,10 @@ end
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 module ID.
"""
@inline
getmodule
(
d
::
Detector
,
module_id
::
Integer
)
=
d
[
module_id
]
"""
Return the detector module for a given string and floor.
"""
@inline
getmodule
(
d
::
Detector
,
string
::
Integer
,
floor
::
Integer
)
=
d
[
string
,
floor
]
...
...
@@ -305,6 +313,10 @@ Return the detector module for a given string and floor (as `Tuple`).
Return the detector module for a given location.
"""
@inline
getmodule
(
d
::
Detector
,
loc
::
Location
)
=
d
[
loc
.
string
,
loc
.
floor
]
"""
Return the `PMT` for a given hit.
"""
@inline
getpmt
(
d
::
Detector
,
hit
)
=
getpmt
(
getmodule
(
d
,
hit
.
dom_id
),
hit
.
channel_id
)
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
)))
...
...
@@ -326,6 +338,13 @@ end
"""
Returns true if there is a module at the given location.
"""
haslocation
(
d
::
Detector
,
loc
::
Location
)
=
haskey
(
d
.
locations
,
(
loc
.
string
,
loc
.
floor
))
"""
Calculate the center of the detector based on the location of the optical modules.
"""
...
...
This diff is collapsed.
Click to expand it.
src/tools/math.jl
+
7
−
0
View file @
3a40ce4c
...
...
@@ -5,3 +5,10 @@ Base.angle(d1::Direction, d2::Direction) = acos(min(dot(normalize(d1), normalize
Base
.
angle
(
a
::
T
,
b
::
T
)
where
{
T
<:
Union
{
KM3io
.
AbstractCalibratedHit
,
KM3io
.
PMT
}}
=
Base
.
angle
(
a
.
dir
,
b
.
dir
)
Base
.
angle
(
a
,
b
::
Union
{
KM3io
.
AbstractCalibratedHit
,
KM3io
.
PMT
})
=
Base
.
angle
(
a
,
b
.
dir
)
Base
.
angle
(
a
::
Union
{
KM3io
.
AbstractCalibratedHit
,
KM3io
.
PMT
},
b
)
=
Base
.
angle
(
a
.
dir
,
b
)
"""
Calculates the disance between two points.
"""
distance
(
a
::
Position
,
b
::
Position
)
=
norm
(
a
-
b
)
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