\(\renewcommand\AA{\unicode{x212B}}\)

IntegratePeaksMD v2

../_images/IntegratePeaksMD-v2_dlg.png

IntegratePeaksMD dialog.

Summary

Integrate single-crystal peaks in reciprocal space, for MDEventWorkspaces.

Properties

Name Direction Type Default Description
InputWorkspace Input MDEventWorkspace Mandatory An input MDEventWorkspace.
PeakRadius Input number 1 Fixed radius around each peak position in which to integrate (in the same units as the workspace).
BackgroundInnerRadius Input number 0 Inner radius to use to evaluate the background of the peak. If smaller than PeakRadius, then we assume BackgroundInnerRadius = PeakRadius.
BackgroundOuterRadius Input number 0 Outer radius to use to evaluate the background of the peak. The signal density around the peak (BackgroundInnerRadius < r < BackgroundOuterRadius) is used to estimate the background under the peak. If smaller than PeakRadius, no background measurement is done.
PeaksWorkspace Input PeaksWorkspace Mandatory A PeaksWorkspace containing the peaks to integrate.
OutputWorkspace Output PeaksWorkspace Mandatory The output PeaksWorkspace will be a copy of the input PeaksWorkspace with the peaks’ integrated intensities.
ReplaceIntensity Input boolean True Always replace intensity in PeaksWorkspacem (default). If false, then do not replace intensity if calculated value is 0 (used for SNSSingleCrystalReduction)
IntegrateIfOnEdge Input boolean True Only warning if all of peak outer radius is not on detector (default). If false, do not integrate if the outer radius is not on a detector.
AdaptiveQBackground Input boolean False Default is false. If true, BackgroundOuterRadius + AdaptiveQMultiplier * |Q| and BackgroundInnerRadius + AdaptiveQMultiplier * |Q|
Ellipsoid Input boolean False Default is sphere.
FixQAxis Input boolean False Default is sphere.
Cylinder Input boolean False Default is sphere. Use next five parameters for cylinder.
CylinderLength Input number 0 Length of cylinder in which to integrate (in the same units as the workspace).
PercentBackground Input number 0 Percent of CylinderLength that is background (20 is 20%)
ProfileFunction Input string Gaussian Fitting function for profile that is used only with Cylinder integration. Allowed values: [‘BackToBackExponential’, ‘Bk2BkExpConvPV’, ‘DeltaFunction’, ‘ElasticDiffRotDiscreteCircle’, ‘ElasticDiffSphere’, ‘ElasticIsoRotDiff’, ‘ExamplePeakFunction’, ‘Gaussian’, ‘IkedaCarpenterPV’, ‘Lorentzian’, ‘PseudoVoigt’, ‘Voigt’, ‘NoFit’]
IntegrationOption Input string GaussianQuadrature Integration method for calculating intensity used only with Cylinder integration. Allowed values: [‘Sum’, ‘GaussianQuadrature’]
ProfilesFile Input string   Save (Optionally) as Isaw peaks file with profiles included. Allowed values: [‘profiles’]
AdaptiveQMultiplier Input number 0 PeakRadius + AdaptiveQMultiplier * |Q| so each peak has a different integration radius. Q includes the 2*pi factor.
CorrectIfOnEdge Input boolean False Only warning if all of peak outer radius is not on detector (default). If false, correct for volume off edge for both background and intensity.
UseOnePercentBackgroundCorrection Input boolean True If this options is enabled, then the the top 1% of the background will be removedbefore the background subtraction.

Description

This algorithm performs integration of single-crystal peaks within a radius (with optional background subtraction) in reciprocal space.

Similar algorithms

See IntegrateEllipsoids v1 for a ways of integrating peaks from data collected in EventWorkspace. PeakIntensityVsRadius v1 is meant to help determine an appropriate value for PeakRadius.

Inputs

The algorithms takes two input workspaces:

  • A MDEventWorkspace containing the events in multi-dimensional space. This would be the output of ConvertToDiffractionMDWorkspace v3.
  • As well as a PeaksWorkspace containing single-crystal peak locations. This could be the output of FindPeaksMD v1
  • The OutputWorkspace will contain a copy of the input PeaksWorkspace, with the integrated intensity and error found being filled in.

Calculations

Integration is performed by summing the weights of each MDEvent within the provided radii. Errors are also summed in quadrature.

IntegratePeaksMD_graph1.png

IntegratePeaksMD_graph1.png

  • All the Radii are specified in \(\AA^{-1}\)
  • A sphere of radius PeakRadius is integrated around the center of each peak.
    • This gives the summed intensity \(I_{peak}\) and the summed squared error \(\sigma I_{peak}^2\).
    • The volume of integration is \(V_{peak}\).
  • If BackgroundOuterRadius is specified, then a shell, with radius r where BackgroundInnerRadius < r < BackgroundOuterRadius, is integrated.
    • This gives the summed intensity \(I_{shell}\) and the summed squared error \(\sigma I_{shell}^2\).
    • The volume of integration is \(V_{shell}\).
    • BackgroundInnerRadius allows you to give some space between the peak and the background area.
    • If the option UseOnePercentBackgroundCorrection is enabled, which it is by default, then the top one percent of the background events are removed so that there are no intensity spikes near the edges.
  • AdaptiveQMultiplier can be used for the radius to vary as a function of the modulus of Q. If the AdaptiveQBackground option is set to True, the background radius also changes so each peak has a different integration radius. Q includes the 2*pi factor.
    • PeakRadius + AdaptiveQMultiplier * |Q|
    • BackgroundOuterRadius + AdaptiveQMultiplier * |Q|
    • BackgroundInnerRadius + AdaptiveQMultiplier * |Q|

Background Subtraction

The background signal within PeakRadius is calculated by scaling the background signal density in the shell to the volume of the peak:

\(I_{bg} = I_{shell} \frac{V_{peak}}{V_{shell}}\)

with the error squared on that value:

\(\sigma I_{bg}^2 = (\frac{V_{peak}}{V_{shell}})^2 \sigma I_{shell}^2\)

This is applied to the integrated peak intensity \(I_{peak}\) to give the corrected intensity \(I_{corr}\):

\(I_{corr} = I_{peak} - I_{bg}\)

with the errors summed in quadrature:

\(\sigma I_{corr}^2 = \sigma I_{peak}^2 + \sigma I_{bg}^2\)

If BackgroundInnerRadius is Omitted

If BackgroundInnerRadius is left blank, then BackgroundInnerRadius = PeakRadius, and the integration is as follows:

IntegratePeaksMD_graph2.png

IntegratePeaksMD_graph2.png

IntegrateIfOnEdge option

Edges for each bank or pack of tubes of the instrument are defined by masking the edges in the PeaksWorkspace instrument. e.g. For TOPAZ pixels 0 and 255 in both directions for the Rectangular Detector. Q in the lab frame for every peak is calculated, call it C For every point on the edge, the trajectory in reciprocal space is a straight line, going through:

\(\vec{O}=(0,0,0)\)

Calculate a point at a fixed momentum, say k=1. Q in the lab frame:

\(\vec{E}=(-k*sin(\theta)*cos(\phi),-k*sin(\theta)*sin(\phi),k-k*cos(\phi))\)

Normalize E to 1:

\(\vec{E}=\vec{E}*(1./\left|\vec{E}\right|)\)

The distance from C to OE is given by:

\(dv=\vec{C}-\vec{E}*(\vec{C} \cdot \vec{E})\)

If:

\(\left|dv\right|<PeakRadius\)

for the integration, one of the detector trajectories on the edge is too close to the peak This method is also applied to all masked pixels. If there are masked pixels trajectories inside an integration volume, the peak must be rejected.

CorrectIfOnEdge option

This is an extension of what was calculated for the IntegrateIfOnEdge option. It will only be calculated if this option is true and the minimum dv is less than PeakRadius or BackgroundOuterRadius.

For the background if

\(\left|dv\right|_{min}<BackgroundOuterRadius\)

\(h = BackgroundOuterRadius - \left|dv\right|_{min}\)

From the minimum of dv the volume of the cap of the sphere is found:

\(V_{cap} = \pi h^2 / 3 (3 * BackgroundOuterRadius - h)\)

The volume of the total sphere is calculated and for the background the volume of the inner radius must be subtracted:

\(V_{shell} = 4/3 \pi (BackgroundOuterRadius^3 - BackgroundInnerRadius^3)\)

The integrated intensity is multiplied by the ratio of the volume of the sphere divided by the volume where data was collected

\(I_{bkgMultiplier} = V_{shell} / (V_{shell} - V_{cap})\)

For the peak assume that the shape is Gaussian. If

\(\left|dv\right|_{min}<PeakRadius\)

\(\sigma = PeakRadius / 3\)

\(h = PeakRadius * exp(-\left|dv\right|_{min}^2 / (2 \sigma^2)\)

From the minimum of dv the volume of the cap of the sphere is found:

\(V_{cap} = \pi h^2 / 3 (3 * PeakRadius - h)\)

and the volume of the sphere is calculated

\(V_{sphere} = 4/3 \pi PeakRadius^3\)

The integrated intensity is multiplied by the ratio of the volume of the sphere divided by the volume where data was collected

\(I_{peakMultiplier} = V_{sphere} / (V_{sphere} - V_{cap})\)

Usage

Example - IntegratePeaks:

User should provide its own event nexus file instead of TOPAZ_3132_event.nxs used within this example. The original TOPAZ_3132_event.nxs file is available in Mantid system tests repository.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def print_tableWS(pTWS,nRows):
    ''' Method to print part of the table workspace '''
    tab_names=pTWS.keys()
    row = ""
    for name in tab_names:
        if len(name)>8:
           name= name[:8]
        row += "| {:8} ".format(name)
    print(row + "|")

    for i in range(nRows):
        row = ""
        for name in tab_names:
              col = pTWS.column(name);
              data2pr=col[i]
              if type(data2pr) is float:
                  row += "| {:8.1f} ".format(data2pr)
              else:
                  row += "| {:8} ".format(str(data2pr))
        print(row + "|")

 # Load a SCD data set and find the peaks
LoadEventNexus(Filename=r'TOPAZ_3132_event.nxs',OutputWorkspace='TOPAZ_3132_nxs')
ConvertToDiffractionMDWorkspace(InputWorkspace='TOPAZ_3132_nxs',OutputWorkspace='TOPAZ_3132_md',LorentzCorrection='1')
FindPeaksMD(InputWorkspace='TOPAZ_3132_md',PeakDistanceThreshold='0.15',MaxPeaks='100',OutputWorkspace='peaks')
FindUBUsingFFT(PeaksWorkspace='peaks',MinD='2',MaxD='16')

 # Perform the peak integration, in-place in the 'peaks' workspace.
peaks= IntegratePeaksMD(InputWorkspace='TOPAZ_3132_md', PeaksWorkspace='peaks',\
     PeakRadius=0.12, BackgroundOuterRadius=0.2, BackgroundInnerRadius=0.16,\
     OutputWorkspace='peaks')

# print the integration results
print_tableWS(peaks,10)

Output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
| RunNumbe | DetID    | h        | k        | l        | Waveleng | Energy   | TOF      | DSpacing | Intens   | SigInt   | BinCount | BankName | Row      | Col      | QLab     | QSample  | PeakNumb |
| 3132     | 1168209  |      0.0 |      0.0 |      0.0 |      1.1 |     66.9 |   5158.0 |      0.7 |   2160.9 |     32.3 |   1326.0 | bank17   |     81.0 |    211.0 | [4.42961,2.81707,7.86314] | [8.75838,3.55459,-0.205083] | 1        |
| 3132     | 1124983  |      0.0 |      0.0 |      0.0 |      1.6 |     33.9 |   7250.6 |      1.0 |   1990.0 |     14.4 |   1060.0 | bank17   |    119.0 |     42.0 | [3.14813,2.43563,4.75389] | [5.9822,1.62965,0.00130101] | 2        |
| 3132     | 1141521  |      0.0 |      0.0 |      0.0 |      1.7 |     28.1 |   7959.1 |      1.0 |    644.6 |      7.3 |   1034.0 | bank17   |     17.0 |    107.0 | [2.60893,2.31831,4.86248] | [5.69311,1.79103,-0.453311] | 3        |
| 3132     | 1125238  |      0.0 |      0.0 |      0.0 |      3.1 |      8.4 |  14518.9 |      2.0 |    750.5 |      2.2 |    880.0 | bank17   |    118.0 |     43.0 | [1.57116,1.21649,2.37775] | [2.98926,0.816337,-0.00161709] | 4        |
| 3132     | 1170852  |      0.0 |      0.0 |      0.0 |      1.6 |     34.0 |   7235.3 |      1.0 |   1826.4 |     14.7 |    762.0 | bank17   |    164.0 |    221.0 | [3.4229,1.70246,5.39532] | [6.0734,2.6008,0.271523] | 5        |
| 3132     | 1156497  |      0.0 |      0.0 |      0.0 |      2.1 |     18.9 |   9718.2 |      1.3 |   5137.6 |     13.4 |    518.0 | bank17   |    145.0 |    165.0 | [2.49117,1.46093,3.88649] | [4.5291,1.70753,0.129446] | 6        |
| 3132     | 1207828  |      0.0 |      0.0 |      0.0 |      1.7 |     27.9 |   7989.1 |      1.3 |   3233.6 |     12.7 |   1024.0 | bank18   |     20.0 |    110.0 | [2.80538,2.29342,3.08833] | [4.71342,0.553533,0.380727] | 7        |
| 3132     | 1218593  |      0.0 |      0.0 |      0.0 |      1.0 |     79.6 |   4729.3 |      0.8 |   3018.1 |     35.4 |    756.0 | bank18   |     33.0 |    152.0 | [4.96533,3.60693,5.32436] | [7.98578,1.19927,0.895763] | 8        |
| 3132     | 1232694  |      0.0 |      0.0 |      0.0 |      1.2 |     53.4 |   5772.9 |      0.9 |   3464.5 |     25.9 |    631.0 | bank18   |     54.0 |    207.0 | [4.29539,2.63813,4.45945] | [6.53086,1.27477,1.00974] | 9        |
| 3132     | 1200023  |      0.0 |      0.0 |      0.0 |      0.7 |    159.1 |   3345.1 |      0.6 |   3796.1 |     71.1 |    509.0 | bank18   |    151.0 |     79.0 | [6.75629,4.8092,5.93224] | [10.0166,0.773518,1.74245] | 10       |

Categories: AlgorithmIndex | MDAlgorithms\Peaks | Crystal\Integration

Source

C++ header: IntegratePeaksMD2.h (last modified: 2020-05-05)

C++ source: IntegratePeaksMD2.cpp (last modified: 2020-06-05)