Skip to content

Commit

Permalink
refs #9581 DetectorEfficiencyCorrections
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Jun 13, 2014
1 parent 9f4fcbe commit 2e2cef2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 14 deletions.
Expand Up @@ -90,7 +90,7 @@ class DLLExport DetectorEfficiencyCor : public API::Algorithm
/// Algorithm's name for identification overriding a virtual method
virtual const std::string name() const { return "DetectorEfficiencyCor"; }
///Summary of algorithms purpose
virtual const std::string summary() const {return "This algorithm adjusts the binned data in a workspace for detector efficiency, calculated from the neutrons' kinetic energy, the gas filled detector's geometry and gas pressure. The data are then multiplied by <math>k_i/k_f</math>.";}
virtual const std::string summary() const {return "This algorithm adjusts the binned data in a workspace for detector efficiency, calculated from the neutrons' kinetic energy, the gas filled detector's geometry and gas pressure. The data are then multiplied by :math:`k_i/k_f`";}

/// Algorithm's version for identification overriding a virtual method
virtual int version() const { return 1; }
Expand Down
18 changes: 9 additions & 9 deletions Code/Mantid/Framework/Algorithms/src/DetectorEfficiencyCor.cpp
Expand Up @@ -64,7 +64,7 @@ const std::string PRESSURE_PARAM = "TubePressure";
const std::string THICKNESS_PARAM = "TubeThickness";
}

// this default constructor calls default constructors and sets other member data to imposible (flag) values
// this default constructor calls default constructors and sets other member data to impossible (flag) values
DetectorEfficiencyCor::DetectorEfficiencyCor() :
Algorithm(), m_inputWS(),m_outputWS(), m_paraMap(NULL), m_Ei(-1.0), m_ki(-1.0),
m_shapeCache(), m_samplePos(), m_spectraSkipped()
Expand All @@ -90,7 +90,7 @@ void DetectorEfficiencyCor::init()
auto checkEi = boost::make_shared<BoundedValidator<double> >();
checkEi->setLower(0.0);
declareProperty("IncidentEnergy", EMPTY_DBL(), checkEi,
"The energy of neutrons leaving the source. This algorithm assumes that this number is accurate and does not correct it using the output from [[GetEi]]." );
"The energy of neutrons leaving the source as can be calculated by :ref:`algm-GetEi`. If this value is provided, uses property value, if it is not present, needs Ei log value set on the workspace." );
}

/** Executes the algorithm
Expand Down Expand Up @@ -132,7 +132,7 @@ void DetectorEfficiencyCor::exec()
m_spectraSkipped.insert(m_spectraSkipped.end(), m_inputWS->getAxis(1)->spectraNo(i));
}
}
// make regular progress reports and check for cancelling the algorithm
// make regular progress reports and check for canceling the algorithm
if ( i % progStep == 0 )
{
progress(static_cast<double>(i)/numHists_d);
Expand All @@ -148,7 +148,7 @@ void DetectorEfficiencyCor::exec()
}
/** Loads and checks the values passed to the algorithm
*
* @throw invalid_argument if there is an incapatible property value so the algorithm can't continue
* @throw invalid_argument if there is an incompatible property value so the algorithm can't continue
*/
void DetectorEfficiencyCor::retrieveProperties()
{
Expand Down Expand Up @@ -285,7 +285,7 @@ double DetectorEfficiencyCor::calculateOneOverK(double loBinBound, double uppBin

/** Update the shape cache if necessary
* @param det :: a pointer to the detector to query
* @param detRadius :: An output paramater that contains the detector radius
* @param detRadius :: An output parameter that contains the detector radius
* @param detAxis :: An output parameter that contains the detector axis vector
*/
void DetectorEfficiencyCor::getDetectorGeometry(const Geometry::IDetector_const_sptr & det, double & detRadius, V3D & detAxis)
Expand Down Expand Up @@ -345,13 +345,13 @@ void DetectorEfficiencyCor::getDetectorGeometry(const Geometry::IDetector_const_
}
}

/** For basic shapes centred on the origin (0,0,0) this returns the distance to the surface in
/** For basic shapes centered on the origin (0,0,0) this returns the distance to the surface in
* the direction of the point given
* @param start :: the distance calculated from origin to the surface in a line towards this point. It should be outside the shape
* @param shape :: the object to calculate for, should be centred on the origin
* @param shape :: the object to calculate for, should be centered on the origin
* @return the distance to the surface in the direction of the point given
* @throw invalid_argument if there is any error finding the distance
* @returns The distance to the surface in metres
* @returns The distance to the surface in meters
*/
double DetectorEfficiencyCor::distToSurface(const V3D & start, const Object *shape) const
{
Expand All @@ -365,7 +365,7 @@ double DetectorEfficiencyCor::distToSurface(const V3D & start, const Object *sha
shape->interceptSurface(track);

if ( track.count() != 1 )
{// the track missed the shape, probably the shape is not centred on the origin
{// the track missed the shape, probably the shape is not centered on the origin
throw std::invalid_argument("Fatal error interpreting the shape of a detector");
}
// the first part of the track will be the part inside the shape, return its length
Expand Down
60 changes: 56 additions & 4 deletions Code/Mantid/docs/source/algorithms/DetectorEfficiencyCor-v1.rst
Expand Up @@ -14,14 +14,16 @@ The probability of neutron detection by each detector in the
energy, angle between their path and the detector axis, detector gas
pressure, radius and wall thickness. The detectors must be cylindrical
and their :sup:`3`\ He partial pressure, wall thickness and radius
stored in the input workspace, the first in atmospheres and the last two
in metres. That workspace then needs to be converted so that its
are attached to the instrument stored in the input workspace,
The first parameter is in atmospheres and the last two in metres.
That workspace then needs to be converted so that its
X-values are in `units <Unit_Factory>`__ of energy transfer, e.g. using
the :ref:`algm-ConvertUnits` algorithm.

To estimate the true number of neutrons that entered the detector the
counts in each bin are divided by the detector efficiency of that
detector at that energy.
detector at that energy. The efficiency iteslef is calculated from
the forumula, tabulated within the algorithm.

The numbers of counts are then multiplied by the value of
:math:`k_i/k_f` for each bin. In that formula :math:`k_i` is the
Expand All @@ -37,6 +39,56 @@ neutron kinetic energy and the energy lost to the sample respectively.

Note: it is not possible to use this `algorithm <algorithm>`__ to
correct for the detector efficiency alone. One solution to this is to
divide the output algorithm by :math:`k_i/k_f` calculated as above.
divide the output of the algorithm by :math:`k_i/k_f` calculated as above.

Usage
-----

**Example - Correct detectors efficiency:**

.. testcode:: ExDetectorEfficiencyCorr

# Simulates Load of a workspace with all necessary parameters #################
detWS = CreateSimulationWorkspace(Instrument='MAR',BinParams=[-50,2,50],UnitX='DeltaE')
detWS.dataE(0)[range(0,50)]=1
AddSampleLog(detWS,LogName='Ei',LogText='52.',LogType='Number');

# Correct detectors efficiency
corWS = DetectorEfficiencyCor(detWS)
corWS = CorrectKiKf(corWS,EMode='Direct')

#
# Look at sample results:
print 'part of the corrected workspace:'
for i in xrange(15,30):
print detWS.readX(0)[i],detWS.readY(0)[i],corWS.readY(0)[i],detWS.readE(0)[i],corWS.readE(0)[i]



.. testcleanup:: ExDetectorEfficiencyCorr

DeleteWorkspace(detWS)
DeleteWorkspace(corWS)

**Output:**

.. testoutput:: ExDetectorEfficiencyCorr

part of the corrected workspace:
-20.0 1.0 1.11489184233 1.0 1.11489184233
-18.0 1.0 1.12451654494 1.0 1.12451654494
-16.0 1.0 1.13460358926 1.0 1.13460358926
-14.0 1.0 1.14519004998 1.0 1.14519004998
-12.0 1.0 1.15631723061 1.0 1.15631723061
-10.0 1.0 1.16803129778 1.0 1.16803129778
-8.0 1.0 1.180384035 1.0 1.180384035
-6.0 1.0 1.19343374325 1.0 1.19343374325
-4.0 1.0 1.20724632323 1.0 1.20724632323
-2.0 1.0 1.22189658402 1.0 1.22189658402
0.0 1.0 1.23746983599 1.0 1.23746983599
2.0 1.0 1.25406384358 1.0 1.25406384358
4.0 1.0 1.2717912377 1.0 1.2717912377
6.0 1.0 1.29078252032 1.0 1.29078252032
8.0 1.0 1.31118984059 1.0 1.31118984059

.. categories::

0 comments on commit 2e2cef2

Please sign in to comment.