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
e77f79ee
Commit
e77f79ee
authored
4 years ago
by
Zineb Aly
Browse files
Options
Downloads
Patches
Plain Diff
mask empty tracks
parent
a64cc4ef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Checking pipeline status
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3io/tools.py
+4
-3
4 additions, 3 deletions
km3io/tools.py
tests/test_tools.py
+14
-9
14 additions, 9 deletions
tests/test_tools.py
with
18 additions
and
12 deletions
km3io/tools.py
+
4
−
3
View file @
e77f79ee
...
...
@@ -271,13 +271,13 @@ def mask(rec_stages, stages):
return
builder
.
snapshot
()
==
1
def
best_track
(
track
s
,
strategy
=
"
first
"
,
rec_type
=
None
,
rec_stages
=
None
):
def
best_track
(
event
s
,
strategy
=
"
first
"
,
rec_type
=
None
,
rec_stages
=
None
):
"""
best track selection based on different strategies
Parameters
----------
track
s : class km3io.offline.OfflineBranch
the
track
s branch.
event
s : class km3io.offline.OfflineBranch
the
event
s branch.
strategy : str
the trategy desired to select the best tracks. It is either:
-
"
first
"
: to select the first tracks.
...
...
@@ -297,6 +297,7 @@ def best_track(tracks, strategy="first", rec_type=None, rec_stages=None):
class km3io.offline.OfflineBranch
tracks class with the desired
"
best tracks
"
selection.
"""
tracks
=
events
.
tracks
[
events
.
n_tracks
>
0
]
if
strategy
==
"
first
"
:
return
tracks
[:,
0
]
...
...
This diff is collapsed.
Click to expand it.
tests/test_tools.py
+
14
−
9
View file @
e77f79ee
...
...
@@ -8,11 +8,16 @@ from pathlib import Path
from
km3io
import
OfflineReader
from
km3io.tools
import
(
to_num
,
cached_property
,
unfold_indices
,
unique
,
uniquecount
,
fitinf
,
fitparams
,
count_nested
,
_find
,
mask
,
best_track
,
rec_types
)
mask
,
best_track
,
rec_types
,
get_w2list_param
)
SAMPLES_DIR
=
Path
(
__file__
).
parent
/
'
samples
'
OFFLINE_FILE
=
OfflineReader
(
SAMPLES_DIR
/
'
km3net_offline.root
'
)
# class TestGetw2listParam(unittest.TestCase):
# def test_get_w2list_param(self):
# xsec_mean = get_w2list_param(OFFLINE_FILE.events, "gseagen", "W2LIST_GSEAGEN_XSEC_MEAN")
# print(xsec_mean)
class
TestFitinf
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -48,25 +53,25 @@ class TestRecoTypes(unittest.TestCase):
class
TestBestTrack
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
track
s
=
OFFLINE_FILE
.
events
.
tracks
self
.
event
s
=
OFFLINE_FILE
.
events
def
test_best_tracks
(
self
):
first_tracks
=
best_track
(
self
.
track
s
,
strategy
=
"
first
"
)
rec_stages_tracks
=
best_track
(
self
.
track
s
,
first_tracks
=
best_track
(
self
.
event
s
,
strategy
=
"
first
"
)
rec_stages_tracks
=
best_track
(
self
.
event
s
,
strategy
=
"
rec_stages
"
,
rec_stages
=
[
1
,
3
,
5
,
4
])
default_best
=
best_track
(
self
.
track
s
,
default_best
=
best_track
(
self
.
event
s
,
strategy
=
"
default
"
,
rec_type
=
"
JPP_RECONSTRUCTION_TYPE
"
)
assert
first_tracks
.
dir_z
[
0
]
==
self
.
tracks
.
dir_z
[
0
][
0
]
assert
first_tracks
.
dir_x
[
1
]
==
self
.
tracks
.
dir_x
[
1
][
0
]
assert
first_tracks
.
dir_z
[
0
]
==
self
.
events
.
tracks
.
dir_z
[
0
][
0
]
assert
first_tracks
.
dir_x
[
1
]
==
self
.
events
.
tracks
.
dir_x
[
1
][
0
]
assert
rec_stages_tracks
.
rec_stages
[
0
]
==
[
1
,
3
,
5
,
4
]
assert
rec_stages_tracks
.
rec_stages
[
1
]
==
[
1
,
3
,
5
,
4
]
assert
default_best
.
lik
[
0
]
==
ak
.
max
(
self
.
tracks
.
lik
[
0
])
assert
default_best
.
lik
[
1
]
==
ak
.
max
(
self
.
tracks
.
lik
[
1
])
assert
default_best
.
lik
[
0
]
==
ak
.
max
(
self
.
events
.
tracks
.
lik
[
0
])
assert
default_best
.
lik
[
1
]
==
ak
.
max
(
self
.
events
.
tracks
.
lik
[
1
])
assert
default_best
.
rec_type
[
0
]
==
4000
...
...
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