diff --git a/src/legendoptics/scintillate.py b/src/legendoptics/scintillate.py index 75190a6..91cb863 100644 --- a/src/legendoptics/scintillate.py +++ b/src/legendoptics/scintillate.py @@ -39,7 +39,23 @@ def get_particle(self, name: str) -> Optional[ScintParticle]: # noqa: UP007 ComputedScintParams = NewType( "ComputedScintParams", tuple[float, float, np.ndarray, np.ndarray] ) -PARTICLE_INDICES = {"electron": 0, "alpha": 1, "ion": 2, "deuteron": 3, "triton": 4} +PARTICLE_INDEX_ELECTRON = 0 +PARTICLE_INDEX_ALPHA = 1 +PARTICLE_INDEX_ION = 2 +PARTICLE_INDEX_DEUTERON = 3 +PARTICLE_INDEX_TRITON = 4 +PARTICLE_INDICES = { + "electron": PARTICLE_INDEX_ELECTRON, + "alpha": PARTICLE_INDEX_ALPHA, + "ion": PARTICLE_INDEX_ION, + "deuteron": PARTICLE_INDEX_DEUTERON, + "triton": PARTICLE_INDEX_TRITON, +} + + +def particle_to_index(particle: str) -> ParticleIndex: + """Converts the given G4 scintillation particle name to a module-internal index.""" + return PARTICLE_INDICES[particle.lower()] def precompute_scintillation_params( @@ -60,7 +76,8 @@ def precompute_scintillation_params( electron = scint_config.get_particle("electron") if electron is None: - raise ValueError() + msg = "missing electron scintillation particle component (used as fallback for all other)" + raise ValueError(msg) for k, v in PARTICLE_INDICES.items(): p = scint_config.get_particle(k) p = electron if p is None else p @@ -75,11 +92,6 @@ def precompute_scintillation_params( return scint_config.flat_top.to("1/keV").m, fano, time_components, particles -def particle_to_index(particle: str) -> ParticleIndex: - """Converts the given G4 scintillation particle name to a module-internal index.""" - return PARTICLE_INDICES[particle.lower()] - - @njit def scintillate_local( params: ComputedScintParams,