g2tools Module¶
g-2 Anomaly¶
The main tool for calculating the muon’s anomaly is:
- g2tools.a_mu(vacpol, Q=1, mmu=None, alpha=None, qmin=None, qmax=None, rescale=None, tol=None, exceptions=True)¶
Compute contribution to g-2 anomaly a_mu = (g-2)/2 from vacuum polarization.
- Parameters
vacpol – Function of
q2for the subtracted vacuum polarization (Pi-hat). Hereq2is space-like and so always positive. (See classvacpol.)Q – Effective charge (in units of the proton’s charge) — for example,
Q = 1./3. ``for s-quark loops (phi, etc) while ``Q = sqrt(5./9.)for u/d loops (rho, etc). (Default is 1.)mmu – Mass of the muon (default is
g2tools.Mmu).alpha – QED coupling (default is
g2tools.ALPHA).qmin – Maximum
qincluded in integral (default isg2tools.QMIN = 1e-15).qmax – Maximum
qincluded in integral (default isg2tools.QMAX = 1e5).rescale – Rescales momentum in vacuum pol.:
vacpol(q2 * rescale**2)(default is 1).tol – Tolerance for integral over
q2(default isg2tools.TOL = 1e-8).exceptions – If
True(default), an exception is raised if there are bad poles in thevacpol. IfFalse, exceptions are suppressed.
- Returns
Value of a_mu corresponding to
Q**2 * vacpol.
Moments¶
The main tools for creating and manipulating moments are:
- g2tools.moments(G, Z=1.0, ainv=1.0, periodic=True, tmin=None, tmax=None, nlist=[4, 6, 8, 10, 12, 14], filter=None)¶
Compute t**n moments of correlator G.
Compute
sum_t t**n G(t)forninnlist, where both positive and negativetare included.- Parameters
G – Array of correlator values
G[t]fort=0,1...(in lattice units).Z – Renormalization factor for current (moments multiplied by
Z**2). Defaul is 1.ainv – Inverse lattice spacing used to convert moments to physical units (n-th moment multiplied by
1/ainv**(n-2)). Default is 1.periodic –
periodic=TrueimpliesG[-t] = G[t](default);periodic=Falseimplies no periodicity in arrayG[t](and results doubled to account for negativet).tmin – minimum
tvalue (in same units as1/ainv) included in moments; ignored ifNone(default).tmax – maximum
tvalue (in same units as1/ainv) included in moments; ignored ifNone(default).nlist – List of moments to calculate. Default is
nlist=[4,6,8...14].filter – Correlator
Gis replaced byfilter(G, t)before moments are calculated. Heretis an array of times (in same units as1/ainv) corresponding to the elements of G. Ignored iffilter=None(default).
- Returns
Dictionary
GmomwhereGmom[n]is then-thmoment.
- g2tools.mom2taylor(mom)¶
Convert moments in dictionary
mominto Taylor series coefficients.
- g2tools.taylor2mom(tayl)¶
Convert Taylor coefficients in array
taylto moments.
Subtracted Vacuum Polarization¶
A subtracted vacuum polarization function (Pi-hat) is
represented by the following classes:
- class g2tools.vacpol(g, order=None, scale=None, rtol=None, qth=0, warn=True, exceptions=True)¶
Subtracted vac. pol’n (
Pi-hat(q2)) from correlator momentsg[n].The current-current correlator is
q2 * Pi(q2), wherePi-hat(q2) = Pi(q2) - Pi(0)is the subtracted (i.e., renormalized) vacuum polariztion function.The vacuum polarization function is a Pade approximant to the Taylor series corresponding to the moments
g[n]. The code estimates the precision of the moments and sets the tolerance for the Pade determination accordingly. The order(m,n)of the Pade can be specified, but might be reduced by the code if the data are noisy.vacpolobjects are used primarily as functions (of q2) but also have several attributes. Attributepseriesis a dictionary containing various powerseries (seegvar.powerseries) describing the function: the vacuum polarization function isq2times a Pade approximant with a numerator given bypseries['num']and a denominator given bypseries['den']. The Taylor series for this function is given byq2timespseries['taylor'].vacpolobjects also have a methodvacpol.badpoles()that tests the poles in the denomator of the Pade.badpoles(qth)returnsFalseif any of the poles is complex or if any are located above-(qth ** 2).qthshould be set equal to the threshold energy for the correlator. If it is unset,qth=0is used. Lists of the poles and their residues (forPi-hat(q2)) are available in attributespoleandresidue, respectively.vacpolhas several static methods for creating specialized examples of vacuum polarizations (e.g., for testing):vacpol.fermion(m)– 1-loop fermion (massm) contribution;vacpol.scalar(m)– 1-loop scalar (massm) contribution;vacpol.vector(m, f)– tree-level contribution from vectorwith mass
mand decay constantf.
- Parameters
g – Dictionary containing moments where
g[n] = sum_t t**n G(t), or array containing Taylor coefficients wherePi-hat(q2) = q2 * sum_j q2**j * g[j].order – Tuple
(m,n)specifying the order of the Pade approximant used to approximatePi-hat(q2)(the function is approximated byq2times an(m-1,n)approximant). The order may be reduced (automatically) if the data are too noisy. If the order is not specified, it is set automatically according to the number of entries inG.scale – Scale factor used to rescale
q2so that the Taylor coefficients are more uniform in size. This is normally set automatically (from the first two moments), but the automatic value is overridden ifscaleis set.rtol – Relative tolerance assumed when determining the Pade approximant. This is normally set automatically (from the standard deviations of the moments), but the automatic value is overridden if
rtolis specified.qth – Threshold for particle production: poles above
-qth**2are bad. Default isqth=0.warnings –
warnings=True(default) causes a warning to be issued when the order has been reduced automatically.warnings=Falsesuppresses the warnings.exceptions – If
True(default), an exception is raised if there are bad poles in thevacpol. IfFalse, exceptions are suppressed.
Methods include:
- taylor(n=None)¶
Return Taylor coefficients for
PI-hat(q2)/q2.- Parameters
n – Maximum number of coefficients returned. Returns all coefficents if
None(default)/
- badpoles(qth=None)¶
True if any pole is complex or above threshold.
- Parameters
qth – Threshold for particle production: poles above
-qth**2are bad. (Default isqth=0.)
- FT(t, ainv=1.0)¶
Fourier transform of
q2 * PI-hat(q2).The Pade approximant can be decomposed into a sum of poles (partial fractions), which give a sum of decaying exponentials when Fourier transformed back to t-space. The amplitudes and energies of these exponentials (for the transform of
q2 * Pi-hat(q2)) are stored ing2tools.vacpolattributesEandampl, respectively.The decomposition into a sum of poles leaves a residual polynomial in
q2(zeroth-order for(n,n)Pades). This is ignored in the Fourier transform since it typically affects the transform only for very smallt. These terms have a negligible effect (suppressed bya**2jon the Taylor coefficientsPi[j]ofPi-hat(q2)(for j>=1).Optional parameter
ainvcan be used to convert the Fourier transform to lattice units (by multiplying it by1/ainv**3) for comparison with simulation data. The timestare then assumed to be in lattice units.- Parameters
t (number, array) – Time in physical units unless
ainvis specified, in which case lattice units are assumed.ainv – Inverse lattice spacing. The Fourier transform is in lattice units if
ainvis specified (assuming the original Taylor coefficients are in physical units).
- static scalar(m, n=10, use_pade=False)¶
1-loop subt. vac. pol’n from a scalar with mass m (and charge=1).
- static fermion(m, n=19, use_pade=False)¶
1-loop subt. vac. pol’n from a fermion with mass m (and charge=1).
- static vector(m, f=1.0, n=10, use_pade=False)¶
Vac. pol. due to a vector with mass
mand decay const.f.The decay constant is defined such that the vacuum polarization function is
Pi-hat = q2 * f**2/2/m**2 / (q2 + m**2). This corresponds intspace tom * f**2 * exp(-m * t) / 4.
- class g2tools.fourier_vacpol(G, Z=1.0, ainv=1.0, periodic=True, tmin=None, tmax=None, filter=None)¶
Subtracted vac. pol’n (
Pi-hat(q2)) from correlatorG(t).The correlator is Fourier transformed to produce a function
Pi_hatof (Euclidean) q2 suitable for use ing2tools.a_mu().See Bernecker & Meyer, EPJA47 (2011) 148 , arXiv:1107.4388 for details on the Fouier transformation.
- Parameters
G (array) – Current-current correlator in an array whose elements are
[G(0),G(a),G(2*a),...,G(-2*a),G(-a)]ifperiodic=Trueor[G(0),G(a),...,G(T*a-1)]otherwise.Gis assumed to be in lattice units.Z – Renormalization factor for current (correlator multiplied by
Z**2). Defaul is 1.ainv – Inverse lattice spacing used to convert Fourier transform to physical units. Default is 1. (Note that
Gin physical units is obtained by multiplyingGin lattice units byainv**3.)tmin – If not
None, include onlyt >= tmin(same units as1/ainv).tmax – If not
None, include onlyt < tmax(same units as1/ainv).periodic –
periodic=TrueimpliesG[-t] = G[t](default);periodic=FalseimpliesG[t]is not periodic and is specified for only non-negativetvalues (results are doubled to account for negativet).filter – Correlator
Gis replaced byfilter(G, t)before moments are calculated. Heretis an array of times (in physical units ifainv!=1) corresponding to the elements of G. Ignored iffilter=None(default).
Re+e-¶
There are two tools for analyzing data from e+e- annihilation to hadrons (Re+e-(E)):
- g2tools.R2G(E, R, ainv=16.0, T=64.0, periodic=False, spline=True)¶
Calculate Euclidean correlator G(t) from data for Re+e-(E).
G(t)is evaluated on a uniform Euclidean grid with grid spacing1/ainvandt <= T.G(0)is set equal to zero.G(t)is calculated in lattice units; multiply byainv**3to convert to physical units.- Parameters
E (array) – Energies at which
R(E)is evaluated.R (array) –
R[i]is the Re+e- value at energyE[i]. ThisR[i]may be a float or agvar.GVarobject (Gaussian random variable).ainv (float) – Inverse grid spacing for the t-grid in GeV. Default is
ainv=16..T (float) – Length of the t-grid in inverse GeV. Default is
T=64.spline (bool) – If
True(default) use monotonic (Steffen) spline to evaluate the integral overs=E**2when calculating a_mu; otherwise use the Trapazoidal Rule. The latter is faster but less accurate.
- Returns
Array
G[i]of values of the Euclidean correlator in lattice units on the t-grid.
- g2tools.R2a_mu(E, R, mmu=None, alpha=None, spline=True)¶
Calclate leading-order hadronic contribution to g-2 anomaly a_mu = (g-2)/2 from Re+e-(E).
- Parameters
E (array) – Energies at which
R(E)is evaluated.R (array) –
R[i]is the Re+e- value at energyE[i].R[i]may be a float or agvar.GVarobject (Gaussian random variable).ainv (float) – Inverse grid spacing for the t-grid in GeV. Default is
ainv=16..T (float) – Length of the t-grid in inverse GeV. Default is
T=64.spline (bool) – If
True(default) use monotonic (Steffen) spline to evaluate the integral overs=E**2when calculating a_mu; otherwise use the Trapazoidal Rule. The latter is faster but less accurate.
- Returns
Value of a_mu corresponding to
R(E).
Padé Approximants¶
The following two functions are used for calculating Padé approximants from
the Taylor coefficients of an arbitrary function. The first
(g2tools.pade_svd()) implements an algorithm that uses svd cuts to
address instabilities caused by uncertainties in the Taylor coefficients. The
second function (g2tools.pade_gvar()) is built on the first but allows
Taylor coefficients to have uncertainties (gvar.GVars). The statistical
uncertainties and correlations between different coefficients are propagated
through the analysis.
- g2tools.pade_svd(f, m, n, rtol=1e-14)¶
[m,n]Pade approximant tosum_i f[i] x**i.The
[m,n]Pade approximant to a series given bysum_i f[i] * x**iis the ratio of polynomials of orderm(numerator) andn(denominator) whose Taylor expansion agrees with that of the original series up to orderm+n.This code is adapted from P. Gonnet, S. Guttel, L. N. Trefethen, SIAM Review Vol 55, No. 1, 101 (2013). It uses an svd algorithm to deal with imprecision in the input data, here specified by the relative tolerance
rtolfor the input coefficientsf[i]. It automatically reduces the order of the approximant if the extraction of Pade coefficients is too unstable given tolerancertol.- Parameters
f – Array
f[i]of power series coefficients fori=0...n+m.m – Maximum order of polynomial in numerator of Pade approximant (
m>=0).n – Maximum order of polynomial in denominator of Pade approximant (
m>=0).rtol – Relative accuracy of input coefficients. (Default is 1e-14.)
- Returns
Tuple of power series coefficients
(p, q)such thatsum_i p[i] x**iis the numerator of the approximant, andsum_i q[i] x**iis the denominator.q[0]is normalized to 1.
- g2tools.pade_gvar(f, m, n, rtol='gavg')¶
[m,n]Pade approximant tosum_i f[i] x**iforGVars.The
[m,n]Pade approximant to a series given bysum_i f[i] * x**iis the ratio of polynomials of orderm(numerator) andn(denominator) whose Taylor expansion agrees with that of the original series up to orderm+n.This code uses an SVD algorithm (see
pade_svd()) to deal with imprecision in the input data. It automatically reduces the order of the approximant if the extraction of Pade coefficients is too unstable given noise in the input data.- Parameters
f – Array
f[i]of power series coefficients fori=0...n+m.m – Maximum order of polynomial in numerator of Pade approximant (
m>=0).n – Maximum order of polynomial in denominator of Pade approximant (
m>=0).rtol (float or str) – If
rtolis a string, it determines how the relative tolerance is determined from the relative uncertainties in thef[i]. Setrtolequal to:'gavg'for the geometric mean (default);'avg'for the average;'min'for the minimum; or'max'for the maximum. Otherwise a number can be specified, in which case the uncertainties inf[i]are ignored.
- Returns
Tuple of power series coefficients
(p, q)such thatsum_i p[i] x**iis the numerator of the approximant, andsum_i q[i] x**iis the denominator.q[0]is normalized to 1.