Mantid
Loading...
Searching...
No Matches
TimeAtSampleStrategyElastic.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 +
7#include <utility>
8
15
16using namespace Mantid::Kernel;
17using namespace Mantid::Geometry;
18
19namespace Mantid::API {
20
21namespace {
22constexpr double ZERO_ADDITIVE_OFFSET{0.};
23}
24
28 : m_spectrumInfo(ws->spectrumInfo()), m_L1s(m_spectrumInfo.l1()),
29 m_beamDir(ws->getInstrument()->getReferenceFrame()->vecPointingAlongBeam()) {}
30
36Correction TimeAtSampleStrategyElastic::calculate(const size_t &workspace_index) const {
37
38 // Calculate TOF ratio
39 double scale;
40 if (m_spectrumInfo.isMonitor(workspace_index)) {
42 scale = std::abs(m_L1s / L1m);
43 } else {
44 scale = m_L1s / (m_L1s + m_spectrumInfo.l2(workspace_index));
45 }
46
47 return Correction(scale, ZERO_ADDITIVE_OFFSET);
48}
49
50} // namespace Mantid::API
bool isMonitor(const size_t index) const
Returns true if the detector(s) associated with the spectrum are monitors.
Kernel::V3D sourcePosition() const
Returns the source position.
Kernel::V3D position(const size_t index) const
Returns the position of the spectrum with given index.
double l2(const size_t index) const
Returns L2 (distance from sample to spectrum).
Correction calculate(const size_t &workspace_index) const override
Calculate correction.
TimeAtSampleStrategyElastic(std::shared_ptr< const Mantid::API::MatrixWorkspace > ws)
Constructor.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
Definition V3D.h:280
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
The Correction struct to be applied as factor * TOF + offset multiplicativeFactor: TOF correction fac...