Skip to content

Commit

Permalink
fix import issue in es.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JostMigenda committed Jul 23, 2020
1 parent eb9c034 commit 23e5fa4
Show file tree
Hide file tree
Showing 3 changed files with 6,247 additions and 6,137 deletions.
2 changes: 1 addition & 1 deletion sntools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
see https://github.com/JostMigenda/sntools.
"""

__version__ = '0.6.0'
__version__ = '0.6.1'
21 changes: 11 additions & 10 deletions sntools/interaction_channels/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

from __future__ import division

# `builtins._flavor` is set in `genevts.py`
# Use `builtins._flavor` (see `genevts.py`) explicitly (instead of `_flavor`)
# to make the code easier to understand--both for humans and for linters.
try:
from __builtin__ import _flavor # Python 2.7
import __builtin__ as builtins # Python 2.7
except ImportError:
from builtins import _flavor # Python 3
import builtins # Python 3
from math import pi, sqrt, log
from scipy import integrate

Expand All @@ -28,7 +29,7 @@ def generate_event(eNu, dirx, diry, dirz):
eNu: neutrino energy
dirx, diry, dirz: direction of outgoing particle (normalized to 1)
"""
incoming_flv = {'e': 12, 'eb': -12, 'x': 14, 'xb': -14}[_flavor]
incoming_flv = {'e': 12, 'eb': -12, 'x': 14, 'xb': -14}[builtins._flavor]
eE = get_eE(eNu, dirz)

evt = Event(98 if incoming_flv > 0 else -98)
Expand Down Expand Up @@ -73,24 +74,24 @@ def dSigma_dE(eNu, eE):
x = sqrt(1 + 2 * mE / T)
i = 1 / 6 * (1 / 3 + (3 - x**2) * (x / 2 * log((x + 1) / (x - 1)) - 1))

if _flavor in ("e", "eb"):
if builtins._flavor in ("e", "eb"):
k = 0.9791 + 0.0097 * i
elif _flavor in ("x", "xb"):
elif builtins._flavor in ("x", "xb"):
k = 0.9970 - 0.00037 * i

g1 = rho_NC * (0.5 - k * sin2theta_w)
g2 = -rho_NC * k * sin2theta_w

if _flavor == "e":
if builtins._flavor == "e":
gL = g1 - 1
gR = g2
elif _flavor == "eb":
elif builtins._flavor == "eb":
gL = g2
gR = g1 - 1
elif _flavor == "x":
elif builtins._flavor == "x":
gL = g1
gR = g2
elif _flavor == "xb":
elif builtins._flavor == "xb":
gL = g2
gR = g1

Expand Down
Loading

0 comments on commit 23e5fa4

Please sign in to comment.