Skip to content

Commit

Permalink
Re #10684 Simplified Mon-2 normalization option
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Feb 2, 2015
1 parent a78eb76 commit e7d5386
Showing 1 changed file with 18 additions and 35 deletions.
53 changes: 18 additions & 35 deletions Code/Mantid/scripts/Inelastic/Direct/DirectEnergyConversion.py
Expand Up @@ -519,7 +519,7 @@ def get_ei(self, data_run, ei_guess):

# Store found incident energy in the class itself
self.incident_energy = ei
if self.prop_man.normalise_method == 'monitor-2':
if self.prop_man.normalise_method == 'monitor-2' and not separate_monitors:
# monitor-2 normalization ranges have to be identified before the
# instrument is shifted in case it is shifted to this monitor (usual
# case)
Expand All @@ -532,13 +532,6 @@ def get_ei(self, data_run, ei_guess):
# copy incident energy obtained on monitor workspace to detectors
# workspace
AddSampleLog(Workspace=data_ws,LogName='Ei',LogText=str(ei),LogType='Number')
# if monitors are separated from the input workspace, we need to
## move them too as this is what happening when monitors are
## integrated into workspace
#result_mon_name = monitor_ws.name() # Do we ever need monitors after this point?
#ScaleX(InputWorkspace=monitor_ws,OutputWorkspace=result_mon_name,Operation="Add",Factor=-mon1_peak,
# InstrumentParameter="DelayTime",Combine=True)
#monitor_ws = mtd[result_mon_name]


resultws_name = data_ws.name()
Expand All @@ -553,11 +546,8 @@ def get_ei(self, data_run, ei_guess):
src_name = data_ws.getInstrument().getSource().getName()
MoveInstrumentComponent(Workspace=resultws_name,ComponentName= src_name, X=mon1_pos.getX(),
Y=mon1_pos.getY(), Z=mon1_pos.getZ(), RelativePosition=False)

#
#if separate_monitors:
# MoveInstrumentComponent(Workspace=result_mon_name,ComponentName= src_name, X=mon1_pos.getX(),
# Y=mon1_pos.getY(), Z=mon1_pos.getZ(), RelativePosition=False)

data_run.synchronize_ws(mtd[resultws_name])
return ei, mon1_peak

Expand Down Expand Up @@ -682,30 +672,23 @@ def _normalize_to_monitor2(self,run,old_name, range_offset=0.0):
kwargs['MonitorSpectrum'] = mon_spect

#Find TOF range, correspondent to incident energy monitor peak
if separate_monitors:
energy_rage = self.mon2_norm_energy_range
TOF_range = self.get_TOF_for_energies(mon_ws,energy_rage,[mon_spect],self._debug_mode)
range_min = TOF_range[0]
range_max = TOF_range[1]
if self._mon2_norm_time_range: # range has been found during ei-calculations
range = self._mon2_norm_time_range
range_min = range[0] + range_offset
range_max = range[1] + range_offset
self._mon2_norm_time_range = None
else:
if self._mon2_norm_time_range:
range = self._mon2_norm_time_range
range_min = range[0] + range_offset
range_max = range[1] + range_offset
self._mon2_norm_time_range = None
else:
mon_ws_name = mon_ws.name()
if mon_ws_name.find('_shifted') != -1:
# monitor-2 normalization ranges have to be identified before the
# instrument is shifted
raise RuntimeError("Instrument have been shifted but no time range has been identified. Monitor-2 normalization can not be performed ")
else:
# instrument and workspace shifted, so TOF will be calculated wrt shifted instrument
energy_rage = self.mon2_norm_energy_range
TOF_range = self.get_TOF_for_energies(mon_ws,energy_rage,[mon_spect],self._debug_mode)
range_min = TOF_range[0]
range_max = TOF_range[1]
#
mon_ws_name = mon_ws.name() #monitor's workspace and detector's workspace are e
if mon_ws_name.find('_shifted') != -1:
# monitor-2 normalization ranges have to be identified before the
# instrument is shifted
raise RuntimeError("Instrument have been shifted but no time range has been identified. Monitor-2 normalization can not be performed ")
else:
# instrument and workspace shifted, so TOF will be calculated wrt shifted instrument
energy_rage = self.mon2_norm_energy_range
TOF_range = self.get_TOF_for_energies(mon_ws,energy_rage,[mon_spect],self._debug_mode)
range_min = TOF_range[0]
range_max = TOF_range[1]

# Normalize to monitor 2
NormaliseToMonitor(InputWorkspace=old_name,OutputWorkspace=old_name,IntegrationRangeMin=range_min,
Expand Down

0 comments on commit e7d5386

Please sign in to comment.