use Claude ai to generate doxygen documentation.

This commit is contained in:
2025-11-10 15:14:08 +01:00
parent aa348c2393
commit 4d70c7baa9
8 changed files with 1751 additions and 129 deletions

View File

@@ -37,49 +37,109 @@
#include "PMsrHandler.h"
#include "PUserFcnBase.h"
// --------------------------------------------------------
// function handling tags
// --------------------------------------------------------
//-------------------------------------------------------------
/**
* <p>Theory function type tags.
*
* <p>These constants identify the built-in theory functions available in
* the THEORY block of MSR files. Each function represents a specific physical
* model for muon spin relaxation, precession, or depolarization.
*
* <p>Theory functions can be combined using addition (+) and multiplication (*):
* - <b>Addition:</b> Independent relaxation channels (e.g., 1/3 fast + 2/3 slow)
* - <b>Multiplication:</b> Multiple relaxation mechanisms (e.g., precession * damping)
*
* <p><b>Categories:</b>
* - <b>Basic:</b> Constants, asymmetries, simple exponentials
* - <b>Static relaxation:</b> Gaussian, Lorentzian (Kubo-Toyabe)
* - <b>Dynamic relaxation:</b> Motional narrowing, spin fluctuations
* - <b>Precession:</b> Cosine, Bessel functions for oscillations
* - <b>Vortex lattice:</b> Internal field distributions in superconductors
* - <b>Special:</b> Spin glass, Abragam, mu-minus, polynomials, user functions
*/
// function tags
/// Undefined or invalid theory function
#define THEORY_UNDEFINED -1
/// Constant value (baseline, background)
#define THEORY_CONST 0
/// Initial asymmetry (multiplicative factor)
#define THEORY_ASYMMETRY 1
/// Simple exponential relaxation: exp(-λt)
#define THEORY_SIMPLE_EXP 2
/// General exponential relaxation: exp(-(λt)^β)
#define THEORY_GENERAL_EXP 3
/// Simple Gaussian relaxation: exp(-σ²t²/2)
#define THEORY_SIMPLE_GAUSS 4
/// Static Gaussian Kubo-Toyabe (zero-field)
#define THEORY_STATIC_GAUSS_KT 5
/// Static Gaussian Kubo-Toyabe in longitudinal field
#define THEORY_STATIC_GAUSS_KT_LF 6
/// Dynamic Gaussian Kubo-Toyabe in longitudinal field
#define THEORY_DYNAMIC_GAUSS_KT_LF 7
/// Static Lorentzian Kubo-Toyabe (zero-field)
#define THEORY_STATIC_LORENTZ_KT 8
/// Static Lorentzian Kubo-Toyabe in longitudinal field
#define THEORY_STATIC_LORENTZ_KT_LF 9
/// Dynamic Lorentzian Kubo-Toyabe in longitudinal field
#define THEORY_DYNAMIC_LORENTZ_KT_LF 10
/// Fast dynamic Gauss-Lorentz Kubo-Toyabe (zero-field)
#define THEORY_DYNAMIC_GAULOR_FAST_KT_ZF 11
/// Fast dynamic Gauss-Lorentz Kubo-Toyabe in longitudinal field
#define THEORY_DYNAMIC_GAULOR_FAST_KT_LF 12
/// Dynamic Gauss-Lorentz Kubo-Toyabe in longitudinal field
#define THEORY_DYNAMIC_GAULOR_KT_LF 13
/// Combined Lorentzian-Gaussian Kubo-Toyabe
#define THEORY_COMBI_LGKT 14
/// Stretched Kubo-Toyabe relaxation
#define THEORY_STR_KT 15
/// Spin glass order parameter function
#define THEORY_SPIN_GLASS 16
/// Random anisotropic hyperfine coupling
#define THEORY_RANDOM_ANISOTROPIC_HYPERFINE 17
/// Abragam relaxation function (diffusion)
#define THEORY_ABRAGAM 18
/// Transverse field cosine precession
#define THEORY_TF_COS 19
/// Internal magnetic field distribution (superconductors)
#define THEORY_INTERNAL_FIELD 20
/// Internal field (Kornilov vortex lattice model)
#define THEORY_INTERNAL_FIELD_KORNILOV 21
/// Internal field (Larkin-Ovchinnikov model)
#define THEORY_INTERNAL_FIELD_LARKIN 22
/// Bessel function (modulated precession)
#define THEORY_BESSEL 23
/// Internal Bessel (field distribution with Bessel)
#define THEORY_INTERNAL_BESSEL 24
/// Skewed Gaussian relaxation (asymmetric rates)
#define THEORY_SKEWED_GAUSS 25
/// Static Nakajima zero-field function
#define THEORY_STATIC_ZF_NK 26
/// Static Nakajima transverse field function
#define THEORY_STATIC_TF_NK 27
/// Dynamic Nakajima zero-field function
#define THEORY_DYNAMIC_ZF_NK 28
/// Dynamic Nakajima transverse field function
#define THEORY_DYNAMIC_TF_NK 29
/// F-μ-F (μ-fluorine) oscillation
#define THEORY_F_MU_F 30
/// Negative muon (μ-) exponential TF decay
#define THEORY_MU_MINUS_EXP 31
/// Polynomial function (arbitrary order)
#define THEORY_POLYNOM 32
/// User-defined external function (shared library)
#define THEORY_USER_FCN 33
// 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
//-------------------------------------------------------------
/**
* <p>Number of parameters for each theory function.
*
* <p>These constants define how many parameters each theory function requires,
* <b>excluding</b> optional time shift. If a function includes time shift,
* add 1 to the parameter count.
*
* <p>Parameters typically include: rates (λ, σ), frequencies (ω, ν),
* phases (φ), fractions, exponents (β), hopping rates (ν_hop), etc.
*/
#define THEORY_PARAM_CONST 1 // const
#define THEORY_PARAM_ASYMMETRY 1 // asymmetry
#define THEORY_PARAM_SIMPLE_EXP 1 // damping (tshift)
@@ -113,31 +173,64 @@
#define THEORY_PARAM_F_MU_F 1 // frequency (tshift)
#define THEORY_PARAM_MU_MINUS_EXP 6 // N0, tau, A, damping, phase, frequency (tshift)
// number of available user functions
//-------------------------------------------------------------
/**
* <p>Maximum number of theory functions in database.
*
* <p>This is the total number of built-in theory functions available,
* including all relaxation, precession, and special functions.
*/
#define THEORY_MAX 34
// maximal number of parameters. Needed in the contents of LF
//-------------------------------------------------------------
/**
* <p>Maximum number of parameters for any theory function.
*
* <p>Used to allocate arrays for longitudinal field calculations where
* parameter values from previous iterations must be cached.
*/
#define THEORY_MAX_PARAM 10
// deg -> rad factor
//-------------------------------------------------------------
/**
* <p>Conversion factor from degrees to radians.
*
* <p>Value: π/180 = 0.017453292519943295
* <p>Used for phase parameters which are specified in degrees in MSR files
* but converted to radians for calculations.
*/
#define DEG_TO_RAD 0.0174532925199432955
// 2 pi
/**
* <p>Mathematical constant 2π.
*
* <p>Used extensively in frequency-to-angular-frequency conversions:
* ω = 2πν
*/
#define TWO_PI 6.28318530717958623
class PTheory;
//--------------------------------------------------------------------------------------
/**
* <p>Structure holding the infos of a the available internally defined functions.
* <p>Database entry for a theory function definition.
*
* <p>This structure stores metadata about each built-in theory function,
* including its identifier, parameter count, name, abbreviation, and
* help text. The database is used for:
* - Parsing THEORY block entries in MSR files
* - Validating parameter counts
* - Generating help text and documentation
* - Writing theory blocks with correct syntax
*/
typedef struct theo_data_base {
UInt_t fType; ///< function tag
UInt_t fNoOfParam; ///< number of parameters for this function
Bool_t fTable; ///< table flag, indicating if the function is generate from a table
TString fName; ///< name of the function as written into the msr-file
TString fAbbrev; ///< abbreviation of the function name
TString fComment; ///< comment added in the msr-file theory block to help the used
TString fCommentTimeShift; ///< comment added in the msr-file theory block if there is a time shift
UInt_t fType; ///< Theory function type tag (THEORY_CONST, THEORY_SIMPLE_EXP, etc.)
UInt_t fNoOfParam; ///< Number of parameters (excluding optional time shift)
Bool_t fTable; ///< True if function requires pre-calculated lookup table (e.g., LF Kubo-Toyabe)
TString fName; ///< Full function name for MSR files (e.g., "simplExpo", "statGssKt")
TString fAbbrev; ///< Short abbreviation (e.g., "se", "stg")
TString fComment; ///< Parameter list shown as help text in MSR file
TString fCommentTimeShift; ///< Parameter list with time shift included
} PTheoDataBase;
//--------------------------------------------------------------------------------------
@@ -251,15 +344,62 @@ static PTheoDataBase fgTheoDataBase[THEORY_MAX] = {
//--------------------------------------------------------------------------------------
/**
* <p>Class handling a theory of a msr-file.
* <p>Theory function evaluator and manager.
*
* <p>This class parses, validates, and evaluates theory functions specified
* in the THEORY block of MSR files. It handles:
* - Parsing theory syntax (function names, parameters, operators)
* - Building theory expression trees (addition/multiplication)
* - Resolving parameter mappings and user functions
* - Evaluating theory at specific time points
* - Caching longitudinal field calculations
* - Loading and managing user-defined shared library functions
*
* <p><b>Theory syntax:</b>
* - Single function: <tt>asymmetry simpleExp 1 3</tt>
* - Addition: <tt>func1 par1... + func2 par1...</tt>
* - Multiplication: <tt>func1 par1... * func2 par1...</tt>
* - Nested: <tt>(func1 + func2) * func3</tt>
*
* <p><b>Parameter resolution:</b>
* Parameters can be direct numbers, parameter references (1, 2, 3, ...),
* map references (map1, map2, ...), or function references (fun1, fun2, ...).
*
* <p><b>Example:</b>
* @code
* THEORY
* asymmetry 1
* TFieldCos 2 3 (phase, freq)
* +
* simpleExp 4 (rate)
* @endcode
* This evaluates to: par1 * cos(par2 + 2π*par3*t) + exp(-par4*t)
*/
class PTheory
{
public:
/**
* <p>Constructor for theory handler.
*
* @param msrInfo Pointer to MSR file handler
* @param runNo Run number for this theory (0-based)
* @param hasParent True if this is a sub-theory (for +/* operators)
*/
PTheory(PMsrHandler *msrInfo, UInt_t runNo, const Bool_t hasParent = false);
virtual ~PTheory();
/// Returns true if theory is valid and ready for evaluation
virtual Bool_t IsValid();
/**
* <p>Evaluates the theory function at time t.
*
* @param t Time in microseconds (μs)
* @param paramValues Vector of fit parameter values
* @param funcValues Vector of evaluated user function values
* @return Theory value at time t
*/
virtual Double_t Func(Double_t t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
private: