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
708b51cf
Commit
708b51cf
authored
5 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Renaming to make functions evt unique and reader for neutrinos and tracks
parent
03f86dff
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/KM3io.jl
+74
-3
74 additions, 3 deletions
src/KM3io.jl
with
74 additions
and
3 deletions
src/KM3io.jl
+
74
−
3
View file @
708b51cf
module
KM3io
using
StaticArrays
using
Corpuscles
abstract type
AbstractHit
end
struct
Cartesian
{
T
}
<:
FieldVector
{
3
,
T
}
x
::
T
y
::
T
z
::
T
end
struct
RawHit
<:
AbstractHit
id
::
Integer
PMid
::
Integer
...
...
@@ -20,10 +27,34 @@ struct Hit <: AbstractHit
track_id
::
Integer
end
struct
KineticInfo
vtx_pos
::
Cartesian
{
T
}
where
{
T
<:
Real
}
dir
::
Cartesian
{
T
}
where
{
T
<:
Real
}
energy
::
Real
time
::
Real
end
struct
Neutrino
id
::
Integer
kin
::
KineticInfo
bjorken
::
Tuple
{
Real
,
Real
}
ichannel
::
Integer
particle
::
PDGID
cc
::
Bool
end
struct
Track
id
::
Integer
kin
::
KineticInfo
particle
::
GeantID
end
struct
Event
hits
::
Vector
{
AbstractHit
}
neutrinos
::
Vector
{
Neutrino
}
tracks
::
Vector
{
Track
}
end
Event
()
=
Event
(
Vector
{
AbstractHit
}())
Event
()
=
Event
(
Vector
{
AbstractHit
}()
,
Vector
{
Neutrino
}(),
Vector
{
Track
}()
)
struct
EvtFile
events
::
Dict
{
T
,
Event
}
where
{
T
<:
Integer
}
...
...
@@ -31,7 +62,7 @@ end
EvtFile
()
=
EvtFile
(
Dict
{
Int64
,
Event
}())
function
read_
hit_entry
(
line
::
AbstractString
)
function
read_
evt_hit
(
line
::
AbstractString
)
fields
=
split
(
line
)
id
=
parse
(
Int64
,
fields
[
2
])
pmt_id
=
parse
(
Int64
,
fields
[
3
])
...
...
@@ -42,6 +73,40 @@ function read_hit_entry(line::AbstractString)
Hit
(
id
,
pmt_id
,
npe
,
time
,
geantid
,
track_id
)
end
function
parse_kin
(
fields
::
Vector
{
T
})
where
{
T
<:
AbstractString
}
x
=
parse
(
Float64
,
fields
[
1
])
y
=
parse
(
Float64
,
fields
[
2
])
z
=
parse
(
Float64
,
fields
[
3
])
pos
=
Cartesian
(
x
,
y
,
z
)
vx
=
parse
(
Float64
,
fields
[
4
])
vy
=
parse
(
Float64
,
fields
[
5
])
vz
=
parse
(
Float64
,
fields
[
6
])
dir
=
Cartesian
(
vx
,
vy
,
vz
)
energy
=
parse
(
Float64
,
fields
[
7
])
time
=
parse
(
Float64
,
fields
[
8
])
KineticInfo
(
pos
,
dir
,
energy
,
time
)
end
function
read_evt_neutrino
(
line
::
AbstractString
)
fields
=
split
(
line
)
id
=
parse
(
Int64
,
fields
[
2
])
kin
=
parse_kin
(
String
.
(
fields
[
3
:
10
]))
bjorken_x
=
parse
(
Float64
,
fields
[
11
])
bjorken_y
=
parse
(
Float64
,
fields
[
12
])
bjorken
=
(
bjorken_x
,
bjorken_y
)
ichan
=
parse
(
Int8
,
fields
[
13
])
particle
=
PDGID
(
parse
(
Int8
,
fields
[
14
]))
cc
=
(
parse
(
Int8
,
fields
[
15
])
==
2
)
Neutrino
(
id
,
kin
,
bjorken
,
ichan
,
particle
,
cc
)
end
function
read_evt_track
(
line
::
AbstractString
)
fields
=
split
(
line
)
id
=
parse
(
Int64
,
fields
[
2
])
kin
=
parse_kin
(
fields
[
3
:
10
])
particle
=
GeantID
(
parse
(
Int8
,
fields
[
11
]))
Track
(
id
,
kin
,
particle
)
end
function
read_evt_file
(
filepath
::
AbstractString
)
f
=
open
(
filepath
)
...
...
@@ -56,8 +121,14 @@ function read_evt_file(filepath::AbstractString)
while
!
occursin
(
"end_event:"
,
line
)
line
=
readline
(
f
)
if
occursin
(
"hit:"
,
line
)
hit
=
read_
hit_entry
(
line
)
hit
=
read_
evt_hit
(
line
)
push!
(
event
.
hits
,
hit
)
elseif
occursin
(
"neutrino:"
,
line
)
neutrino
=
read_evt_neutrino
(
line
)
push!
(
event
.
neutrinos
,
neutrino
)
elseif
occursin
(
"track_in:"
,
line
)
track
=
read_evt_track
(
line
)
push!
(
event
.
tracks
,
track
)
end
end
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