\(\renewcommand\AA{\unicode{x212B}}\)
PolarizationAngleCorrectionMD v1¶
Summary¶
Apply polarization angle correction to MDEventWorkspace
Properties¶
| Name | Direction | Type | Default | Description | 
|---|---|---|---|---|
| InputWorkspace | Input | 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 | Mandatory | The output MDEventWorkspace with polarization angle correction applied | 
Description¶
User inputs an in-plane polarization \(P_a\) 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.
- If the MDEvent is in Q-sample frame, convert it to Q-lab by \(Q_{lab} = R \times Q_{sample}\) where \(R\) is goniometer rotation matrix. 
- Calculate the horizontal plane angle between momentum transfer and direct beam \(\gamma = \tan^{-1}(Q_{lab,x}, Q_{lab,z})\) 
- Calculate the Scharpf angle as \(\alpha = \gamma - P_a\) , where \(P_a\) is the polarization angle 
- Correction factor \(F\) is equal to \(1 / \cos(2\alpha)\) if \(|\cos(2\alpha)|\) is greater than precision, else it is zero. 
- Apply correction to each MDEvent as 
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