mist-hep 0.1.0
ROOT-backed analysis helpers built on mist
Loading...
Searching...
No Matches
functions.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2//
3// mist/hep/fit/functions.h — fit-function factories.
4//
5// Replaces AAU's pattern of "global TF1* fLevyTsallis; call fSetLevyTsallis()
6// before use" with explicit factories that return owned TF1 instances.
7// Callers decide lifetime; nothing leaks at TU scope.
8//
9// Each factory takes (name, x_min, x_max) and returns an owned TF1 handle
10// (mist::hep::owned::root_ptr<TF1>). Parameters can be configured by the
11// caller via the returned handle; sensible initial values + names are set on
12// construction.
13//
14#pragma once
15
16#include <TF1.h>
17
18#include <mist/hep/owned.h>
19
20namespace mist::hep::fit {
21
22// ---------------------------------------------------------------------------
23// Levy–Tsallis (Tsallis-Pareto) spectrum, the standard ALICE pT-spectrum
24// parametrisation:
25//
26// dN/dpT = pT * dN/dy * (n-1)(n-2) / (n*C * (n*C + m0*(n-2)))
27// * [1 + (mT - m0) / (n*C)] ^ (-n)
28//
29// mT = sqrt(pT^2 + m0^2)
30//
31// Parameters (after construction):
32// 0: dNdy — yield normalisation (default 1.0)
33// 1: n — power-law index (default 7.0)
34// 2: C — slope parameter [GeV] (default 0.25)
35// 3: m0 — particle mass [GeV] (default 0.13957, charged pion)
36//
37// The mass parameter is left as a free parameter by default so the caller can
38// either FixParameter(3, m_particle) before fitting, or scan it.
39// ---------------------------------------------------------------------------
41 const char* name = "levy_tsallis",
42 double x_min = 0.0,
43 double x_max = 10.0);
44
45// ---------------------------------------------------------------------------
46// q-exponential (Tsallis) primitive — a reusable building block.
47//
48// q_exp(x, q) = exp(x) if q == 1
49// = [1 + (1 - q) x]^(1/(1-q)) if that base is > 0
50// = 0 otherwise
51// ---------------------------------------------------------------------------
52[[nodiscard]] double q_exp(double x, double q);
53
54// ---------------------------------------------------------------------------
55// Gaussian: norm * exp(-0.5 * ((x - mean)/sigma)^2)
56// 0: norm (default 1)
57// 1: mean (default 0.5*(x_min+x_max))
58// 2: sigma (default 0.1*(x_max-x_min))
59// ---------------------------------------------------------------------------
61 const char* name = "gauss", double x_min = 0.0, double x_max = 1.0);
62
63// ---------------------------------------------------------------------------
64// q-Gaussian (Tsallis) with a flat baseline:
65// f(x) = baseline + norm * q_exp(-(x-mean)^2 / (2 sigma^2), q)
66// 0: norm 1: mean 2: sigma 3: q 4: baseline
67// defaults: norm=1, mean=mid, sigma=0.1*range, q=1.1, baseline=0
68// ---------------------------------------------------------------------------
70 const char* name = "qgauss", double x_min = 0.0, double x_max = 1.0);
71
72// ---------------------------------------------------------------------------
73// Exponentially-modified Gaussian (EMG):
74// f(x) = norm * (lambda/2) * exp((lambda/2)*(2 mean + lambda sigma^2 - 2x))
75// * erfc((mean + lambda sigma^2 - x) / (sqrt(2) sigma))
76// 0: mean 1: sigma 2: lambda 3: norm
77// ---------------------------------------------------------------------------
79 const char* name = "exgauss", double x_min = 0.0, double x_max = 1.0);
80
81// ---------------------------------------------------------------------------
82// Error-function turn-on:
83// f(x) = baseline + height * 0.5 * (erf((x - x0)/width) + 1)
84// 0: x0 1: width 2: height 3: baseline
85// ---------------------------------------------------------------------------
87 const char* name = "erf_step", double x_min = 0.0, double x_max = 1.0);
88
89// ---------------------------------------------------------------------------
90// Exponential: norm * exp(slope * x)
91// 0: norm 1: slope
92// ---------------------------------------------------------------------------
94 const char* name = "expo", double x_min = 0.0, double x_max = 1.0);
95
96// ---------------------------------------------------------------------------
97// Arrhenius activation form, linear in 1/T:
98// ln(y) = lnA - Ea / (k_B * T) -> f(T) = exp(lnA - Ea/(k_B T))
99// x is temperature T [K]; k_B = 8.617333e-5 eV/K.
100// 0: lnA 1: Ea_eV
101// ---------------------------------------------------------------------------
103 const char* name = "arrhenius", double x_min = 200.0, double x_max = 350.0);
104
105} // namespace mist::hep::fit
Definition functions.h:20
mist::hep::owned::root_ptr< TF1 > make_qgauss(const char *name="qgauss", double x_min=0.0, double x_max=1.0)
Definition functions.cxx:108
mist::hep::owned::root_ptr< TF1 > make_exgauss(const char *name="exgauss", double x_min=0.0, double x_max=1.0)
Definition functions.cxx:120
double q_exp(double x, double q)
Definition functions.cxx:90
mist::hep::owned::root_ptr< TF1 > make_levy_tsallis(const char *name="levy_tsallis", double x_min=0.0, double x_max=10.0)
Definition functions.cxx:76
mist::hep::owned::root_ptr< TF1 > make_expo(const char *name="expo", double x_min=0.0, double x_max=1.0)
Definition functions.cxx:142
mist::hep::owned::root_ptr< TF1 > make_erf_step(const char *name="erf_step", double x_min=0.0, double x_max=1.0)
Definition functions.cxx:131
mist::hep::owned::root_ptr< TF1 > make_gauss(const char *name="gauss", double x_min=0.0, double x_max=1.0)
Definition functions.cxx:98
mist::hep::owned::root_ptr< TF1 > make_arrhenius(const char *name="arrhenius", double x_min=200.0, double x_max=350.0)
Definition functions.cxx:151
std::unique_ptr< T, root_deleter > root_ptr
Definition owned.h:60