Skip to content

Commit

Permalink
tune tof
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Jul 29, 2024
1 parent 54e082c commit 3510fe1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
25 changes: 14 additions & 11 deletions RefRed/calculations/lr_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,29 @@ def __init__(
# chopper settings
use_emission_delay = False
if "BL4B:Chop:Skf2:ChopperModerator" in mt_run:
base_path = mt_run.getProperty("BL4B:Det:TH:DlyDet:BasePath").value[0]
moderator_calc = mt_run.getProperty("BL4B:Chop:Skf2:ChopperModerator").value[0]
t_mult = mt_run.getProperty("BL4B:Chop:Skf2:ChopperMultiplier").value[0]
t_off = mt_run.getProperty("BL4B:Chop:Skf2:ChopperOffset").value[0]
use_emission_delay = moderator_calc == 1

wl_half_width = 1.7 * 60 / self.frequency
wl_half_width = 1.6 * 60 / self.frequency
wl_delta_full_range = 0.8 * 60 / self.frequency

# Calculate the TOF range to select
if use_emission_delay:
# We cut 5% on each side compared to the case without correction to avoid the shoulders
tmin = (self.dMD * (self.lambda_requested - wl_half_width * 0.95) / H_OVER_M_NEUTRON * 1e-4 + t_off) / (
1 - t_mult / 1000
)
tmax = (self.dMD * (self.lambda_requested + wl_half_width * 0.95) / H_OVER_M_NEUTRON * 1e-4 + t_off) / (
1 - t_mult / 1000
)
else:
tmin = self.dMD / H_OVER_M_NEUTRON * (self.lambda_requested - wl_half_width) * 1e-4
tmax = self.dMD / H_OVER_M_NEUTRON * (self.lambda_requested + wl_half_width) * 1e-4
self.dMD = base_path

tmin = self.dMD / H_OVER_M_NEUTRON * (self.lambda_requested - wl_half_width) * 1e-4
tmax = self.dMD / H_OVER_M_NEUTRON * (self.lambda_requested + wl_half_width) * 1e-4

if use_emission_delay:
wl_min = self.lambda_requested - wl_half_width
wl_max = self.lambda_requested + wl_half_width
# Empirical additional delay to get rid of the ramp
ramp_delay = -750 + 125.0 * (self.lambda_requested - 4)
tmin += t_off + t_mult * wl_min + ramp_delay
tmax += t_off + t_mult * wl_max

if lconfig is not None:
autotmin = float(lconfig.tof_range[0])
Expand Down
25 changes: 14 additions & 11 deletions RefRed/sf_calculator/lr_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,28 @@ def __init__(self, workspace, read_options):
# chopper settings
use_emission_delay = False
if "BL4B:Chop:Skf2:ChopperModerator" in mt_run:
base_path = mt_run.getProperty("BL4B:Det:TH:DlyDet:BasePath").value[0]
moderator_calc = mt_run.getProperty("BL4B:Chop:Skf2:ChopperModerator").value[0]
t_mult = mt_run.getProperty("BL4B:Chop:Skf2:ChopperMultiplier").value[0]
t_off = mt_run.getProperty("BL4B:Chop:Skf2:ChopperOffset").value[0]
use_emission_delay = moderator_calc == 1

wl_half_width = 1.7 * 60 / self.frequency
wl_half_width = 1.6 * 60 / self.frequency

# Calculate the TOF range to select
if use_emission_delay:
# We cut 5% on each side compared to the case without correction to avoid the shoulders
tmin = (self.dMD * (self.lambda_requested - wl_half_width * 0.95) / H_OVER_M_NEUTRON * 1e-4 + t_off) / (
1 - t_mult / 1000
)
tmax = (self.dMD * (self.lambda_requested + wl_half_width * 0.95) / H_OVER_M_NEUTRON * 1e-4 + t_off) / (
1 - t_mult / 1000
)
else:
tmax = self.dMD / H_OVER_M_NEUTRON * (self.lambda_requested + wl_half_width) * 1e-4
tmin = self.dMD / H_OVER_M_NEUTRON * (self.lambda_requested - wl_half_width) * 1e-4
self.dMD = base_path

tmax = self.dMD / H_OVER_M_NEUTRON * (self.lambda_requested + wl_half_width) * 1e-4
tmin = self.dMD / H_OVER_M_NEUTRON * (self.lambda_requested - wl_half_width) * 1e-4

if use_emission_delay:
wl_min = self.lambda_requested - wl_half_width
wl_max = self.lambda_requested + wl_half_width
# Empirical additional delay to get rid of the ramp
ramp_delay = -750 + 125.0 * (self.lambda_requested - 4)
tmin += t_off + t_mult * wl_min + ramp_delay
tmax += t_off + t_mult * wl_max

if self.read_options['is_auto_tof_finder'] or self.tof_range is None:
autotmin = tmin
Expand Down

0 comments on commit 3510fe1

Please sign in to comment.