Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
km3py
km3io
Commits
148419a7
Commit
148419a7
authored
5 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Add header stuff
parent
16de656e
No related branches found
No related tags found
2 merge requests
!24
Refactor offline
,
!22
WIP: Slicing and refactoring offline
Pipeline
#9271
failed
5 years ago
Stage: test
Stage: coverage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
km3io/definitions/__init__.py
+6
-0
6 additions, 0 deletions
km3io/definitions/__init__.py
km3io/definitions/mc_header.py
+30
-0
30 additions, 0 deletions
km3io/definitions/mc_header.py
km3io/offline.py
+41
-4
41 additions, 4 deletions
km3io/offline.py
with
77 additions
and
4 deletions
km3io/definitions/__init__.py
0 → 100644
+
6
−
0
View file @
148419a7
#!/usr/bin/env python3
from
.mc_header
import
data
as
mc_header
from
.trigger
import
data
as
trigger
from
.fitparameters
import
data
as
fitparameters
from
.reconstruction
import
data
as
reconstruction
This diff is collapsed.
Click to expand it.
km3io/definitions/mc_header.py
0 → 100644
+
30
−
0
View file @
148419a7
#!/usr/bin/env python3
data
=
{
"
DAQ
"
:
"
livetime
"
,
"
seed
"
:
"
program level iseed
"
,
"
PM1_type_area
"
:
"
type area TTS
"
,
"
PDF
"
:
"
i1 i2
"
,
"
model
"
:
"
interaction muon scattering numberOfEnergyBins
"
,
"
can
"
:
"
zmin zmax r
"
,
"
genvol
"
:
"
zmin zmax r volume numberOfEvents
"
,
"
merge
"
:
"
time gain
"
,
"
coord_origin
"
:
"
x y z
"
,
"
translate
"
:
"
x y z
"
,
"
genhencut
"
:
"
gDir Emin
"
,
"
k40
"
:
"
rate time
"
,
"
norma
"
:
"
primaryFlux numberOfPrimaries
"
,
"
livetime
"
:
"
numberOfSeconds errorOfSeconds
"
,
"
flux
"
:
"
type key file_1 file_2
"
,
"
spectrum
"
:
"
alpha
"
,
"
fixedcan
"
:
"
xcenter ycenter zmin zmax radius
"
,
"
start_run
"
:
"
run_id
"
,
}
for
key
in
"
cut_primary cut_seamuon cut_in cut_nu
"
.
split
():
data
[
key
]
=
"
Emin Emax cosTmin cosTmax
"
for
key
in
"
generator physics simul
"
.
split
():
data
[
key
]
=
"
program version date time
"
for
key
in
data
.
keys
():
data
[
key
]
=
data
[
key
].
split
()
This diff is collapsed.
Click to expand it.
km3io/offline.py
+
41
−
4
View file @
148419a7
...
...
@@ -3,9 +3,7 @@ import uproot
import
numpy
as
np
import
awkward1
as
ak
import
warnings
import
km3io.definitions.trigger
import
km3io.definitions.fitparameters
import
km3io.definitions.reconstruction
from
.definitions
import
mc_header
MAIN_TREE_NAME
=
"
E
"
# 110 MB based on the size of the largest basket found so far in km3net
...
...
@@ -102,7 +100,7 @@ class OfflineReader:
for
n
,
x
in
self
.
_fobj
[
'
Head
'
].
_map_3c_string_2c_string_3e_
.
items
(
):
header
[
n
.
decode
(
"
utf-8
"
)]
=
x
.
decode
(
"
utf-8
"
).
strip
()
return
header
return
Header
(
header
)
else
:
warnings
.
warn
(
"
Your file header has an unsupported format
"
)
...
...
@@ -485,6 +483,44 @@ class Usr:
return
'
\n
'
.
join
(
entries
)
def
_to_num
(
value
):
"""
Convert value to a numerical value if possible
"""
if
value
is
None
:
return
None
try
:
return
int
(
value
)
except
ValueError
:
try
:
return
float
(
value
)
except
ValueError
:
pass
else
:
return
value
class
Header
:
"""
The online header
"""
def
__init__
(
self
,
header
):
self
.
_data
=
{}
for
attribute
,
fields
in
mc_header
.
items
():
values
=
header
.
get
(
attribute
,
''
).
split
()
if
not
values
:
continue
Constructor
=
namedtuple
(
attribute
,
fields
)
if
len
(
values
)
<
len
(
fields
):
values
+=
[
None
]
*
(
len
(
fields
)
-
len
(
values
))
self
.
_data
[
attribute
]
=
Constructor
(
**
{
f
:
_to_num
(
v
)
for
(
f
,
v
)
in
zip
(
fields
,
values
)})
for
attribute
,
value
in
self
.
_data
.
items
():
setattr
(
self
,
attribute
,
value
)
def
__str__
(
self
):
lines
=
[
"
MC Header:
"
]
for
value
in
self
.
_data
.
values
():
lines
.
append
(
"
{}
"
.
format
(
value
))
return
"
\n
"
.
join
(
lines
)
class
BranchElement
:
"""
wrapper for offline tracks
"""
def
__init__
(
self
,
tree
,
mapper
,
index
=
slice
(
None
)):
...
...
@@ -508,6 +544,7 @@ class BranchElement:
# self._EntryType = namedtuple(mapper.name[:-1], self.keys())
for
key
in
self
.
keys
():
# print("setting", self._mapper.name, key)
setattr
(
self
,
key
,
self
[
key
])
def
keys
(
self
):
...
...
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