Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lar: emission interpolation in defining function #36

Merged
merged 4 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/source/exts/optics_plot_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def do_plot(

if "call_x" in options:
# special case for LAr properties
x = np.linspace(112 * u.nm, 650 * u.nm, num=200)
lim = [112 * u.nm, 650 * u.nm]
if "xlim" in options:
lim = [xl * u.nm for xl in options["xlim"]]
x = np.linspace(*lim, num=200)
ys = obj(x)
# wrap the result in a tuple, if needed
ys = ys if isinstance(ys, tuple) else (ys,)
Expand Down
27 changes: 16 additions & 11 deletions src/legendoptics/lar.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,21 @@ def lar_refractive_index(λ: Quantity, method: str = "cern2020") -> Quantity:
return np.sqrt(lar_dielectric_constant(λ, method))


def lar_emission_spectrum() -> tuple[Quantity, Quantity]:
def lar_emission_spectrum(λ: Quantity) -> Quantity:
"""Return the LAr emission spectrum, adapted from [Heindl2010]_.

.. optics-plot::
.. optics-plot:: {'call_x': True, 'xlim': [116, 141]}
"""
return readdatafile("lar_emission_heindl2010.dat")
heindl = readdatafile("lar_emission_heindl2010.dat")

# sample the measured emission spectrum and avoid the fluctuations below 115 nm.
scint_em = InterpolatingGraph(
*heindl,
min_idx=115 * u.nm,
max_idx=150 * u.nm,
)(λ)

return scint_em


def lar_fano_factor() -> float:
Expand Down Expand Up @@ -256,11 +265,11 @@ def lar_scintillation_params(flat_top_yield: Quantity = 31250 / u.MeV) -> ScintC
relative to the one of flat top particles is:

.. math::
Y_\texrm{e} &= 0.8 Y
Y_\textrm{e} &= 0.8 Y

Y_\texrm{alpha} &= 0.7 Y
Y_\textrm{alpha} &= 0.7 Y

Y_\texrm{recoils} &= 0.2\textrm{--}0.4
Y_\textrm{recoils} &= 0.2\textrm{--}0.4

Excitation ratio:
For example, for nuclear recoils it should be 0.75
Expand Down Expand Up @@ -412,11 +421,7 @@ def pyg4_lar_attach_scintillation(
λ_peak = pyg4_sample_λ(116 * u.nm, 141 * u.nm)

# sample the measured emission spectrum.
scint_em = InterpolatingGraph(
*lar_emission_spectrum(),
min_idx=115 * u.nm,
max_idx=150 * u.nm,
)(λ_peak)
scint_em = lar_emission_spectrum(λ_peak)
# make sure that the scintillation spectrum is zero at the boundaries.
scint_em[0] = 0
scint_em[-1] = 0
Expand Down
3 changes: 2 additions & 1 deletion src/legendoptics/pyg4utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def _val_pint_to_gdml(v):
v = v.m_as(base_unit)
return unit, v

length_u = ["m", "cm", "mm", "um"]
# Only as of Geant4 11.1.0, `um` and `nm` are supported.
length_u = ["km", "m", "cm", "mm", "um", "nm"]
dimless_props = [
"RINDEX",
"WLSCOMPONENT",
Expand Down
17 changes: 9 additions & 8 deletions tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ def test_import():
import legendoptics.tpb

legendoptics.lar.lar_fano_factor()
legendoptics.lar.lar_emission_spectrum()
wvl = np.arange(110, 400, 20) * u.nm
legendoptics.lar.lar_dielectric_constant_bideau_mehu(wvl)
legendoptics.lar.lar_dielectric_constant_cern2020(wvl)
legendoptics.lar.lar_dielectric_constant(wvl)
legendoptics.lar.lar_refractive_index(wvl)
legendoptics.lar.lar_rayleigh(wvl, 87 * u.K)
legendoptics.lar.lar_abs_length(wvl)
λ_peak = np.arange(116, 141, 20) * u.nm
legendoptics.lar.lar_emission_spectrum(λ_peak)
λ = np.arange(110, 400, 20) * u.nm
legendoptics.lar.lar_dielectric_constant_bideau_mehu(λ)
legendoptics.lar.lar_dielectric_constant_cern2020(λ)
legendoptics.lar.lar_dielectric_constant(λ)
legendoptics.lar.lar_refractive_index(λ)
legendoptics.lar.lar_rayleigh(λ, 87 * u.K)
legendoptics.lar.lar_abs_length(λ)
legendoptics.lar.lar_peak_attenuation_length()
legendoptics.lar.lar_lifetimes()
legendoptics.lar.lar_scintillation_params()
Expand Down
5 changes: 3 additions & 2 deletions tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import numpy as np
import pint

from legendoptics.lar import lar_emission_spectrum, lar_refractive_index
from legendoptics.copper import copper_reflectivity
from legendoptics.lar import lar_refractive_index
from legendoptics.plot import plot_continuous_prop, plot_discrete_prop

u = pint.get_application_registry()
Expand All @@ -15,4 +16,4 @@ def test_plot_continuous_prop():

def test_plot_discrete_prop():
fig, ax = plt.subplots()
plot_discrete_prop(ax, lar_emission_spectrum)
plot_discrete_prop(ax, copper_reflectivity)