Mantid
Loading...
Searching...
No Matches
ModeratorTzero.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/Algorithm.h"
13#include "MantidAlgorithms/DllConfig.h"
17
18namespace Mantid {
19namespace Algorithms {
20/* Corrects the time of flight (TOF) by a time offset that is dependent on the
21 energy of the neutron after passing through the moderator.
22 A heuristic formula for the correction is stored in the instrument definition
23 file. Below is shown the entry in the instrument file for the VISION beamline:
24 <!-- formula for t0 calculation. See
25 http://muparser.sourceforge.net/mup_features.html#idDef2 for available
26 operators-->
27 <parameter name="t0_formula" type="string">
28 <value val="34.746 - 0.166672*incidentEnergy +
29 0.00020538*incidentEnergy^(2.0)" />
30 </parameter>
31
32 The recorded TOF = t_0 + t_i + t_f with
33 t_0: emission time from the moderator
34 t_1: time from moderator to sample
35 t_2: time from sample to detector
36 This algorithm will replace TOF with TOF' = TOF-t_0 = t_i+t_f
37
38 For a direct geometry instrument, the incidente energy E_1 is the same for all
39 neutrons. Hence, the moderator emission time is the same for all neutrons.
40 For an indirect geometry instrument, E_1 is different for each neutron and is
41 not known. However, the final energy E_2 selected by the analyzers is known.
42 t_0 = func(E_1) , a function of the incident energy
43 t_1 = L_1/v_1 with L_1 the distance from moderator to sample, and v_1 the
44 initial unknown velocity ( E_1=1/2*m*v_1^2)
45 t_2 = L_2/v_2 with L_2 the distance from sample to detector, and v_2 is the
46 final fixed velocity ( E_2=1/2*m*v_2^2)
47
48 We obtain TOF' in an iterative process, taking into account the fact that the
49 correction t_0 is much smaller than t_i+t_f. Thus
50 TOF-t_0^(n) = L_1/v_1^(n) + L_2/v_2 , n=0, 1, 2,..
51 Set t_0^(0)=0 and obtain v_1^(0) from the previous formula. From v_1^(0) we
52 obtain E_1^(0)
53 Set t_0^(1)=func( E_1^(0) ) and repeat the steps until |t_0^(n+1) - t_0^(n+1)|
54 < 1 microsec. Typically, three to four iterations are needed for convergence.
55
56 @author Jose Borreguero
57 @date 03/04/2013
58*/
59class MANTID_ALGORITHMS_DLL ModeratorTzero : public Mantid::API::Algorithm {
60public:
64 const std::string name() const override { return "ModeratorTzero"; }
66 const std::string summary() const override {
67 return "Corrects the time of flight of an indirect geometry instrument by "
68 "a time offset that is dependent on the energy of the neutron after "
69 "passing through the moderator.";
70 }
71
73 int version() const override { return (1); }
74 const std::vector<std::string> seeAlso() const override { return {"ModeratorTzeroLinear"}; }
76 const std::string category() const override { return "CorrectionFunctions\\InstrumentCorrections"; }
78 void setFormula(const std::string &formula);
80 double gett1min();
81
82private:
83 // Initialisation code
84 void init() override;
86 void exec() override;
88 void execEvent(const std::string &emode);
91 double CalculateT0indirect(const double &tof, const double &L1, const double &t2, double &E1, mu::Parser &parser);
94 double CalculateT0elastic(const double &tof, const double &L12, double &E1, mu::Parser &parser);
95 const double m_convfactor;
98 size_t m_niter;
100 double m_tolTOF;
103 std::string m_formula;
105 const double m_t1min;
106};
107
108} // namespace Algorithms
109} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
const double m_t1min
tof limit for fast neutrons
const std::string summary() const override
Summary of algorithms purpose.
std::string m_formula
string containing the heuristic regression for the moderator emission time versus neutron energy
double m_tolTOF
tolerance for calculating E1, in micro-seconds
int version() const override
Algorithm's version.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
size_t m_niter
Maximum number of iterations when calculating the emission time from the moderator.
const std::string name() const override
Algorithm's name.
const std::string category() const override
Algorithm's category for identification.
Helper class which provides the Collimation Length for SANS instruments.