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

Exciton ratio #249

Closed
wants to merge 9 commits into from
Closed
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
4 changes: 4 additions & 0 deletions fuse/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
(("Number of photons at interaction position", "photons"), np.int32),
(("Number of electrons at interaction position", "electrons"), np.int32),
(("Number of excitons at interaction position", "excitons"), np.int32),
(
("Ratio of excitons to photons at interaction position", "exciton_to_photon_ratio"),
np.float32,
),
]


Expand Down
20 changes: 13 additions & 7 deletions fuse/plugins/detector_physics/s1_photon_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def compute(self, interactions_in_roi):
positions=positions,
e_dep=instruction["ed"],
n_photons_emitted=n_photons,
n_excitons=instruction["excitons"].astype(np.int64),
exciton_to_photon_ratio=instruction["exciton_to_photon_ratio"],
local_field=instruction["e_field"],
)

Expand Down Expand Up @@ -260,7 +260,7 @@ class S1PhotonPropagation(S1PhotonPropagationBase):
"""Child plugin to simulate the propagation of S1 photons using optical
propagation and luminescence timing from nestpy."""

__version__ = "0.3.1"
__version__ = "0.3.2"

child_plugin = True

Expand Down Expand Up @@ -348,7 +348,7 @@ def photon_timings(
positions,
e_dep,
n_photons_emitted,
n_excitons,
exciton_to_photon_ratio,
local_field,
):
"""Calculate distribution of photon arrival timnigs
Expand All @@ -361,7 +361,7 @@ def photon_timings(
positions: nx3 array of true XYZ positions from instruction
e_dep: energy of the deposit, 1d float array
n_photons_emitted: number of orignally emitted photons/quanta, 1d int array
n_excitons: number of exctions in deposit, 1d int array
exciton_to_photon_ratio: Ratio of exctions to photons of the deposit, 1d int array
local_field: local field in the point of the deposit, 1d array of floats
Returns:
photon timing array
Expand All @@ -381,15 +381,21 @@ def photon_timings(
n_photon_hits=n_photon_hits,
n_photons_emitted=n_photons_emitted,
recoil_type=recoil_type,
n_excitons=n_excitons,
exciton_to_photon_ratio=exciton_to_photon_ratio,
local_field=local_field,
e_dep=e_dep,
)

return _photon_timings

def nest_scintillation_timing(
self, n_photon_hits, n_photons_emitted, recoil_type, n_excitons, local_field, e_dep
self,
n_photon_hits,
n_photons_emitted,
recoil_type,
exciton_to_photon_ratio,
local_field,
e_dep,
):

assert np.all(
Expand Down Expand Up @@ -421,7 +427,7 @@ def nest_scintillation_timing(
scint_time = self.nestpy_calc.GetPhotonTimes(
nestpy.INTERACTION_TYPE(recoil_type[i]),
n_times_to_sample,
n_excitons[i],
round(exciton_to_photon_ratio[i] * n_times_to_sample),
local_field[i],
e_dep[i],
)
Expand Down
9 changes: 8 additions & 1 deletion fuse/plugins/micro_physics/yields.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NestYields(FuseBasePlugin):
"""Plugin that calculates the number of photons, electrons and excitons
produced by energy deposit using nestpy."""

__version__ = "0.2.2"
__version__ = "0.2.3"

depends_on = ("interactions_in_roi", "electric_field_values")
provides = "quanta"
Expand Down Expand Up @@ -64,10 +64,17 @@ def compute(self, interactions_in_roi):
result["photons"] = photons
result["electrons"] = electrons
result["excitons"] = excitons
result["exciton_to_photon_ratio"] = np.divide(
excitons.astype(np.float32),
photons.astype(np.float32),
out=np.zeros(len(photons), dtype=np.float32),
where=photons != 0,
).astype(np.float32)
else:
result["photons"] = np.empty(0)
result["electrons"] = np.empty(0)
result["excitons"] = np.empty(0)
result["exciton_to_photon_ratio"] = np.empty(0)

# Unlock the nest random generator seed again
nest_rng.unlock_seed()
Expand Down
3 changes: 2 additions & 1 deletion tests/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def build_random_instructions(n):

df["photons"] = np.random.uniform(100, 5000, n)
df["electrons"] = np.random.uniform(100, 5000, n)
df["excitons"] = np.zeros(n)
df["excitons"] = df["photons"]
df["exciton_to_photon_ratio"] = np.ones(n) # Lets use a ratio of 1 for the tests.

df["e_field"] = np.array([23] * n)
df["nestid"] = np.array([7] * n)
Expand Down