first implementation of userFcn concept. Not yet tested
This commit is contained in:
parent
bb49da5b4a
commit
6159700e85
@ -56,19 +56,19 @@ short term:
|
||||
|
||||
* something is wrong with lifetimecorrection plot of musrview (up shifted data) **FIXED** 08-05-16
|
||||
|
||||
* implement access to user-function, i.e. functions not
|
||||
defined within musrfit, using the ROOT dictionary feature
|
||||
to look for them and use them. **UNDER WAY, NOT TESTED YET** 08-06-05
|
||||
|
||||
---------------------
|
||||
intermediate term:
|
||||
---------------------
|
||||
|
||||
* implement access to user-function, i.e. functions not
|
||||
* start writing docu, i.e. transferring WKM doc from German -> English and
|
||||
describe new features with examples!
|
||||
* introduce error numbers with corresponding docu/explanation in the latex-docu.
|
||||
* implement RRF stuff
|
||||
* implement NonMuSR stuff
|
||||
defined within musrfit, using the ROOT dictionary feature
|
||||
to look for them and use them.
|
||||
* think about if it is worth to modify wkm in order to read
|
||||
the new msr-files, so that wkmview can be used for an intermediate
|
||||
time.
|
||||
|
@ -94,6 +94,7 @@ OBJS += PTheory.o
|
||||
OBJS += PFitterFcn.o
|
||||
OBJS += PFitter.o
|
||||
OBJS += PMusrCanvas.o PMusrCanvasDict.o
|
||||
OBJS += PUserFcnBase.o PUserFcnBaseDict.o
|
||||
|
||||
EXTOBJS =
|
||||
EXTOBJS += MuSR_td_PSI_bin.o
|
||||
@ -132,6 +133,10 @@ PMusrCanvasDict.cpp: ../include/PMusrCanvas.h ../include/PMusrCanvasLinkDef.h
|
||||
@echo "Generating dictionary $@..."
|
||||
rootcint -v -f $@ -c -p $^
|
||||
|
||||
PUserFcnBaseDict.cpp: ../include/PUserFcnBase.h ../include/PUserFcnBaseLinkDef.h
|
||||
@echo "Generating dictionary $@..."
|
||||
rootcint -v -f $@ -c -p $^
|
||||
|
||||
install: all
|
||||
@echo "Installing shared lib: libPMusr.so ( you must be root ;-) )"
|
||||
ifeq ($(OS),LINUX)
|
||||
|
@ -262,12 +262,13 @@ PTheory::PTheory(PMsrHandler *msrInfo, unsigned int runNo, const bool hasParent)
|
||||
fValid = false;
|
||||
} else { // invoke user function object
|
||||
fUserFcn = 0;
|
||||
fUserFcn = TClass::GetClass(fUserFcnClassName.Data())->New();
|
||||
fUserFcn = (PUserFcnBase*)TClass::GetClass(fUserFcnClassName.Data())->New();
|
||||
cout << endl << ">> fUserFcn = " << fUserFcn;
|
||||
if (fUserFcn == 0) {
|
||||
cout << endl << "**ERROR**: PTheory: user function object could not be invoked. See line no " << line->fLineNo;
|
||||
fValid = false;
|
||||
} else { // get the pointer to the user function evaluation routine
|
||||
} else { // user function valid, hence expand the fUserParam vector to the proper size
|
||||
fUserParam.resize(fParamNo.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,6 +291,7 @@ PTheory::~PTheory()
|
||||
//cout << endl << "PTheory::~PTheory() ..." << endl;
|
||||
|
||||
fParamNo.clear();
|
||||
fUserParam.clear();
|
||||
|
||||
if (fMul) {
|
||||
delete fMul;
|
||||
@ -307,9 +309,8 @@ PTheory::~PTheory()
|
||||
}
|
||||
|
||||
if (fUserFcn) {
|
||||
/*
|
||||
delete fUserFcn;
|
||||
fUserFcn = 0;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,7 +348,7 @@ bool PTheory::IsValid()
|
||||
* \param t
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::Func(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::Func(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
|
||||
if (fMul) {
|
||||
@ -714,7 +715,7 @@ void PTheory::MakeCleanAndTidyTheoryBlock(PMsrLines *fullTheoryBlock)
|
||||
* \param paramValues is an array of parameter values [par1, par2, ..., parX1,
|
||||
* internalPar1, ..., internalParX2, map1, ..., mapX3, fun1, ..., funX4]
|
||||
*/
|
||||
double PTheory::Asymmetry(const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::Asymmetry(const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double asym;
|
||||
|
||||
@ -740,7 +741,7 @@ double PTheory::Asymmetry(const vector<double>& paramValues, const vector<double
|
||||
* \param paramValues parameter values, here only one, namely the depolarization
|
||||
* rate \f$\lambda\f$ in \f$(1/\mu\mathrm{s})\f$
|
||||
*/
|
||||
double PTheory::SimpleExp(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::SimpleExp(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double lambda;
|
||||
|
||||
@ -761,7 +762,7 @@ double PTheory::SimpleExp(register double t, const vector<double>& paramValues,
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::GeneralExp(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::GeneralExp(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[2];
|
||||
|
||||
@ -784,7 +785,7 @@ double PTheory::GeneralExp(register double t, const vector<double>& paramValues,
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::SimpleGauss(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::SimpleGauss(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double sigma;
|
||||
|
||||
@ -805,7 +806,7 @@ double PTheory::SimpleGauss(register double t, const vector<double>& paramValues
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::StaticGaussKT(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::StaticGaussKT(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double sigma;
|
||||
|
||||
@ -828,7 +829,7 @@ double PTheory::StaticGaussKT(register double t, const vector<double>& paramValu
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::StaticKTLF(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::StaticKTLF(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[2]; // frequency, damping
|
||||
|
||||
@ -868,7 +869,7 @@ double PTheory::StaticKTLF(register double t, const vector<double>& paramValues,
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::DynamicKTLF(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::DynamicKTLF(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@ -880,7 +881,7 @@ double PTheory::DynamicKTLF(register double t, const vector<double>& paramValues
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::CombiLGKT(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::CombiLGKT(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[2];
|
||||
|
||||
@ -907,7 +908,7 @@ double PTheory::CombiLGKT(register double t, const vector<double>& paramValues,
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::SpinGlass(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::SpinGlass(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
if (paramValues[fParamNo[0]] == 0.0)
|
||||
return 1.0;
|
||||
@ -940,7 +941,7 @@ double PTheory::SpinGlass(register double t, const vector<double>& paramValues,
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::RandomAnisotropicHyperfine(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::RandomAnisotropicHyperfine(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[2];
|
||||
|
||||
@ -967,7 +968,7 @@ double PTheory::RandomAnisotropicHyperfine(register double t, const vector<doubl
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::Abragam(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::Abragam(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[2];
|
||||
|
||||
@ -993,7 +994,7 @@ double PTheory::Abragam(register double t, const vector<double>& paramValues, co
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::InternalField(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::InternalField(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[4]; // phase, freq, transversal rate, longitudinal rate
|
||||
|
||||
@ -1019,7 +1020,7 @@ double PTheory::InternalField(register double t, const vector<double>& paramValu
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::TFCos(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::TFCos(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[2];
|
||||
|
||||
@ -1042,7 +1043,7 @@ double PTheory::TFCos(register double t, const vector<double>& paramValues, cons
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::Bessel(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::Bessel(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[2];
|
||||
|
||||
@ -1065,7 +1066,7 @@ double PTheory::Bessel(register double t, const vector<double>& paramValues, con
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::InternalBessel(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::InternalBessel(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[4]; // phase, frequency, Trate, Lrate
|
||||
|
||||
@ -1091,7 +1092,7 @@ double PTheory::InternalBessel(register double t, const vector<double>& paramVal
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::SkewedGauss(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::SkewedGauss(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
double val[4]; // phase, freq, sigma-, sigma+
|
||||
double skg;
|
||||
@ -1138,18 +1139,33 @@ double PTheory::SkewedGauss(register double t, const vector<double>& paramValues
|
||||
* \param t time in \f$(\mu\mathrm{s})\f$
|
||||
* \param paramValues
|
||||
*/
|
||||
double PTheory::UserFcn(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const
|
||||
double PTheory::UserFcn(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const
|
||||
{
|
||||
static bool first = true;
|
||||
|
||||
static bool first = true;
|
||||
if (first) {
|
||||
first = false;
|
||||
cout << endl << ">> UserFcn: fParamNo.size()=" << fParamNo.size();
|
||||
cout << endl << ">> UserFcn: fParamNo.size()=" << fParamNo.size() << ", fUserParam.size()=" << fUserParam.size();
|
||||
for (unsigned int i=0; i<fParamNo.size(); i++) {
|
||||
cout << endl << ">> " << i << ": " << fParamNo[i]+1;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
// check if FUNCTIONS are used
|
||||
for (unsigned int i=0; i<fUserParam.size(); i++) {
|
||||
if (fParamNo[i] < MSR_PARAM_FUN_OFFSET) { // parameter or resolved map
|
||||
fUserParam[i] = paramValues[fParamNo[i]];
|
||||
} else { // function
|
||||
fUserParam[i] = funcValues[fParamNo[i]-MSR_PARAM_FUN_OFFSET];
|
||||
}
|
||||
}
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
for (unsigned int i=0; i<fUserParam.size(); i++) {
|
||||
cout << endl << "-> " << i << ": " << fUserParam[i];
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
return (*fUserFcn)(t, fUserParam);
|
||||
}
|
||||
|
@ -32,12 +32,12 @@
|
||||
#ifndef _PTHEORY_H_
|
||||
#define _PTHEORY_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <TString.h>
|
||||
#include <TF1.h>
|
||||
|
||||
#include "PMusr.h"
|
||||
#include "PMsrHandler.h"
|
||||
#include "PUserFcnBase.h"
|
||||
|
||||
// #include <gsl_sf_hyperg.h>
|
||||
//
|
||||
@ -178,29 +178,29 @@ class PTheory
|
||||
virtual ~PTheory();
|
||||
|
||||
virtual bool IsValid();
|
||||
virtual double Func(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double Func(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
|
||||
private:
|
||||
virtual int SearchDataBase(TString name);
|
||||
virtual void MakeCleanAndTidyTheoryBlock(PMsrLines* fullTheoryBlock);
|
||||
|
||||
virtual double Asymmetry(const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double SimpleExp(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double GeneralExp(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double SimpleGauss(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double StaticGaussKT(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double StaticKTLF(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double DynamicKTLF(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double CombiLGKT(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double SpinGlass(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double RandomAnisotropicHyperfine(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double Abragam(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double InternalField(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double TFCos(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double Bessel(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double InternalBessel(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double SkewedGauss(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double UserFcn(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
|
||||
virtual double Asymmetry(const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double SimpleExp(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double GeneralExp(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double SimpleGauss(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double StaticGaussKT(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double StaticKTLF(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double DynamicKTLF(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double CombiLGKT(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double SpinGlass(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double RandomAnisotropicHyperfine(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double Abragam(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double InternalField(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double TFCos(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double Bessel(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double InternalBessel(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double SkewedGauss(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
virtual double UserFcn(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
|
||||
|
||||
// variables
|
||||
bool fValid;
|
||||
@ -215,7 +215,8 @@ class PTheory
|
||||
TF1 *fStaticKTLFFunc;
|
||||
|
||||
TString fUserFcnClassName; ///< name of the user function class for within root
|
||||
void *fUserFcn; ///< pointer to the user function object
|
||||
PUserFcnBase *fUserFcn; ///< pointer to the user function object
|
||||
mutable PDoubleVector fUserParam; ///< vector holding the resolved user function parameters, i.e. map and function resolved.
|
||||
|
||||
PMsrHandler *fMsrInfo;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user