musrfit 1.10.0
PTheory Class Reference

Theory function evaluator and expression tree manager. More...

#include <PTheory.h>

Collaboration diagram for PTheory:

Public Member Functions

 PTheory (PMsrHandler *msrInfo, UInt_t runNo, const Bool_t hasParent=false)
 Constructor that parses the THEORY block and builds the expression tree.
 
virtual ~PTheory ()
 Destructor that recursively cleans up the expression tree.
 
virtual Bool_t IsValid ()
 Checks if the entire theory expression tree is valid.
 
virtual Double_t Func (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Evaluates the theory function at a given time point.
 

Private Member Functions

virtual void CleanUp (PTheory *theo)
 Recursively deletes child theory nodes (fAdd and fMul).
 
virtual Int_t SearchDataBase (TString name)
 Searches fgTheoDataBase for a function by name or abbreviation.
 
virtual Int_t GetUserFcnIdx (UInt_t lineNo) const
 Returns the index of user functions up to the given line.
 
virtual void MakeCleanAndTidyTheoryBlock (PMsrLines *fullTheoryBlock)
 Reformats the theory block for clean MSR file output.
 
virtual void MakeCleanAndTidyPolynom (UInt_t i, PMsrLines *fullTheoryBlock)
 Formats a polynomial theory line with proper spacing.
 
virtual void MakeCleanAndTidyUserFcn (UInt_t i, PMsrLines *fullTheoryBlock)
 Formats a user function theory line with proper spacing.
 
virtual Double_t Constant (const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Returns constant value. Formula: c.
 
virtual Double_t Asymmetry (const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Returns asymmetry value. Formula: A.
 
virtual Double_t SimpleExp (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Simple exponential relaxation. Formula: exp(-λt)
 
virtual Double_t GeneralExp (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 General (stretched) exponential. Formula: exp(-(λt)^β)
 
virtual Double_t SimpleGauss (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Simple Gaussian relaxation. Formula: exp(-σ²t²/2)
 
virtual Double_t StaticGaussKT (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Static Gaussian Kubo-Toyabe (ZF). Formula: 1/3 + 2/3(1-σ²t²)exp(-σ²t²/2)
 
virtual Double_t StaticGaussKTLF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Static Gaussian Kubo-Toyabe (LF). Requires numerical integration.
 
virtual Double_t DynamicGaussKTLF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Dynamic Gaussian Kubo-Toyabe (LF). Strong collision model.
 
virtual Double_t StaticLorentzKT (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Static Lorentzian Kubo-Toyabe (ZF). Formula: 1/3 + 2/3(1-at)exp(-at)
 
virtual Double_t StaticLorentzKTLF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Static Lorentzian Kubo-Toyabe (LF). Requires numerical integration.
 
virtual Double_t DynamicLorentzKTLF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Dynamic Lorentzian Kubo-Toyabe (LF). Strong collision model.
 
virtual Double_t DynamicGauLorKTZFFast (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Fast dynamic Gaussian-Lorentzian KT (ZF). Approximate fast calculation.
 
virtual Double_t DynamicGauLorKTLFFast (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Fast dynamic Gaussian-Lorentzian KT (LF). Approximate fast calculation.
 
virtual Double_t DynamicGauLorKTLF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Dynamic Gaussian-Lorentzian KT (LF). Full numerical calculation.
 
virtual Double_t CombiLGKT (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Combined Lorentzian-Gaussian KT. Product of both relaxation types.
 
virtual Double_t StrKT (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Stretched Kubo-Toyabe. Formula: exp(-(σt)^β) with KT-like recovery.
 
virtual Double_t SpinGlass (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Spin glass relaxation function. Edwards-Anderson order parameter.
 
virtual Double_t RandomAnisotropicHyperfine (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Random anisotropic hyperfine coupling. Powder average of anisotropic coupling.
 
virtual Double_t Abragam (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Abragam relaxation. Motional narrowing formula.
 
virtual Double_t TFCos (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Transverse field cosine. Formula: cos(φ + 2πνt)
 
virtual Double_t InternalField (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Internal field distribution. Gaussian field distribution model.
 
virtual Double_t InternalFieldGK (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Internal field (Kornilov model). Vortex lattice field distribution.
 
virtual Double_t InternalFieldLL (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Internal field (Larkin-Ovchinnikov model). Vortex lattice field distribution.
 
virtual Double_t Bessel (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Bessel function precession. Formula: J₀(2πνt + φ)
 
virtual Double_t InternalBessel (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Internal Bessel field distribution. Combines Bessel with relaxation.
 
virtual Double_t SkewedGauss (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Skewed Gaussian. Asymmetric relaxation rates before/after zero crossing.
 
virtual Double_t StaticNKZF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Static Nakajima-Keren (ZF). Combined nuclear and electronic relaxation.
 
virtual Double_t StaticNKTF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Static Nakajima-Keren (TF). Combined nuclear and electronic relaxation with precession.
 
virtual Double_t DynamicNKZF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Dynamic Nakajima-Keren (ZF). With spin fluctuations.
 
virtual Double_t DynamicNKTF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Dynamic Nakajima-Keren (TF). With spin fluctuations and precession.
 
virtual Double_t FmuF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 F-μ-F oscillation. Muon bound between two fluorine atoms.
 
virtual Double_t MuMinusExpTF (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 μ⁻ exponential TF. Negative muon in transverse field.
 
virtual Double_t Polynom (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 Polynomial function. Formula: Σᵢ pᵢtⁱ
 
virtual Double_t UserFcn (Double_t t, const PDoubleVector &paramValues, const PDoubleVector &funcValues) const
 User-defined function. Calls external shared library function.
 
virtual void CalculateGaussLFIntegral (const Double_t *val) const
 Calculates and caches Gaussian LF integral for static KT.
 
virtual void CalculateLorentzLFIntegral (const Double_t *val) const
 Calculates and caches Lorentzian LF integral for static KT.
 
virtual Double_t GetLFIntegralValue (const Double_t t) const
 Retrieves cached LF integral value at time t using interpolation.
 
virtual void CalculateDynKTLF (const Double_t *val, Int_t tag) const
 Calculates dynamic KT in LF using integral equation approach.
 
virtual Double_t GetDynKTLFValue (const Double_t t) const
 Retrieves cached dynamic KT LF value at time t.
 
virtual Double_t GetDyn_GL_KTLFValue (const Double_t t) const
 Retrieves cached dynamic Gauss-Lorentz KT LF value at time t.
 

Private Attributes

Bool_t fValid
 True if this theory node and its parse state are valid.
 
UInt_t fType
 Theory function type (THEORY_CONST, THEORY_SIMPLE_EXP, etc.)
 
std::vector< UInt_t > fParamNo
 Resolved parameter indices (0-based). Values >= MSR_PARAM_FUN_OFFSET are function references.
 
UInt_t fNoOfParam
 Expected number of parameters for this function type.
 
PTheoryfAdd
 Pointer to addition child node (left branch of tree)
 
PTheoryfMul
 Pointer to multiplication child node (right branch of tree)
 
Int_t fUserFcnIdx
 Index of this user function among all userFcn entries (for global state)
 
TString fUserFcnClassName
 ROOT class name for user function (e.g., "TMyFunction")
 
TString fUserFcnSharedLibName
 Shared library path (e.g., "libMyFunctions.so")
 
PUserFcnBasefUserFcn
 Pointer to instantiated user function object.
 
PDoubleVector fUserParam
 Resolved parameter values for user function calls.
 
PMsrHandlerfMsrInfo
 Pointer to MSR file handler (not owned)
 
Double_t fSamplingTime
 Time step for LF integral calculation (default 1 ns = 0.001 μs)
 
Double_t fPrevParam [THEORY_MAX_PARAM]
 Previous parameter values for cache invalidation check.
 
PDoubleVector fLFIntegral
 Cached static LF KT integral values.
 
Double_t fDynLFdt
 Time step for dynamic LF integral equation.
 
PDoubleVector fDynLFFuncValue
 Cached dynamic Gaussian/Lorentzian LF KT values.
 
PDoubleVector fDyn_GL_LFFuncValue
 Cached dynamic Gauss-Lorentz LF KT values.
 

Detailed Description

Theory function evaluator and expression tree manager.

PTheory is the core class responsible for parsing, validating, and evaluating theory functions specified in the THEORY block of MSR files. It implements a binary expression tree to handle complex combinations of theory functions.

Overview

The theory describes the expected muon polarization as a function of time. Different physical phenomena (relaxation, precession, field distributions) are represented by different theory functions that can be combined.

Expression Tree Structure

Theory expressions are parsed into a binary tree where:

  • Each node represents a theory function
  • Left child (fAdd) represents addition (+)
  • Right child (fMul) represents multiplication (*)

Example MSR theory block:

* THEORY
*   a 1           # asymmetry
*   tf 2 3        # TFieldCos
*   se 4          # simpleExp
*   +
*   a 5
*   tf 6 7
* 

Becomes: (par1 * cos(φ₂ + 2πν₃t) * exp(-λ₄t)) + (par5 * cos(φ₆ + 2πν₇t))

Syntax Details

Function specification:

function_name param1 param2 ... paramN (optional comment)

Parameter types:

  • Direct number: 1, 2, 3 → parameter index (1-based)
  • Map reference: map1, map2 → indirection via RUN block map
  • Function reference: fun1, fun2 → evaluated FUNCTIONS block entry

Operators:

  • + on separate line: Addition of following terms
  • Consecutive lines without +: Implicit multiplication

Available Functions

Basic:

  • const (c): Constant value
  • asymmetry (a): Initial asymmetry
  • simplExpo (se): exp(-λt)
  • generExpo (ge): exp(-(λt)^β)
  • simpleGss (sg): exp(-σ²t²/2)

Kubo-Toyabe (Gaussian):

  • statGssKt (stg): Static ZF Gaussian KT
  • statGssKTLF (sgktlf): Static LF Gaussian KT
  • dynGssKTLF (dgktlf): Dynamic LF Gaussian KT

Kubo-Toyabe (Lorentzian):

  • statExpKT (sekt): Static ZF Lorentzian KT
  • statExpKTLF (sektlf): Static LF Lorentzian KT
  • dynExpKTLF (dektlf): Dynamic LF Lorentzian KT

Precession:

  • TFieldCos (tf): cos(φ + 2πνt)
  • bessel (b): J₀(2πνt + φ)
  • internFld (ifld): Internal field distribution

Special:

  • spinGlass (spg): Spin glass relaxation
  • abragam (ab): Motional narrowing
  • userFcn (u): User-defined external function

Longitudinal Field Calculations

LF Kubo-Toyabe functions require numerical integration which is cached for efficiency. The cache is invalidated when parameters change. Caching variables:

  • fPrevParam: Previous parameter values for change detection
  • fLFIntegral: Cached integral values
  • fDynLFFuncValue: Dynamic KT function cache

User Functions

External functions can be loaded from shared libraries:

userFcn libMyFunctions.so MyFunctionClass param1 param2 ...

User functions must inherit from PUserFcnBase and implement:

  • operator()(Double_t t, const std::vector<Double_t>& par)
See also
PUserFcnBase, PMsrHandler, fgTheoDataBase

Definition at line 445 of file PTheory.h.

Constructor & Destructor Documentation

◆ PTheory()

PTheory::PTheory ( PMsrHandler * msrInfo,
UInt_t runNo,
const Bool_t hasParent = false )

Constructor that parses the THEORY block and builds the expression tree.

Parses the THEORY block and builds a binary expression tree.

Parses the theory block from the MSR file, validates function names and parameter counts, resolves parameter references, and recursively builds the expression tree for operators (+ and *).

Parsing algorithm:

  1. Get current line from theory block
  2. Remove comments (text after '(' or '#')
  3. Tokenize to extract function name and parameters
  4. Look up function in fgTheoDataBase
  5. Validate parameter count
  6. Resolve parameter references (direct, map, fun)
  7. If next line is not '+', recursively create fMul child
  8. If next line is '+', skip it and recursively create fAdd child
  9. For user functions: load shared library and instantiate class
Parameters
msrInfoPointer to MSR file handler containing theory block
runNoRun number (0-based) for parameter map resolution
hasParentFalse for root theory, true for child nodes. Controls static counter reset for recursive parsing.
Warning
If parsing fails, fValid is set to false and error messages are output to stderr. Always check IsValid() after construction.

The constructor recursively parses the theory block from the MSR file and builds a binary tree structure. Each theory function becomes a node, with multiplication creating right children and addition creating left children.

Example Theory Block:

   THEORY
     a 1          # asymmetry
     tf 2 3       # TFieldCos (phase, frequency)
     se 4         # simpleExp (rate)
     +
     a 5
     tf 6 7
     se 8
     +
     a 9
     tf 10 11

Resulting Binary Tree:

                a 1
              +/   \*
             a 5   tf 2 3
           + /  \*    \ *
           a 9  a 5   se 4
             \*   \*
        tf 10 11  tf 6 7
                   \*
                   se 8

The tree is evaluated as: (a1 * tf23 * se4) + (a5 * tf67 * se8) + (a9 * tf1011)

Parsing Algorithm:

  1. Initialize member variables and static counters (lineNo, depth)
  2. Get current line from theory block (skip if beyond end)
  3. Remove comments: text after '(' or '#'
  4. Tokenize line into function name and parameters
  5. Search fgTheoDataBase for function (by name or abbreviation)
  6. Validate parameter count (except for polynom and userFcn)
  7. For each parameter token:
    • If "mapN": resolve via RUN block map vector
    • If "funN": get function index + MSR_PARAM_FUN_OFFSET
    • Otherwise: direct parameter number (1-based → 0-based)
  8. If next line is not '+': increment depth, create fMul child recursively
  9. If depth=0 and next line is '+': skip '+', create fAdd child recursively
  10. For root node: call MakeCleanAndTidyTheoryBlock() to format output
  11. For userFcn: load shared library and instantiate class object

User Function Handling: User functions require special parsing:

  • Token 1: shared library name (e.g., "libMyFunc.so")
  • Token 2: class name (e.g., "TMyFunction")
  • Token 3+: parameters The library is loaded via gSystem->Load() and the class instantiated via TClass::GetClass()->New().
Parameters
msrInfoPointer to MSR file handler (NOT owned, must outlive PTheory)
runNoZero-based run number for map parameter resolution
hasParentfalse (default) for root theory node, true for child nodes. Controls reset of static line/depth counters.
Warning
Sets fValid=false on errors. Always check IsValid() after construction.
See also
fgTheoDataBase, SearchDataBase(), IsValid()

Definition at line 125 of file PTheory.cpp.

References fAdd, fDynLFdt, fgTheoDataBase, PMsrLineStructure::fLine, PMsrLineStructure::fLineNo, fMsrInfo, fMul, fNoOfParam, fParamNo, fPrevParam, fSamplingTime, fType, fUserFcn, fUserFcnClassName, fUserFcnIdx, fUserFcnSharedLibName, fUserParam, fValid, PMsrHandler::GetFuncIndex(), PMsrHandler::GetMsrRunList(), PMsrHandler::GetMsrTheory(), GetUserFcnIdx(), gGlobalUserFcn, MakeCleanAndTidyTheoryBlock(), MSR_PARAM_FUN_OFFSET, PTheory(), SearchDataBase(), status, THEORY_MAX_PARAM, THEORY_POLYNOM, THEORY_UNDEFINED, and THEORY_USER_FCN.

Referenced by CleanUp(), and PTheory().

◆ ~PTheory()

PTheory::~PTheory ( )
virtual

Destructor that recursively cleans up the expression tree.

Releases all allocated resources:

  • Clears parameter and function value vectors
  • Clears LF integral caches
  • Recursively deletes child theory nodes (fAdd, fMul)
  • Deletes user function object if present
  • Clears global user function vector

Releases all resources allocated by this theory node and its children:

  1. Clears parameter number vector (fParamNo)
  2. Clears user function parameter cache (fUserParam)
  3. Clears LF integral caches (fLFIntegral, fDynLFFuncValue)
  4. Recursively deletes child nodes via CleanUp()
  5. Deletes user function object if present
  6. Clears global user function vector
Note
Child nodes (fAdd, fMul) are deleted via CleanUp() which traverses the entire tree recursively.

Definition at line 375 of file PTheory.cpp.

References CleanUp(), fDynLFFuncValue, fLFIntegral, fParamNo, fUserFcn, fUserParam, and gGlobalUserFcn.

Member Function Documentation

◆ Abragam()

Double_t PTheory::Abragam ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Abragam relaxation. Motional narrowing formula.

theory function: Abragam function

\[ = \exp\left[-\frac{\sigma^2}{\gamma^2}\left(e^{-\gamma t}-1+\gamma t\right)\right] \]

or the time shifted version of it.

meaning of paramValues: $\sigma$, $\gamma$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2274 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ Asymmetry()

Double_t PTheory::Asymmetry ( const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Returns asymmetry value. Formula: A.

Returns the initial asymmetry value.

Mathematical form:

\[ P(t) = A \]

The asymmetry represents the initial polarization of the muon beam and is typically used as a multiplicative prefactor for oscillating/relaxing functions. Typical values range from 0.15 to 0.30 depending on detector geometry.

Parameters:

  • fParamNo[0]: Asymmetry value A
Parameters
paramValuesVector of fit parameter values
funcValuesVector of evaluated function values
Returns
Asymmetry value A

Definition at line 1187 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ Bessel()

Double_t PTheory::Bessel ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Bessel function precession. Formula: J₀(2πνt + φ)

theory function: spherical bessel function including phase

\[ = j_0(2\pi\nu t + \varphi) \]

or the time shifted version of it.

meaning of paramValues: $\nu$, $\varphi$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2505 of file PTheory.cpp.

References DEG_TO_RAD, fParamNo, MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ CalculateDynKTLF()

virtual void PTheory::CalculateDynKTLF ( const Double_t * val,
Int_t tag ) const
privatevirtual

Calculates dynamic KT in LF using integral equation approach.

Referenced by DynamicGauLorKTLF(), DynamicGaussKTLF(), and DynamicLorentzKTLF().

◆ CalculateGaussLFIntegral()

virtual void PTheory::CalculateGaussLFIntegral ( const Double_t * val) const
privatevirtual

Calculates and caches Gaussian LF integral for static KT.

Referenced by StaticGaussKTLF().

◆ CalculateLorentzLFIntegral()

virtual void PTheory::CalculateLorentzLFIntegral ( const Double_t * val) const
privatevirtual

Calculates and caches Lorentzian LF integral for static KT.

Referenced by StaticLorentzKTLF().

◆ CleanUp()

void PTheory::CleanUp ( PTheory * theo)
privatevirtual

Recursively deletes child theory nodes (fAdd and fMul).

Recursively clean up theory

If data were a pointer to some data on the heap, here, we would call delete on it. If it were a "composed" object, its destructor would get called automatically after our own destructor, so we would not have to worry about it.

So all we have to clean up is the left and right subchild. It turns out that we don't have to check for null pointers; C++ automatically ignores a call to delete on a NULL pointer (according to the man page, the same is true with malloc() in C)

the COOLEST part is that if right is a non-null pointer, the destructor gets called recursively!

Parameters
theopointer to the theory object

Definition at line 830 of file PTheory.cpp.

References fAdd, fMul, and PTheory().

Referenced by ~PTheory().

◆ CombiLGKT()

Double_t PTheory::CombiLGKT ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Combined Lorentzian-Gaussian KT. Product of both relaxation types.

theory function: dynamic Lorentzain Kubo-Toyabe in longitudinal applied field

\[ =  1/3 + 2/3 \left(1-(\sigma t)^2-\lambda t\right) \exp\left(-1/2(\sigma t)^2-\lambda t\right)\]

or the time shifted version of it.

meaning of paramValues: $\lambda$, $\sigma$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2083 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ Constant()

Double_t PTheory::Constant ( const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Returns constant value. Formula: c.

Returns a constant value (baseline, background).

Mathematical form:

\[ P(t) = c \]

Used for constant offsets, fixed backgrounds, or baseline corrections.

Parameters:

  • fParamNo[0]: Constant value c
Parameters
paramValuesVector of fit parameter values
funcValuesVector of evaluated function values
Returns
Constant value c

Definition at line 1152 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ DynamicGauLorKTLF()

Double_t PTheory::DynamicGauLorKTLF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Dynamic Gaussian-Lorentzian KT (LF). Full numerical calculation.

Local Gaussian, global Lorentzian in LF. For details see "Muon Spin Rotation, Relaxation, and Resonance", A. Yaouanc and P. Dalmas Sec. 6.4, Eq.(6.86).

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)
Returns
Polarization value of this function

Definition at line 1954 of file PTheory.cpp.

References CalculateDynKTLF(), fDyn_GL_LFFuncValue, fParamNo, fPrevParam, GetDyn_GL_KTLFValue(), GetDynKTLFValue(), MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ DynamicGauLorKTLFFast()

Double_t PTheory::DynamicGauLorKTLFFast ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Fast dynamic Gaussian-Lorentzian KT (LF). Approximate fast calculation.

Local Gaussian, global Lorentzian approximation in the limit

\[ \nu_c \gg \gamma_\mu \Delta_{\rm L} \]

in LF. For details see "Muon Spin Rotation, Relaxation, and Resonance", A. Yaouanc and P. Dalmas Sec. 6.4, Eq.(6.93).

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)
Returns
Polarization value of this function

Definition at line 1907 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ DynamicGauLorKTZFFast()

Double_t PTheory::DynamicGauLorKTZFFast ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Fast dynamic Gaussian-Lorentzian KT (ZF). Approximate fast calculation.

Local Gaussian, global Lorentzian approximation in the limit

\[ \nu_c \gg \gamma_\mu \Delta_{\rm L} \]

in ZF. For details see "Muon Spin Rotation, Relaxation, and Resonance", A. Yaouanc and P. Dalmas Sec. 6.4, Eq.(6.89).

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)
Returns
Polarization value of this function

Definition at line 1867 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ DynamicGaussKTLF()

Double_t PTheory::DynamicGaussKTLF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Dynamic Gaussian Kubo-Toyabe (LF). Strong collision model.

theory function: dynamic Gaussian Kubo-Toyabe in longitudinal applied field

\[ = \frac{1}{2\pi \imath}\int_{\gamma-\imath\infty}^{\gamma+\imath\infty}
      \frac{f_{\mathrm{G}}(s+\Gamma)}{1-\Gamma f_{\mathrm{G}}(s+\Gamma)} \exp(s t) \mathrm{d}s,
      \mathrm{~where~}\,f_{\mathrm{G}}(s)\equiv \int_0^{\infty}G_{\mathrm{G,LF}}(t)\exp(-s t) \mathrm{d}t\]

or the time shifted version of it. $G_{\mathrm{G,LF}}(t)$ is the static Gaussian Kubo-Toyabe in longitudinal applied field.

The current implementation is not realized via the above formulas, but ...

meaning of paramValues: $\sigma$, $\nu$, $\Gamma$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 1521 of file PTheory.cpp.

References CalculateDynKTLF(), fParamNo, fPrevParam, GetDynKTLFValue(), MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ DynamicLorentzKTLF()

Double_t PTheory::DynamicLorentzKTLF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Dynamic Lorentzian Kubo-Toyabe (LF). Strong collision model.

theory function: dynamic Lorentzain Kubo-Toyabe in longitudinal applied field (see R. S. Hayano et al., Phys. Rev. B 20 (1979) 850; P. Dalmas de Reotier and A. Yaouanc, J. Phys.: Condens. Matter 4 (1992) 4533; A. Keren, Phys. Rev. B 50 (1994) 10039).

\[ =  \frac{1}{2\pi \imath}\int_{\gamma-\imath\infty}^{\gamma+\imath\infty}
\frac{f_{\mathrm{L}}(s+\Gamma)}{1-\Gamma f_{\mathrm{L}}(s+\Gamma)} \exp(s t) \mathrm{d}s,
\mathrm{~where~}\,f_{\mathrm{L}}(s)\equiv \int_0^{\infty}G_{\mathrm{L,LF}}(t)\exp(-s t) \mathrm{d}t\]

or the time shifted version of it. $G_{\mathrm{L,LF}}(t)$ is the static Lorentzain Kubo-Toyabe function in longitudinal field

The current implementation is not realized via the above formulas, but ...

meaning of paramValues: $a$, $\nu$, $\Gamma$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 1759 of file PTheory.cpp.

References CalculateDynKTLF(), fParamNo, fPrevParam, GetDynKTLFValue(), and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ DynamicNKTF()

Double_t PTheory::DynamicNKTF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Dynamic Nakajima-Keren (TF). With spin fluctuations and precession.

theory function: dynamicNKTF (see D.R. Noakes and G.M. Kalvius Phys. Rev. B 56, 2352 (1997) and A. Yaouanc and P. Dalmas de Reotiers, "Muon Spin Rotation, Relaxation, and Resonance" Oxford, Section 6.4.1.3) However, I have rewritten it using the identity $\Delta_{\rm eff}^2 = (1+R_b^2) \Delta_0^2$, which allows to massively simplify the formula which now only involves $R_b$ and $\Delta_0$. Here $\Delta_0$ Will be given in units of $1/\mu\mathrm{sec}$.

\begin{eqnarray*}\Theta(t) &=& \frac{\exp(-\nu_c t) - 1 - \nu_c t}{\nu_c^2} \\
P_{X}^{\rm dyn}(t) &=& \sqrt{\frac{1}{1+2 R_b^2 \Delta_0^2 \Theta(t)}}\,\exp\left[-\frac{\Delta_0^2 \Theta(t)}{1+2 R_b^2 \Delta_0^2 \Theta(t)}\right]\,\cos(\gamma B_{\rm ext} t + \varphi)
\end{eqnarray*}

meaning of paramValues: $\varphi$, $\nu = \gamma B_{\rm ext}$, $\Delta_0$, $R_{\rm b} = \Delta_{\rm GbG}/\Delta_0$, $\nu_c$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2856 of file PTheory.cpp.

References DEG_TO_RAD, fParamNo, MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ DynamicNKZF()

Double_t PTheory::DynamicNKZF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Dynamic Nakajima-Keren (ZF). With spin fluctuations.

theory function: dynamicNKZF (see D.R. Noakes and G.M. Kalvius Phys. Rev. B 56, 2352 (1997) and A. Yaouanc and P. Dalmas de Reotiers, "Muon Spin Rotation, Relaxation, and Resonance" Oxford, Section 6.4.1.3) However, I have rewritten it using the identity $\Delta_{\rm eff}^2 = (1+R_b^2) \Delta_0^2$, which allows to massively simplify the formula which now only involves $R_b$ and $\Delta_0$. Here $\Delta_0$ Will be given in units of $1/\mu\mathrm{sec}$.

\begin{eqnarray*}\Theta(t) &=& \frac{\exp(-\nu_c t) - 1 - \nu_c t}{\nu_c^2} \\
P_{Z}^{\rm dyn}(t) &=& \sqrt{\frac{1}{1+4 R_b^2 \Delta_0^2 \Theta(t)}}\,\exp\left[-\frac{2 \Delta_0^2 \Theta(t)}{1+4 R_b^2 \Delta_0^2 \Theta(t)}\right]
\end{eqnarray*}

meaning of paramValues: $\Delta_0$, $R_{\rm b} = \Delta_{\rm GbG}/\Delta_0$, $\nu_c$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2795 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ FmuF()

virtual Double_t PTheory::FmuF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

F-μ-F oscillation. Muon bound between two fluorine atoms.

Referenced by Func().

◆ Func()

Double_t PTheory::Func ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
virtual

Evaluates the theory function at a given time point.

Evaluates the theory expression tree at a given time point.

Recursively evaluates the expression tree at time t using the provided parameter values. The evaluation follows the tree structure:

  • If both fMul and fAdd exist: this_func * fMul + fAdd
  • If only fMul exists: this_func * fMul
  • If only fAdd exists: this_func + fAdd
  • If neither exists: this_func
Parameters
tTime in microseconds (μs) for μSR fits, or x-value for non-μSR
paramValuesVector of current fit parameter values (FITPARAMETER block)
funcValuesVector of evaluated function values (FUNCTIONS block)
Returns
Evaluated theory value (polarization or asymmetry) at time t
Note
For thread-safety, LF calculations cache results which may need recalculation if parameters change between calls.

Recursively evaluates the binary tree, combining function values according to the tree structure (multiplication for consecutive lines, addition for '+' separated sections).

Evaluation Algorithm: Based on tree structure, one of four cases applies:

  1. fMul && fAdd: this_func(t) * fMul->Func(t) + fAdd->Func(t)
  2. fMul only: this_func(t) * fMul->Func(t)
  3. fAdd only: this_func(t) + fAdd->Func(t)
  4. Leaf node: this_func(t)

Parameter Resolution: Within each function, parameters are accessed via fParamNo indices:

  • If fParamNo[i] < MSR_PARAM_FUN_OFFSET: use paramValues[fParamNo[i]]
  • If fParamNo[i] >= MSR_PARAM_FUN_OFFSET: use funcValues[fParamNo[i] - MSR_PARAM_FUN_OFFSET]

LF Caching: Longitudinal field functions (StaticGaussKTLF, DynamicLorentzKTLF, etc.) use cached integral values that are recalculated only when parameters change. This is handled transparently within each LF function.

Parameters
tTime in microseconds for μSR fits, or x-axis value for non-μSR data
paramValuesVector of current fit parameter values from FITPARAMETER block
funcValuesVector of evaluated function values from FUNCTIONS block
Returns
Evaluated polarization/asymmetry value at time t
Note
This method is const but uses mutable members for LF caching.
See also
Constant(), TFCos(), StaticGaussKT(), etc. for individual function implementations

Definition at line 468 of file PTheory.cpp.

References Abragam(), Asymmetry(), Bessel(), CombiLGKT(), Constant(), DynamicGauLorKTLF(), DynamicGauLorKTLFFast(), DynamicGauLorKTZFFast(), DynamicGaussKTLF(), DynamicLorentzKTLF(), DynamicNKTF(), DynamicNKZF(), fAdd, FmuF(), fMul, fType, GeneralExp(), InternalBessel(), InternalField(), InternalFieldGK(), InternalFieldLL(), MuMinusExpTF(), Polynom(), RandomAnisotropicHyperfine(), SimpleExp(), SimpleGauss(), SkewedGauss(), SpinGlass(), StaticGaussKT(), StaticGaussKTLF(), StaticLorentzKT(), StaticLorentzKTLF(), StaticNKTF(), StaticNKZF(), StrKT(), TFCos(), THEORY_ABRAGAM, THEORY_ASYMMETRY, THEORY_BESSEL, THEORY_COMBI_LGKT, THEORY_CONST, THEORY_DYNAMIC_GAULOR_FAST_KT_LF, THEORY_DYNAMIC_GAULOR_FAST_KT_ZF, THEORY_DYNAMIC_GAULOR_KT_LF, THEORY_DYNAMIC_GAUSS_KT_LF, THEORY_DYNAMIC_LORENTZ_KT_LF, THEORY_DYNAMIC_TF_NK, THEORY_DYNAMIC_ZF_NK, THEORY_F_MU_F, THEORY_GENERAL_EXP, THEORY_INTERNAL_BESSEL, THEORY_INTERNAL_FIELD, THEORY_INTERNAL_FIELD_KORNILOV, THEORY_INTERNAL_FIELD_LARKIN, THEORY_MU_MINUS_EXP, THEORY_POLYNOM, THEORY_RANDOM_ANISOTROPIC_HYPERFINE, THEORY_SIMPLE_EXP, THEORY_SIMPLE_GAUSS, THEORY_SKEWED_GAUSS, THEORY_SPIN_GLASS, THEORY_STATIC_GAUSS_KT, THEORY_STATIC_GAUSS_KT_LF, THEORY_STATIC_LORENTZ_KT, THEORY_STATIC_LORENTZ_KT_LF, THEORY_STATIC_TF_NK, THEORY_STATIC_ZF_NK, THEORY_STR_KT, THEORY_TF_COS, THEORY_USER_FCN, and UserFcn().

◆ GeneralExp()

Double_t PTheory::GeneralExp ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

General (stretched) exponential. Formula: exp(-(λt)^β)

Generalized (stretched) exponential relaxation function.

Mathematical form:

\[ P(t) = \exp\left(-[\lambda t]^\beta\right) \]

or with time shift:

\[ P(t) = \exp\left(-[\lambda (t-t_{\rm shift})]^\beta\right) \]

The stretched exponential (Kohlrausch function) represents relaxation in systems with a distribution of correlation times:

  • β = 1: Simple exponential
  • β < 1: Stretched exponential (distributed relaxation)
  • β = 2: Gaussian relaxation

Parameters:

  • fParamNo[0]: Relaxation rate λ (μs⁻¹)
  • fParamNo[1]: Stretching exponent β
  • fParamNo[2]: (optional) Time shift t_shift (μs)
Parameters
tTime in μs
paramValuesVector of fit parameter values
funcValuesVector of evaluated function values
Returns
Stretched exponential value at time t

Definition at line 1277 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ GetDyn_GL_KTLFValue()

virtual Double_t PTheory::GetDyn_GL_KTLFValue ( const Double_t t) const
privatevirtual

Retrieves cached dynamic Gauss-Lorentz KT LF value at time t.

Referenced by DynamicGauLorKTLF().

◆ GetDynKTLFValue()

virtual Double_t PTheory::GetDynKTLFValue ( const Double_t t) const
privatevirtual

Retrieves cached dynamic KT LF value at time t.

Referenced by DynamicGauLorKTLF(), DynamicGaussKTLF(), and DynamicLorentzKTLF().

◆ GetLFIntegralValue()

virtual Double_t PTheory::GetLFIntegralValue ( const Double_t t) const
privatevirtual

Retrieves cached LF integral value at time t using interpolation.

Referenced by StaticGaussKTLF(), and StaticLorentzKTLF().

◆ GetUserFcnIdx()

Int_t PTheory::GetUserFcnIdx ( UInt_t lineNo) const
privatevirtual

Returns the index of user functions up to the given line.

Counts user function occurrences in theory block up to a given line.

Parameters
lineNoCurrent line number in theory block
Returns
Count of userFcn entries before this line

Scans the theory block from line 1 to lineNo (inclusive) and counts how many lines contain "userFcn". This index is used to:

  • Identify which global user function object to use
  • Track multiple user functions in a single theory
Parameters
lineNoCurrent line number being parsed (1-based in theory block)
Returns
Index of current user function (0-based count), or -1 if no userFcn entries found up to lineNo
Note
The search is case-insensitive ("userFcn", "USERFCN", etc. all match).

Definition at line 896 of file PTheory.cpp.

References fMsrInfo.

Referenced by PTheory().

◆ InternalBessel()

Double_t PTheory::InternalBessel ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Internal Bessel field distribution. Combines Bessel with relaxation.

theory function: internal field bessel function

\[ = \alpha\,j_0\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)\exp\left(-\lambda_{\mathrm{T}}t\right)+(1-\alpha)\,\exp\left(-\lambda_{\mathrm{L}}t\right)\]

or the time shifted version of it.

meaning of paramValues: $\alpha$, $\varphi$, $\nu$, $\lambda_{\rm T}$, $\lambda_{\rm L}$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2546 of file PTheory.cpp.

References DEG_TO_RAD, fParamNo, MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ InternalField()

Double_t PTheory::InternalField ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Internal field distribution. Gaussian field distribution model.

theory function: internal field function

\[ = \alpha\,\cos\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)\exp\left(-\lambda_{\mathrm{T}}t\right)+(1-\alpha)\,\exp\left(-\lambda_{\mathrm{L}}t\right)\]

or the time shifted version of it.

meaning of paramValues: $\alpha$, $\varphi$, $\nu$, $\lambda_{\rm T}$, $\lambda_{\rm L}$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2359 of file PTheory.cpp.

References DEG_TO_RAD, fParamNo, MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ InternalFieldGK()

Double_t PTheory::InternalFieldGK ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Internal field (Kornilov model). Vortex lattice field distribution.

theory function: internal field function Gauss-Kornilov (see Physics Letters A 153, 364 (1991)).

\[ = \alpha\,\left[\cos(2\pi\nu t)-\frac{\sigma^2 t}{2\pi\nu}\sin(2\pi\nu t)\right]\exp(-[\sigma t]^2/2)+(1-\alpha)\,\exp(-(\lambda t)^\beta)\]

or the time shifted version of it. For the powder averaged case, $\alpha=2/3$.

meaning of paramValues: $\alpha$, $\nu$, $\sigma$, $\lambda$, $\beta$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2401 of file PTheory.cpp.

References fParamNo, MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ InternalFieldLL()

Double_t PTheory::InternalFieldLL ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Internal field (Larkin-Ovchinnikov model). Vortex lattice field distribution.

theory function: internal field function Lorentz-Larkin (see Physica B: Condensed Matter 289-290, 153 (2000)).

\[ = \alpha\,\left[\cos(2\pi\nu t)-\frac{a}{2\pi\nu}\sin(2\pi\nu t)\right]\exp(-a t)+(1-\alpha)\,\exp(-(\lambda t)^\beta)\]

or the time shifted version of it. For the powder averaged case, $\alpha=2/3$.

meaning of paramValues: $\alpha$, $\nu$, $a$, $\lambda$, $\beta$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2453 of file PTheory.cpp.

References fParamNo, MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ IsValid()

Bool_t PTheory::IsValid ( )
virtual

Checks if the entire theory expression tree is valid.

Recursively checks if the entire theory expression tree is valid.

Recursively validates all nodes in the tree. A theory is valid only if this node and all its children (fAdd and fMul) are valid.

Returns
true if all nodes are valid, false if any node has errors
Note
Call this after construction to verify the theory was parsed successfully before attempting evaluation.

Traverses the binary tree and checks fValid for this node and all descendant nodes. A theory tree is valid only if ALL nodes are valid.

Validation logic:

  • If fMul and fAdd both exist: return fValid && fMul->IsValid() && fAdd->IsValid()
  • If only fMul exists: return fValid && fMul->IsValid()
  • If only fAdd exists: return fValid && fAdd->IsValid()
  • If leaf node: return fValid
Returns
true if this node and all descendants are valid, false otherwise
Note
Should always be called after construction to verify successful parsing. A single invalid node anywhere in the tree causes the entire theory to be marked invalid.

Definition at line 415 of file PTheory.cpp.

References fAdd, fMul, and fValid.

◆ MakeCleanAndTidyPolynom()

void PTheory::MakeCleanAndTidyPolynom ( UInt_t i,
PMsrLines * fullTheoryBlock )
privatevirtual

Formats a polynomial theory line with proper spacing.

Polynomial functions have variable parameter count, so they require special formatting. Creates output in format:

* polynom  tshift    p0    p1    p2 ... pn (tshift p0 p1 ... pn)
* 
Parameters
iLine index (1-based) in the theory block
fullTheoryBlockPointer to theory block lines (modified in place)

Definition at line 1040 of file PTheory.cpp.

References PMsrLineStructure::fLine.

Referenced by MakeCleanAndTidyTheoryBlock().

◆ MakeCleanAndTidyTheoryBlock()

void PTheory::MakeCleanAndTidyTheoryBlock ( PMsrLines * fullTheoryBlock)
privatevirtual

Reformats the theory block for clean MSR file output.

Reformats the theory block with consistent spacing and comments.

Processes each line in the theory block to produce clean, well-formatted output suitable for writing back to MSR files. Formatting includes:

  • Function name left-aligned in 10-character field
  • Parameters right-aligned in 6-character fields
  • Comment string appended showing parameter names

Example transformation:

* Input:  "tf   2  3"
* Output: "TFieldCos      2     3  (phase frequency)"
* 

Special handling for:

Parameters
fullTheoryBlockPointer to theory block lines (modified in place)
Note
Called only by root theory node (hasParent=false) after successful parsing.

Definition at line 943 of file PTheory.cpp.

References fgTheoDataBase, PMsrLineStructure::fLine, MakeCleanAndTidyPolynom(), MakeCleanAndTidyUserFcn(), THEORY_MAX, and THEORY_UNDEFINED.

Referenced by PTheory().

◆ MakeCleanAndTidyUserFcn()

void PTheory::MakeCleanAndTidyUserFcn ( UInt_t i,
PMsrLines * fullTheoryBlock )
privatevirtual

Formats a user function theory line with proper spacing.

User functions have variable structure (library, class, parameters), so they require special formatting. Creates output in format:

* userFcn libName.so ClassName param1 param2 ... paramN
* 
Parameters
iLine index (1-based) in the theory block
fullTheoryBlockPointer to theory block lines (modified in place)

Definition at line 1103 of file PTheory.cpp.

References PMsrLineStructure::fLine.

Referenced by MakeCleanAndTidyTheoryBlock().

◆ MuMinusExpTF()

virtual Double_t PTheory::MuMinusExpTF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

μ⁻ exponential TF. Negative muon in transverse field.

Referenced by Func().

◆ Polynom()

virtual Double_t PTheory::Polynom ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Polynomial function. Formula: Σᵢ pᵢtⁱ

Referenced by Func().

◆ RandomAnisotropicHyperfine()

Double_t PTheory::RandomAnisotropicHyperfine ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Random anisotropic hyperfine coupling. Powder average of anisotropic coupling.

theory function: random anisotropic hyperfine function (see R. E. Turner and D. R. Harshman, Phys. Rev. B 34 (1986) 4467)

\[ = \frac{1}{6}\left(1-\frac{\nu t}{2}\right)\exp\left(-\frac{\nu t}{2}\right)+\frac{1}{3}\left(1-\frac{\nu t}{4}\right)\exp\left(-\frac{\nu t + 2.44949\lambda t}{4}\right)\]

or the time shifted version of it.

meaning of paramValues: $\nu$, $\lambda$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2229 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ SearchDataBase()

Int_t PTheory::SearchDataBase ( TString name)
privatevirtual

Searches fgTheoDataBase for a function by name or abbreviation.

Searches fgTheoDataBase for a theory function by name or abbreviation.

Parameters
nameFunction name (e.g., "simplExpo") or abbreviation (e.g., "se")
Returns
Index in fgTheoDataBase, or THEORY_UNDEFINED if not found

Performs case-insensitive search through the theory database to find a matching function. If found, sets fType and fNoOfParam member variables.

Search matches either:

  • Full function name (e.g., "simplExpo", "TFieldCos")
  • Abbreviation (e.g., "se", "tf")
Parameters
nameFunction name or abbreviation to search for
Returns
Index in fgTheoDataBase (0 to THEORY_MAX-1), or THEORY_UNDEFINED (-1) if not found
Note
Side effects: Sets fType and fNoOfParam when function is found.
See also
fgTheoDataBase

Definition at line 862 of file PTheory.cpp.

References fgTheoDataBase, fNoOfParam, fType, THEORY_MAX, and THEORY_UNDEFINED.

Referenced by PTheory().

◆ SimpleExp()

Double_t PTheory::SimpleExp ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Simple exponential relaxation. Formula: exp(-λt)

Simple exponential relaxation function.

Mathematical form:

\[ P(t) = \exp\left(-\lambda t\right) \]

or with time shift:

\[ P(t) = \exp\left(-\lambda [t-t_{\rm shift}] \right) \]

Represents exponential muon spin relaxation due to dynamic fluctuations in the fast-fluctuation limit (BPP-type relaxation).

Parameters:

  • fParamNo[0]: Relaxation rate λ (μs⁻¹)
  • fParamNo[1]: (optional) Time shift t_shift (μs)
Parameters
tTime in μs
paramValuesVector of fit parameter values
funcValuesVector of evaluated function values
Returns
Exponential relaxation value at time t

Definition at line 1225 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ SimpleGauss()

Double_t PTheory::SimpleGauss ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Simple Gaussian relaxation. Formula: exp(-σ²t²/2)

Simple Gaussian relaxation function.

Mathematical form:

\[ P(t) = \exp\left(-\frac{1}{2} [\sigma t]^2\right) \]

or with time shift:

\[ P(t) = \exp\left(-\frac{1}{2} [\sigma (t-t_{\rm shift})]^2\right) \]

Represents Gaussian muon spin relaxation due to static random fields with a Gaussian distribution. The parameter σ = γ_μ ΔB where ΔB is the RMS field width.

Parameters:

  • fParamNo[0]: Relaxation rate σ (μs⁻¹)
  • fParamNo[1]: (optional) Time shift t_shift (μs)
Parameters
tTime in μs
paramValuesVector of fit parameter values
funcValuesVector of evaluated function values
Returns
Gaussian relaxation value at time t

Definition at line 1334 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ SkewedGauss()

Double_t PTheory::SkewedGauss ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Skewed Gaussian. Asymmetric relaxation rates before/after zero crossing.

theory function: skewed Gaussian function

\begin{eqnarray*} &=& \frac{\sigma_{-}}{\sigma_{+}+\sigma_{-}}\exp\left[-\frac{\sigma_{-}^2t^2}{2}\right]
\left\lbrace\cos\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)+
\sin\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)\mathrm{Erfi}\left(\frac{\sigma_{-}t}{\sqrt{2}}\right)\right\rbrace+\\
& & \frac{\sigma_{+}}{\sigma_{+}+\sigma_{-}}
\exp\left[-\frac{\sigma_{+}^2t^2}{2}\right]\left\lbrace\cos\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)-
\sin\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)\mathrm{Erfi}\left(\frac{\sigma_{+}t}{\sqrt{2}}\right)\right\rbrace
\end{eqnarray*}

or the time shifted version of it.

meaning of paramValues: $\varphi$, $\nu$, $\sigma_{-}$, $\sigma_{+}$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2595 of file PTheory.cpp.

References DEG_TO_RAD, fParamNo, MSR_PARAM_FUN_OFFSET, SQRT_PI, SQRT_TWO, and TWO_PI.

Referenced by Func().

◆ SpinGlass()

Double_t PTheory::SpinGlass ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Spin glass relaxation function. Edwards-Anderson order parameter.

theory function: spin glass function

\[ = \frac{1}{3}\exp\left(-\sqrt{\frac{4\lambda^2(1-q)t}{\gamma}}\right)+\frac{2}{3}\left(1-\frac{q\lambda^2t^2}{\sqrt{\frac{4\lambda^2(1-q)t}{\gamma}+q\lambda^2t^2}}\right)\exp\left(-\sqrt{\frac{4\lambda^2(1-q)t}{\gamma}+q\lambda^2t^2}\right)\]

or the time shifted version of it.

meaning of paramValues: $\lambda$, $\gamma$, $q$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2178 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ StaticGaussKT()

Double_t PTheory::StaticGaussKT ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Static Gaussian Kubo-Toyabe (ZF). Formula: 1/3 + 2/3(1-σ²t²)exp(-σ²t²/2)

Static Gaussian Kubo-Toyabe relaxation function in zero field.

Mathematical form:

\[ P(t) = \frac{1}{3} + \frac{2}{3} \left[1-(\sigma t)^2\right] \exp\left[-\frac{1}{2} (\sigma t)^2\right] \]

or with time shift:

\[ P(t) = \frac{1}{3} + \frac{2}{3} \left[1-(\sigma \{t-t_{\rm shift}\})^2\right] \exp\left[-\frac{1}{2} (\sigma \{t-t_{\rm shift}\})^2\right] \]

The Kubo-Toyabe function describes muon spin relaxation in a powder sample with random static nuclear magnetic moments creating a Gaussian field distribution at the muon site.

Physical interpretation:

  • 1/3 component: Muons with spin parallel to local field (unrelaxed)
  • 2/3 component: Muons with spin perpendicular to local field (relaxing)
  • Recovery at long times: Partial repolarization to 1/3

Parameters:

  • fParamNo[0]: Relaxation rate σ = γ_μ ΔB (μs⁻¹), where ΔB is RMS field
  • fParamNo[1]: (optional) Time shift t_shift (μs)
Parameters
tTime in μs
paramValuesVector of fit parameter values
funcValuesVector of evaluated function values
Returns
Gaussian Kubo-Toyabe value at time t
See also
StaticGaussKTLF() for longitudinal field version

Definition at line 1390 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ StaticGaussKTLF()

Double_t PTheory::StaticGaussKTLF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Static Gaussian Kubo-Toyabe (LF). Requires numerical integration.

theory function: static Gaussian Kubo-Toyabe in longitudinal applied field

\[ = 1-\frac{2\sigma^2}{(2\pi\nu)^2}\left[1-\exp\left(-1/2 \{\sigma t\}^2\right)\cos(2\pi\nu t)\right] +
    \frac{2\sigma^4}{(2\pi\nu)^3}\int^t_0 \exp\left(-1/2 \{\sigma \tau\}^2\right)\sin(2\pi\nu\tau)\mathrm{d}\tau \]

or the time shifted version of it.

meaning of paramValues: $\sigma$, $\nu$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 1432 of file PTheory.cpp.

References CalculateGaussLFIntegral(), fParamNo, fPrevParam, GetLFIntegralValue(), and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ StaticLorentzKT()

Double_t PTheory::StaticLorentzKT ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Static Lorentzian Kubo-Toyabe (ZF). Formula: 1/3 + 2/3(1-at)exp(-at)

theory function: static Lorentzain Kubo-Toyabe in zero applied field (see Uemura et al. PRB 31, 546 (85)).

\[ = 1/3 + 2/3 [1 - \lambda t] \exp(-\lambda t) \]

or the time shifted version of it.

meaning of paramValues: $\lambda$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 1619 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ StaticLorentzKTLF()

Double_t PTheory::StaticLorentzKTLF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Static Lorentzian Kubo-Toyabe (LF). Requires numerical integration.

theory function: static Lorentzain Kubo-Toyabe in longitudinal applied field (see Uemura et al. PRB 31, 546 (85)).

\[ = 1-\frac{a}{2\pi\nu}j_1(2\pi\nu t)\exp\left(-at\right)-
      \left(\frac{a}{2\pi\nu}\right)^2 \left[j_0(2\pi\nu t)\exp\left(-at\right)-1\right]-
      a\left[1+\left(\frac{a}{2\pi\nu}\right)^2\right]\int^t_0 \exp\left(-a\tau\right)j_0(2\pi\nu\tau)\mathrm{d}\tau) \]

or the time shifted version of it.

meaning of paramValues: $a$, $\nu$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 1662 of file PTheory.cpp.

References CalculateLorentzLFIntegral(), fParamNo, fPrevParam, GetLFIntegralValue(), and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ StaticNKTF()

Double_t PTheory::StaticNKTF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Static Nakajima-Keren (TF). Combined nuclear and electronic relaxation with precession.

theory function: staticNKTF (see D.R. Noakes and G.M. Kalvius Phys. Rev. B 56, 2352 (1997) and A. Yaouanc and P. Dalmas de Reotiers, "Muon Spin Rotation, Relaxation, and Resonance" Oxford, Section 6.4.1.3) However, I have rewritten it using the identity $\Delta_{\rm eff}^2 = (1+R_b^2) \Delta_0^2$, which allows to massively simplify the formula which now only involves $R_b$ and $\Delta_0$. Here $\Delta_0$ Will be given in units of $1/\mu\mathrm{sec}$.

\[ = \frac{1}{\sqrt{1+(R_b \gamma\Delta_0 t)^2}}\,
    \exp\left[-\frac{(\gamma\Delta_0 t)^2}{2(1+(R_b \gamma\Delta_0 t)^2)}\right]\,
    \cos(\gamma B_{\rm ext} t + \varphi) \]

meaning of paramValues: $\varphi$, $\nu = \gamma B_{\rm ext}$, $\Delta_0$, $R_{\rm b} = \Delta_{\rm GbG}/\Delta_0$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2739 of file PTheory.cpp.

References DEG_TO_RAD, fParamNo, MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ StaticNKZF()

Double_t PTheory::StaticNKZF ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Static Nakajima-Keren (ZF). Combined nuclear and electronic relaxation.

theory function: staticNKZF (see D.R. Noakes and G.M. Kalvius Phys. Rev. B 56, 2352 (1997) and A. Yaouanc and P. Dalmas de Reotiers, "Muon Spin Rotation, Relaxation, and Resonance" Oxford, Section 6.4.1.3) However, I have rewritten it using the identity $\Delta_{\rm eff}^2 = (1+R_b^2) \Delta_0^2$, which allows to massively simplify the formula which now only involves $R_b$ and $\Delta_0$. Here $\Delta_0$ Will be given in units of $1/\mu\mathrm{sec}$.

\[ = \frac{1}{3} + \frac{2}{3}\,\frac{1}{\left(1+(R_b \Delta_0 t)^2\right)^{3/2}}\,
   \left(1 - \frac{(\Delta_0 t)^2}{\left(1+(R_b \Delta_0 t)^2\right)}\right)\,
   \exp\left[\frac{(\Delta_0 t)^2}{2\left(1+(R_b \Delta_0 t)^2\right)}\right] \]

meaning of paramValues: $\Delta_0$, $R_{\rm b} = \Delta_{\rm GbG}/\Delta_0$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2684 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ StrKT()

Double_t PTheory::StrKT ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Stretched Kubo-Toyabe. Formula: exp(-(σt)^β) with KT-like recovery.

theory function: stretched Kubo-Toyabe in zero field. Ref: Crook M. R. and Cywinski R., J. Phys. Condens. Matter, 9 (1997) 1149.

\[ =  1/3 + 2/3 \left(1-(\sigma t)^\beta \right) \exp\left(-(\sigma t)^\beta / \beta\right)\]

or the time shifted version of it.

meaning of paramValues: $\sigma$, $\beta$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2129 of file PTheory.cpp.

References fParamNo, and MSR_PARAM_FUN_OFFSET.

Referenced by Func().

◆ TFCos()

Double_t PTheory::TFCos ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

Transverse field cosine. Formula: cos(φ + 2πνt)

theory function: cosine including phase

\[ = \cos(2\pi\nu t + \varphi) \]

or the time shifted version of it.

meaning of paramValues: $\nu$, $\varphi$ [, $t_{\rm shift}$]

return: function value

Parameters
ttime in $(\mu\mathrm{s})$, or x-axis value for non-muSR fit
paramValuesparameter values
funcValuesvector with the functions (i.e. functions of the parameters)

Definition at line 2318 of file PTheory.cpp.

References DEG_TO_RAD, fParamNo, MSR_PARAM_FUN_OFFSET, and TWO_PI.

Referenced by Func().

◆ UserFcn()

virtual Double_t PTheory::UserFcn ( Double_t t,
const PDoubleVector & paramValues,
const PDoubleVector & funcValues ) const
privatevirtual

User-defined function. Calls external shared library function.

Referenced by Func().

Member Data Documentation

◆ fAdd

PTheory* PTheory::fAdd
private

Pointer to addition child node (left branch of tree)

Definition at line 637 of file PTheory.h.

Referenced by CleanUp(), Func(), IsValid(), and PTheory().

◆ fDyn_GL_LFFuncValue

PDoubleVector PTheory::fDyn_GL_LFFuncValue
mutableprivate

Cached dynamic Gauss-Lorentz LF KT values.

Definition at line 655 of file PTheory.h.

Referenced by DynamicGauLorKTLF().

◆ fDynLFdt

Double_t PTheory::fDynLFdt
mutableprivate

Time step for dynamic LF integral equation.

Definition at line 653 of file PTheory.h.

Referenced by PTheory().

◆ fDynLFFuncValue

PDoubleVector PTheory::fDynLFFuncValue
mutableprivate

Cached dynamic Gaussian/Lorentzian LF KT values.

Definition at line 654 of file PTheory.h.

Referenced by ~PTheory().

◆ fLFIntegral

PDoubleVector PTheory::fLFIntegral
mutableprivate

Cached static LF KT integral values.

Definition at line 652 of file PTheory.h.

Referenced by ~PTheory().

◆ fMsrInfo

PMsrHandler* PTheory::fMsrInfo
private

Pointer to MSR file handler (not owned)

Definition at line 647 of file PTheory.h.

Referenced by GetUserFcnIdx(), and PTheory().

◆ fMul

PTheory* PTheory::fMul
private

Pointer to multiplication child node (right branch of tree)

Definition at line 638 of file PTheory.h.

Referenced by CleanUp(), Func(), IsValid(), and PTheory().

◆ fNoOfParam

UInt_t PTheory::fNoOfParam
private

Expected number of parameters for this function type.

Definition at line 636 of file PTheory.h.

Referenced by PTheory(), and SearchDataBase().

◆ fParamNo

◆ fPrevParam

Double_t PTheory::fPrevParam[THEORY_MAX_PARAM]
mutableprivate

Previous parameter values for cache invalidation check.

Definition at line 651 of file PTheory.h.

Referenced by DynamicGauLorKTLF(), DynamicGaussKTLF(), DynamicLorentzKTLF(), PTheory(), StaticGaussKTLF(), and StaticLorentzKTLF().

◆ fSamplingTime

Double_t PTheory::fSamplingTime
mutableprivate

Time step for LF integral calculation (default 1 ns = 0.001 μs)

Definition at line 650 of file PTheory.h.

Referenced by PTheory().

◆ fType

UInt_t PTheory::fType
private

Theory function type (THEORY_CONST, THEORY_SIMPLE_EXP, etc.)

Definition at line 634 of file PTheory.h.

Referenced by Func(), PTheory(), and SearchDataBase().

◆ fUserFcn

PUserFcnBase* PTheory::fUserFcn
private

Pointer to instantiated user function object.

Definition at line 644 of file PTheory.h.

Referenced by PTheory(), and ~PTheory().

◆ fUserFcnClassName

TString PTheory::fUserFcnClassName
private

ROOT class name for user function (e.g., "TMyFunction")

Definition at line 642 of file PTheory.h.

Referenced by PTheory().

◆ fUserFcnIdx

Int_t PTheory::fUserFcnIdx
private

Index of this user function among all userFcn entries (for global state)

Definition at line 641 of file PTheory.h.

Referenced by PTheory().

◆ fUserFcnSharedLibName

TString PTheory::fUserFcnSharedLibName
private

Shared library path (e.g., "libMyFunctions.so")

Definition at line 643 of file PTheory.h.

Referenced by PTheory().

◆ fUserParam

PDoubleVector PTheory::fUserParam
mutableprivate

Resolved parameter values for user function calls.

Definition at line 645 of file PTheory.h.

Referenced by PTheory(), and ~PTheory().

◆ fValid

Bool_t PTheory::fValid
private

True if this theory node and its parse state are valid.

Definition at line 633 of file PTheory.h.

Referenced by IsValid(), and PTheory().


The documentation for this class was generated from the following files: