Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
OutputWorkspace | Output | MatrixWorkspace | Mandatory | The workspace which will hold the results of the asymmetry calculation. |
PairName | Input | string | The name of the pair. Must contain at least one alphanumeric character. | |
Alpha | Input | number | 1 | Alpha parameter used in the asymmetry calculation. |
SpecifyGroupsManually | Input | boolean | False | Specify the pair of groups manually |
InputWorkspace1 | Input | Workspace | Input workspace containing data from grouped detectors. | |
InputWorkspace2 | Input | Workspace | Input workspace containing data from grouped detectors. | |
InputWorkspace | Input | WorkspaceGroup | Input workspace containing data from detectors which are to be grouped. | |
Group1 | Input | int list | 1 | The grouping of detectors, comma separated list of detector IDs or hyphenated ranges of IDs. |
Group2 | Input | int list | 2 | The grouping of detectors, comma separated list of detector IDs or hyphenated ranges of IDs. |
SummedPeriods | Input | int list | 1 | A list of periods to sum in multiperiod data. |
SubtractedPeriods | Input | int list | A list of periods to subtract in multiperiod data. |
When interacting with the Muon Analysis interface, operations such as detector grouping, group and pair asymmetry are performed on data. This algorithm performs a “pair asymmetry” operation, in other words it takes two groups (from MuonGroupingCounts v1 for example) and calculates the asymmetry between them using the common formula from AsymmetryCalc v1.
This algorithm is part of a set of four; with MuonPreProcess v1 being run first; and the output being fed into this one. Alternatively, the groups may be calculated by using MuonPreProcess v1 followed by MuonGroupingCounts v1 and fed into this algorithm by switching off SpecifyGroupsManually. This allows the replication of the workflow used by the muon analysis interface to produce group data.
A Pair in this context refers to a pair of groups. A workspace has one or more spectra contained within it; each spectra has a unique detector ID. Assuming the y-values represent counts; a detector group is a sum over a given set of detectors.
With a pair, one may define an asymmetry operation as in AsymmetryCalc v1;
where and
are the forward and backwards groups and alpha is the balance parameter.
The pair must be given a name via PairName which can consist of letters, numbers and underscores.
The pair name does not affect the data; however the name is used in the muon interface when automatically generating workspace names from group data.
Additionally, a value for alpha must be supplied, and which must be non-negative.
There are two options for supplying the group data :
Both single and multi period data are supported by the algorithm.
The SummedPeriods and SubtractedPeriods inputs are used to control the way that periods are combined. so for example;
would combine periods in the combination .
Example - Using MuonPreProcess and Specifying Groups Manually for Single Period Data
# Create a workspaces with four spectra
dataX = [0, 1, 2, 3, 4, 5] * 4
dataY = [10, 20, 30, 20, 10] + \
[20, 30, 40, 30, 20] + \
[30, 40, 50, 40, 30] + \
[40, 50, 60, 50, 40]
input_workspace = CreateWorkspace(dataX, dataY, NSpec=4)
for i in range(4):
# set detector IDs to be 1,2,3,4
# these do not have to be the same as the spectrum numbers
# (the spectrum number are 0,1,2,3 in this case)
input_workspace.getSpectrum(i).setDetectorID(i + 1)
pre_processed_workspace = MuonPreProcess(InputWorkspace=input_workspace)
output_workspace = MuonPairingAsymmetry(InputWorkspace=pre_processed_workspace,
PairName="myPair",
Alpha=1.0,
SpecifyGroupsManually=True,
Group1=[1, 2],
Group2=[3, 4])
print("X values are : {}".format([round(float(i), 3) for i in output_workspace.readX(0)]))
print("Y values are : {}".format([round(float(i), 3) for i in output_workspace.readY(0)]))
Output:
X values are : [0.5, 1.5, 2.5, 3.5, 4.5]
Y values are : [-0.4, -0.286, -0.222, -0.286, -0.4]
Example - Using MuonPreProcess and Specifying Groups Manually for Multi Period Data
# Create a workspaces with four spectra
dataX = [0, 1, 2, 3, 4, 5] * 4
dataY = [10, 20, 30, 20, 10] + \
[20, 30, 40, 30, 20] + \
[30, 40, 50, 40, 30] + \
[40, 50, 60, 50, 40]
input_workspace = CreateWorkspace(dataX, dataY, NSpec=4)
input_workspace_1 = CreateWorkspace(dataX, dataY, NSpec=4)
for i in range(4):
# set detector IDs to be 1,2,3,4
# these do not have to be the same as the spectrum numbers
# (the spectrum number are 0,1,2,3 in this case)
input_workspace.getSpectrum(i).setDetectorID(i + 1)
input_workspace_1.getSpectrum(i).setDetectorID(i + 1)
# Create multi period data
multi_period_data = GroupWorkspaces(input_workspace)
multi_period_data.addWorkspace(input_workspace_1)
pre_processed_workspace = MuonPreProcess(InputWorkspace=multi_period_data)
output_workspace = MuonPairingAsymmetry(InputWorkspace=pre_processed_workspace,
PairName="myPair",
Alpha=1.0,
SpecifyGroupsManually=True,
Group1=[1, 2],
Group2=[3, 4],
SummedPeriods=[1, 2])
print("X values are : {}".format([round(float(i), 3) for i in output_workspace.readX(0)]))
print("Y values are : {}".format([round(float(i), 3) for i in output_workspace.readY(0)]))
Output:
X values are : [0.5, 1.5, 2.5, 3.5, 4.5]
Y values are : [-0.4, -0.286, -0.222, -0.286, -0.4]
Example - Using MuonPreProcess, MuonGroupingCounts for Single Period Data
# Create a workspaces with four spectra
dataX = [0, 1, 2, 3, 4, 5] * 4
dataY = [10, 20, 30, 20, 10] + \
[20, 30, 40, 30, 20] + \
[30, 40, 50, 40, 30] + \
[40, 50, 60, 50, 40]
input_workspace = CreateWorkspace(dataX, dataY, NSpec=4)
for i in range(4):
# set detector IDs to be 1,2,3,4
# these do not have to be the same as the spectrum numbers
# (the spectrum number are 0,1,2,3 in this case)
input_workspace.getSpectrum(i).setDetectorID(i + 1)
pre_processed_workspace = MuonPreProcess(InputWorkspace=input_workspace)
group_workspace_1 = MuonGroupingCounts(InputWorkspace=pre_processed_workspace,
GroupName="fwd",
Grouping=[1, 2])
group_workspace_2 = MuonGroupingCounts(InputWorkspace=pre_processed_workspace,
GroupName="bwd",
Grouping=[3, 4])
output_workspace = MuonPairingAsymmetry(InputWorkspace=pre_processed_workspace,
PairName="myPair",
Alpha=1.0,
SpecifyGroupsManually=False,
InputWorkspace1=group_workspace_1,
InputWorkspace2=group_workspace_2)
print("X values are : {}".format([round(float(i), 3) for i in output_workspace.readX(0)]))
print("Y values are : {}".format([round(float(i), 3) for i in output_workspace.readY(0)]))
Output:
X values are : [0.5, 1.5, 2.5, 3.5, 4.5]
Y values are : [-0.4, -0.286, -0.222, -0.286, -0.4]
Categories: Algorithm Index | Muon\DataHandling
C++ source: MuonPairingAsymmetry.cpp (last modified: 2019-01-24)
C++ header: MuonPairingAsymmetry.h (last modified: 2019-03-19)