CreateEPP v1

../_images/CreateEPP-v1_dlg.png

CreateEPP dialog.

Summary

Creates a nominal EPP table compatible with what is returned by the FindEPP algorithm.

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory An input workspace.
OutputWorkspace Output TableWorkspace Mandatory The calculated output EPP table.
Sigma Input number 0 The value to fill the Sigma column with.

Description

This algorithm generates an elastic peak position (EPP) table like the one created by the FindEPP algorithm. Unlike FindEPP which finds the elastic peak positions by fitting, CreateEPP calculates the peak position from the instrument geometry and incident energy. The algorithm is can be used in cases where FindEPP fails e.g. due to poor signal-to-noise ratio.

The ideal elastic peak position t_{EPP} corresponds to the time-of-flight between the source and the detector:

t_{EPP} = (l_1 + l_2) / v,

where l_1 is the source-to-sample distance, l_2 is the sample-to-detector distance and v is the neutron velocity. The velocity in turn is given by

v = \sqrt{2 E_i / m_n},

where E_i is the incident energy and m_n the neutron mass.

CreateEPP reads E_i from the ‘Ei’ sample log entry of InputWorkspace.

The columns in the OutputWorkspace are the same as in FindEPP. Since the calculation done by CreateEPP gives only the ideal elastic peak positions, the rest of the columns are filled as follows:

  • ‘Sigma’: set to the Sigma input property.
  • ‘PeakCentreError’, ‘SigmaError’ and ‘HeightError’: set unconditionally to zero.
  • ‘Height’: set to the Y value of the bin at the elastic peak position.
  • ‘chiSq’: set unconditionally to one.
  • ‘FitStatus’: set unconditionally to “success”.

Usage

Example - CreateEPP

from mantid.kernel import DeltaEModeType, UnitConversion
import numpy

CreateSampleWorkspace(
    OutputWorkspace='exWS',
    Function='Flat background',
    NumBanks=3,
    BankPixelWidth=2,
    Xmax=10000,
    BinWidth=50,
    PixelSpacing=0.01,
    BankDistanceFromSample=1.0
)
ws = mtd['exWS']
# Fill the sample workspace with some Gaussian elastic peaks.
Ei = 10.0  # Incident energy, in meV.
def peak(xs, centre):  # A helper function to generate a peak.
    xs = (xs[:-1] + xs[1:]) * 0.5  # Convert bin edges to bin centres.
    ys = 10.0 * numpy.exp(-numpy.square((xs - centre) / 100))
    return ys
instrument = ws.getInstrument()
source = instrument.getSource()
sample = instrument.getSample()
L1 = sample.getDistance(source)
for i in range(ws.getNumberHistograms()):
    detector = ws.getDetector(i)
    L2 = sample.getDistance(detector)
    tof = UnitConversion.run('Energy', 'TOF', Ei, L1, L2, 0.0, DeltaEModeType.Direct, Ei)
    ys =ws.dataY(i)
    ys += peak(ws.dataX(i), tof)
# The 'Ei' sample log shall hold the incident energy.
ws.mutableRun().addProperty('Ei', Ei, True)

# Compare CreateEPP and FindEPP results.
createEPPWS = CreateEPP(InputWorkspace=ws)
findEPPWS = FindEPP(InputWorkspace='exWS')

epp1 = createEPPWS.cell('PeakCentre', 0)
print('CreateEPP gives {0} as the first elastic peak position.'.format(epp1))
epp2 = findEPPWS.cell('PeakCentre', 0)
print('FindEPP gives {0}.'.format(epp2))

Output:

CreateEPP gives 7952.80766719 as the first elastic peak position.
FindEPP gives 7952.80766888.

Categories: Algorithms | Utility

Source

C++ source: CreateEPP.cpp

C++ header: CreateEPP.h