Skip to content

Commit

Permalink
Merge pull request #27 from neutrons/fix_template
Browse files Browse the repository at this point in the history
Add dead time parameters to template
  • Loading branch information
mdoucet authored Apr 26, 2024
2 parents 97d09b4 + 347d370 commit 4c4d3bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion reduction/lr_reduction/DeadTimeCorrection.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def PyExec(self):
dead_time = self.getProperty("DeadTime").value
tof_step = self.getProperty("TOFStep").value
paralyzing = self.getProperty("Paralyzable").value
output_workspace = self.getPropertyValue("OutputWorkspace")

# Rebin the data according to the tof_step we want to compute the correction with
tof_min, tof_max = self.getProperty("TOFRange").value
Expand All @@ -54,7 +55,7 @@ def PyExec(self):
_ws_sc = Rebin(InputWorkspace=ws_event_data, Params="%s,%s,%s" % (tof_min, tof_step, tof_max), PreserveEvents=False)

# Get the total number of counts on the detector for each TOF bin per pulse
counts_ws = SumSpectra(_ws_sc)
counts_ws = SumSpectra(_ws_sc, OutputWorkspace=output_workspace)

# If we have error events, add them since those are also detector triggers
if ws_error_events is not None:
Expand Down
9 changes: 8 additions & 1 deletion reduction/lr_reduction/reduction_template_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def __init__(self):
# Dead time correction
self.dead_time:bool = False
self.paralyzable:bool = True
self.dead_time_value = 4.2
self.dead_time_tof_step = 150

def from_dict(self, data_dict, permissible=True):
r"""
Expand Down Expand Up @@ -154,7 +156,8 @@ def to_xml(self):
# Dead time correction
_xml += "<dead_time_correction>%s</dead_time_correction>\n" % str(self.dead_time)
_xml += "<dead_time_paralyzable>%s</dead_time_paralyzable>\n" % str(self.paralyzable)

_xml += "<dead_time_value>%s</dead_time_value>\n" % str(self.dead_time_value)
_xml += "<dead_time_tof_step>%s</dead_time_tof_step>\n" % str(self.dead_time_tof_step)
_xml += "</RefLData>\n"

return _xml
Expand Down Expand Up @@ -261,6 +264,10 @@ def from_xml_element(self, instrument_dom):
default=self.dead_time)
self.paralyzable = getBoolElement(instrument_dom, "dead_time_paralyzable",
default=self.paralyzable)
self.dead_time_value = getFloatElement(instrument_dom, "dead_time_value",
default=self.dead_time_value)
self.dead_time_tof_step = getFloatElement(instrument_dom, "dead_time_tof_step",
default=self.dead_time_tof_step)


###### Utility functions to read XML content ########################
Expand Down

0 comments on commit 4c4d3bc

Please sign in to comment.