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
bd1d18a9
Commit
bd1d18a9
authored
4 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Preparation
parent
022ef40d
No related branches found
No related tags found
1 merge request
!44
Draft: Resolve "Final fix for best_track"
Pipeline
#14169
failed
4 years ago
Stage: test
Stage: coverage
Stage: doc
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3io/definitions/__init__.py
+7
-0
7 additions, 0 deletions
km3io/definitions/__init__.py
km3io/tools.py
+34
-14
34 additions, 14 deletions
km3io/tools.py
with
41 additions
and
14 deletions
km3io/definitions/__init__.py
+
7
−
0
View file @
bd1d18a9
...
...
@@ -13,3 +13,10 @@ fitparameters_idx = {v: k for k, v in fitparameters.items()}
reconstruction_idx
=
{
v
:
k
for
k
,
v
in
reconstruction
.
items
()}
w2list_genhen_idx
=
{
v
:
k
for
k
,
v
in
w2list_genhen
.
items
()}
w2list_gseagen_idx
=
{
v
:
k
for
k
,
v
in
w2list_gseagen
.
items
()}
recos
=
{
"
jmuon
"
:
reconstruction
[
"
JPP_RECONSTRUCTION_TYPE
"
],
"
jshower
"
:
reconstruction
[
"
JPP_RECONSTRUCTION_TYPE
"
],
"
dusjshower
"
:
reconstruction
[
"
DUSJ_RECONSTRUCTION_TYPE
"
],
"
aashower
"
:
reconstruction
[
"
AANET_RECONSTRUCTION_TYPE
"
],
}
This diff is collapsed.
Click to expand it.
km3io/tools.py
+
34
−
14
View file @
bd1d18a9
...
...
@@ -4,7 +4,7 @@ import numpy as np
import
awkward1
as
ak1
import
uproot
from
.definitions
import
fitparameters
,
reconstruction
,
w2list_genhen
,
w2list_gseagen
from
.definitions
import
fitparameters
,
reconstruction
,
w2list_genhen
,
w2list_gseagen
,
recos
# 110 MB based on the size of the largest basket found so far in km3net
BASKET_CACHE_SIZE
=
110
*
1024
**
2
...
...
@@ -270,7 +270,7 @@ def mask(rec_stages, stages):
return
builder
.
snapshot
()
==
1
def
best_track
(
tracks
,
strategy
=
"
default
"
,
rec
_type
=
None
):
def
best_track
(
tracks
,
strategy
=
"
default
"
,
rec
o
=
None
):
"""
best track selection based on different strategies
Parameters
...
...
@@ -283,8 +283,8 @@ def best_track(tracks, strategy="default", rec_type=None):
-
"
default
"
: to select the best tracks (the first ones) corresponding to a specific
reconstruction algorithm (JGandalf, Jshowerfit, etc). This requires rec_type input.
Example: best_track(my_tracks, strategy=
"
default
"
, rec_type=
"
JPP_RECONSTRUCTION_TYPE
"
).
rec
_type
: str,
optional
r
econstruction type
as defined in the official KM3NeT-Dataformat.
rec
o
: str,
required when using the
"
default
"
strategy
R
econstruction type
: e.g. jmuon, jshower, dusjshower or aashower
Returns
-------
...
...
@@ -294,9 +294,10 @@ def best_track(tracks, strategy="default", rec_type=None):
Raises
------
ValueError
ValueError raised when:
- an invalid strategy is requested.
- a subset of events with empty tracks is used.
- an invalid strategy is requested.
- a subset of events with empty tracks is used.
KeyError
- unable to find reconstruction stages
"""
options
=
[
'
first
'
,
'
default
'
]
if
strategy
not
in
options
:
...
...
@@ -311,27 +312,46 @@ def best_track(tracks, strategy="default", rec_type=None):
if
strategy
==
"
first
"
:
if
n_events
==
1
:
out
=
tracks
[
0
]
else
:
out
=
tracks
[:,
0
]
return
tracks
[
0
]
return
tracks
[:,
0
]
if
strategy
==
"
default
"
and
rec
_type
is
None
:
if
strategy
==
"
default
"
and
rec
o
is
None
:
raise
ValueError
(
"
rec_type must be provided when the default strategy is used.
"
)
"
The reco parameter must be provided when the default strategy is used.
"
)
if
strategy
==
"
default
"
and
reco
is
not
None
:
if
reco
not
in
recos
:
raise
ValueError
(
"
Unknown reconstruction, please choose from: {}
"
.
format
(
"
,
"
.
join
(
recos
.
keys
)))
rec_type
=
recos
[
reco
]
reco
=
reco
.
upper
()
try
:
rec_stage_min_idx
=
reconstruction
[
reco
+
"
BEGIN
"
]
rec_stage_max_idx
=
reconstruction
[
reco
+
"
END
"
]
except
KeyError
:
raise
KeyError
(
"
Unable to find the reconstruction stages for {}
"
.
format
(
reco
))
# backward compat for aanet
if
reco
==
"
AASHOWER
"
:
rec_stage_min_idx
=
0
rec_stage_max_idx
=
np
.
iinfo
(
np
.
int32
).
max
if
strategy
==
"
default
"
and
rec_type
is
not
None
:
if
n_events
==
1
:
raise
NotImplementedError
# first mask to select those with the correct reconstruction type
rec_types
=
tracks
[
tracks
.
rec_type
==
reconstruction
[
rec_type
]]
# TODO: check if rec_stages are all between rec_stage_min_idx and rec_stage_max_idx
len_stages
=
count_nested
(
rec_types
.
rec_stages
,
axis
=
1
)
# TODO: etc.
longest
=
rec_types
[
len_stages
==
ak1
.
max
(
len_stages
,
axis
=
0
)]
out
=
longest
[
longest
.
lik
==
ak1
.
max
(
longest
.
lik
,
axis
=
0
)]
else
:
# TODO: not done yet
raise
NotImplementedError
rec_types
=
tracks
[
tracks
.
rec_type
==
reconstruction
[
rec_type
]]
len_stages
=
count_nested
(
rec_types
.
rec_stages
,
axis
=
2
)
longest
=
rec_types
[
len_stages
==
ak1
.
max
(
len_stages
,
axis
=
1
)]
out
=
longest
[
longest
.
lik
==
ak1
.
max
(
longest
.
lik
,
axis
=
1
)]
return
out
return
out
def
get_multiplicity
(
tracks
,
rec_stages
):
...
...
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