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;
21
22namespace Mantid::API {
23
24namespace {
25// A constant among all spectra
26constexpr double TWO_MEV_OVER_MASS = 2. * PhysicalConstants::meV / PhysicalConstants::NeutronMass;
27} // namespace
28
29//----------------------------------------------------------------------------------------------
33 // Get L1
34 const auto &samplepos = ws->getInstrument()->getSample()->getPos();
35 const auto &sourcepos = ws->getInstrument()->getSource()->getPos();
36 const double l1 = samplepos.distance(sourcepos);
37
38 // Calculate constant (to all spectra) shift
39 m_constShift = l1 / std::sqrt(ei * TWO_MEV_OVER_MASS);
40}
41
46Correction Mantid::API::TimeAtSampleStrategyDirect::calculate(const size_t & /*workspace_index*/) const {
47 constexpr double SET_TOF_TO_ZERO{0.};
48 // Correction is L1 and Ei dependent only. Detector positions are not required.
49 return Correction(SET_TOF_TO_ZERO, m_constShift);
50}
51} // namespace Mantid::API
double m_constShift
Cached L1, Ei dependent const shift.
Correction calculate(const size_t &workspace_index) const override
Calculate corrections to get a Time at Sample for a DG instrument.
TimeAtSampleStrategyDirect(const std::shared_ptr< const Mantid::API::MatrixWorkspace > &ws, double ei)
Constructor.
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 multiplicativeFactor: TOF correction fac...