Skip to content

Commit

Permalink
pyg4: implement correct energy sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelHu committed Aug 16, 2023
1 parent f33f717 commit a1926c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/legendoptics/nylon.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
In: Astroparticle Physics 97 (2018). https://doi.org/10.1016/j.astropartphys.2017.10.003
.. [Benziger2007] J. Benziger et al. “The Nylon Scintillator Containment Vessels for the
Borexino Solar Neutrino Experiment” In: nternational Journal of Modern Physics A, 29(16)
Borexino Solar Neutrino Experiment” In: International Journal of Modern Physics A, 29(16)
(2014). https://doi.org/10.1016/j.nima.2007.08.176
"""

Expand Down
7 changes: 6 additions & 1 deletion src/legendoptics/pyg4utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def _val_pint_to_gdml(v):
def addVecPropertyPint(self, name, e, v): # noqa: N802
vunit, v = _val_pint_to_gdml(v)
eunit, e = _val_pint_to_gdml(e)
v = np.array(v)
e = np.array(e)

if name in length_props and vunit not in length_u:
log.warning("Wrong unit %s for property %s", vunit, name)
Expand All @@ -114,7 +116,10 @@ def addVecPropertyPint(self, name, e, v): # noqa: N802
if eunit not in ["", "eV", "keV", "MeV", "GeV", "TeV", "PeV"]:
log.warning("Wrong energy unit %s", eunit)

# TODO: necessary to reorder values
# reorder the values to be in ascending energy order.
sort = np.argsort(e)
e = e[sort]
v = v[sort]

return g4.Material.addVecProperty(self, name, e, v, eunit, vunit)

Expand Down

0 comments on commit a1926c1

Please sign in to comment.