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

ApplyMuonDetectorGrouping v1

../_images/ApplyMuonDetectorGrouping-v1_dlg.png

ApplyMuonDetectorGrouping dialog.

Summary

Group several muon detector IDs together and perform an analysis (either counts or asymmetry).

Properties

Name Direction Type Default Description
InputWorkspace Input Workspace Mandatory Input workspace containing data from detectors which are to be grouped.
InputWorkspaceGroup InOut WorkspaceGroup Mandatory The workspace group to which the output will be added.
GroupName Input string   The name of the group. Must contain at least one alphanumeric character.
Grouping Input string 1 The grouping of detectors, comma separated list of detector IDs or hyphenated ranges of IDs.
AnalysisType Input string Counts The type of analysis to perform on the spectra. Allowed values: [‘Counts’, ‘Asymmetry’]
TimeMin Input number 0.1 Start time for the data in ms. Only used with the asymmetry analysis.
TimeMax Input number 32 End time for the data in ms. Only used with the asymmetry analysis.
RebinArgs Input string   Rebin arguments. No rebinning if left empty.
TimeOffset Input number 0 Shift the times of all data by a fixed amount. The value given corresponds to the bin that will become 0.0 seconds.
SummedPeriods Input string 1 A list of periods to sum in multiperiod data.
SubtractedPeriods Input string   A list of periods to subtract in multiperiod data.
ApplyDeadTimeCorrection Input boolean False Whether dead time correction should be applied to input workspace
DeadTimeTable Input TableWorkspace   Table with dead time information. Must be specified if ApplyDeadTimeCorrection is set true.

Description

The algorithm is essentially a wrapper around the MuonProcess v1 algorithm, summing a group of detector IDs, and optionally performing an asymmetry calculation. This algorithm only applies to a grouping of detectors (see … for the equivalent algorithm on pairs of groups), it does not crop the data.

ApplyMuonDetectorGrouping takes an input workspace containing the data (with multiple detector IDs), groups it according to the optional user inputs, creates a unique name for the grouped data, and finally adds it to (or replaces it in) the supplied WorkspaceGroup. Multiple period data is supported through SummedPeriods and SubtractedPeriods. Various other optional behaviours are possible as detailed below.

Analysis

The algorithm supports two analysis types:

  • Counts - The spectra associated to the given detector IDs via Grouping are summed (with errors added in quadrature), see MuonGroupDetectors v1. Note that if several detector IDs are associated to the same spectra, the spectra will be counted once for each ID.
  • Asymmetry - The summation from Counts is performed. Then the asymmetry between the given group and muon exponential decay is calculated (see EstimateMuonAsymmetryFromCounts v1), between the times TimeMin and TimeMax.

The way in which period data is combined before the analysis is determined by SummedPeriods and SubtractedPeriods. For example, setting SummedPeriods to “1,2” and SubtractedPeriods to “3,4” would result in the period spectra being combined in the form \((1+2)-(3+4)\).

Note that the action of SummedPeriods and SubtractedPeriods is performed before the Counts/Asymmetry analysis.

The workspaces which hold the analysed data are stored in the WorkspaceGroup, using a unique name. From the following variables

  1. The InputWorkspaceGroup name is “inputGroup”
  2. AnalysisType is “Counts”
  3. GroupName is “test”

then the name would be “inputGroup; Group; test; Counts; #1”. A second workspace is also created with the same name, but ending in “#1_Raw”, the only difference being that the RebinArgs are not applied to the latter workspace. If period arithmetic is required, for example SummedPeriods is “1,2” then the name would be “inputGroup; Group; test; Counts; 1+2; #1”.

An option exists to apply dead time correction to the counts if ApplyDeadTimeCorrection is true, requiring a DeadTimeTable with the format as in ApplyDeadTimeCorr v1.

The TimeOffset parameter shifts the time axis to start at the given time (all bins are offset by the value). In MuonProcess v1 this is equivalent to LoadedTimeZero - TimeZero. Note that the TimeMin and TimeMax refer to the values before the offset is applied.

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 grouping, please refer to MuonGroupDetectors v1 documentation.

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

Example - Counts for EMU run with time offset and rebinning:

# Clear the ADS before starting
AnalysisDataService.clear()

# Create the workspace group in which the analysed workspaces will be placed
ws = CreateSampleWorkspace()
wsGroup = GroupWorkspaces("ws")
RenameWorkspace(  InputWorkspace="wsGroup",
                  OutputWorkspace='MUSR00015193',
                  OverwriteExisting=True)

# Load the data
LoadMuonNexus(  Filename='MUSR00015193.nxs',
                OutputWorkspace='MuonAnalysis')

ApplyMuonDetectorGrouping(
                InputWorkspace='MuonAnalysis',
                InputWorkspaceGroup='MUSR00015193',
                GroupName='Test',
                Grouping='1,2,3,5-10',
                TimeOffset=0.0,
                RebinArgs = "0.2")


output_rebin = mtd['MUSR00015193; Group; Test; Counts; #1']
print("Total counts (rebinned) : {0:.0f}".format( sum(output_rebin.readY(0))) )

output_noRebin = mtd['MUSR00015193; Group; Test; Counts; #1_Raw']
print("Total counts (no rebin) : {0:.0f}\n".format(sum(output_noRebin.readY(0))) )


print("Time range (original) : {0:.3f} - {1:.3f} mus".format(mtd['MuonAnalysis_1'].readX(0)[0],mtd['MuonAnalysis_1'].readX(0)[-1]))
print("Time range (no rebin) : {0:.3f} - {1:.3f} mus".format(output_noRebin.readX(0)[0],output_noRebin.readX(0)[-1]))
print("Time range (rebinned) : {0:.3f} - {1:.3f} mus\n".format(output_rebin.readX(0)[0],output_rebin.readX(0)[-1]))

print("Time step (original)  : {0:.3f} mus".format(mtd['MuonAnalysis_1'].readX(0)[1]-mtd['MuonAnalysis_1'].readX(0)[0]))
print("Time step (no rebin)  : {0:.3f} mus".format(output_noRebin.readX(0)[1]-output_noRebin.readX(0)[0]))
print("Time step (rebinned)  : {0:.3f} mus".format(output_rebin.readX(0)[1]-output_rebin.readX(0)[0]))

Output:

Total counts (rebinned) : 79970
Total counts (no rebin) : 79970

Time range (original) : -0.550 - 31.450 mus
Time range (no rebin) : 0.106 - 31.450 mus
Time range (rebinned) : 0.106 - 31.306 mus

Time step (original)  : 0.016 mus
Time step (no rebin)  : 0.016 mus
Time step (rebinned)  : 0.200 mus

Categories: AlgorithmIndex | Muon\DataHandling

Source

C++ header: ApplyMuonDetectorGrouping.h (last modified: 2020-03-25)

C++ source: ApplyMuonDetectorGrouping.cpp (last modified: 2020-04-07)