PolarizationAngleCorrectionMD v1

Summary

Apply polarization angle correction to MDEventWorkspace

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MDEventWorkspace

Mandatory

An input MDEventWorkspace. Must be in Q_sample/Q_lab frame. Must have an axis as DeltaE

PolarizationAngle

Input

number

0

An in-plane polarization angle​, between -180 and 180 degrees

Precision

Input

number

1

Precision (between 0 and 1). Any event whose absolute value of cosine of 2 of its schaf angle less than this precision will be ignored.

OutputWorkspace

Output

MDEventWorkspace

Mandatory

The output MDEventWorkspace with polarization angle correction applied

Description

User inputs an in-plane polarization Pa angle between -180 and 180 degrees, and a precision (between 0 and 1). Then for every MD event, a polarization angle correction is applied as below.

  1. If the MDEvent is in Q-sample frame, convert it to Q-lab by Qlab=R×Qsample where R is goniometer rotation matrix.

  2. Calculate the horizontal plane angle between momentum transfer and direct beam γ=tan1(Qlab,x,Qlab,z)

  3. Calculate the Scharpf angle as α=γPa , where Pa is the polarization angle

  4. Correction factor F is equal to 1/cos(2α) if |cos(2α)| is greater than precision, else it is zero.

  5. Apply correction to each MDEvent as

I=I×FErr2=Err2×F2

Inputs

Input MDEventWorkspace must be in Q-lab or Q-sample. |Q| is not allowed.

Usage

Example - Run Applying Polarization Angle Correction

we1 = CreateSampleWorkspace(WorkspaceType='Event',
                           Function='Flat background',
                           BankPixelWidth=1,
                           XUnit='DeltaE',
                           XMin=-10,
                           XMax=19,
                           BinWidth=0.5)
AddSampleLog(Workspace=we1,LogName='Ei', LogText='20.', LogType='Number')
MoveInstrumentComponent(Workspace=we1, ComponentName='bank1', X=3, Z=3, RelativePosition=False)
MoveInstrumentComponent(Workspace=we1, ComponentName='bank2', X=-3, Z=-3, RelativePosition=False)
SetGoniometer(Workspace=we1, Axis0='30,0,1,0,1')

# Old way
we1c = HyspecScharpfCorrection(InputWorkspace=we1,
                               PolarizationAngle=-10,
                               Precision=0.2)
md1c_sample = ConvertToMD(InputWorkspace=we1c, QDimensions='Q3D', Q3DFrames='Q_sample')

# new way
md1sample = ConvertToMD(InputWorkspace=we1, QDimensions='Q3D')
mdpacMDsample = PolarizationAngleCorrectionMD(InputWorkspace=md1sample, PolarizationAngle=-10, Precision=0.2)
r = CompareMDWorkspaces(Workspace1=md1c_sample, Workspace2=mdpacMDsample, Tolerance=0.001, CheckEvents=True)
print('Number of MDEvents: {} == {}'.format(md1c_sample.getNEvents(), mdpacMDsample.getNEvents()))
print('MDEventWorkspaces are equal = {}.  Results: {}'.format(r.Equals, r.Result))

Output:

Number of MDEvents: 1972 == 1972
MDEventWorkspaces are equal = True.  Results: Success!

Categories: AlgorithmIndex | MDAlgorithms

Source

C++ header: PolarizationAngleCorrectionMD.h

C++ source: PolarizationAngleCorrectionMD.cpp