Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | The name of the input 2D workspace. |
OutputWorkspace | Output | MatrixWorkspace | Mandatory | The name of the output 2D workspace. |
Spectra | Input | int list | The workspace indices to remove the exponential decay from. | |
StartX | Input | number | 0.1 | The lower limit for calculating the asymmetry (an X value). |
EndX | Input | number | 15 | The upper limit for calculating the asymmetry (an X value). |
FittingFunction | Input | string | name = GausOsc, A = 10.0, Sigma = 0.2, Frequency = 1.0, Phi = 0.0 | The additional fitting functions to be used. |
InputDataType | Input | string | counts | If the data is raw counts or asymmetry. Allowed values: [‘counts’, ‘asymmetry’] |
Minimizer | Input | string | Levenberg-MarquardtMD | Minimizer to use for fitting. Allowed values: [‘BFGS’, ‘Conjugate gradient (Fletcher-Reeves imp.)’, ‘Conjugate gradient (Polak-Ribiere imp.)’, ‘Damped GaussNewton’, ‘FABADA’, ‘Levenberg-Marquardt’, ‘Levenberg-MarquardtMD’, ‘More-Sorensen’, ‘Simplex’, ‘SteepestDescent’, ‘Trust Region’] |
MaxIterations | Input | number | 500 | Stop after this number of iterations if a good fit is not found |
NormalizationConstant | Output | dbl list | ||
PreviousNormalizationConstant | Input | dbl list | Normalization constant used to estimate asymmetry |
This algorithm calculates the asymmetry from the specified muon spectra. By default, all of the spectra in a workspace will be corrected.
The formula for calculating the asymmetry (from counts) is given by:
where is the muon lifetime (2.1969811e-6 seconds), :math:’F’ is the number of good frames and is a fitted normalisation constant. The normalisation is calculated by fitting to the normalised counts which is given by
and the fitting function is given by
where is a user defined function.
It is also possible to calculate the asymmetry from an estimated asymmetry.
Example - Calculating Asymmetry From Counts: This example is for calculating the Asymmetry from counts.
import math
import numpy as np
xData=np.linspace(start=0,stop=10,num=22)
yData=[]
tau = 2.1969811
for x in xData:
yData.append(50.*(1+10.*math.cos(3.*x))*math.exp(-x/tau))
input = CreateWorkspace(xData,yData)
run = input.getRun()
run.addProperty("goodfrm","10","None",True)
output,norm=CalculateMuonAsymmetry (InputWorkspace=input,spectra=0,StartX=1,EndX=5,FittingFunction= "name = GausOsc, A = 10.0, Sigma = 0.2, Frequency = 1.0, Phi = 0.0",InputDataType="counts",Minimizer="Levenberg-MarquardtMD",MaxIterations=500 )
print "Asymmetry: ",['{0:.2f}'.format(value) for value in output.readY(0)]
print "Normalization constant: {0:.2f}".format(norm[0])
Output:
Asymmetry: ['10.00', '1.42', '-9.60', '-4.14', '8.42', '6.53', '-6.57', '-8.39', '4.20', '9.58', '-1.48', '-10.00', '-1.35', '9.62', '4.08', '-8.46', '-6.48', '6.62', '8.36', '-4.25', '-9.56', '1.54']
Normalization constant: 5.00
Example - Calculating Asymmetry From Estimated Asymmetry: This example is for calculating the Asymmetry from an estimate of the asymmetry.
import math
import numpy as np
xData=np.linspace(start=0,stop=10,num=22)
yData=[]
tau = 2.1969811
for x in xData:
yData.append(50.*(1+10.*math.cos(3.*x))*math.exp(-x/tau))
input = CreateWorkspace(xData,yData)
run = input.getRun()
run.addProperty("goodfrm","10","None",True)
estAsymm,estNorm=CalculateMuonAsymmetry(InputWorkspace=input,spectra=0,StartX=1,EndX=5)
output,norm=CalculateMuonAsymmetry(InputWorkspace=estAsymm,spectra=0,StartX=1,EndX=5,FittingFunction= "name = GausOsc, A = 10.0, Sigma = 0.2, Frequency = 1.0, Phi = 0.0",InputDataType="asymmetry",Minimizer="Levenberg-MarquardtMD",MaxIterations=500,PreviousNormalizationConstant=estNorm )
print "Asymmetry: ",['{0:.2f}'.format(value) for value in output.readY(0)]
print "Normalization constant: {0:.2f}".format(norm[0])
Output:
Asymmetry: ['10.00', '1.42', '-9.60', '-4.14', '8.42', '6.53', '-6.57', '-8.39', '4.20', '9.58', '-1.48', '-10.00', '-1.35', '9.62', '4.08', '-8.46', '-6.48', '6.62', '8.36', '-4.25', '-9.56', '1.54']
Normalization constant: 5.00
Categories: Algorithms | Muon