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;
18using namespace Mantid::API;
19
20namespace Mantid::Algorithms {
21
25 : m_ws(std::move(ws)), m_spectrumInfo(m_ws->spectrumInfo()),
26 m_beamDir(m_ws->getInstrument()->getReferenceFrame()->vecPointingAlongBeam()) {}
27
33Correction TimeAtSampleStrategyElastic::calculate(const size_t &workspace_index) const {
34
35 // Calculate TOF ratio
36 const double L1s = m_spectrumInfo.l1();
37 double scale;
38 if (m_spectrumInfo.isMonitor(workspace_index)) {
40 scale = std::abs(L1s / L1m);
41 } else {
42 scale = L1s / (L1s + m_spectrumInfo.l2(workspace_index));
43 }
44
45 return Correction(0., scale);
46}
47
48} // namespace Mantid::Algorithms
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).
double l1() const
Returns L1 (distance from source to sample).
TimeAtSampleStrategyElastic(std::shared_ptr< const Mantid::API::MatrixWorkspace > ws)
Constructor.
Correction calculate(const size_t &workspace_index) const override
Calculate correction.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
Definition: V3D.h:274
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
STL namespace.
The Correction struct to be applied as factor * TOF + offset offset:: TOF offset in unit of TOF facto...