## Parton Distributions

The parton distributions file contains the `PDF` class. `PDF` is the base class, from which specific `PDF` classes are derived.

The choice of which PDF to use is made by settings in the `Pythia` class, see here. These settings also allow to access all the proton PDF's available in the LHAPDF library [Wha05,Buc15]. Thus there is no need for a normal user to study the `PDF` class. The structure must only be understood when interfacing new PDF's, e.g. ones not yet found in LHAPDF.

### The PDF base class

`PDF` 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 `Pythia` always defines two PDF objects in an event, one for each beam.

Once a `PDF` object has been constructed, call it `pdf`, the main method is `pdf.xf( id, x, Q2)`, which returns x*f_id(x, Q2), properly taking into account whether the beam is an antiparticle or not.

Whenever the `xf` member is called with a new flavour, x or Q^2, the `xfUpdate` member is called to do the actual updating. This routine may either update that particular flavour or all flavours at this (x, Q^2) point. (In the latter case the saved `id` value `idSav` should be set to 9.) The choice is to be made by the producer of a given set, based on what he/she deems most effective, given that sometimes only one flavour need be evaluated, and about equally often all flavours are needed at the same x and Q^2. Anyway, the latest value is always kept in memory. This is the other reason why `Pythia` has one separate `PDF` object for each beam, so that values at different x can be kept in memory.

Two further public methods are `xfVal( id, x, Q2)` and `xfSea( id, x, Q2)`. These are simple variants whereby the quark distributions can be subdivided into a valence and a sea part. If these are not directly accessible in the parametrization, one can make the simplified choices u_sea = ubar_sea, u_val = u_tot - u_sea, and correspondingly for d. (Positivity will always be guaranteed at output.) The `xfUpdate` method should also take care of updating this information.

A method `setExtrapolate(bool)` allows you to switch between freezing parametrizations at the low-x boundary (`false`) or extrapolate them outside the boundary (`true`). 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 Q_min and Q_max. (And also at x_max, but this is irrelevant when x_max = 1.)

With `insideBounds(double x, double Q2)` you can probe whether an (x, Q^2) pair falls inside the fit region or not. The `alphaS(double Q2)` method returns the alpha_s of the PDF at the given Q^2 scale, while `mQuarkPDF(int id)` returns the quark masses used to set flavour thresholds. Currently these three methods are only implemented for LHAPDF6.

### Derived classes

There is only one pure virtual method, `xfUpdate`, that therefore must be implemented in any derived class. A reasonable number of such classes come with the program:

For protons:

- `LHAPDF` provides a plugin interface class to the LHAPDF library[Wha05,Buc15]. It loads either the `LHAPDF5` or `LHAPDF6` class.
- `GRV94L` gives the GRV 94 L parametrization [Glu95].
- `CTEQ5L` gives the CTEQ 5 L parametrization [Lai00].
- `MSTWpdf` gives the four distributions of the MRST/MSTW group that have been implemented.
- `CTEQ6pdf` gives the six distributions of the CTEQ/CT group that have been implemented.
- `NNPDF` gives four distributions from the NNPDF 2.3 QCD+QED sets that have been implemented.
- `LHAGrid1` can read and use files in the LHAPDF6 lhagrid1 format, assuming that the same x grid is used for all Q subgrids. Results are not exactly identical with LHAPDF6, owing to different interpolation.
- `nPDF, Isospin, EPS09` three classes allowing to introduce nuclear modifications to a specified proton PDF. The first is base class for the other two, where `Isospin` only provides the appropriate mix of protons and isospin-conjugate neutrons, while `EPS09` also contains nuclear modification factors [Esk09].

The current default is NNPDF 2.3.

For charged pions:

- `GRVpiL` gives the GRV 1992 pi+ parametrization.

For Pomerons (used to describe diffraction):

- `PomFix` gives a simple but flexible Q2-independent parametrization.
- `PomH1FitAB` gives the H1 2006 Fit A and Fit B parametrizations.
- `PomH1Jets` gives the H1 2007 Jets parametrization.

For photons:

- `CJKL` gives the CJKL parametrization [Cor03].
- `GammaPoint` gives the trivial distribution of a pointlike (i.e. unresolved) photon.

For charged leptons (e, mu, tau) and the proton:

- `Lepton` gives a QED parametrization [Kle89]. 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 x → 1, which gives numerical problems. Like in PYTHIA 6, the pdf is therefore made to vanish for x > 1 - 10^{-10}, and scaled up in the range 1 - 10^{-7} < x < 1 - 10^{-10} in such a way that the total area under the pdf is preserved.
- `LeptonPoint` gives the trivial distribution of a pointlike (i.e. unresolved) charged lepton.
- `EPAexternal` provides an external photon flux to study photoproduction with different fluxes. Still optimized for lepton beams, but also other fluxes can be studied.
- `Lepton2gamma` gives the convolution between photon flux from leptons and photon PDFs.
- `ProtonPoint` gives the equivalent photon spectrum of an unresolved proton.

For neutrinos:

- `NeutrinoPoint` is the only method, so there is no choice. Analogously to `LeptonPoint` it gives the distribution of a pointlike (i.e. unresolved) neutrino. A difference, however, is that neutrinos always are lefthanded, so there is no need to average over incoming spin states. Since the PYTHIA formalism assumes unpolarized beams, and thus implicitly includes a 1/2 for incoming fermions, the `NeutrinoPoint` PDF is normalized to 2 rather than 1 to compensate for this.

There is another method, `isSetup()`, that returns the base-class boolean variable `isSet`. This variable is initially `true`, but could be set `false` if the setup procedure of a PDF failed, e.g. if the user has chosen an unknown PDF set.

The MRST/MSTW, CTEQ/CT, NNPDF and H1 PDF routines are based on the interpolation in (x, Q) grids. The grid files are stored in the `xmldoc` 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.