Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3BUU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
simulation
KM3BUU
Commits
0f2ee957
Commit
0f2ee957
authored
4 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
KM3NeT dataformat lib load cosmetics
parent
1a664b6f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
KM3NeT Dataformat data writeout
Pipeline
#16334
failed
4 years ago
Stage: test
Stage: coverage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
km3buu/config.py
+24
-8
24 additions, 8 deletions
km3buu/config.py
km3buu/output.py
+7
-3
7 additions, 3 deletions
km3buu/output.py
km3buu/tests/test_output.py
+13
-6
13 additions, 6 deletions
km3buu/tests/test_output.py
with
44 additions
and
17 deletions
km3buu/config.py
+
24
−
8
View file @
0f2ee957
...
...
@@ -28,9 +28,18 @@ CONFIG_PATH = os.path.expanduser("~/.km3buu/config")
log
=
get_logger
(
__name__
)
GENERAL_SECTION
=
"
General
"
KM3NET_LIB_PATH_KEY
=
"
km3net_lib_path
"
GIBUU_SECTION
=
"
GiBUU
"
GIBUU_IMAGE_PATH_KEY
=
"
image_path
"
PROPOSAL_SECTION
=
"
PROPOSAL
"
PROPOSAL_ITP_PATH_KEY
=
"
itp_table_path
"
GSEAGEN_SECTION
=
"
gSeagen
"
GSEAGEN_PATH_KEY
=
"
path
"
GSEAGEN_MEDIA_COMPOSITION_FILE
=
"
MediaComposition.xml
"
...
...
@@ -62,8 +71,7 @@ class Config(object):
@property
def
gibuu_image_path
(
self
):
key
=
"
image_path
"
image_path
=
self
.
get
(
GIBUU_SECTION
,
key
)
image_path
=
self
.
get
(
GIBUU_SECTION
,
GIBUU_IMAGE_PATH_KEY
)
if
image_path
is
None
or
not
isfile
(
image_path
):
dev_path
=
abspath
(
join
(
dirname
(
__file__
),
os
.
pardir
,
IMAGE_NAME
))
if
isfile
(
dev_path
):
...
...
@@ -86,26 +94,34 @@ class Config(object):
@gibuu_image_path.setter
def
gibuu_image_path
(
self
,
value
):
section
=
"
GiBUU
"
key
=
"
image_path
"
section
=
GIBUU_SECTION
key
=
GIBUU_IMAGE_PATH_KEY
self
.
set
(
section
,
key
,
value
)
@property
def
proposal_itp_tables
(
self
):
default_path
=
abspath
(
join
(
dirname
(
__file__
),
"
../.tables
"
))
return
self
.
get
(
PROPOSAL_SECTION
,
"
itp_table_path
"
,
default_path
)
return
self
.
get
(
PROPOSAL_SECTION
,
PROPOSAL_ITP_PATH_KEY
,
default_path
)
@proposal_itp_tables.setter
def
proposal_itp_tables
(
self
,
value
):
self
.
set
(
PROPOSAL_SECTION
,
"
itp_table_path
"
,
value
)
self
.
set
(
PROPOSAL_SECTION
,
PROPOSAL_ITP_PATH_KEY
,
value
)
@property
def
gseagen_path
(
self
):
return
self
.
get
(
GSEAGEN_SECTION
,
"
path
"
)
return
self
.
get
(
GSEAGEN_SECTION
,
GSEAGEN_PATH_KEY
)
@gseagen_path.setter
def
gseagen_path
(
self
,
value
):
self
.
set
(
GIBUU_SECTION
,
"
path
"
,
value
)
self
.
set
(
GIBUU_SECTION
,
GSEAGEN_PATH_KEY
,
value
)
@property
def
km3net_lib_path
(
self
):
return
self
.
set
(
GENERAL_SECTION
,
KM3NET_LIB_PATH_KEY
,
None
)
@km3net_lib_path.setter
def
km3net_lib_path
(
self
,
value
):
return
self
.
get
(
GENERAL_SECTION
,
KM3NET_LIB_PATH_KEY
,
value
)
def
read_media_compositions
(
filename
):
...
...
This diff is collapsed.
Click to expand it.
km3buu/output.py
+
7
−
3
View file @
0f2ee957
...
...
@@ -26,13 +26,17 @@ import scipy.constants as constants
import
mendeleev
from
.jobcard
import
Jobcard
,
read_jobcard
,
PDGID_LOOKUP
from
.config
import
read_default_media_compositions
from
.config
import
Config
,
read_default_media_compositions
try
:
import
ROOT
ROOT
.
gSystem
.
Load
(
join
(
environ
(
"
KM3NET_LIB
"
,
"
libKM3NeTROOT.so
"
)))
libpath
=
environ
.
get
(
"
KM3NET_LIB
"
)
if
libpath
:
libpath
=
Config
().
km3net_lib_path
ROOT
.
gSystem
.
Load
(
join
(
libpath
,
"
libKM3NeTROOT.so
"
))
except
:
pass
import
warnings
warnings
.
warn
(
"
KM3NeT dataformat library was not loaded.
"
,
ImportWarning
)
EVENT_FILENAME
=
"
FinalEvents.dat
"
ROOT_PERT_FILENAME
=
"
EventOutput.Pert.[0-9]{8}.root
"
...
...
This diff is collapsed.
Click to expand it.
km3buu/tests/test_output.py
+
13
−
6
View file @
0f2ee957
...
...
@@ -15,19 +15,25 @@ from unittest.mock import patch
import
numpy
as
np
import
pytest
import
km3io
from
km3buu.output
import
*
from
os
import
listdir
from
os
import
listdir
,
environ
from
os.path
import
abspath
,
join
,
dirname
from
km3net_testdata
import
data_path
from
tempfile
import
NamedTemporaryFile
,
TemporaryDirectory
from
km3buu.output
import
*
from
km3buu.config
import
Config
TESTDATA_DIR
=
data_path
(
"
gibuu
"
)
try
:
import
aa
,
ROOT
AANET_AVAILABLE
=
True
import
ROOT
libpath
=
environ
.
get
(
"
KM3NET_LIB
"
)
if
libpath
is
None
:
libpath
=
Config
().
km3net_lib_path
KM3NET_LIB_AVAILABLE
=
(
ROOT
.
gSystem
.
Load
(
join
(
libpath
,
"
libKM3NeTROOT.so
"
))
==
0
)
except
ImportError
:
AANET
_AVAILABLE
=
False
KM3NET_LIB
_AVAILABLE
=
False
class
TestXSection
(
unittest
.
TestCase
):
...
...
@@ -73,7 +79,8 @@ class TestGiBUUOutput(unittest.TestCase):
w2
[:
3
],
[
7.63360911e+01
,
3.60997502e-01
,
1.13273189e+03
])
@pytest.mark.skipif
(
not
AANET_AVAILABLE
,
reason
=
"
aanet required
"
)
@pytest.mark.skipif
(
not
KM3NET_LIB_AVAILABLE
,
reason
=
"
KM3NeT dataformat required
"
)
class
TestAANET
(
unittest
.
TestCase
):
def
setUp
(
self
):
output
=
GiBUUOutput
(
TESTDATA_DIR
)
...
...
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