Fixed eloss bug

This commit is contained in:
James Szalkie 2026-07-01 14:59:11 -04:00
parent 3a0c04b1c0
commit 99fe598ee4
5 changed files with 1009 additions and 1005 deletions

View File

@ -58,7 +58,7 @@ private:
const float radius = 88;
const float width = 40;
const float length = 75; // 75
const float gap = 46; // 46
const float gap = 0; // 46
short id; // -1 when no hit
short chUp;

File diff suppressed because it is too large Load Diff

View File

@ -163,6 +163,8 @@ def make_E_vs_x(
print(f"[INFO] saved: {outfile}")
interp_cache.pop((label.lower(), medium.lower()), None)
return x, E
#Generate energy loss tables from file
@ -190,8 +192,10 @@ def load_table(filename):
def get_interpolators(particle, medium):
if particle in interp_cache:
return interp_cache[particle]
cache_key = (particle.lower(), medium.lower())
if cache_key in interp_cache:
return interp_cache[cache_key]
filename = f"{medium}Loss/E_vs_x_{particle}.dat"
@ -211,7 +215,7 @@ def get_interpolators(particle, medium):
fill_value="extrapolate"
)
interp_cache[particle] = (E_of_x, x_of_E)
interp_cache[cache_key] = (E_of_x, x_of_E)
return E_of_x, x_of_E
@ -264,7 +268,7 @@ def resolve_particle(name):
try:
element = pt.elements.symbol(element_symbol)
isotope = element[A] # <-- THIS is the correct way
isotope = element[A]
return (
isotope.number, # Z
@ -679,7 +683,7 @@ class MyInteractiveApp(cmd.Cmd):
Ei_offset = Ei * 1.1
table_specs = f"{particle} {Ei_offset}"
try:
self.do_make_table(table_specs)
#self.do_make_table(table_specs)
Ef = energy_loss(particle, medium, Ei, dl)
print(f"\nFinal energy: {Ef:.6f} MeV\n")
except:

File diff suppressed because it is too large Load Diff