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

MuonPreProcess v1

../_images/MuonPreProcess-v1_dlg.png

MuonPreProcess dialog.

Summary

Perform a series of common analysis pre-processing steps on Muon data. Sample logs are modified to record the input parameters.

Properties

Name Direction Type Default Description
InputWorkspace Input Workspace Mandatory Input workspace containing data from detectors that the grouping/pairing will be applied to.
OutputWorkspace Output WorkspaceGroup Mandatory The output workspace group with all corrections applied. For single period data, a group is returned with a single workspace.
TimeMin Input number Optional Start time for the data in micro seconds.
TimeMax Input number Optional End time for the data in micro seconds.
RebinArgs Input dbl list   Parameters used for rebinning. If empty - rebinning is not done.
TimeOffset Input number Optional Shift the times of all data by a fixed amount (in micro seconds). The value given corresponds to the bin that will become 0.0 seconds.
TimeZeroTable Input TableWorkspace   TableWorkspace with time zero information, used to apply time zero correction
DeadTimeTable Input TableWorkspace   TableWorkspace with dead time information, used to apply dead time correction.

Description

When interacting with the Muon Analysis interface, operations such as detector grouping, group and pair asymmetry are performed on data. As part of the workflow, several “pre-processing” steps are also necessary; such as rebinning and cropping the data, applying dead time corrections and applying time zero corrections/shifting the time axis by a fixed amount (sometimes referred to as “first good data”).

This algorithm intends to capture the common pre-processing steps, which are not muon physics specific concepts, and apply them all at once to produce data which is ready for the muon-specific operations. This way, scripting the workflows of the Muon Analysis interface is much more intuitive and simple.

Analysis

As indicated in the input variable names to this algorithm; there are five distinct operations applied to the input data. In order of application these are;

  1. Apply dead time correction through the DeadTimeTable input.
  2. Apply time zero correction through the TimeZeroTable input.
  3. Apply a time offset to the time axis through the TimeOffset input, which may be positive or negative. This time offset is directly added to all times within the workspace.
  4. Apply a cropping to the upper (lower) ends of the time axis via the TimeMax (TimeMin) input.
  5. Finally, apply a rebinning via RebinArgs, using the same syntax as in Rebin v1.

The InputWorkspace can be a single workspace object, and multi period data is supported by supplying a WorkspaceGroup as the input workspace, where each workspace within the group represents a single period.

The OutputWorkspace is always a Workspace Group; for single period data the group only contains a single workspace. The reason for this is so that the muon algorithms MuonGroupingCounts, MuonGroupingAsymmetry and MuonPairingAsymmetry can expect a consistent input between single and multi period data, and where single period data is just a limiting case of multi period data.

Four of the operations listed above correspond to a run of ApplyDeadTimeCorr v1, ChangeBinOffset v1, CropWorkspace v1 and Rebin v1 respectively; and so the documentation of these algorithms can be consulted for more detailed discussion of precisely how the operations are applied. Time zero correction does not correspond to it’s own algorithm.

As already mentioned; the output of this algorithm can (and is intended to be) fed into one of the following algorithms;

  1. MuonGroupingCounts
  2. MuonGroupingAsymmetry
  3. MuonPairingAsymmetry

Usage

Note

To run these usage examples please first download the usage data, and add these to your path. In Mantid this is done using Manage User Directories.

Note

For examples of applying custom dead times, please refer to ApplyDeadTimeCorr v1 documentation.

For examples of applying custom rebinning, please refer to Rebin v1 documentation.

Example - The output is always a WorkspaceGroup

# Single period data
dataX = [0, 1, 2, 3, 4, 5]
dataY = [10, 20, 30, 20, 10]
input_workspace = CreateWorkspace(dataX, dataY)

output_workspace = MuonPreProcess(InputWorkspace=input_workspace)

print("Input workspace is a {}".format(input_workspace.id()))
print("Output workspace is a {}".format(output_workspace.id()))
print("X values are : {}".format(output_workspace[0].readX(0)))
print("Y values are : {}".format(output_workspace[0].readY(0)))

Output:

Input workspace is a Workspace2D
Output workspace is a WorkspaceGroup
X values are : [ 0.  1.  2.  3.  4.  5.]
Y values are : [ 10.  20.  30.  20.  10.]

Example - Applying only a time offset

dataX = [0, 1, 2, 3, 4, 5]
dataY = [10, 20, 30, 20, 10]
input_workspace = CreateWorkspace(dataX, dataY)

output_workspace = MuonPreProcess(InputWorkspace=input_workspace,
                                            TimeOffset=0.5)

print("X values are : {}".format(output_workspace[0].readX(0)))
print("Y values are : {}".format(output_workspace[0].readY(0)))

Output:

X values are : [ 0.5  1.5  2.5  3.5  4.5  5.5]
Y values are : [ 10.  20.  30.  20.  10.]

Example - Applying only a rebin

dataX = [0, 1, 2, 3, 4, 5]
dataY = [10, 20, 30, 20, 10]
input_workspace = CreateWorkspace(dataX, dataY)

output_workspace = MuonPreProcess(InputWorkspace=input_workspace,
                                            RebinArgs=2)

print("X values are : {}".format(output_workspace[0].readX(0)))
print("Y values are : {}".format(output_workspace[0].readY(0)))

Output:

X values are : [ 0.  2.  4.  5.]
Y values are : [ 30.  50.  10.]

Example - Applying only a crop

dataX = [0, 1, 2, 3, 4, 5]
dataY = [10, 20, 30, 20, 10]
input_workspace = CreateWorkspace(dataX, dataY)

output_workspace = MuonPreProcess(InputWorkspace=input_workspace,
                                            TimeMin=2,
                                            TimeMax=4)

print("X values are : {}".format(output_workspace[0].readX(0)))
print("Y values are : {}".format(output_workspace[0].readY(0)))

Output:

X values are : [ 2.  3.  4.]
Y values are : [ 30.  20.]

Example - Applying only a dead time correction

dataX = [0, 1, 2, 3, 4, 5] * 4
dataY = [100, 200, 300, 200, 100] * 4
input_workspace = CreateWorkspace(dataX, dataY, NSpec=4)
# dead time correction requires the number of good frames to be set
AddSampleLog(Workspace=input_workspace, LogName="goodfrm", LogText="1")

# create the dead time table
dead_times = CreateEmptyTableWorkspace()
dead_times.addColumn("int", "spectrum", 0)
dead_times.addColumn("float", "dead-time", 0)
[dead_times.addRow([i + 1, 0.5]) for i in range(4)]

output_workspace = MuonPreProcess(InputWorkspace=input_workspace,
                                            DeadTimeTable=dead_times)
print("X values are : {}".format(output_workspace[0].readX(0)))
print("Y values are : {}".format(output_workspace[0].readY(0).round(1)))

Output:

X values are : [ 0.  1.  2.  3.  4.  5.]
Y values are : [ 100.3  201.2  302.8  201.2  100.3]

Example - Applying only a time zero correction

dataX = [0, 1, 2, 3, 4, 5] * 4
dataY = [100, 200, 300, 200, 100] * 4
input_workspace = CreateWorkspace(dataX, dataY, NSpec=4)

# Create a time zero table
time_zero_table = CreateEmptyTableWorkspace()
time_zero_table.addColumn("double", "time zero")
[time_zero_table.addRow([i+2]) for i in range(4)]

output_workspace = MuonPreProcess(InputWorkspace=input_workspace,
                                  TimeZeroTable=time_zero_table)

print("X values are : [{:.0f}, {:.0f}, {:.0f}, {:.0f}, {:.0f}, {:.0f}]".format(
    output_workspace[0].readX(0)[0],output_workspace[0].readX(0)[1],
    output_workspace[0].readX(0)[2],output_workspace[0].readX(0)[3],
    output_workspace[0].readX(0)[4],output_workspace[0].readX(0)[5]))
print("Y values are : [{:.0f}, {:.0f}, {:.0f}, {:.0f}, {:.0f}]".format(
    output_workspace[0].readY(0)[0],output_workspace[0].readY(0)[1],
    output_workspace[0].readY(0)[2],output_workspace[0].readY(0)[3],
    output_workspace[0].readY(0)[4]))

Output:

X values are : [-2, -1, 0, 1, 2, 3]
Y values are : [100, 200, 300, 200, 100]

Categories: AlgorithmIndex | Muon\DataHandling

Source

C++ header: MuonPreProcess.h

C++ source: MuonPreProcess.cpp