Skip to content

Commit

Permalink
Refs #9568. ApplyDeadTimeCorr
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Jun 6, 2014
1 parent 3327e2c commit 9c3a66c
Showing 1 changed file with 86 additions and 10 deletions.
96 changes: 86 additions & 10 deletions Code/Mantid/docs/source/algorithms/ApplyDeadTimeCorr-v1.rst
Expand Up @@ -9,18 +9,94 @@
Description
-----------

Apply deadtime correction to each spectra of a workspace. Define:
Assuming that the ``InputWorkspace`` contains measured
counts as a function of TOF, the algorithm returns a workspace
containing true counts as a function of the same TOF binning
according to

| `` ``\ :math:`{\displaystyle{N}}`\ `` = true count``
| `` ``\ :math:`{\displaystyle{M}}`\ `` = measured count``
| `` ``\ :math:`{\displaystyle{t_{dead}}}`\ `` = dead-time``
| `` ``\ :math:`{\displaystyle{t_{bin}}}`\ `` = time bin width``
| `` ``\ :math:`{\displaystyle{F}}`\ `` = Number of good frames``
.. math:: N = \frac{M}{(1-M*(\frac{t_{dead}}{t_{bin}*F}))}

Then this algorithm assumes that the InputWorkspace contains measured
counts as a function of TOF and returns a workspace containing true
counts as a function of the same TOF binning according to
where

.. math:: N = \frac{M}{(1-M*(\frac{t_{dead}}{t_{bin}*F}))}
| :math:`N` = true count
| :math:`M` = measured count
| :math:`t_{dead}` = dead-time
| :math:`t_{bin}` = time bin width
| :math:`F` = number of good frames
``DeadTimeTable`` is expected to have 2 columns:

1. Integer type, containing spectrum number (not index)
2. Double type, containing :math:`t_{dead}` value of the spectrum

Usage
-----

.. include:: ../usagedata-note.txt

**Example - Applying the correction using custom dead times:**

.. testcode:: ExCustomDeadTimes

# Load single period of a MUSR run
input = LoadMuonNexus('MUSR0015189.nxs', EntryNumber=1)

# Remove uninteresting bins
input = CropWorkspace('input', XMin=0.55, XMax=12)

# Create a table with some arbitrary dead times
dead_times = CreateEmptyTableWorkspace()
dead_times.addColumn('int', 'Spectrum no.')
dead_times.addColumn('double', 'Deadtime')

for i in range(1,65):
dead_times.addRow([i, 0.1])

output = ApplyDeadTimeCorr('input','dead_times')

original = Integration('input')
corrected = Integration('output')

format_str = 'Spectrum: {:d}; original: {:.3f}; corrected: {:.3f}'

for s in [0,32,63]:
print format_str.format(s, original.readY(s)[0], corrected.readY(s)[0])

Output:

.. testoutput:: ExCustomDeadTimes

Spectrum: 0; original: 6643.000; corrected: 6861.714
Spectrum: 32; original: 10384.000; corrected: 10928.727
Spectrum: 63; original: 8875.000; corrected: 9273.499

**Example - Applying the correction using dead times stored in the Nexus file:**

.. testcode:: ExLoadedDeadTimes

# Load a MUSR run
input = LoadMuonNexus('MUSR0015189.nxs', DeadTimeTable='dead_times')

# Remove uninteresting bins
input = CropWorkspace('input', XMin=0.55, XMax=12)

# Apply the loaded dead times
output = ApplyDeadTimeCorr('input','dead_times')

original = Integration(input.getItem(0))
corrected = Integration(output.getItem(0))

format_str = 'Spectrum: {:d}; original: {:.3f}; corrected: {:.3f}'

for s in [0,32,63]:
print format_str.format(s, original.readY(s)[0], corrected.readY(s)[0])

Output:

.. testoutput:: ExLoadedDeadTimes

Spectrum: 0; original: 6643.000; corrected: 6670.079
Spectrum: 32; original: 10384.000; corrected: 10451.664
Spectrum: 63; original: 8875.000; corrected: 8922.105

.. categories::

0 comments on commit 9c3a66c

Please sign in to comment.