192 lines
6.0 KiB
C++
192 lines
6.0 KiB
C++
/***************************************************************************
|
|
|
|
PMusrfitFunc.h
|
|
|
|
Author: Andreas Suter
|
|
e-mail: andreas.suter@psi.ch
|
|
|
|
***************************************************************************/
|
|
|
|
/***************************************************************************
|
|
* Copyright (C) 2007-2025 by Andreas Suter *
|
|
* andreas.suter@psi.ch *
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with this program; if not, write to the *
|
|
* Free Software Foundation, Inc., *
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
***************************************************************************/
|
|
|
|
#ifndef _PMUSRFITFUNC_H_
|
|
#define _PMUSRFITFUNC_H_
|
|
|
|
#include <QString>
|
|
#include <QVector>
|
|
|
|
/**
|
|
* @brief The PFuncParam class represents a parameter of a musrfit function.
|
|
*
|
|
* This class holds information about a single parameter of a musrfit theory function,
|
|
* including its name, default value, and whether it should be treated as a map
|
|
* (run-specific parameter) rather than a global parameter.
|
|
*/
|
|
class PFuncParam {
|
|
public:
|
|
/**
|
|
* @brief Constructor. Initializes to default values.
|
|
*/
|
|
PFuncParam() { initParam(); }
|
|
|
|
/**
|
|
* @brief Destructor.
|
|
*/
|
|
~PFuncParam() {}
|
|
|
|
/**
|
|
* @brief Initializes all member variables to default values.
|
|
*
|
|
* Sets name to "UnDef", value to 0.0, and map flag to false.
|
|
*/
|
|
void initParam() { fName = "UnDef"; fValue = 0.0; fMap = false; }
|
|
|
|
/**
|
|
* @brief Sets the parameter name.
|
|
* @param name Parameter name (e.g., "rate", "phase", "sigma").
|
|
*/
|
|
void setParamName(QString name) { fName = name; }
|
|
|
|
/**
|
|
* @brief Sets the default parameter value.
|
|
* @param dval Default value.
|
|
*/
|
|
void setParamValue(double dval) { fValue = dval; }
|
|
|
|
/**
|
|
* @brief Sets whether this parameter should be a map.
|
|
* @param isMap true if this is a run-specific (map) parameter.
|
|
*/
|
|
void setParamMap(bool isMap) { fMap = isMap; }
|
|
|
|
/**
|
|
* @brief Returns the parameter name.
|
|
* @return Parameter name.
|
|
*/
|
|
QString getParamName() { return fName; }
|
|
|
|
/**
|
|
* @brief Returns the default parameter value.
|
|
* @return Default value.
|
|
*/
|
|
double getParamValue() { return fValue; }
|
|
|
|
/**
|
|
* @brief Checks if this is a map parameter.
|
|
* @return true if this is a run-specific (map) parameter.
|
|
*/
|
|
bool isMap() { return fMap; }
|
|
|
|
private:
|
|
QString fName; ///< parameter name
|
|
double fValue; ///< default parameter value
|
|
bool fMap; ///< flag indicating if this is a map (run-specific) parameter
|
|
};
|
|
|
|
/**
|
|
* @brief The PMusrfitFunc class represents a musrfit theory function.
|
|
*
|
|
* This class holds the definition of a musrfit theory function including its
|
|
* full name, abbreviation (used in msr-files), number of parameters, and
|
|
* the parameter definitions. Examples include simpleGss (sg), simpleLor (sl),
|
|
* TFieldCos (tf), etc.
|
|
*/
|
|
class PMusrfitFunc {
|
|
public:
|
|
/**
|
|
* @brief Constructor. Initializes to default values.
|
|
*/
|
|
PMusrfitFunc() { initFunc(); }
|
|
|
|
/**
|
|
* @brief Destructor.
|
|
*/
|
|
~PMusrfitFunc() {}
|
|
|
|
/**
|
|
* @brief Initializes all member variables to default values.
|
|
*/
|
|
void initFunc();
|
|
|
|
/**
|
|
* @brief Sets the function name.
|
|
* @param name Full function name (e.g., "simpleGss").
|
|
*/
|
|
void setName(QString name) { fName = name; }
|
|
|
|
/**
|
|
* @brief Sets the function abbreviation.
|
|
* @param abbrv Abbreviation used in msr-files (e.g., "sg").
|
|
*/
|
|
void setAbbrv(QString abbrv) { fAbbrv = abbrv; }
|
|
|
|
/**
|
|
* @brief Sets the number of parameters this function takes.
|
|
* @param ival Number of parameters.
|
|
*/
|
|
void setNoOfParam(int ival) { fNoOfParam = ival; }
|
|
|
|
/**
|
|
* @brief Adds a parameter definition to this function.
|
|
* @param param Parameter object to add.
|
|
*/
|
|
void addFuncParam(PFuncParam param) { fParam.push_back(param); }
|
|
|
|
/**
|
|
* @brief Returns the function name.
|
|
* @return Full function name.
|
|
*/
|
|
QString getName() { return fName; }
|
|
|
|
/**
|
|
* @brief Returns the function abbreviation.
|
|
* @return Abbreviation string.
|
|
*/
|
|
QString getAbbrv() { return fAbbrv; }
|
|
|
|
/**
|
|
* @brief Returns the number of parameters.
|
|
* @return Number of parameters.
|
|
*/
|
|
int getNoOfParam() { return fNoOfParam; }
|
|
|
|
/**
|
|
* @brief Returns a function parameter by index.
|
|
* @param idx Index of the parameter.
|
|
* @return PFuncParam at the given index, or default param if out of range.
|
|
*/
|
|
PFuncParam getFuncParam(int idx);
|
|
|
|
/**
|
|
* @brief Returns a pointer to the parameter vector.
|
|
* @return Pointer to the QVector of PFuncParam.
|
|
*/
|
|
QVector<PFuncParam> *getFuncParams() { return &fParam; }
|
|
|
|
private:
|
|
QString fName; ///< full function name
|
|
QString fAbbrv; ///< abbreviation for msr-files
|
|
int fNoOfParam; ///< number of parameters
|
|
QVector<PFuncParam> fParam; ///< parameter definitions
|
|
};
|
|
|
|
#endif // _PMUSRFITFUNC_H_
|