17using namespace CurveFitting;
27 :
ComptonProfile(), m_integrationSteps(256), m_thetaStep(0.0), m_phiStep(0.0) {}
54 int steps =
value.asInt();
57 throw std::runtime_error(std::string(
STEPS_ATTR) +
" attribute must be positive and non-zero");
60 throw std::runtime_error(std::string(
STEPS_ATTR) +
" attribute must be an even number");
82 const HistogramData::HistogramE &errors)
const {
83 std::vector<double> result(
ySpace().size());
85 std::transform(result.begin(), result.end(), errors.begin(), result.begin(), std::divides<double>());
101 std::vector<double> s2Cache;
108 const double prefactorJ = (1.0 / (sqrt(2.0 * M_PI) * sigmaX * sigmaY * sigmaZ)) * (2.0 / M_PI);
109 const double prefactorFSE =
110 (pow(sigmaX, 4) + pow(sigmaY, 4) + pow(sigmaZ, 4)) / (9.0 * sqrt(2.0 * M_PI) * sigmaX * sigmaY * sigmaZ);
112 const auto &yspace =
ySpace();
113 const auto &modq =
modQ();
114 if (modq.empty() || yspace.empty()) {
115 throw std::runtime_error(
"Y values or Q values not set");
118 for (
size_t i = 0; i < nData; i++) {
119 const double y(yspace[i]);
120 const double q(modq[i]);
125 result[i] = amplitude * (j + fse);
189 a = i % 2 == 1 ? 4 : 2;
192 b = j % 2 == 1 ? 4 : 2;
217 double sinTheta2 = pow(sin(theta), 2);
218 double sinPhi2 = pow(sin(phi), 2);
219 double cosTheta2 = pow(cos(theta), 2);
220 double cosPhi2 = pow(cos(phi), 2);
222 double x = (sinTheta2 * cosPhi2) / sigmaX2;
223 double y = (sinTheta2 * sinPhi2) / sigmaY2;
224 double z = cosTheta2 / sigmaZ2;
226 double s2 =
x +
y +
z;
230 s2Cache.emplace_back(s2);
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.
Attribute is a non-fitting parameter.
void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue)
Declare a single attribute.
virtual void declareAttributes()
Override to declare function attributes.
virtual void setAttribute(const std::string &name, const Attribute &)
Set a value to attribute attName.
size_t parameterIndex(const std::string &name) const override
Returns the index of parameter name.
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.
This class serves as a base-class for ComptonProfile type functions.
const std::vector< double > & modQ() const
Access Q values cache.
void declareParameters() override
Declare parameters that will never participate in the fit.
const std::vector< double > & ySpace() const
Access y-values cache.
static const char * SIGMA_X_PARAM
std::string name() const override
A string identifier for this function.
MultivariateGaussianComptonProfile()
Default constructor required for factory.
double calculateFSE(std::vector< double > s2Cache, double y) const
Calculates the A3 FSE correction.
double calculateIntegrandFSE(double s2, double y) const
Calculates the integrand of the A3 FSE correction.
void setAttribute(const std::string &name, const Attribute &value) override
Set an attribute value (and possibly cache its value)
void massProfile(double *result, const size_t nData) const override
Compute the function.
double calculateIntegrandJ(double s2, double y) const
Calculates the integrand of the mass profile.
double intervalCoeff(int i, int j) const
Obtains a cell of the coefficient grid for Simpson's integration in 2D.
std::vector< size_t > intensityParameterIndices() const override
Returns the indices of the intensity parameters.
static const char * SIGMA_Y_PARAM
double m_thetaStep
Delta theta in integration.
static const char * SIGMA_Z_PARAM
static const char * STEPS_ATTR
static const char * AMP_PARAM
size_t fillConstraintMatrix(Kernel::DblMatrix &cmatrix, const size_t start, const HistogramData::HistogramE &errors) const override
Fill in the columns of the matrix for this mass.
void declareAttributes() override
Declare parameters that will never participate in the fit.
int m_integrationSteps
Number of steps to perform during integration.
void buildS2Cache(std::vector< double > &s2Cache) const
Caches values of S2 for all theta and phi in integration range.
void declareParameters() override
Declare the function parameters.
double m_phiStep
Delta phi in integration.
double calculateJ(std::vector< double > s2Cache, double y) const
Calculates the mass profile.
void setColumn(const size_t nCol, const std::vector< T > &newCol)