musrfit 1.10.0
PTheory.cpp File Reference
#include <iostream>
#include <vector>
#include <cmath>
#include <TObject.h>
#include <TString.h>
#include <TF1.h>
#include <TObjString.h>
#include <TObjArray.h>
#include <TClass.h>
#include <TMath.h>
#include <Math/SpecFuncMathMore.h>
#include "PMsrHandler.h"
#include "PTheory.h"
Include dependency graph for PTheory.cpp:

Go to the source code of this file.

Macros

#define SQRT_TWO   1.41421356237
 
#define SQRT_PI   1.77245385091
 

Variables

std::vector< void * > gGlobalUserFcn
 Global storage for user function objects requiring persistent state.
 

Macro Definition Documentation

◆ SQRT_PI

#define SQRT_PI   1.77245385091

Definition at line 48 of file PTheory.cpp.

Referenced by PTheory::SkewedGauss().

◆ SQRT_TWO

#define SQRT_TWO   1.41421356237

Definition at line 47 of file PTheory.cpp.

Referenced by PTheory::SkewedGauss().

Variable Documentation

◆ gGlobalUserFcn

std::vector<void*> gGlobalUserFcn
extern

Global storage for user function objects requiring persistent state.

This vector provides a global container for user functions that need to maintain state across multiple evaluations or share data between runs. It is primarily used by user functions implementing the "global part" interface (NeedGlobalPart(), SetGlobalPart(), GlobalPartIsValid()).

Usage Pattern

User functions with expensive initialization (lookup tables, precomputed grids, loaded data files) store their global objects here:

// In user function's SetGlobalPart implementation:
void TMyFcn::SetGlobalPart(std::vector<void*> &globalPart, UInt_t idx) {
if (idx < globalPart.size() && globalPart[idx] != nullptr) {
fGlobal = static_cast<MyGlobalData*>(globalPart[idx]);
} else {
fGlobal = new MyGlobalData();
fGlobal->Initialize(); // Expensive one-time computation
if (idx < globalPart.size())
globalPart[idx] = fGlobal;
else
globalPart.push_back(fGlobal);
}
}
Note
The vector stores void pointers, so user functions must cast appropriately and manage memory for their specific data types.
Warning
User functions are responsible for proper cleanup of their global objects to avoid memory leaks.
See also
PUserFcnBase::SetGlobalPart() for the interface to populate this vector
PTheory for how global parts are initialized during theory setup

Definition at line 155 of file PUserFcnBase.cpp.

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