diff --git a/src/classes/PRunBase.cpp b/src/classes/PRunBase.cpp index 712544ca..97a5d98f 100644 --- a/src/classes/PRunBase.cpp +++ b/src/classes/PRunBase.cpp @@ -68,7 +68,9 @@ PRunBase::PRunBase() *

* * \param msrInfo pointer to the msr info structure - * \param runNo number of the run of the msr-file + * \param rawData + * \param runNo + * \param tag */ PRunBase::PRunBase(PMsrHandler *msrInfo, PRunDataHandler *rawData, unsigned int runNo, EPMusrHandleTag tag) { diff --git a/src/classes/PTheory.cpp b/src/classes/PTheory.cpp index d628cb67..1c8d104f 100644 --- a/src/classes/PTheory.cpp +++ b/src/classes/PTheory.cpp @@ -166,10 +166,11 @@ PTheory::PTheory(PMsrHandler *msrInfo, unsigned int runNo, const bool hasParent) } // line is a valid function, hence analyze parameters - if (((unsigned int)(tokens->GetEntries()-1) != fNoOfParam) && (idx != THEORY_USER_FCN)) { + if (((unsigned int)(tokens->GetEntries()-1) != fNoOfParam) && + ((idx != THEORY_USER_FCN) && (idx != THEORY_POLYNOM))) { cout << endl << "**ERROR**: PTheory(): Theory line '" << line->fLine.Data() << "'"; - cout << " in line no " << line->fLineNo; - cout << " expecting " << fgTheoDataBase[idx].fNoOfParam << ", but found " << tokens->GetEntries()-1; + cout << endl << " in line no " << line->fLineNo; + cout << endl << " expecting " << fgTheoDataBase[idx].fNoOfParam << ", but found " << tokens->GetEntries()-1; fValid = false; } // keep function index @@ -435,6 +436,10 @@ double PTheory::Func(register double t, const PDoubleVector& paramValues, const return SkewedGauss(t, paramValues, funcValues) * fMul->Func(t, paramValues, funcValues) + fAdd->Func(t, paramValues, funcValues); break; + case THEORY_POLYNOM: + return Polynom(t, paramValues, funcValues) * fMul->Func(t, paramValues, funcValues) + + fAdd->Func(t, paramValues, funcValues); + break; case THEORY_USER_FCN: return UserFcn(t, paramValues, funcValues) * fMul->Func(t, paramValues, funcValues) + fAdd->Func(t, paramValues, funcValues); @@ -494,6 +499,9 @@ double PTheory::Func(register double t, const PDoubleVector& paramValues, const case THEORY_SKEWED_GAUSS: return SkewedGauss(t, paramValues, funcValues) * fMul->Func(t, paramValues, funcValues); break; + case THEORY_POLYNOM: + return Polynom(t, paramValues, funcValues) * fMul->Func(t, paramValues, funcValues); + break; case THEORY_USER_FCN: return UserFcn(t, paramValues, funcValues) * fMul->Func(t, paramValues, funcValues); break; @@ -554,6 +562,9 @@ double PTheory::Func(register double t, const PDoubleVector& paramValues, const case THEORY_SKEWED_GAUSS: return SkewedGauss(t, paramValues, funcValues) + fAdd->Func(t, paramValues, funcValues); break; + case THEORY_POLYNOM: + return Polynom(t, paramValues, funcValues) + fAdd->Func(t, paramValues, funcValues); + break; case THEORY_USER_FCN: return UserFcn(t, paramValues, funcValues) + fAdd->Func(t, paramValues, funcValues); break; @@ -612,6 +623,9 @@ double PTheory::Func(register double t, const PDoubleVector& paramValues, const case THEORY_SKEWED_GAUSS: return SkewedGauss(t, paramValues, funcValues); break; + case THEORY_POLYNOM: + return Polynom(t, paramValues, funcValues); + break; case THEORY_USER_FCN: return UserFcn(t, paramValues, funcValues); break; @@ -675,9 +689,19 @@ void PTheory::MakeCleanAndTidyTheoryBlock(PMsrLines *fullTheoryBlock) // make a handable string out of the asymmetry token ostr = dynamic_cast(tokens->At(0)); str = ostr->GetString(); - // check if the line is just a '+'or a userFcn; if so nothing to be done - if (str.Contains("+") || str.Contains("userFcn")) + // check if the line is just a '+' if so nothing to be done + if (str.Contains("+")) continue; + // check if the function is a polynom + if (!str.CompareTo("p") || str.Contains("polynom")) { + MakeCleanAndTidyPolynom(i, fullTheoryBlock); + continue; + } + // check if the function is a userFcn + if (!str.CompareTo("u") || str.Contains("userFcn")) { + MakeCleanAndTidyUserFcn(i, fullTheoryBlock); + continue; + } // search the theory function for (unsigned int j=0; j + * + * \param fullTheoryBlock + */ +void PTheory::MakeCleanAndTidyPolynom(unsigned int i, PMsrLines *fullTheoryBlock) +{ + PMsrLineStructure *line; + TString str, tidy; + TObjArray *tokens = 0; + TObjString *ostr; + char substr[256]; + +cout << endl << ">> MakeCleanAndTidyPolynom: " << (*fullTheoryBlock)[i].fLine.Data(); + + // init tidy + tidy = TString("polynom "); + // get the line to be prettyfied + line = &(*fullTheoryBlock)[i]; + // copy line content to str in order to remove comments + str = line->fLine.Copy(); + // tokenize line + tokens = str.Tokenize(" \t"); + + for (unsigned int j=1; j<(unsigned int)tokens->GetEntries(); j++) { + ostr = dynamic_cast(tokens->At(j)); + str = ostr->GetString(); + sprintf(substr, "%6s", str.Data()); + tidy += TString(substr); + } + + // add comment + tidy += " (tshift p0 p1 ... pn)"; + + // write tidy string back into theory block + (*fullTheoryBlock)[i].fLine = tidy; + + // clean up + if (tokens) { + delete tokens; + tokens = 0; + } +} + +//-------------------------------------------------------------------------- +// MakeCleanAndTidyUserFcn private +//-------------------------------------------------------------------------- +/** + *

+ * + * \param fullTheoryBlock + */ +void PTheory::MakeCleanAndTidyUserFcn(unsigned int i, PMsrLines *fullTheoryBlock) +{ + PMsrLineStructure *line; + TString str, tidy; + TObjArray *tokens = 0; + TObjString *ostr; + +cout << endl << ">> MakeCleanAndTidyUserFcn: " << (*fullTheoryBlock)[i].fLine.Data(); + + // init tidy + tidy = TString("userFcn "); + // get the line to be prettyfied + line = &(*fullTheoryBlock)[i]; + // copy line content to str in order to remove comments + str = line->fLine.Copy(); + // tokenize line + tokens = str.Tokenize(" \t"); + + for (unsigned int j=1; j<(unsigned int)tokens->GetEntries(); j++) { + ostr = dynamic_cast(tokens->At(j)); + str = ostr->GetString(); + tidy += str; + } + + // write tidy string back into theory block + (*fullTheoryBlock)[i].fLine = tidy; + + // clean up + if (tokens) { + delete tokens; + tokens = 0; + } +} + //-------------------------------------------------------------------------- /** *

Asymmetry @@ -1149,6 +1262,38 @@ double PTheory::SkewedGauss(register double t, const PDoubleVector& paramValues, return skg; } +//-------------------------------------------------------------------------- +/** + *

+ * + * \param t time in \f$(\mu\mathrm{s})\f$ + * \param paramValues tshift, p0, p1, ..., pn + */ +double PTheory::Polynom(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const +{ + double result = 0.0; + double tshift; + double val; + double expo = 0.0; + + // check if FUNCTIONS are used + for (unsigned int i=0; i diff --git a/src/include/PTheory.h b/src/include/PTheory.h index b0d910cb..840ef19f 100644 --- a/src/include/PTheory.h +++ b/src/include/PTheory.h @@ -68,28 +68,30 @@ #define THEORY_BESSEL 13 #define THEORY_INTERNAL_BESSEL 14 #define THEORY_SKEWED_GAUSS 15 -#define THEORY_USER_FCN 16 +#define THEORY_POLYNOM 16 +#define THEORY_USER_FCN 17 // function parameter tags, i.e. how many parameters has a specific function +// if there is a comment with a (tshift), the number of parameters is increased by one #define THEORY_PARAM_ASYMMETRY 1 // asymetry -#define THEORY_PARAM_SIMPLE_EXP 1 // damping -#define THEORY_PARAM_GENERAL_EXP 2 // damping, exponents -#define THEORY_PARAM_SIMPLE_GAUSS 1 // damping -#define THEORY_PARAM_STATIC_GAUSS_KT 1 // damping -#define THEORY_PARAM_STATIC_KT_LF 2 // frequency, damping -#define THEORY_PARAM_DYNAMIC_KT_LF 3 // frequency, damping, hop-rate -#define THEORY_PARAM_COMBI_LGKT 2 // Lorentz rate, Gauss rate -#define THEORY_PARAM_SPIN_GLASS 3 // rate, hop-rate, order parameter -#define THEORY_PARAM_RANDOM_ANISOTROPIC_HYPERFINE 2 // frequency, rate -#define THEORY_PARAM_ABRAGAM 2 // rate, hop-rate -#define THEORY_PARAM_INTERNAL_FIELD 4 // phase, frequency, TF damping, damping -#define THEORY_PARAM_TF_COS 2 // phase, frequency -#define THEORY_PARAM_BESSEL 2 // phase, frequency -#define THEORY_PARAM_INTERNAL_BESSEL 5 // fraction, phase, frequency, TF damping, damping -#define THEORY_PARAM_SKEWED_GAUSS 4 // phase, frequency, rate minus, rate plus +#define THEORY_PARAM_SIMPLE_EXP 1 // damping (tshift) +#define THEORY_PARAM_GENERAL_EXP 2 // damping, exponents (tshift) +#define THEORY_PARAM_SIMPLE_GAUSS 1 // damping (tshift) +#define THEORY_PARAM_STATIC_GAUSS_KT 1 // damping (tshift) +#define THEORY_PARAM_STATIC_KT_LF 2 // frequency, damping (tshift) +#define THEORY_PARAM_DYNAMIC_KT_LF 3 // frequency, damping, hop-rate (tshift) +#define THEORY_PARAM_COMBI_LGKT 2 // Lorentz rate, Gauss rate (tshift) +#define THEORY_PARAM_SPIN_GLASS 3 // rate, hop-rate, order parameter (tshift) +#define THEORY_PARAM_RANDOM_ANISOTROPIC_HYPERFINE 2 // frequency, rate (tshift) +#define THEORY_PARAM_ABRAGAM 2 // rate, hop-rate (tshift) +#define THEORY_PARAM_INTERNAL_FIELD 4 // phase, frequency, TF damping, damping (tshift) +#define THEORY_PARAM_TF_COS 2 // phase, frequency (tshift) +#define THEORY_PARAM_BESSEL 2 // phase, frequency (tshift) +#define THEORY_PARAM_INTERNAL_BESSEL 5 // fraction, phase, frequency, TF damping, damping (tshift) +#define THEORY_PARAM_SKEWED_GAUSS 4 // phase, frequency, rate minus, rate plus (tshift) // number of available user functions -#define THEORY_MAX 17 +#define THEORY_MAX 18 // deg -> rad factor #define DEG_TO_RAD 0.0174532925199432955 @@ -165,6 +167,9 @@ static PTheoDataBase fgTheoDataBase[THEORY_MAX] = { {THEORY_SKEWED_GAUSS, THEORY_PARAM_SKEWED_GAUSS, false, "skewedGss", "skg", "(phase frequency rate_m rate_p)"}, + {THEORY_POLYNOM, 0, false, + "polynom", "p", "(tshift p0 p1 ... pn)"}, + {THEORY_USER_FCN, 0, false, "userFcn", "u", ""}}; @@ -184,6 +189,8 @@ class PTheory private: virtual int SearchDataBase(TString name); virtual void MakeCleanAndTidyTheoryBlock(PMsrLines* fullTheoryBlock); + virtual void MakeCleanAndTidyPolynom(unsigned int i, PMsrLines* fullTheoryBlock); + virtual void MakeCleanAndTidyUserFcn(unsigned int i, PMsrLines* fullTheoryBlock); virtual double Asymmetry(const PDoubleVector& paramValues, const PDoubleVector& funcValues) const; virtual double SimpleExp(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const; @@ -201,6 +208,7 @@ class PTheory 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 Polynom(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const; virtual double UserFcn(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const; // variables