/
DoublePulseFit.h
126 lines (110 loc) · 4.93 KB
/
DoublePulseFit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/MultiDomainFunction.h"
#include "MantidAPI/ParamFunction.h"
#include "MantidCurveFitting/Functions/Convolution.h"
#include "MantidCurveFitting/IFittingAlgorithm.h"
namespace Mantid {
namespace API {
class FunctionDomain;
class FunctionValues;
class Workspace;
class IFuncMinimizer;
} // namespace API
namespace CurveFitting {
namespace Algorithms {
MANTID_CURVEFITTING_DLL Mantid::API::IFunction_sptr
getDoublePulseFunction(std::shared_ptr<const API::IFunction> const &function, double offset, double firstPulseWeight,
double secondPulseWeight);
MANTID_CURVEFITTING_DLL Mantid::API::IFunction_sptr
getDoublePulseMultiDomainFunction(std::shared_ptr<const API::MultiDomainFunction> const &function, double offset,
double firstPulseWeight, double secondPulseWeight);
MANTID_CURVEFITTING_DLL Mantid::API::IFunction_sptr
extractInnerFunction(std::shared_ptr<const Mantid::CurveFitting::Functions::Convolution> const &function);
MANTID_CURVEFITTING_DLL Mantid::API::IFunction_sptr
extractInnerFunction(std::shared_ptr<const API::MultiDomainFunction> const &function);
/**
A function to fit muon data from a double pulse source. It does this by
convoluting the input fitting function with two delta functions. This has the
same interface as Fit and be used in it's place.
The static properties are:
<UL>
<LI>Function - The fitting function</LI>
<LI>InputWorkspace - First input workspace with the data</LI>
<LI>DomainType - The type of function domain to use: Simple, Sequential, or
Parallel</LI>
<LI>Ties - Optional parameter ties</LI>
<LI>Constraints - Optional parameter constraints</LI>
<LI>MaxIterations - Max number of iterations, default 500</LI>
<LI>OutputStatus - A string with the output status</LI>
<LI>OutputChi2overDoF - The final chi^2 over degrees of freedom</LI>
<LI>Minimizer - The minimizer, default Levenberg-Marquardt</LI>
<LI>CostFunction - The cost function , default Least squares</LI>
<LI>CreateOutput - A flag to create output workspaces.</LI>
<LI>Output - Optional base name for the output workspaces.</LI>
<LI>TimeOffset - The time offset between the two pulses.</LI>
</UL>
After setting "Function" and "InputWorkspace" additional dynamic properties can
be declared.
Property "Function" must be set first. If it is of a multi-domain variety the
algorithm will
declare a number of properties with names "InputWorkspace_#" where # stands for
a number from 1
to n-1 where n is the number of domains required for the function. All the
workspace properties
have to be set.
After a "InputWorkspace[_#]" property is set more dynamic proeprties can be
declared. This depends
on the functions and the type of the workspace. For example, if "Function" is
IFunction1D and
"InputWorkspace" is a MatrixWorkspace then properties "WorkspaceIndex",
"StartX", and "EndX" will
be added.
If the output workspaces are to be created they will have the following
properties:
<UL>
<LI>OutputNormalisedCovarianceMatrix - A TableWorkspace with the covariance
matrix</LI>
<LI>OutputParameters - A TableWorkspace with the optimized parameters</LI>
<LI>OutputWorkspace - Optional: some functions and input workspaces may alow
to create a workspace
with the calculated values</LI>
</UL>
*/
class MANTID_CURVEFITTING_DLL DoublePulseFit : public IFittingAlgorithm {
public:
/// Default constructor
DoublePulseFit();
/// Algorithm's name for identification overriding a virtual method
const std::string name() const override { return "DoublePulseFit"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "A function to fit muon data from a double pulse source. Wraps Fit.";
}
/// Algorithm's version for identification overriding a virtual method
int version() const override { return (1); }
const std::vector<std::string> seeAlso() const override {
return {"FitGaussian", "UserFunction1D", "PlotPeakByLogValue", "SplineBackground", "EvaluateFunction", "Fit"};
}
private:
void initConcrete() override;
void execConcrete() override;
std::vector<Mantid::API::MatrixWorkspace_sptr> getWorkspaces() const;
void declareAdditionalProperties();
void runFitAlgorith(const Mantid::API::IAlgorithm_sptr &fitAlgorithm, const Mantid::API::IFunction_sptr &function,
int maxIterations);
void setOutputProperties();
void createOutput(const Mantid::API::IAlgorithm_sptr &fitAlg, const Mantid::API::IFunction_sptr &function);
bool m_makeOutput;
bool m_outputFitData;
bool m_multiDomain;
};
} // namespace Algorithms
} // namespace CurveFitting
} // namespace Mantid