Mantid
Loading...
Searching...
No Matches
GetEi2.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2008 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"
15#include "MantidAlgorithms/DllConfig.h"
17
18//----------------------------------------------------------------------
19// Forward Declarations
20//----------------------------------------------------------------------
21namespace Mantid {
22namespace HistogramData {
23class HistogramY;
24class HistogramX;
25class HistogramE;
26} // namespace HistogramData
27} // namespace Mantid
28namespace Mantid {
29namespace Algorithms {
48class MANTID_ALGORITHMS_DLL GetEi2 final : public API::Algorithm {
49public:
51 GetEi2();
53 void init() override;
55 void exec() override;
56
58 const std::string name() const override { return "GetEi"; }
60 const std::string summary() const override {
61 return "Calculates the kinetic energy of neutrons leaving the source based "
62 "on the time it takes for them to travel between two monitors.";
63 }
64
66 int version() const override { return 2; }
67 const std::vector<std::string> seeAlso() const override { return {"GetAllEi", "GetEiMonDet", "GetEiT0atSNS"}; }
69 const std::string category() const override { return "Inelastic\\Ei"; }
70
71private:
73 double calculateEi(const double initial_guess);
76 double getDistanceFromSource(const size_t ws_index, const API::SpectrumInfo &spectrumInfo) const;
78 double calculatePeakPosition(const size_t ws_index, const double t_min, const double t_max);
80 API::MatrixWorkspace_sptr extractSpectrum(const size_t ws_index, const double start, const double end);
82 double calculatePeakWidthAtHalfHeight(const API::MatrixWorkspace_sptr &data_ws, const double prominence,
83 std::vector<double> &peak_x, std::vector<double> &peak_y,
84 std::vector<double> &peak_e) const;
86 double calculateFirstMoment(const API::MatrixWorkspace_sptr &monitor_ws, const double prominence);
88 API::MatrixWorkspace_sptr rebin(const API::MatrixWorkspace_sptr &monitor_ws, const double first, const double width,
89 const double end);
91 void integrate(double &integral_val, double &integral_err, const HistogramData::HistogramX &x,
92 const HistogramData::HistogramY &s, const HistogramData::HistogramE &e, const double xmin,
93 const double xmax) const;
95 void storeEi(const double ei) const;
96
100 std::pair<int, double> m_peak1_pos;
109 const double m_peak_signif;
111 const double m_peak_deriv;
113 const double m_binwidth_frac;
115 const double m_bkgd_frac;
116};
117
118} // namespace Algorithms
119} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
Definition: SpectrumInfo.h:53
Requires an estimate for the initial neutron energy which it uses to search for monitor peaks and fro...
Definition: GetEi2.h:48
const std::string summary() const override
Summary of algorithms purpose.
Definition: GetEi2.h:60
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
Definition: GetEi2.h:67
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
Definition: GetEi2.h:69
double m_tof_window
The percentage deviation from the estimated peak time that defines the peak region.
Definition: GetEi2.h:107
const double m_bkgd_frac
The fraction of the peakwidth to use in calculating background points.
Definition: GetEi2.h:115
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Definition: GetEi2.h:58
double m_t_to_mev
Conversion factor between time and energy.
Definition: GetEi2.h:104
int version() const override
Algorithm's version for identification overriding a virtual method.
Definition: GetEi2.h:66
API::MatrixWorkspace_sptr m_input_ws
The input workspace.
Definition: GetEi2.h:98
const double m_peak_signif
Number of std deviations to consider a peak.
Definition: GetEi2.h:109
std::pair< int, double > m_peak1_pos
The calculated position of the first peak.
Definition: GetEi2.h:100
bool m_fixedei
True if the Ei should be fixed at the guess energy.
Definition: GetEi2.h:102
const double m_peak_deriv
Number of std deviations to consider a peak for the derivative.
Definition: GetEi2.h:111
const double m_binwidth_frac
The fraction of the peak width for the new bins.
Definition: GetEi2.h:113
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
void MANTID_KERNEL_DLL rebin(const std::vector< double > &xold, const std::vector< double > &yold, const std::vector< double > &eold, const std::vector< double > &xnew, std::vector< double > &ynew, std::vector< double > &enew, bool distribution, bool addition=false)
Rebins data according to a new output X array.
Helper class which provides the Collimation Length for SANS instruments.