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

MuonGroupingCounts v1

Summary

Apply a grouping (summation of counts) across a set of detectors in Muon data.

See Also

MuonProcess, Minus, Plus, MuonGroupingAsymmetry, MuonPairingAsymmetry, MuonPreProcess

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

WorkspaceGroup

Mandatory

Input workspace containing data from detectors which are to be grouped.

OutputWorkspace

Output

Workspace

Mandatory

Output workspace which will hold the grouped data.

GroupName

Input

string

The name of the group. Must contain at least one alphanumeric character.

Grouping

Input

int list

1

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.

Description

When interacting with the Muon Analysis interface, operations such as detector grouping, group asymmetry and pair asymmetry are performed on data. This algorithm performs a “grouping counts” operation, in other words it sums the counts associated to a given sequence of detector IDs.

This algorithm is part of a set of four; with MuonPreProcess v1 being run first; and the output being fed into this one. This allows the replication of the workflow used by the muon analysis interface to produce group data.

Analysis

A workspace has one or more spectra contained within it; for muon data each spectra has a unique detector ID. Assuming the y-values represent counts; a detector grouping operation causes the counts to be summed across the given set of detector IDs which are supplied to the Grouping argument (for example 1,2,3,4,5 and 1-5).

The InputWorkspace must be a WorkspaceGroup, where each workspace within the workspace-group represents a single period. Thus, single period data is just a workspaceGroup with a single workspace within it.

The detector-group must be given a name via GroupName which can consist of letters, numbers and underscores.

  1. Valid names : “fwd”, “fwd2”, “fwd_2”, “1234”

  2. Invalid names : “”, “fwd!”, “fwd “

The detector-group name does not affect the data; however the name is used in the muon interface when automatically generating workspace names from detector-group data.

Multi period 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;

  1. SummedPeriods = 1,2

  2. SubtractedPeriods = 3,4

would combine periods in the combination $(1+2)-(3+4)$.

Usage

Example - Using MuonPreProcess followed by MuonGroupingCounts on Single Period Data

# Single period data with four spectra
dataX = [0, 1, 2, 3, 4, 5] * 4
dataY = [10, 20, 30, 20, 10] * 4
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)

# We are not actually applying any processing to the data
# but the algorithm will convert our single period data into
# the required form (a WorkspaceGroup)
pre_processed_workspace = MuonPreProcess(InputWorkspace=input_workspace)

output_workspace = MuonGroupingCounts(InputWorkspace=pre_processed_workspace,
                                                GroupName="fwd",
                                                Grouping=[1, 2, 3, 4])

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

Output:

X values are : [ 0.  1.  2.  3.  4.  5.]
Y values are : [  40.   80.  120.   80.   40.]

Example - Using Only MuonGroupingCounts on Single Period Data

# Create a workspaces with four spectra
dataX = [0, 1, 2, 3, 4, 5] * 4
dataY = [10, 20, 30, 20, 10] * 4
ws = 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)
    ws.getSpectrum(i).setDetectorID(i + 1)

# Put the workspace inside a WorkspaceGroup
input_workspace = GroupWorkspaces(ws)

output_workspace = MuonGroupingCounts(InputWorkspace=input_workspace,
                                                GroupName="fwd",
                                                Grouping=[1, 2, 3, 4])

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

Output:

X values are : [ 0.  1.  2.  3.  4.  5.]
Y values are : [  40.   80.  120.   80.   40.]

Example - Multi Period Data

# Create two workspaces with four spectra
dataX = [0, 1, 2, 3, 4, 5] * 4
dataY = [10, 20, 30, 20, 10] * 4
ws1 = CreateWorkspace(dataX, dataY, NSpec=4)
ws2 = 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)
    ws1.getSpectrum(i).setDetectorID(i + 1)
    ws2.getSpectrum(i).setDetectorID(i + 1)

# Create multi period data
multi_period_data = GroupWorkspaces(ws1)
multi_period_data.addWorkspace(ws2)

# This time we won't run MuonPreProcess, as we don't want to apply any pre-processing
# and we already have a WorkspaceGroup

output_workspace = MuonGroupingCounts(InputWorkspace=multi_period_data,
                                                GroupName="fwd",
                                                Grouping=[1, 2, 3, 4],
                                                SummedPeriods=[1, 2])

# We have asked for periods 1+2, with each period summing detectors 1,2,3,4
print("X values are : {}".format(output_workspace.readX(0)))
print("Y values are : {}".format(output_workspace.readY(0)))

Output:

X values are : [ 0.  1.  2.  3.  4.  5.]
Y values are : [  80.  160.  240.  160.   80.]

Categories: AlgorithmIndex | Muon\DataHandling

Source

C++ header: MuonGroupingCounts.h

C++ source: MuonGroupingCounts.cpp