Mantid
Loading...
Searching...
No Matches
TimeAtSampleStrategyDirect.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
13#include "MantidKernel/Logger.h"
16#include "MantidKernel/V3D.h"
17#include <cmath>
18
19using namespace Mantid::Kernel;
20using namespace Mantid::Geometry;
21using namespace Mantid::API;
22
23namespace Mantid::Algorithms {
24
25//----------------------------------------------------------------------------------------------
29 : m_constShift(0) {
30
31 // A constant among all spectra
32 constexpr double TWO_MEV_OVER_MASS = 2. * PhysicalConstants::meV / PhysicalConstants::NeutronMass;
33
34 // Get L1
35 const auto &samplepos = ws->getInstrument()->getSample()->getPos();
36 const auto &sourcepos = ws->getInstrument()->getSource()->getPos();
37 double l1 = samplepos.distance(sourcepos);
38
39 // Calculate constant (to all spectra) shift
40 m_constShift = l1 / std::sqrt(ei * TWO_MEV_OVER_MASS);
41}
42
48
49 // Correction is L1 and Ei dependent only. Detector positions are not
50 // required.
51 return Correction(0, m_constShift);
52}
53} // namespace Mantid::Algorithms
double m_constShift
Cached L1, Ei dependent const shift.
TimeAtSampleStrategyDirect(const std::shared_ptr< const Mantid::API::MatrixWorkspace > &ws, double ei)
Constructor.
Correction calculate(const size_t &workspace_index) const override
Calculate corrections to get a Time at Sample for a DG instrument.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
static constexpr double NeutronMass
Mass of the neutron in kg.
static constexpr double meV
1 meV in Joules.
The Correction struct to be applied as factor * TOF + offset offset:: TOF offset in unit of TOF facto...