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
5dd73c0b
Commit
5dd73c0b
authored
3 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Refine interface of visual energy
parent
94fbbb4b
No related branches found
No related tags found
1 merge request
!25
Visible energy
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3buu/physics.py
+51
-12
51 additions, 12 deletions
km3buu/physics.py
km3buu/tests/test_physics.py
+1
-1
1 addition, 1 deletion
km3buu/tests/test_physics.py
with
52 additions
and
13 deletions
km3buu/physics.py
+
51
−
12
View file @
5dd73c0b
...
@@ -107,51 +107,89 @@ HE_PARAMS = {
...
@@ -107,51 +107,89 @@ HE_PARAMS = {
}
}
@np.vectorize
def
_get_particle_rest_mass
(
pdgid
):
def
_get_particle_rest_mass
(
pdgid
):
return
Particle
.
from_pdgid
(
pdgid
).
mass
/
1e3
@np.vectorize
def
vfunc
(
x
):
mass
=
Particle
.
from_pdgid
(
x
).
mass
if
mass
is
None
:
return
0
return
mass
/
1e3
pdgids
,
invmap
=
np
.
unique
(
ak
.
to_numpy
(
pdgid
),
return_inverse
=
True
)
masses
=
vfunc
(
pdgids
)
return
masses
[
invmap
]
def
visible_energy_fraction
(
pdgid
,
energy
):
def
get_kinetic_energy
(
energy
,
pdgid
):
"""
"""
Returns the visible energy fraction in the one particle approximation (OPA)
Returns the kinetic energy
Parameters
----------
energy: float [GeV]
Total energy of the given particle
pdgid: int
PDGID of the given particle
"""
mass
=
np
.
array
(
_get_particle_rest_mass
(
pdgid
))
return
np
.
sqrt
(
ak
.
to_numpy
(
energy
)
**
2
-
mass
**
2
)
def
visible_energy
(
energy
,
pdgid
):
"""
Returns the visible energy in the one particle approximation (OPA)
how it is used in JSirene (i.e. JPythia.hh)
how it is used in JSirene (i.e. JPythia.hh)
Parameters
Parameters
----------
----------
energy: float [GeV]
Total energy of the given particle
pdgid: int
pdgid: int
PDGID of the given particle
PDGID of the given particle
"""
return
get_kinetic_energy
(
energy
,
pdgid
)
*
visible_energy_fraction
(
energy
,
pdgid
)
def
visible_energy_fraction
(
energy
,
pdgid
):
"""
Returns the visible energy fraction in the one particle approximation (OPA)
how it is used in JSirene (i.e. JPythia.hh)
Parameters
----------
energy: float [GeV]
energy: float [GeV]
Total energy of the given particle
Total energy of the given particle
pdgid: int
PDGID of the given particle
"""
"""
pdgid
=
ak
.
to_numpy
(
pdgid
)
pdgid
=
ak
.
to_numpy
(
pdgid
)
retval
=
np
.
zeros_like
(
pdgid
,
dtype
=
np
.
float64
)
retval
=
np
.
zeros_like
(
pdgid
,
dtype
=
np
.
float64
)
mask
=
np
.
isin
(
pdgid
,
[
11
,
-
11
,
22
,
111
,
221
])
mask
=
np
.
isin
(
pdgid
,
[
11
,
-
11
,
22
,
111
,
221
])
retval
[
mask
]
=
1.0
retval
[
mask
]
=
1.0
mask
=
np
.
isin
(
pdgid
,
[
-
211
,
211
])
mask
=
np
.
isin
(
pdgid
,
[
-
211
,
211
])
mass
=
np
.
array
(
_get_particle_rest_mass
(
pdgid
[
mask
]))
ekin
=
get_kinetic_energy
(
energy
[
mask
],
pdgid
[
mask
])
tmp
=
np
.
sqrt
(
ak
.
to_numpy
(
energy
)[
mask
]
**
2
-
mass
**
2
)
retval
[
mask
]
=
high_energy_weight
(
ekin
)
retval
[
mask
]
=
high_energy_weight
(
tmp
)
mask
=
np
.
isin
(
pdgid
,
[
13
])
mask
=
np
.
isin
(
pdgid
,
[
13
])
if
np
.
any
(
mask
):
if
np
.
any
(
mask
):
mass
=
Particle
.
from_pdgid
(
13
).
mass
/
1e3
mass
=
Particle
.
from_pdgid
(
13
).
mass
/
1e3
tmp
=
np
.
sqrt
(
ak
.
to_numpy
(
energy
)[
mask
]
**
2
-
mass
**
2
)
ekin
=
np
.
sqrt
(
ak
.
to_numpy
(
energy
)[
mask
]
**
2
-
mass
**
2
)
retval
[
mask
]
=
muon_range_seawater
(
tmp
,
mass
)
/
4.7
retval
[
mask
]
=
muon_range_seawater
(
ekin
,
mass
)
/
4.7
return
retval
return
retval
@np.vectorize
@np.vectorize
def
km3_opa_fraction
(
pdgid
,
energy
):
def
km3_opa_fraction
(
energy
,
pdgid
):
"""
"""
Returns the visible energy fraction in the one particle approximation (OPA)
Returns the visible energy fraction in the one particle approximation (OPA)
how it is used in KM3
how it is used in KM3
Parameters
Parameters
----------
----------
pdgid: int
PDGID of the given particle
energy: float [GeV]
energy: float [GeV]
Kinetic energy of the given particle
Kinetic energy of the given particle
pdgid: int
PDGID of the given particle
"""
"""
# Cover trivial cases, i.e. 'non-visible' particles and ultra-high energy
# Cover trivial cases, i.e. 'non-visible' particles and ultra-high energy
...
@@ -268,6 +306,7 @@ def neutron_weight(energy):
...
@@ -268,6 +306,7 @@ def neutron_weight(energy):
energy
+
1e4
*
NEUTRON_PARAMS
[
"
Ni
"
]
*
energy
**
2
+
energy
+
1e4
*
NEUTRON_PARAMS
[
"
Ni
"
]
*
energy
**
2
+
1e4
*
NEUTRON_PARAMS
[
"
Nj
"
]
*
energy
**
3
)
/
norm
1e4
*
NEUTRON_PARAMS
[
"
Nj
"
]
*
energy
**
3
)
/
norm
@np.vectorize
@np.vectorize
def
high_energy_weight
(
energy
):
def
high_energy_weight
(
energy
):
"""
"""
...
...
This diff is collapsed.
Click to expand it.
km3buu/tests/test_physics.py
+
1
−
1
View file @
5dd73c0b
...
@@ -49,7 +49,7 @@ class TestVisEnergyParticle(unittest.TestCase):
...
@@ -49,7 +49,7 @@ class TestVisEnergyParticle(unittest.TestCase):
def
test_particles
(
self
):
def
test_particles
(
self
):
for
i
,
pdgid
in
enumerate
(
self
.
particles
):
for
i
,
pdgid
in
enumerate
(
self
.
particles
):
val
=
km3_opa_fraction
(
pdgid
,
self
.
ref_values
[
0
,
:])
val
=
km3_opa_fraction
(
self
.
ref_values
[
0
,
:]
,
pdgid
)
assert
np
.
allclose
(
self
.
ref_values
[
i
+
1
,
:],
assert
np
.
allclose
(
self
.
ref_values
[
i
+
1
,
:],
val
,
val
,
rtol
=
0.05
,
rtol
=
0.05
,
...
...
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