17using namespace CurveFitting::Algorithms;
23const char *WSINDEX_NAME =
"WorkspaceIndex";
24const char *MASS_NAME =
"Mass";
25const char *VOIGT_CUT_OFF =
"VoigtEnergyCutOff";
28const char *POS_PARAM =
"Position";
33const double STDDEV_TO_FWHM = 0.5 * std::sqrt(std::log(4.0));
39 m_efixed(0.0), m_hwhmLorentz(0.0) {}
58 m_voigt->setParameter(2, lorentzFWHM);
59 m_voigt->setParameter(3, gaussFWHM);
60 m_voigt->functionLocal(out, xValues, nData);
61 const double norm = 1.0 / (0.5 * M_PI * lorentzFWHM);
62 using std::placeholders::_1;
63 std::transform(out, out + nData, out, std::bind(std::multiplies<double>(), _1, norm));
68 m_gauss->setParameter(0, 0.5 * amp / M_PI / sigmaTotalSq);
70 m_gauss->setParameter(2, sqrt(sigmaTotalSq));
71 m_gauss->functionLocal(out, xValues, nData);
92 auto workspace = std::dynamic_pointer_cast<const API::MatrixWorkspace>(ws);
94 throw std::invalid_argument(
"ComptonPeakProfile expected an object of type MatrixWorkspace, type=" + ws->id());
101 const double sth = sin(detpar.
theta);
103 const double ei = detpar.
efixed / pow(distFact, 2.0);
104 const double v1 = std::sqrt(detpar.
efixed / MASS_TO_MEV);
106 const double v2 = std::sqrt(ei / MASS_TO_MEV);
107 const double trec = detpar.
l1 / v1 + detpar.
l2 / v2;
113 double yplus(0.0), yminus(0.0), dummy(0.0);
114 detpar.
efixed += dELorentz;
116 detpar.
efixed -= 2.0 * dELorentz;
140 if (
name == WSINDEX_NAME)
142 else if (
name == MASS_NAME)
144 else if (
name == VOIGT_CUT_OFF)
double value
The value of the point.
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
IPeaksWorkspace_sptr workspace
This is a specialization of IFunction for functions of one real argument.
Attribute is a non-fitting parameter.
void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue)
Declare a single attribute.
virtual void setAttribute(const std::string &name, const Attribute &)
Set a value to attribute attName.
Implements the part of IFunction interface dealing with parameters.
void declareParameter(const std::string &name, double initValue=0, const std::string &description="") override
Declare a new parameter.
double getParameter(size_t i) const override
Get i-th parameter.
static DetectorParams getDetectorParameters(const API::MatrixWorkspace_const_sptr &ws, const size_t index)
Creates a POD struct containing the required detector parameters for this spectrum.
static double getComponentParameter(const Geometry::IComponent &det, const Geometry::ParameterMap &pmap, const std::string &name)
Retrieve a component parameter.
static void calculateY(double &yspace, double &qspace, double &ei, const double mass, const double tsec, const double k1, const double v1, const DetectorParams &detpar)
Convert single time value to Y,Q & Ei values.
void setAttribute(const std::string &name, const Attribute &value) override
std::shared_ptr< API::IPeakFunction > m_gauss
Gaussian function for lower-energy peaks.
std::shared_ptr< API::IPeakFunction > m_voigt
Voigt function for higher-energy peaks.
void setWorkspace(std::shared_ptr< const API::Workspace > ws) override
Cache a copy of the workspace pointer and pull out the parameters.
void declareAttributes() override
Override to declare function attributes.
double m_mass
Mass of peak.
ComptonPeakProfile()
Default constructor required for factory.
double m_efixed
Final energy of analyser.
double m_hwhmLorentz
Calculated value of lorentz width.
void declareParameters() override
Override to declare function parameters.
void setUpForFit() override
Ensure the object is ready to be fitted.
std::string name() const override
A string identifier for this function.
double m_voigtCutOff
Below this value a Voigt is used for profile approximation.
size_t m_wsIndex
WorkspaceIndex attribute.
void function1D(double *out, const double *xValues, const size_t nData) const override
Calculates the value of the function for each x value and stores in the given output array.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
static constexpr double E_mev_toNeutronWavenumberSq
Transformation coefficient to transform neutron energy into neutron wavevector: K-neutron[m^-10] = sq...
static constexpr double NeutronMass
Mass of the neutron in kg.
static constexpr double meV
1 meV in Joules.
Generate a tableworkspace to store the calibration results.
Simple data structure to store nominal detector values It avoids some functions taking a huge number ...
double efixed
final energy
double theta
scattering angle in radians
double l1
source-sample distance in metres
double l2
sample-detector distance in metres