Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bugfix/10829_MDNormDirectSC_help'
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Dec 22, 2014
2 parents 585fa47 + 890003d commit 08f4c05
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 14 deletions.
10 changes: 5 additions & 5 deletions Code/Mantid/Framework/MDAlgorithms/src/MDNormDirectSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,9 @@ void MDNormDirectSC::calculateNormalization(
}

auto *prog = new API::Progress(this, 0.3, 1.0, ndets);
// PARALLEL_FOR_NO_WSP_CHECK()
PARALLEL_FOR_NO_WSP_CHECK()
for (int64_t i = 0; i < ndets; i++) {
// PARALLEL_START_INTERUPT_REGION
PARALLEL_START_INTERUPT_REGION

const auto detID = detIDs[i];
double theta(0.0), phi(0.0);
Expand Down Expand Up @@ -514,17 +514,17 @@ void MDNormDirectSC::calculateNormalization(
// *PC
double signal = solid * delta;

// PARALLEL_CRITICAL(updateMD)
PARALLEL_CRITICAL(updateMD)
{
signal += m_normWS->getSignalAt(linIndex);
m_normWS->setSignalAt(linIndex, signal);
}
}
prog->report();

// PARALLEL_END_INTERUPT_REGION
PARALLEL_END_INTERUPT_REGION
}
// PARALLEL_CHECK_INTERUPT_REGION
PARALLEL_CHECK_INTERUPT_REGION

delete prog;
}
Expand Down
72 changes: 63 additions & 9 deletions Code/Mantid/docs/source/algorithms/MDNormDirectSC-v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,80 @@ Description

The algorithm calculates a normalization MD workspace for single crystal direct geometry inelastic experiments.
Trajectories of each detector in reciprocal space are calculated, and the flux is integrated between intersections with each
MDBox.
MDBox. A brief introduction to the multi-dimensional data normalization can be found :ref:`here <MDNorm>`

.. Note::

This is an experimental algorithm in Release 3.3. Please check the nightly Mantid build, and the Mantid webpage
for better offline help and usage examples.

.. Note::

If the MDEvent input workspace is generated from an event workspace, the algorithm gives the correct normalization
only if the event workspace is cropped and binned to the same energy transfer range. If the workspace is not cropped,
one might have events in places where the normalization is calculated to be 0.


Usage
-----
.. Try not to use files in your examples,
but if you cannot avoid it then the (small) files must be added to
autotestdata\UsageData and the following tag unindented
.. include:: ../usagedata-note.txt

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

**Example - MDNormDirectSC**

.. testcode:: MDNormDirectSCExample


import mantid
import os
from mantid.simpleapi import *
config['default.facility']="SNS"
from numpy import *

DGS_input_data=Load("CNCS_7860")
# Keep events (SofPhiEIsDistribution=False)
# Do not normalize by proton charge in DgsReduction
DGS_output_data=DgsReduction(
SampleInputWorkspace=DGS_input_data,
SofPhiEIsDistribution=False,
IncidentBeamNormalisation="None",
EnergyTransferRange="-1.5,0.01,2.7",
)
DGS_output_data=DGS_output_data[0]
SetGoniometer(DGS_output_data,Axis0="10.,0,1,0,1")
SetUB(DGS_output_data, 5.,3.2,7.2)
DGS_output_data=CropWorkspace(DGS_output_data,XMin=-1.5,XMax=2.7)
MDE=ConvertToMD(DGS_output_data,
QDimensions="Q3D",
dEAnalysisMode="Direct",
Q3DFrames="HKL",
QConversionScales="HKL")
histoData,histoNorm=MDNormDirectSC(MDE,
AlignedDim0="[H,0,0],-0.2,1.6,100",
AlignedDim1="DeltaE,-1.5,3.,100",
)
normalized=histoData/histoNorm
print "The normalization workspace shape is "+str(histoNorm.getSignalArray().shape)
print "Out of those elements, "+str(nonzero(histoNorm.getSignalArray())[0].size)+" are nonzero"

.. testoutput:: MDNormDirectSCExample




The normalization workspace shape is (100, 100)
Out of those elements, 6712 are nonzero

.. testcleanup:: MDNormDirectSCExample

DeleteWorkspace(DGS_input_data)
DeleteWorkspace(DGS_output_data)
DeleteWorkspace(MDE)
DeleteWorkspace(histoData)
DeleteWorkspace(histoNorm)
DeleteWorkspace(normalized)


The output would look like:

.. figure:: /images/MDNormDirectSC.png
:alt: MDNormDirectSC.png

.. categories::

23 changes: 23 additions & 0 deletions Code/Mantid/docs/source/concepts/MDNorm.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. _MDNorm:

Multi dimensional neutron scattering data normalization
=======================================================

In any experiment, a measurement consists of a raw quantity of interest and
a statistical significance of the measurement itself.
For neutron diffraction, the differential scattering cross section at some
point :math:`\mathbf{Q}` in the reciprocal space, measured with a single
detector with a solid angle :math:`d \Omega`, is given by:

.. math::
\frac{d \sigma}{d \Omega}=\frac{N}{\Phi \times d \Omega}
where :math:`N` is the number of scattered neutrons in a small volume
:math:`d \mathbf{Q}` around :math:`\mathbf{Q}`, and :math:`\Phi` is
the time integrated incident flux that contribute to the scattering in the given
volume.




Binary file added Code/Mantid/docs/source/images/MDNormDirectSC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 08f4c05

Please sign in to comment.