parameters: (workspace, normalize_to_monitor_state)
return_statement: return workspace
docstring: Removes an offset from the monitor data.
  
      A certain region of the data set is selected which corresponds to only background data. This data is averaged
      which results in a mean background value which is subtracted from the data.
      :param workspace: the workspace which is to be corrected.
      :param normalize_to_monitor_state: a SANSStateNormalizeToMonitor object.
      :return: the corrected workspace.
docstring_summary: Removes an offset from the monitor data.
docstring_tokens: Removes an offset from the monitor data .
function: def _perform_flat_background_correction(workspace, normalize_to_monitor_state):
      """
      Removes an offset from the monitor data.
  
      A certain region of the data set is selected which corresponds to only background data. This data is averaged
      which results in a mean background value which is subtracted from the data.
      :param workspace: the workspace which is to be corrected.
      :param normalize_to_monitor_state: a SANSStateNormalizeToMonitor object.
      :return: the corrected workspace.
      """
  
      # Get the time range for the for the background calculation. First check if there is an entry for the
      # incident monitor.
      incident_monitor_spectrum_number = normalize_to_monitor_state.incident_monitor
      incident_monitor_spectrum_as_string = str(incident_monitor_spectrum_number)
      background_tof_monitor_start = normalize_to_monitor_state.background_TOF_monitor_start
      background_tof_monitor_stop = normalize_to_monitor_state.background_TOF_monitor_stop
  
      if incident_monitor_spectrum_as_string in list(background_tof_monitor_start.keys()) and \
         incident_monitor_spectrum_as_string in list(background_tof_monitor_stop.keys()):
          start_tof = background_tof_monitor_start[incident_monitor_spectrum_as_string]
          stop_tof = background_tof_monitor_stop[incident_monitor_spectrum_as_string]
      else:
          start_tof = normalize_to_monitor_state.background_TOF_general_start
          stop_tof = normalize_to_monitor_state.background_TOF_general_stop
  
      # Only if a TOF range was set, do we have to perform a correction
      if start_tof and stop_tof:
          flat_name = "CalculateFlatBackground"
          flat_options = {"InputWorkspace": workspace,
                          "OutputWorkspace": EMPTY_NAME,
                          "StartX": start_tof,
                          "EndX": stop_tof,
                          "Mode": "Mean"}
          flat_alg = create_unmanaged_algorithm(flat_name, **flat_options)
          flat_alg.execute()
          workspace = flat_alg.getProperty("OutputWorkspace").value
      return workspace
function_tokens: def _perform_flat_background_correction ( workspace , normalize_to_monitor_state ) : # Get the time range for the for the background calculation. First check if there is an entry for the # incident monitor. incident_monitor_spectrum_number = normalize_to_monitor_state . incident_monitor incident_monitor_spectrum_as_string = str ( incident_monitor_spectrum_number ) background_tof_monitor_start = normalize_to_monitor_state . background_TOF_monitor_start background_tof_monitor_stop = normalize_to_monitor_state . background_TOF_monitor_stop if incident_monitor_spectrum_as_string in list ( background_tof_monitor_start . keys ( ) ) and incident_monitor_spectrum_as_string in list ( background_tof_monitor_stop . keys ( ) ) : start_tof = background_tof_monitor_start [ incident_monitor_spectrum_as_string ] stop_tof = background_tof_monitor_stop [ incident_monitor_spectrum_as_string ] else : start_tof = normalize_to_monitor_state . background_TOF_general_start stop_tof = normalize_to_monitor_state . background_TOF_general_stop # Only if a TOF range was set, do we have to perform a correction if start_tof and stop_tof : flat_name = "CalculateFlatBackground" flat_options = { "InputWorkspace" : workspace , "OutputWorkspace" : EMPTY_NAME , "StartX" : start_tof , "EndX" : stop_tof , "Mode" : "Mean" } flat_alg = create_unmanaged_algorithm ( flat_name , * * flat_options ) flat_alg . execute ( ) workspace = flat_alg . getProperty ( "OutputWorkspace" ) . value return workspace