Skip to content

Commit

Permalink
Merge pull request #128 from neutrons/fix_tof_range
Browse files Browse the repository at this point in the history
Fine-tune automated TOF range selection
  • Loading branch information
mdoucet authored Jul 29, 2024
2 parents 86df159 + 1fe7356 commit bb47a16
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
23 changes: 13 additions & 10 deletions RefRed/calculations/lr_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ 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]
Expand All @@ -137,16 +138,18 @@ def __init__(

# 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 = -450 + 100.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
23 changes: 13 additions & 10 deletions RefRed/sf_calculator/lr_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ 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]
Expand All @@ -85,16 +86,18 @@ def __init__(self, workspace, read_options):

# 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 = -450 + 100.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

1 comment on commit bb47a16

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline for refred-dev has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/conda-legacy-deploy/-/pipelines/596959"

Please sign in to comment.