<chapter name="Parton Distributions"> 
 
<h2>Parton Distributions</h2> 
 
The parton distributions file contains the <code>PDF</code> class. 
<code>PDF</code> is the base class, from which specific <code>PDF</code> 
classes are derived. 
 
<p/> 
The choice of which PDF to use is made by settings in the 
<code>Pythia</code> class, see <aloc href="PDFSelection">here</aloc>. 
These settings also allow to access all the proton PDF's available in the 
LHAPDF library <ref>Wha05,Buc15</ref>. Thus there is no need for a normal 
user to study the <code>PDF</code> class. The structure must only be 
understood when interfacing new PDF's, e.g. ones not yet found in LHAPDF. 
 
<h3>The PDF base class</h3> 
 
<code>PDF</code> defines the interface that all PDF classes should respect. 
The constructor requires the incoming beam species to be given: 
even if used for a proton PDF, one needs to know whether the beam 
is actually an antiproton. This is one of the reasons why <code>Pythia</code> 
always defines two PDF objects in an event, one for each beam. 
 
PDFs should be defined by overriding the <code>PDF</code> base class, then 
overriding the following protected method: 
 
<method name="virtual void PDF::xfUpdate(int id, double x, double Q2)"> 
Calculates the PDF distributions for the specified parton id at 
<ei>(x, Q^2)</ei> and stores the resulting values in the corresponding 
fields. If <code>id == 9</code>, the values should be calculated for all 
relevant partons. The user may choose to always calculate the value for 
all partons, in which case they should set <code>idSav = 9</code>. 
 
The <code>PDF</code> class flexibly handles antiparticle and isospin 
symmetries, so <code>xfUpdate</code> should always give the values that 
correspond to the particle with positive <code>id</code> and isospin. 
Further details and special cases are discussed below, and users should 
read those carefully before implementing their own PDFs. 
</method> 
 
<p/> 
PDFs can be obtained from PYTHIA through the 
<code>Pythia::getPDFPtr</code> method. The <code>PDF</code> class offers 
a number of public methods. 
 
<method name="double PDF::xf(int id, double x, double Q2)"> 
Returns <ei>x * f_id(x, Q2)</ei> for the hadron represented by the 
<code>PDF</code> object. The actual value is calculated by a call 
to <code>xfUpdate</code>, which must be overridden by classes inheriting 
from <code>PDF</code>. The result is cached, and subsequent calls 
with the same <code>id</code>, <code>x</code> and <code>Q2</code> arguments 
will return the cached value instead of recalculating them. 
</method> 
 
<method name="double PDF::xfVal(int id, double x, double Q2)"> 
</method> 
<methodmore name="double PDF::xfSea(int id, double x, double Q2)"> 
Returns the valence or sea part of the specified distribution. These methods 
also use caching, as described above, and will call <code>xfUpdate</code> 
to calculate the distributions if necessary. 
</methodmore> 
 
<method name="virtual void setExtrapolate(bool extrapolate)"> 
Subclasses of <code>PDF</code> may override this method to switch 
between freezing parametrizations at the low-<ei>x</ei> boundary 
(<code>false</code>) or extrapolate them outside the boundary 
(<code>true</code>). This method works both for LHAPDF 5, LHAPDF6 and 
modern internal PDFs. (For some older PDFs the behaviour implemented by 
the original authors is maintained.) In either case the PDFs are frozen 
at <ei>Q_min</ei> and <ei>Q_max</ei>. (And also at <ei>x_max</ei>, but 
this is irrelevant when <ei>x_max = 1</ei>.) 
</method> 
 
<method name="virtual bool insideBounds(double x, double Q2)"> 
Subclasses of <code>PDF</code> may override this method to give the user 
information about whether the specified <ei>(x, Q^2)</ei> pair falls inside 
the fit region or not. Currently only implemented for LHAPDF6. 
</method> 
 
<method name="double alphaS(double Q2)"> 
</method> 
<methodmore name="double mQuarkPDF(int id)"> 
Subclasses of <code>PDF</code> may override these methods to respectively 
give the <ei>alpha_s</ei> of the PDF at the specified <ei>Q^2</ei> scale, 
and the quark mass used to set the flavour threshold for the specified 
quark <ei>id</ei>. Currently only implemented for LHAPDF6. 
</methodmore> 
 
<h3>Symmetries and special cases</h3> 
The <code>PDF</code> class is designed to handle particles through 
charge conjugation and isospin symmetries when available. For this reason, 
<code>xfUpdate</code> should always behave the same way, independent of 
which beam variant is specified for the PDF. Specifically, the particle should 
always be assumed to have a positive id, and if there are isospin variants, 
it should be assumed it is the particle with the largest available isospin 
(the only exceptions are <ei>Delta^+^+</ei> and <ei>Delta^-</ei>, which are 
treated as variants of the proton). For instance, that means that if the beam 
is <ei>n</ei>, then <code>xfUpdate</code> should return values as though 
it was <ei>p</ei>. 
Particles where <ei>u</ei> and <ei>d</ei> are symmetric (at least 
at LO), such as <ei>Sigma^0</ei> and <ei>Lambda^0</ei>, use the average 
of the <ei>u</ei> and <ei>d</ei> contents. The <ei>pi^0</ei> also uses 
the average of <ei>pi^+/pi^-</ei>, with additional complications due to 
its ambiguous valence content, as described in the next paragraph. Finally, 
<ei>K^0_S/K^0_L</ei> should be treated as <ei>K^+</ei> by 
<code>xfUpdate</code>. 
 
<p/> 
Some mesons have ambiguous valence content. These are <ei>eta/eta'</ei>, 
<ei>K^0_S/K^0_L</ei>, the pomeron, and all unflavoured diagonal mesons such 
as <ei>pi^0</ei>, <ei>rho^0</ei>, <ei>omega</ei>, <ei>f_0(980)</ei>, etc. 
In these cases, the <code>PDF</code> class keeps track of the current 
valence content, and gives the corresponding PDF values. The valence content 
is randomly chosen for each generated event. When the <code>PDF</code> is 
created, the default choice is defined as the content that is implied by 
the particle id, i.e. <ei>d dbar</ei> for <ei>pi^0</ei> or <ei>rho^0</ei>, 
<ei>u ubar</ei> for <ei>eta</ei> or <ei>omega</ei>, and <ei>s sbar</ei> for 
<ei>eta'</ei>. 
 
<p/> 
For diagonal mesons (except <ei>pi^0</ei>), the <ei>q</ei> and 
<ei>qbar</ei> contents are always the same. In some contexts, it is 
still physically meaningful to separate the content into valence 
and sea, but the valence content can no longer be defined as 
<ei>v(x) = q(x) - qbar(x)</ei>, since <ei>qbar</ei> does not 
correspond to sea content in this scenario. To circumvent this, the 
antiquark content will instead be used to store the sea content, and the 
<code>PDF</code> class will take this into account when determining which 
value to return. This is implemented in the SU21 data files, e.g. 
the <ei>-4</ei> column in <code>SU21Jpsi.dat</code> gives the value of 
the <ei>c/cbar</ei> sea. This is also true for <ei>eta/eta'</ei>, which 
use this scheme for <ei>d/dbar</ei>, <ei>u/ubar</ei> and <ei>s/sbar</ei>. 
 
<h3>Derived classes</h3> 
 
There is only one pure virtual method, <code>xfUpdate</code>, that 
therefore must be implemented in any derived class. A reasonable 
number of such classes come with the program: 
 
<p/> 
For any particle, including all modern proton sets and the SU21 
family covering almost all hadrons: 
<ul> 
<li><code>LHAGrid1</code> can read and use files in the LHAPDF6 lhagrid1 
format, assuming that the same <ei>x</ei> grid is used for all <ei>Q</ei> 
subgrids. Results are not exactly identical with LHAPDF6, owing to a 
different interpolation.</li> 
</ul> 
 
For protons: 
<ul> 
<li><code>LHAPDF</code> provides a plugin interface class to the 
LHAPDF library<ref>Wha05,Buc15</ref>. It loads either the 
<code>LHAPDF5</code> or <code>LHAPDF6</code> class.</li> 
<li><code>GRV94L</code> gives the GRV 94 L parametrization 
<ref>Glu95</ref>.</li> 
<li><code>CTEQ5L</code> gives the CTEQ 5 L parametrization 
<ref>Lai00</ref>.</li> 
<li><code>MSTWpdf</code> gives the four distributions of the 
MRST/MSTW group that have been implemented.</li> 
<li><code>CTEQ6pdf</code> gives the six distributions of the 
CTEQ/CT group that have been implemented.</li> 
<li><code>NNPDF</code> gives four distributions from the NNPDF 2.3 
QCD+QED sets that have been implemented.</li> 
<li><code>nPDF, Isospin, EPS09</code> three classes allowing to introduce 
nuclear modifications to a specified proton PDF. The first is base class 
for the other two, where <code>Isospin</code> only provides the 
appropriate mix of protons and isospin-conjugate neutrons, while 
<code>EPS09</code> also contains nuclear modification factors 
<ref>Esk09</ref>.</li> 
</ul> 
The current default is NNPDF 2.3. 
 
<p/> 
For charged pions: 
<ul> 
<li><code>GRVpiL</code> gives the GRV 1992 pi+ parametrization.</li> 
</ul> 
 
<p/> 
For Pomerons (used to describe diffraction): 
<ul> 
<li><code>PomFix</code> gives a simple but flexible 
<ei>Q2</ei>-independent parametrization.</li> 
<li><code>PomH1FitAB</code> gives the H1 2006 Fit A and Fit B 
parametrizations.</li> 
<li><code>PomH1Jets</code> gives the H1 2007 Jets parametrization.</li> 
</ul> 
 
<p/> 
For photons: 
<ul> 
<li><code>CJKL</code> gives the CJKL parametrization <ref>Cor03</ref>.</li> 
<li><code>GammaPoint</code> gives the trivial distribution of a 
pointlike (i.e. unresolved) photon.</li> 
</ul> 
 
<p/> 
For charged leptons (e, mu, tau) and the proton: 
<ul> 
<li><code>Lepton</code> gives a QED parametrization <ref>Kle89</ref>. 
In QED there are not so many ambiguities, so here one set should be 
enough. On the other hand, there is the problem that the 
lepton-inside-lepton pdf is integrably divergent for <ei>x &rarr; 1</ei>, 
which gives numerical problems. Like in PYTHIA 6, the pdf is therefore 
made to vanish for <ei>x > 1 - 10^{-10}</ei>, and scaled up in the range 
<ei>1 - 10^{-7} &lt; x &lt; 1 - 10^{-10}</ei> in such a way that the 
total area under the pdf is preserved.</li> 
<li><code>LeptonPoint</code> gives the trivial distribution of a 
pointlike (i.e. unresolved) charged lepton.</li> 
<li><code>EPAexternal</code> provides an external photon flux to study 
photoproduction with different fluxes. Still optimized for lepton beams, 
but also other fluxes can be studied.</li> 
<li><code>Lepton2gamma</code> gives the convolution between photon 
flux from leptons and photon PDFs.</li> 
<li><code>ProtonPoint</code> gives the equivalent photon spectrum 
of an unresolved proton.</li> 
</ul> 
 
<p/> 
For neutrinos: 
<ul> 
<li><code>NeutrinoPoint</code> is the only method, so there is no choice. 
Analogously to <code>LeptonPoint</code> it gives the distribution of a 
pointlike (i.e. unresolved) neutrino. The fact that neutrinos are always 
lefthanded, so that there is no need to average for spin states of incoming 
fermions, is accounted in the relevant cross sections and also 
<code>NeutrinoPoint</code> PDFs are normalized to 1.</li> 
</ul> 
 
<p/> 
There is another method, <code>isSetup()</code>, that returns the 
base-class boolean variable <code>isSet</code>. This variable is 
initially <code>true</code>, but could be set <code>false</code> if the 
setup procedure of a PDF failed, e.g. if the user has chosen an unknown 
PDF set. 
 
<p/> 
The MRST/MSTW, CTEQ/CT, NNPDF and H1 PDF routines are based on the 
interpolation in <ei>(x, Q)</ei> grids. The grid files are stored in the 
<code>xmldoc</code> subdirectory, like settings and particle data. 
Only PDF sets that will be used are read in during the initialization 
stage. Just as input streams can be used to initialize the settings 
and particle data, so can the individual PDFs be constructed.   See 
the header files for explicit constructor descriptions. 
 
</chapter> 
 
<!-- Copyright (C) 2026 Torbjorn Sjostrand --> 
