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
90679798
Commit
90679798
authored
3 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Change output writing to geometry (w/o header so far)
parent
1728a022
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Detector geometries
Pipeline
#19046
failed
3 years ago
Stage: test
Stage: coverage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
km3buu/output.py
+12
-16
12 additions, 16 deletions
km3buu/output.py
with
12 additions
and
16 deletions
km3buu/output.py
+
12
−
16
View file @
90679798
...
@@ -27,6 +27,7 @@ import mendeleev
...
@@ -27,6 +27,7 @@ import mendeleev
from
datetime
import
datetime
from
datetime
import
datetime
from
.jobcard
import
Jobcard
,
read_jobcard
,
PDGID_LOOKUP
from
.jobcard
import
Jobcard
,
read_jobcard
,
PDGID_LOOKUP
from
.geometry
import
DetectorVolume
,
CanVolume
from
.config
import
Config
,
read_default_media_compositions
from
.config
import
Config
,
read_default_media_compositions
from
.__version__
import
version
from
.__version__
import
version
...
@@ -360,7 +361,7 @@ class GiBUUOutput:
...
@@ -360,7 +361,7 @@ class GiBUUOutput:
def
write_detector_file
(
gibuu_output
,
def
write_detector_file
(
gibuu_output
,
ofile
=
"
gibuu.offline.root
"
,
ofile
=
"
gibuu.offline.root
"
,
can
=
(
0
,
476.5
,
403.4
),
geometry
=
CanVolume
(
),
livetime
=
3.156e7
,
livetime
=
3.156e7
,
propagate_tau
=
True
):
# pragma: no cover
propagate_tau
=
True
):
# pragma: no cover
"""
"""
...
@@ -372,12 +373,13 @@ def write_detector_file(gibuu_output,
...
@@ -372,12 +373,13 @@ def write_detector_file(gibuu_output,
Output object which wraps the information from the GiBUU output files
Output object which wraps the information from the GiBUU output files
ofile: str
ofile: str
Output filename
Output filename
can: tuple
geometry: DetectorVolume
The can dimensions which are used to distribute the events
The detector geometry which should be used
(z_min, z_max, radius)
livetime: float
livetime: float
The data livetime
The data livetime
"""
"""
if
not
isinstance
(
geometry
,
DetectorVolume
):
raise
TypeError
(
"
Geometry needs to be a DetectorVolume
"
)
evt
=
ROOT
.
Evt
()
evt
=
ROOT
.
Evt
()
outfile
=
ROOT
.
TFile
.
Open
(
ofile
,
"
RECREATE
"
)
outfile
=
ROOT
.
TFile
.
Open
(
ofile
,
"
RECREATE
"
)
...
@@ -445,8 +447,7 @@ def write_detector_file(gibuu_output,
...
@@ -445,8 +447,7 @@ def write_detector_file(gibuu_output,
targets_per_volume
=
target_density
*
(
1e3
*
constants
.
Avogadro
/
targets_per_volume
=
target_density
*
(
1e3
*
constants
.
Avogadro
/
target
[
0
].
atomic_weight
)
target
[
0
].
atomic_weight
)
can_volume
=
np
.
pi
*
(
can
[
1
]
-
can
[
0
])
*
np
.
power
(
can
[
2
],
2
)
w2
=
gibuu_output
.
w2weights
(
geometry
.
volume
,
targets_per_volume
,
4
*
np
.
pi
)
w2
=
gibuu_output
.
w2weights
(
can_volume
,
targets_per_volume
,
4
*
np
.
pi
)
head
=
ROOT
.
Head
()
head
=
ROOT
.
Head
()
header_dct
=
EMPTY_KM3NET_HEADER_DICT
.
copy
()
header_dct
=
EMPTY_KM3NET_HEADER_DICT
.
copy
()
...
@@ -454,11 +455,11 @@ def write_detector_file(gibuu_output,
...
@@ -454,11 +455,11 @@ def write_detector_file(gibuu_output,
timestamp
=
datetime
.
now
()
timestamp
=
datetime
.
now
()
header_dct
[
"
simul
"
]
=
"
KM3BUU {} {}
"
.
format
(
header_dct
[
"
simul
"
]
=
"
KM3BUU {} {}
"
.
format
(
version
,
timestamp
.
strftime
(
"
%Y%m%d %H%M%S
"
))
version
,
timestamp
.
strftime
(
"
%Y%m%d %H%M%S
"
))
header_dct
[
"
can
"
]
=
"
{:.1f} {:.1f} {:.1f}
"
.
format
(
*
can
)
#
header_dct["can"] = "{:.1f} {:.1f} {:.1f}".format(*can)
header_dct
[
"
tgen
"
]
=
"
{:.1f}
"
.
format
(
livetime
)
header_dct
[
"
tgen
"
]
=
"
{:.1f}
"
.
format
(
livetime
)
header_dct
[
"
flux
"
]
=
"
{:d} 0 0
"
.
format
(
nu_type
)
header_dct
[
"
flux
"
]
=
"
{:d} 0 0
"
.
format
(
nu_type
)
header_dct
[
"
genvol
"
]
=
"
0 {:.1f} {:.1f} {:.1f} {:d}
"
.
format
(
#
header_dct["genvol"] = "0 {:.1f} {:.1f} {:.1f} {:d}".format(
can
[
1
],
can
[
2
],
can_volume
,
gibuu_output
.
generated_events
)
#
can[1], can[2], can_volume, gibuu_output.generated_events)
header_dct
[
"
cut_nu
"
]
=
"
{:.2f} {:.2f} -1 1
"
.
format
(
gibuu_output
.
energy_min
,
header_dct
[
"
cut_nu
"
]
=
"
{:.2f} {:.2f} -1 1
"
.
format
(
gibuu_output
.
energy_min
,
gibuu_output
.
energy_max
)
gibuu_output
.
energy_max
)
...
@@ -471,16 +472,11 @@ def write_detector_file(gibuu_output,
...
@@ -471,16 +472,11 @@ def write_detector_file(gibuu_output,
evt
.
id
=
mc_event_id
evt
.
id
=
mc_event_id
evt
.
mc_run_id
=
mc_event_id
evt
.
mc_run_id
=
mc_event_id
# Weights
# Weights
evt
.
w
.
push_back
(
can_
volume
)
#w1 (can volume)
evt
.
w
.
push_back
(
geometry
.
volume
)
#w1 (can volume)
evt
.
w
.
push_back
(
w2
[
mc_event_id
])
#w2
evt
.
w
.
push_back
(
w2
[
mc_event_id
])
#w2
evt
.
w
.
push_back
(
-
1.0
)
#w3 (= w2*flux)
evt
.
w
.
push_back
(
-
1.0
)
#w3 (= w2*flux)
# Vertex Position
# Vertex Position
r
=
can
[
2
]
*
np
.
sqrt
(
np
.
random
.
uniform
(
0
,
1
))
vtx_pos
=
np
.
array
(
geometry
.
random_pos
())
phi
=
np
.
random
.
uniform
(
0
,
2
*
np
.
pi
)
pos_x
=
r
*
np
.
cos
(
phi
)
pos_y
=
r
*
np
.
sin
(
phi
)
pos_z
=
np
.
random
.
uniform
(
can
[
0
],
can
[
1
])
vtx_pos
=
np
.
array
([
pos_x
,
pos_y
,
pos_z
])
# Direction
# Direction
phi
=
np
.
random
.
uniform
(
0
,
2
*
np
.
pi
)
phi
=
np
.
random
.
uniform
(
0
,
2
*
np
.
pi
)
cos_theta
=
np
.
random
.
uniform
(
-
1
,
1
)
cos_theta
=
np
.
random
.
uniform
(
-
1
,
1
)
...
...
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