Commit b072b048 authored by Philipp Oleynik's avatar Philipp Oleynik
Browse files

Old LUT, new two-slope core

parent 476e9e72
......@@ -19,7 +19,7 @@ else:
sixs_lut = npzfile['arr_0']
side_threshold = 0.035 # TODO: It is a magic number.
core_threshold = 0.600 # in MeV TODO: Another magic number. Chosen as an initial value.
core_threshold = 0.520 # in MeV TODO: Another magic number. Chosen as an initial value.
radiation_area = 5 * 5 * 4 * const.pi # radius 5 cm sphere area in cm2
......@@ -69,17 +69,18 @@ def core_energy_to_64(radiated_energy):
:param radiated_energy: Input energy in MeV, float.
:return: An output channel, 0..63 integer value.
"""
# core_cal_intercept = 178.8581 # old ones, should not be used
# core_cal_slope = 15.5249
# core_cal_power = 2.5937
core_instr_offset = 166
core_cal_slope = 47.121
core_cal_offset = 157 # TODO: It is a magic number. Fitted only, not verified.
adc_11 = saturate2048(int(radiated_energy * core_cal_slope + core_cal_offset)) - core_instr_offset
core_cal_slope_high = 47.363
core_cal_offset_high = 155
core_cal_slope_low = 33.1541
core_cal_offset_low = 169.3 # TODO: It is a magic number. Fitted only, not verified.
x = max(radiated_energy * core_cal_slope_high + core_cal_offset_high,
radiated_energy * core_cal_slope_low + core_cal_offset_low)
adc_11 = saturate2048(int(x)) - core_instr_offset
adc_8 = logbit11to8(adc11=int(adc_11))
mute = 0 if radiated_energy < core_threshold else 1 # A correction for the threshold
x = 1 if radiated_energy > core_threshold else 0 # A correction for the algorithm in the SIXS firmware
return mute*(int(round(adc_8)) // 4) if adc_8 >= 4 else x
y = 1 if radiated_energy > core_threshold else 0 # A correction for the algorithm in the SIXS firmware
return mute * (int(round(adc_8)) // 4) if adc_8 >= 4 else y
def side_energy_to_64(energy, side): # MeV to 6 bit side
......@@ -89,10 +90,15 @@ def side_energy_to_64(energy, side): # MeV to 6 bit side
:param energy: Input energy in MeV, float.
:return: An output channel, 0..63 integer value.
"""
side_cal_intercept = np.array([167.513, 158.190, 172.329, 165.407, 173.593])
side_cal_slope = np.array([243.464, 250.992, 253.015, 252.194, 253.492])
side_cal_intercept_low = np.array([167.513, 158.190, 172.329, 165.407, 173.593])
side_cal_slope_low = np.array([243.464, 250.992, 253.015, 252.194, 253.492])
side_cal_intercept_high = np.array([151.416, 138.757, 153.346, 147.083, 154.024])
side_cal_slope_high = np.array([284.069, 286.196, 284.543, 286.994, 288.152])
side_instr_offset = np.array([168, 159, 174, 167, 175])
adc_11 = saturate2048(int(side_cal_intercept[side] + side_cal_slope[side] * energy)) - side_instr_offset[side]
x = max(side_cal_intercept_high[side] + side_cal_slope_high[side] * energy,
side_cal_intercept_low[side] + side_cal_slope_low[side] * energy)
adc_11 = saturate2048(int(x)) - side_instr_offset[side]
adc_8 = logbit11to8(adc11=int(adc_11))
return int(round(adc_8)) // 4 if adc_8 >= 0 else 0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment