StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PartonDistributions.h
1 // PartonDistributions.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // Header files for parton densities.
7 // PDF: base class.
8 // LHAPDF: interface to the LHAPDF library.
9 // LHAGrid1: internal read and use files in the LHAPDF6 lhagrid1 format.
10 // GRV94L: GRV 94L parton densities.
11 // CTEQ5L: CTEQ 5L parton densities.
12 // MSTWpdf: MRST LO*, LO**, MSTW 2008 LO, NLO.
13 // CTEQ6pdf: CTEQ 6L, 6L1, 66, CT09 MC1, MC2, MCS.
14 // ProtonPoint: unresolved proton with equivalent photon spectrum.
15 // GRVpiL: GRV LO pion parton densities.
16 // PomFix: Q2-independent Pomeron parton densities.
17 // PomH1FitAB: H1 2006 Fit A and Fit B Pomeron PDFs.
18 // PomH1Jets: H1 2007 Jets Pomeron PDFs.
19 // PomHISASD: a proton masked as a Pomeron for heavy ions applications.
20 // Lepton: parton densities inside a lepton.
21 // LeptonPoint: an unresolved lepton (mainly dummy).
22 // NeutrinoPoint: an unresolved neutrino (mainly dummy).
23 // CJKL: CJKL parton densities for photons.
24 // Lepton2gamma: convolution of photon flux from leptons and photon PDFs.
25 // PhotonPoint: an unresolved photon.
26 // Proton2gammaDZ: Photon flux from protons according to Drees-Zeppenfeld.
27 // Nucleus2gamma: Photon flux from heavy nuclei.
28 // EPAexternal: approximated photon flux used for sampling of external flux.
29 // nPDF: a nuclear PDF, derived from a proton ditto.
30 // Isospin: isospin modification for nuclear pDF
31 // EPS09, EPPS16: nuclear modification factors.
32 
33 
34 #ifndef Pythia8_PartonDistributions_H
35 #define Pythia8_PartonDistributions_H
36 
37 #include "Pythia8/Basics.h"
38 #include "Pythia8/Info.h"
39 #include "Pythia8/MathTools.h"
40 #include "Pythia8/ParticleData.h"
41 #include "Pythia8/PythiaStdlib.h"
42 #include "Pythia8/SharedPointers.h"
43 
44 namespace Pythia8 {
45 
46 //==========================================================================
47 
48 // Base class for parton distribution functions.
49 
50 class PDF {
51 
52 public:
53 
54  // Constructor.
55  PDF(int idBeamIn = 2212) : idBeam(idBeamIn), idBeamAbs(abs(idBeam)),
56  idVal1(), idVal2(), xsVal(), xcVal(), xbVal(), xsSea(), xcSea(), xbSea()
57  { setValenceContent();
58  idSav = 9; xSav = -1.; Q2Sav = -1.;
59  xu = 0.; xd = 0.; xs = 0.; xubar = 0.; xdbar = 0.; xsbar = 0.; xc = 0.;
60  xb = 0.; xg = 0.; xlepton = 0.; xgamma = 0.; xuVal = 0.; xuSea = 0.;
61  xdVal = 0.; xdSea = 0.; isSet = true; isInit = false;
62  hasGammaInLepton = false; }
63 
64  // Destructor.
65  virtual ~PDF() {}
66 
67  // Confirm that PDF has been set up (important for LHAPDF and H1 Pomeron).
68  virtual bool isSetup() {return isSet;}
69 
70  // Dynamic choice of meson valence flavours for pi0, K0S, K0L, Pomeron.
71  virtual void newValenceContent(int idVal1In, int idVal2In) {
72  idVal1 = idVal1In; idVal2 = idVal2In;}
73 
74  // Allow extrapolation beyond boundaries. This is optional.
75  virtual void setExtrapolate(bool) {}
76 
77  // Read out parton density.
78  virtual double xf(int id, double x, double Q2);
79 
80  // Read out valence and sea part of parton densities.
81  virtual double xfVal(int id, double x, double Q2);
82  virtual double xfSea(int id, double x, double Q2);
83 
84  // Check whether x and Q2 values fall inside the fit bounds (LHAPDF6 only).
85  virtual bool insideBounds(double, double) {return true;}
86 
87  // Access the running alpha_s of a PDF set (LHAPDF6 only).
88  virtual double alphaS(double) { return 1.;}
89 
90  // Return quark masses used in the PDF fit (LHAPDF6 only).
91  virtual double mQuarkPDF(int) { return -1.;}
92 
93  // Return number of members of this PDF family (LHAPDF6 only).
94  virtual int nMembers() { return 1;}
95 
96  // Error envelope from PDF uncertainty.
97  struct PDFEnvelope {
98  double centralPDF, errplusPDF, errminusPDF, errsymmPDF, scalePDF;
99  vector<double> pdfMemberVars;
100  PDFEnvelope() : centralPDF(-1.0), errplusPDF(0.0), errminusPDF(0.0),
101  errsymmPDF(0.0), scalePDF(-1.0), pdfMemberVars(0.0) {};
102  };
103 
104  // Calculate PDF envelope.
105  virtual void calcPDFEnvelope(int, double, double, int) {}
106  virtual void calcPDFEnvelope(pair<int,int>, pair<double,double>, double,
107  int) {}
108  virtual PDFEnvelope getPDFEnvelope() { return PDFEnvelope(); }
109 
110  // Approximate photon PDFs by decoupling the scale and x-dependence.
111  virtual double gammaPDFxDependence(int, double) { return 0.; }
112 
113  // Provide the reference scale for logarithmic Q^2 evolution for photons.
114  virtual double gammaPDFRefScale(int) { return 0.; }
115 
116  // Sample the valence content for photons.
117  virtual int sampleGammaValFlavor(double) { return 0.; }
118 
119  // The total x-integrated PDFs. Relevant for MPIs with photon beams.
120  virtual double xfIntegratedTotal(double) { return 0.; }
121 
122  // Return the sampled value for x_gamma.
123  virtual double xGamma() { return 1.; }
124 
125  // Keep track of pomeron momentum fraction.
126  virtual void xPom(double = -1.0) {}
127 
128  // Return accurate and approximated photon fluxes and PDFs.
129  virtual double xfFlux(int , double , double ) { return 0.; }
130  virtual double xfApprox(int , double , double ) { return 0.; }
131  virtual double xfGamma(int , double , double ) { return 0.; }
132  virtual double intFluxApprox() { return 0.; }
133  virtual bool hasApproxGammaFlux() { return false; }
134 
135  // Return the kinematical limits and sample Q2 and x.
136  virtual double getXmin() { return 0.; }
137  virtual double getXhadr() { return 0.; }
138  virtual double sampleXgamma(double ) { return 0.; }
139  virtual double sampleQ2gamma(double ) { return 0.; }
140 
141  // Normal PDFs unless gamma inside lepton -> an overestimate for sampling.
142  virtual double xfMax(int id, double x, double Q2) { return xf( id, x, Q2); }
143 
144  // Normal PDFs unless gamma inside lepton -> Do not sample x_gamma.
145  virtual double xfSame(int id, double x, double Q2) { return xf( id, x, Q2); }
146 
147  // Allow for new scaling factor for VMD PDFs.
148  virtual void setVMDscale(double = 1.) {}
149 
150 protected:
151 
152  // Allow the LHAPDF class to access these methods.
153  friend class LHAPDF;
154 
155  // Store relevant quantities.
156  int idBeam, idBeamAbs, idSav, idVal1, idVal2;
157  double xSav, Q2Sav;
158  double xu, xd, xs, xubar, xdbar, xsbar, xc, xb, xg, xlepton, xgamma,
159  xuVal, xuSea, xdVal, xdSea;
160  bool isSet, isInit;
161 
162  // More valence and sea flavors for photon PDFs.
163  double xsVal, xcVal, xbVal, xsSea, xcSea, xbSea;
164 
165  // True if a photon beam inside a lepton beam, otherwise set false.
166  bool hasGammaInLepton;
167 
168  // Resolve valence content for assumed meson. Possibly modified later.
169  void setValenceContent();
170 
171  // Update parton densities.
172  virtual void xfUpdate(int id, double x, double Q2) = 0;
173 
174  // Small routine for error printout, depending on infoPtr existing or not.
175  void printErr(string errMsg, Info* infoPtr = 0) {
176  if (infoPtr !=0) infoPtr->errorMsg(errMsg);
177  else cout << errMsg << endl;
178  }
179 
180 };
181 
182 //==========================================================================
183 
184 // LHAPDF plugin interface class.
185 
186 class LHAPDF : public PDF {
187 
188 public:
189 
190  // Constructor and destructor.
191  LHAPDF(int idIn, string pSet, Info* infoPtrIn);
192  ~LHAPDF();
193 
194  // Confirm that PDF has been set up.
195  bool isSetup() {return pdfPtr != nullptr ? pdfPtr->isSetup() : false;}
196 
197  // Dynamic choice of meson valence flavours for pi0, K0S, K0L, Pomeron.
198  void newValenceContent(int idVal1In, int idVal2In) {
199  if (pdfPtr != nullptr) pdfPtr->newValenceContent(idVal1In, idVal2In);}
200 
201  // Allow extrapolation beyond boundaries.
202  void setExtrapolate(bool extrapolate) {
203  if (pdfPtr != nullptr) pdfPtr->setExtrapolate(extrapolate);}
204 
205  // Read out parton density
206  double xf(int id, double x, double Q2) {
207  return pdfPtr != nullptr ? pdfPtr->xf(id, x, Q2) : 0;}
208 
209  // Read out valence and sea part of parton densities.
210  double xfVal(int id, double x, double Q2) {
211  return pdfPtr != nullptr ? pdfPtr->xfVal(id, x, Q2) : 0;}
212  double xfSea(int id, double x, double Q2) {
213  return pdfPtr != nullptr ? pdfPtr->xfSea(id, x, Q2) : 0;}
214 
215  // Check whether x and Q2 values fall inside the fit bounds (LHAPDF6 only).
216  bool insideBounds(double x, double Q2) {
217  return pdfPtr != nullptr ? pdfPtr->insideBounds(x, Q2) : true;}
218 
219  // Access the running alpha_s of a PDF set (LHAPDF6 only).
220  double alphaS(double Q2) {
221  return pdfPtr != nullptr ? pdfPtr->alphaS(Q2) : 1.;}
222 
223  // Return quark masses used in the PDF fit (LHAPDF6 only).
224  double mQuarkPDF(int idIn) {
225  return pdfPtr != nullptr ? pdfPtr->mQuarkPDF(idIn) : -1.;}
226 
227  // Return quark masses used in the PDF fit (LHAPDF6 only).
228  int nMembers() {
229  return pdfPtr != nullptr ? pdfPtr->nMembers() : 1;}
230 
231 
232  // Calculate PDF envelope.
233  void calcPDFEnvelope(int idNow, double xNow, double Q2Now, int valSea) {
234  if (pdfPtr != nullptr)
235  pdfPtr->calcPDFEnvelope(idNow, xNow, Q2Now, valSea);}
236  void calcPDFEnvelope(pair<int,int> idNows, pair<double,double> xNows,
237  double Q2Now, int valSea) {
238  if (pdfPtr != nullptr) pdfPtr->calcPDFEnvelope(idNows,xNows,Q2Now,valSea);}
239  PDFEnvelope getPDFEnvelope() {
240  return pdfPtr != nullptr ? pdfPtr->getPDFEnvelope() : PDFEnvelope();}
241 
242 private:
243 
244  // Resolve valence content for assumed meson.
245  void setValenceContent() {if (pdfPtr != nullptr)
246  pdfPtr->setValenceContent();}
247 
248  // Update parton densities.
249  void xfUpdate(int id, double x, double Q2) {
250  if (pdfPtr != nullptr) pdfPtr->xfUpdate(id, x, Q2);}
251 
252  // Typedefs of the hooks used to access the plugin.
253  typedef PDF* NewPDF(int, string, int, Info*);
254  typedef void DeletePDF(PDF*);
255 
256  // The loaded LHAPDF object, info pointer, and plugin name, and plugin.
257  PDF* pdfPtr;
258  Info* infoPtr;
259  string name;
260  PluginPtr libPtr;
261 
262 };
263 
264 //==========================================================================
265 
266 // The LHAGrid1 can be used to read files in the LHAPDF6 lhagrid1 format,
267 // assuming that the same x grid is used for all Q subgrids.
268 // Results are not identical with LHAPDF6, owing to different interpolation.
269 
270 class LHAGrid1 : public PDF {
271 
272 public:
273 
274  // Constructor.
275  LHAGrid1(int idBeamIn = 2212, string pdfWord = "void",
276  string xmlPath = "../share/Pythia8/xmldoc/", Info* infoPtr = 0)
277  : PDF(idBeamIn), doExtraPol(false), nx(), nq(), nqSub(), xMin(), xMax(),
278  qMin(), qMax(), pdfVal(), pdfGrid(), pdfSlope(NULL) {
279  init( pdfWord, xmlPath, infoPtr); };
280 
281  // Constructor with a stream.
282  LHAGrid1(int idBeamIn, istream& is, Info* infoPtr = 0)
283  : PDF(idBeamIn), doExtraPol(false), nx(), nq(), nqSub(), xMin(), xMax(),
284  qMin(), qMax(), pdfVal(), pdfGrid(), pdfSlope(NULL) {
285  init( is, infoPtr); };
286 
287  // Destructor.
288  ~LHAGrid1() { for (int iid = 0; iid < 12; ++iid) {
289  for (int iq = 0; iq < nq; ++iq) delete[] pdfGrid[iid][iq];
290  delete[] pdfGrid[iid]; }
291  if (pdfSlope) { for (int iid = 0; iid < 12; ++iid) delete[] pdfSlope[iid];
292  delete[] pdfSlope;} };
293 
294  // Allow extrapolation beyond boundaries. This is optional.
295  void setExtrapolate(bool doExtraPolIn) {doExtraPol = doExtraPolIn;}
296 
297 private:
298 
299  // Variables to be set during code initialization.
300  bool doExtraPol;
301  int nx, nq, nqSub;
302  vector<int> nqSum;
303  double xMin, xMax, qMin, qMax, pdfVal[12];
304  vector<double> xGrid, lnxGrid, qGrid, lnqGrid, qDiv;
305  double** pdfGrid[12];
306  double** pdfSlope;
307 
308  // Initialization of data array.
309  void init( string pdfSet, string pdfdataPath, Info* infoPtr);
310 
311  // Initialization through a stream.
312  void init( istream& is, Info* infoPtr);
313 
314  // Update PDF values.
315  void xfUpdate(int id, double x, double Q2);
316 
317  // Interpolation in the grid for a given PDF flavour.
318  void xfxevolve(double x, double Q2);
319 
320 };
321 
322 //==========================================================================
323 
324 // Gives the GRV 94L (leading order) parton distribution function set
325 // in parametrized form. Authors: M. Glueck, E. Reya and A. Vogt.
326 
327 class GRV94L : public PDF {
328 
329 public:
330 
331  // Constructor.
332  GRV94L(int idBeamIn = 2212) : PDF(idBeamIn) {}
333 
334 private:
335 
336  // Update PDF values.
337  void xfUpdate(int , double x, double Q2);
338 
339  // Auxiliary routines used during the updating.
340  double grvv (double x, double n, double ak, double bk, double a,
341  double b, double c, double d);
342  double grvw (double x, double s, double al, double be, double ak,
343  double bk, double a, double b, double c, double d, double e, double es);
344  double grvs (double x, double s, double sth, double al, double be,
345  double ak, double ag, double b, double d, double e, double es);
346 
347 };
348 
349 //==========================================================================
350 
351 // Gives the CTEQ 5L (leading order) parton distribution function set
352 // in parametrized form. Parametrization by J. Pumplin. Authors: CTEQ.
353 
354 class CTEQ5L : public PDF {
355 
356 public:
357 
358  // Constructor.
359  CTEQ5L(int idBeamIn = 2212) : PDF(idBeamIn) {}
360 
361 private:
362 
363  // Update PDF values.
364  void xfUpdate(int , double x, double Q2);
365 
366 };
367 
368 //==========================================================================
369 
370 // The MSTWpdf class.
371 // MRST LO*(*) and MSTW 2008 PDF's, specifically the LO one.
372 // Original C++ version by Jeppe Andersen.
373 // Modified by Graeme Watt <watt(at)hep.ucl.ac.uk>.
374 // Sets available:
375 // iFit = 1 : MRST LO* (2007).
376 // iFit = 2 : MRST LO** (2008).
377 // iFit = 3 : MSTW 2008 LO, central member.
378 // iFit = 4 : MSTW 2008 NLO, central member. (Warning!)
379 
380 class MSTWpdf : public PDF {
381 
382 public:
383 
384  // Constructor.
385  MSTWpdf(int idBeamIn = 2212, int iFitIn = 1,
386  string pdfdataPath = "../share/Pythia8/pdfdata/", Info* infoPtr = 0)
387  : PDF(idBeamIn), iFit(), alphaSorder(), alphaSnfmax(), mCharm(), mBottom(),
388  alphaSQ0(), alphaSMZ(), distance(), tolerance(), xx(), qq(),
389  c() {init( iFitIn, pdfdataPath, infoPtr);}
390 
391  // Constructor with a stream.
392  MSTWpdf(int idBeamIn, istream& is, Info* infoPtr = 0)
393  : PDF(idBeamIn), iFit(), alphaSorder(), alphaSnfmax(), mCharm(), mBottom(),
394  alphaSQ0(), alphaSMZ(), distance(), tolerance(), xx(), qq(),
395  c() {init( is, infoPtr);}
396 
397 private:
398 
399  // Constants: could only be changed in the code itself.
400  static const int np, nx, nq, nqc0, nqb0;
401  static const double xmin, xmax, qsqmin, qsqmax, xxInit[65], qqInit[49];
402 
403  // Data read in from grid file or set at initialization.
404  int iFit, alphaSorder, alphaSnfmax;
405  double mCharm, mBottom, alphaSQ0, alphaSMZ, distance, tolerance,
406  xx[65], qq[49], c[13][64][48][5][5];
407 
408  // Initialization of data array.
409  void init( int iFitIn, string pdfdataPath, Info* infoPtr);
410 
411  // Initialization through a stream.
412  void init( istream& is, Info* infoPtr);
413 
414  // Update PDF values.
415  void xfUpdate(int , double x, double Q2);
416 
417  // Evaluate PDF of one flavour species.
418  double parton(int flavour,double x,double q);
419  double parton_interpolate(int flavour,double xxx,double qqq);
420  double parton_extrapolate(int flavour,double xxx,double qqq);
421 
422  // Auxiliary routines for evaluation.
423  int locate(double xx[],int n,double x);
424  double polderivative1(double x1, double x2, double x3, double y1,
425  double y2, double y3);
426  double polderivative2(double x1, double x2, double x3, double y1,
427  double y2, double y3);
428  double polderivative3(double x1, double x2, double x3, double y1,
429  double y2, double y3);
430 
431 };
432 
433 //==========================================================================
434 
435 // The CTEQ6pdf class.
436 // Proton sets available:
437 // iFit = 1 : CTEQ6L
438 // iFit = 2 : CTEQ6L1
439 // iFit = 3 : CTEQ66.00 (NLO, central member)
440 // iFit = 4 : CT09MC1
441 // iFit = 5 : CT09MC2
442 // iFit = 6 : CT09MCS
443 // Pomeron sets available (uses same .pds file format as CTEQ6pdf) :
444 // iFit = 11: ACTWB14
445 // iFit = 12: ACTWD14
446 // iFit = 13: ACTWSG14
447 // iFit = 14: ACTWD19
448 
449 class CTEQ6pdf : public PDF {
450 
451 public:
452 
453  // Constructor.
454  CTEQ6pdf(int idBeamIn = 2212, int iFitIn = 1, double rescaleIn = 1.,
455  string pdfdataPath = "../share/Pythia8/pdfdata/", Info* infoPtr = 0)
456  : PDF(idBeamIn), doExtraPol(false), iFit(), order(), nQuark(), nfMx(),
457  mxVal(), nX(), nT(), nG(), iGridX(), iGridQ(), iGridLX(), iGridLQ(),
458  rescale(rescaleIn), lambda(), mQ(), qIni(), qMax(), tv(), xMin(), xv(),
459  upd(), xvpow(), xMinEps(), xMaxEps(), qMinEps(), qMaxEps(), fVec(),
460  tConst(), xConst(), dlx(), xLast(),
461  qLast() {init( iFitIn, pdfdataPath, infoPtr);}
462 
463  // Constructor with a stream.
464  CTEQ6pdf(int idBeamIn, istream& is, bool isPdsGrid = false,
465  Info* infoPtr = 0) : PDF(idBeamIn), doExtraPol(false), iFit(),
466  order(), nQuark(), nfMx(), mxVal(), nX(), nT(), nG(), iGridX(), iGridQ(),
467  iGridLX(), iGridLQ(), rescale(), lambda(), mQ(), qIni(), qMax(), tv(),
468  xMin(), xv(), upd(), xvpow(), xMinEps(), xMaxEps(), qMinEps(), qMaxEps(),
469  fVec(), tConst(), xConst(), dlx(), xLast(),
470  qLast() { init( is, isPdsGrid, infoPtr); }
471 
472  // Allow extrapolation beyond boundaries. This is optional.
473  void setExtrapolate(bool doExtraPolIn) {doExtraPol = doExtraPolIn;}
474 
475 private:
476 
477  // Constants: could only be changed in the code itself.
478  static const double EPSILON, XPOWER;
479 
480  // Data read in from grid file or set at initialization.
481  bool doExtraPol;
482  int iFit, order, nQuark, nfMx, mxVal, nX, nT, nG,
483  iGridX, iGridQ, iGridLX, iGridLQ;
484  double rescale, lambda, mQ[7], qIni, qMax, tv[26], xMin, xv[202], upd[57773],
485  xvpow[202], xMinEps, xMaxEps, qMinEps, qMaxEps, fVec[5],
486  tConst[9], xConst[9], dlx, xLast, qLast;
487 
488  // Initialization of data array.
489  void init( int iFitIn, string pdfdataPath, Info* infoPtr);
490 
491  // Initialization through a stream.
492  void init( istream& is, bool isPdsGrid, Info* infoPtr);
493 
494  // Update PDF values.
495  void xfUpdate(int id, double x, double Q2);
496 
497  // Evaluate PDF of one flavour species.
498  double parton6(int iParton, double x, double q);
499 
500  // Interpolation in grid.
501  double polint4F(double xgrid[], double fgrid[], double xin);
502 
503 };
504 
505 //==========================================================================
506 
507 // SA Unresolved proton: equivalent photon spectrum from
508 // V.M. Budnev, I.F. Ginzburg, G.V. Meledin and V.G. Serbo,
509 // Phys. Rept. 15 (1974/1975) 181.
510 
511 class ProtonPoint : public PDF {
512 
513 public:
514 
515  // Constructor.
516  ProtonPoint(int idBeamIn = 2212, Info* infoPtrIn = 0)
517  : PDF(idBeamIn), infoPtr(infoPtrIn) {}
518 
519 private:
520 
521  // Stored value for PDF choice.
522  static const double ALPHAEM, Q2MAX, Q20, A, B, C;
523 
524  // Update PDF values.
525  void xfUpdate(int , double x, double Q2);
526 
527  // phi function from Q2 integration.
528  double phiFunc(double x, double Q);
529 
530  // Info and errors
531  Info* infoPtr;
532 
533 };
534 
535 //==========================================================================
536 
537 // Gives the GRV 1992 pi+ (leading order) parton distribution function set
538 // in parametrized form. Authors: Glueck, Reya and Vogt.
539 
540 class GRVpiL : public PDF {
541 
542 public:
543 
544  // Constructor.
545  GRVpiL(int idBeamIn = 211, double rescaleIn = 1.) :
546  PDF(idBeamIn) {rescale = rescaleIn;}
547 
548  // Allow for new rescaling factor of the PDF for VMD beams.
549  void setVMDscale(double rescaleIn = 1.) {rescale = rescaleIn;}
550 
551 private:
552 
553  // Rescaling of pion PDF for VMDs.
554  double rescale;
555 
556  // Update PDF values.
557  void xfUpdate(int , double x, double Q2);
558 
559 };
560 
561 //==========================================================================
562 
563 // Gives generic Q2-independent Pomeron PDF.
564 
565 class PomFix : public PDF {
566 
567 public:
568 
569  // Constructor.
570  PomFix(int idBeamIn = 990, double PomGluonAIn = 0.,
571  double PomGluonBIn = 0., double PomQuarkAIn = 0.,
572  double PomQuarkBIn = 0., double PomQuarkFracIn = 0.,
573  double PomStrangeSuppIn = 0.) : PDF(idBeamIn),
574  PomGluonA(PomGluonAIn), PomGluonB(PomGluonBIn),
575  PomQuarkA(PomQuarkAIn), PomQuarkB(PomQuarkBIn),
576  PomQuarkFrac(PomQuarkFracIn), PomStrangeSupp(PomStrangeSuppIn),
577  normGluon(), normQuark() { init(); }
578 
579 private:
580 
581  // Stored value for PDF choice.
582  double PomGluonA, PomGluonB, PomQuarkA, PomQuarkB, PomQuarkFrac,
583  PomStrangeSupp, normGluon, normQuark;
584 
585  // Initialization of some constants.
586  void init();
587 
588  // Update PDF values.
589  void xfUpdate(int , double x, double);
590 
591 };
592 
593 //==========================================================================
594 
595 // The H1 2006 Fit A and Fit B Pomeron parametrization.
596 // H1 Collaboration, A. Aktas et al., "Measurement and QCD Analysis of
597 // the Diffractive Deep-Inelastic Scattering Cross Section at HERA",
598 // DESY-06-049, Eur. Phys. J. C48 (2006) 715. e-Print: hep-ex/0606004.
599 
600 class PomH1FitAB : public PDF {
601 
602 public:
603 
604  // Constructor.
605  PomH1FitAB(int idBeamIn = 990, int iFit = 1, double rescaleIn = 1.,
606  string pdfdataPath = "../share/Pythia8/pdfdata/", Info* infoPtr = 0)
607  : PDF(idBeamIn), doExtraPol(false), nx(), nQ2(), rescale(rescaleIn), xlow(),
608  xupp(), dx(), Q2low(), Q2upp(), dQ2(), gluonGrid(), quarkGrid()
609  { init( iFit, pdfdataPath, infoPtr); }
610 
611  // Constructor with a stream.
612  PomH1FitAB(int idBeamIn, double rescaleIn, istream& is,
613  Info* infoPtr = 0) : PDF(idBeamIn), doExtraPol(false), nx(), nQ2(),
614  rescale(rescaleIn), xlow(),xupp(), dx(), Q2low(), Q2upp(), dQ2(),
615  gluonGrid(), quarkGrid() { init( is, infoPtr); }
616 
617  // Allow extrapolation beyond boundaries. This is optional.
618  void setExtrapolate(bool doExtraPolIn) {doExtraPol = doExtraPolIn;}
619 
620 private:
621 
622  // Limits for grid in x, in Q2, and data in (x, Q2).
623  bool doExtraPol;
624  int nx, nQ2;
625  double rescale, xlow, xupp, dx, Q2low, Q2upp, dQ2;
626  double gluonGrid[100][30];
627  double quarkGrid[100][30];
628 
629  // Initialization of data array.
630  void init( int iFit, string pdfdataPath, Info* infoPtr);
631 
632  // Initialization through a stream.
633  void init( istream& is, Info* infoPtr);
634 
635  // Update PDF values.
636  void xfUpdate(int , double x, double );
637 
638 };
639 
640 //==========================================================================
641 
642 // The H1 2007 Jets Pomeron parametrization..
643 // H1 Collaboration, A. Aktas et al., "Dijet Cross Sections and Parton
644 // Densities in Diffractive DIS at HERA", DESY-07-115, Aug 2007. 33pp.
645 // Published in JHEP 0710:042,2007. e-Print: arXiv:0708.3217 [hep-ex]
646 
647 class PomH1Jets : public PDF {
648 
649 public:
650 
651  // Constructor.
652  PomH1Jets(int idBeamIn = 990, int iFit = 1, double rescaleIn = 1.,
653  string pdfdataPath = "../share/Pythia8/pdfdata/", Info* infoPtr = 0)
654  : PDF(idBeamIn), doExtraPol(false), rescale(rescaleIn), xGrid(), Q2Grid(),
655  gluonGrid(), singletGrid(), charmGrid()
656  {init( iFit, pdfdataPath, infoPtr);}
657 
658  // Constructor with a stream.
659  PomH1Jets(int idBeamIn, double rescaleIn, istream& is,
660  Info* infoPtr = 0) : PDF(idBeamIn), doExtraPol(false),
661  rescale(rescaleIn), xGrid(), Q2Grid(), gluonGrid(), singletGrid(),
662  charmGrid() { init( is, infoPtr); }
663 
664  // Allow extrapolation beyond boundaries. This is optional.
665  void setExtrapolate(bool doExtraPolIn) {doExtraPol = doExtraPolIn;}
666 
667 private:
668 
669  // Arrays for grid in x, in Q2, and data in (x, Q2).
670  bool doExtraPol;
671  double rescale;
672  double xGrid[100];
673  double Q2Grid[88];
674  double gluonGrid[100][88];
675  double singletGrid[100][88];
676  double charmGrid[100][88];
677 
678  // Initialization of data array.
679  void init( int iFit, string pdfdataPath, Info* infoPtr);
680 
681  // Initialization through a stream.
682  void init( istream& is, Info* infoPtr);
683 
684  // Update PDF values.
685  void xfUpdate(int id, double x, double );
686 
687 };
688 
689 //==========================================================================
690 
691 // A proton masked as a Pomeron for use within the Heavy Ion machinery
692 
693 class PomHISASD : public PDF {
694 
695 public:
696 
697  // Basic constructor
698  PomHISASD(int idBeamIn, PDFPtr ppdf, Settings & settings,
699  Info* infoPtrIn = 0) : PDF(idBeamIn), pPDFPtr(ppdf),
700  xPomNow(-1.0), hixpow(4.0), newfac(1.0) {
701  infoPtr = infoPtrIn;
702  hixpow = settings.parm("PDF:PomHixSupp");
703  if ( settings.mode("Angantyr:SASDmode") == 3 ) newfac =
704  log(settings.parm("Beams:eCM")/settings.parm("Diffraction:mMinPert"));
705  if ( settings.mode("Angantyr:SASDmode") == 4 ) newfac = 0.0;
706  }
707 
708  // Delete also the proton PDF
709  ~PomHISASD() { }
710 
711  // (re-)Set the x_pomeron value.
712  void xPom(double xpom = -1.0) { xPomNow = xpom; }
713 
714 private:
715 
716  // The proton PDF.
717  PDFPtr pPDFPtr;
718 
719  // The momentum fraction if the corresponding pomeron.
720  double xPomNow;
721 
722  // The high-x suppression power.
723  double hixpow;
724 
725  // Special options.
726  double newfac;
727 
728  // Report possible errors.
729  Info* infoPtr;
730 
731  // Update PDF values.
732  void xfUpdate(int , double x, double Q2);
733 
734 };
735 
736 //==========================================================================
737 
738 // Gives electron (or muon, or tau) parton distribution.
739 
740 class Lepton : public PDF {
741 
742 public:
743 
744  // Constructor.
745  Lepton(int idBeamIn = 11) : PDF(idBeamIn), m2Lep(), Q2maxGamma(),
746  infoPtr(), rndmPtr() {}
747 
748  // Constructor with further info.
749  Lepton(int idBeamIn, double Q2maxGammaIn, Info* infoPtrIn)
750  : PDF(idBeamIn), m2Lep() { Q2maxGamma = Q2maxGammaIn;
751  infoPtr = infoPtrIn; rndmPtr = infoPtrIn->rndmPtr; }
752 
753  // Sample the Q2 value.
754  double sampleQ2gamma(double Q2min)
755  { return Q2min * pow(Q2maxGamma / Q2min, rndmPtr->flat()); }
756 
757 private:
758 
759  // Constants: could only be changed in the code itself.
760  static const double ALPHAEM, ME, MMU, MTAU;
761 
762  // Update PDF values.
763  void xfUpdate(int id, double x, double Q2);
764 
765  // The squared lepton mass, set at initialization.
766  double m2Lep, Q2maxGamma;
767 
768  // Pointer to info, needed to get sqrt(s) to fix x_gamma limits.
769  Info* infoPtr;
770 
771  // Pointer to random number generator, needed to sample Q2.
772  Rndm* rndmPtr;
773 
774 };
775 
776 //==========================================================================
777 
778 // Gives electron (or other lepton) parton distribution when unresolved.
779 
780 class LeptonPoint : public PDF {
781 
782 public:
783 
784  // Constructor.
785  LeptonPoint(int idBeamIn = 11) : PDF(idBeamIn) {}
786 
787 private:
788 
789  // Update PDF values in trivial way.
790  void xfUpdate(int , double , double ) {xlepton = 1; xgamma = 0.;}
791 
792 };
793 
794 //==========================================================================
795 
796 // Gives neutrino parton distribution when unresolved (only choice for now).
797 // Note factor of 2 since only lefthanded implies no spin averaging.
798 
799 class NeutrinoPoint : public PDF {
800 
801 public:
802 
803  // Constructor.
804  NeutrinoPoint(int idBeamIn = 12) : PDF(idBeamIn) {}
805 
806 private:
807 
808  // Update PDF values, with spin factor of 2.
809  void xfUpdate(int , double , double ) {xlepton = 2; xgamma = 0.;}
810 
811 };
812 
813 //==========================================================================
814 
815 // Gives the CJKL leading order parton distribution function set
816 // in parametrized form for the real photons. Authors: F.Cornet, P.Jankowski,
817 // M.Krawczyk and A.Lorca, Phys. Rev. D68: 014010, 2003.
818 
819 class CJKL : public PDF {
820 
821 public:
822 
823  // Constructor. Needs the randon number generator to sample valence content.
824  CJKL(int idBeamIn = 22, Rndm* rndmPtrIn = 0 ) : PDF(idBeamIn) {
825  rndmPtr = rndmPtrIn; }
826 
827  // Functions to approximate pdfs for ISR.
828  double gammaPDFxDependence(int id, double);
829  double gammaPDFRefScale(int);
830 
831  // Set the valence content for photons.
832  int sampleGammaValFlavor(double Q2);
833 
834  // The total x-integrated PDFs. Relevant for MPIs with photon beams.
835  double xfIntegratedTotal(double Q2);
836 
837 private:
838 
839  // Parameters related to the fit.
840  static const double ALPHAEM, Q02, Q2MIN, Q2REF, LAMBDA, MC, MB;
841 
842  // Pointer to random number generator used for valence sampling.
843  Rndm *rndmPtr;
844 
845  // Update PDF values.
846  void xfUpdate(int , double x, double Q2);
847 
848  // Functions for updating the point-like part.
849  double pointlikeG(double x, double s);
850  double pointlikeU(double x, double s);
851  double pointlikeD(double x, double s);
852  double pointlikeC(double x, double s, double Q2);
853  double pointlikeB(double x, double s, double Q2);
854 
855  // Functions for updating the hadron-like part.
856  double hadronlikeG(double x, double s);
857  double hadronlikeSea(double x, double s);
858  double hadronlikeVal(double x, double s);
859  double hadronlikeC(double x, double s, double Q2);
860  double hadronlikeB(double x, double s, double Q2);
861 
862 };
863 
864 //==========================================================================
865 
866 // Convolution with photon flux from leptons and photon PDFs.
867 // Photon flux from equivalent photon approximation (EPA).
868 // Contains a pointer to a photon PDF set and samples the
869 // convolution integral event-by-event basis.
870 // Includes also a overestimate for the PDF set in order to set up
871 // the phase-space sampling correctly.
872 
873 class Lepton2gamma : public PDF {
874 
875 public:
876 
877  // Constructor.
878  Lepton2gamma(int idBeamIn, double m2leptonIn, double Q2maxGamma,
879  PDFPtr gammaPDFPtrIn, Info* infoPtrIn)
880  : PDF(idBeamIn), m2lepton(m2leptonIn), Q2max(Q2maxGamma), xGm(),
881  sampleXgamma(true), gammaPDFPtr(gammaPDFPtrIn),rndmPtr(infoPtrIn->rndmPtr),
882  infoPtr(infoPtrIn) { hasGammaInLepton = true; }
883 
884  // Overload the member function definitions where relevant.
885  void xfUpdate(int id, double x, double Q2);
886  double xGamma() { return xGm; }
887  double xfMax(int id, double x, double Q2);
888  double xfSame(int id, double x, double Q2);
889 
890  // Sample the Q2 value.
891  double sampleQ2gamma(double Q2min)
892  { return Q2min * pow(Q2max / Q2min, rndmPtr->flat()); }
893 
894 private:
895 
896  // Parameters for convolution.
897  static const double ALPHAEM, Q2MIN;
898  double m2lepton, Q2max, xGm;
899 
900  // Sample new value for x_gamma.
901  bool sampleXgamma;
902 
903  // Photon PDFs which the photon flux is convoluted with.
904  PDFPtr gammaPDFPtr;
905 
906  // Pointer to random number generator used for sampling x_gamma.
907  Rndm* rndmPtr;
908 
909  // Pointer to info, needed to get sqrt(s) to fix x_gamma limits.
910  Info* infoPtr;
911 
912 };
913 
914 //==========================================================================
915 
916 // Gives photon parton distribution when unresolved.
917 
918 class GammaPoint : public PDF {
919 
920 public:
921 
922  // Constructor.
923  GammaPoint(int idBeamIn = 22) : PDF(idBeamIn) {}
924 
925 private:
926 
927  // Update PDF values in trivial way.
928  void xfUpdate(int , double , double ) { xgamma = 1.;}
929 
930 };
931 
932 //==========================================================================
933 
934 // Unresolved proton: equivalent photon spectrum according
935 // to the approximation by Drees and Zeppenfeld,
936 // Phys.Rev. D39 (1989) 2536.
937 
938 class Proton2gammaDZ : public PDF {
939 
940 public:
941 
942  // Constructor.
943  Proton2gammaDZ(int idBeamIn = 2212) : PDF(idBeamIn) {}
944 
945 private:
946 
947  // Stored parameters.
948  static const double ALPHAEM, Q20;
949 
950  // Update PDF values.
951  void xfUpdate(int , double x, double Q2);
952 
953 };
954 
955 //==========================================================================
956 
957 // Unresolved nucleus: equivalent photon approximation
958 // for impact parameter integrated flux according to standard
959 // form introduced in J.D. Jackson, Classical Electrodynamics,
960 // 2nd edition, John Wiley & Sons (1975).
961 
962 class Nucleus2gamma : public PDF {
963 
964 public:
965 
966  // Constructor.
967  Nucleus2gamma(int idBeamIn, double bMinIn, double mNucleonIn) :
968  PDF(idBeamIn), a(), z(), bMin(bMinIn), mNucleon(mNucleonIn)
969  { initNucleus(); }
970 
971 private:
972 
973  // Stored constant parameters.
974  static const double ALPHAEM;
975 
976  // Initialize flux parameters.
977  void initNucleus();
978 
979  // Update PDF values.
980  void xfUpdate(int , double x, double Q2);
981 
982  // Mass number and electric charge.
983  int a, z;
984 
985  // Minimum impact parameter for integration and per-nucleon mass.
986  double bMin, mNucleon;
987 
988 };
989 
990 //==========================================================================
991 
992 // Equivalent photon approximation for sampling with external photon flux.
993 
994 class EPAexternal : public PDF {
995 
996 public:
997 
998  // Constructor.
999  EPAexternal(int idBeamIn, double m2In, PDFPtr gammaFluxPtrIn,
1000  PDFPtr gammaPDFPtrIn, Info* infoPtrIn) : PDF(idBeamIn), m2(m2In),
1001  Q2max(), Q2min(), xMax(), xMin(), xHadr(), norm(), xPow(), xCut(), norm1(),
1002  norm2(), integral1(), integral2(), bmhbarc(), gammaFluxPtr(gammaFluxPtrIn),
1003  gammaPDFPtr(gammaPDFPtrIn), infoPtr(infoPtrIn),
1004  rndmPtr(infoPtrIn->rndmPtr), settingsPtr(infoPtrIn->settingsPtr) {
1005  hasGammaInLepton = true; init(); }
1006 
1007  // Update PDFs.
1008  void xfUpdate(int , double x, double Q2);
1009 
1010  // External flux and photon PDFs, and approximated flux for sampling.
1011  double xfFlux(int id, double x, double Q2 = 1.);
1012  double xfGamma(int id, double x, double Q2);
1013  double xfApprox(int id, double x, double Q2);
1014  double intFluxApprox();
1015 
1016  // This derived class use approximated flux for sampling.
1017  bool hasApproxGammaFlux() { return true; }
1018 
1019  // Kinematics.
1020  double getXmin() { return xMin; }
1021  double getXhadr() { return xHadr; }
1022 
1023  // Sampling of the x and Q2 according to differential flux.
1024  double sampleXgamma(double xMinIn);
1025  double sampleQ2gamma(double )
1026  { return Q2min * pow(Q2max / Q2min, rndmPtr->flat()); }
1027 
1028 private:
1029 
1030  // Initialization.
1031  void init();
1032 
1033  // Kinematics.
1034  static const double ALPHAEM;
1035  double m2, Q2max, Q2min, xMax, xMin, xHadr, norm, xPow, xCut,
1036  norm1, norm2, integral1, integral2, bmhbarc;
1037  int approxMode;
1038 
1039  // Photon Flux and PDF.
1040  PDFPtr gammaFluxPtr;
1041  PDFPtr gammaPDFPtr;
1042 
1043  // Pointer to info, needed to get sqrt(s) to fix x_gamma limits.
1044  Info* infoPtr;
1045 
1046  // Pointer to random number generator used for sampling x_gamma.
1047  Rndm* rndmPtr;
1048 
1049  // Pointer to settings to get Q2max.
1050  Settings* settingsPtr;
1051 
1052 };
1053 
1054 //==========================================================================
1055 
1056 // A derived class for nuclear PDFs. Needs a pointer for (free) proton PDFs.
1057 
1058 class nPDF : public PDF {
1059 
1060 public:
1061 
1062  // Constructor.
1063  nPDF(int idBeamIn = 2212, PDFPtr protonPDFPtrIn = 0) : PDF(idBeamIn), ruv(),
1064  rdv(), ru(), rd(), rs(), rc(), rb(), rg(), a(), z(), za(), na(),
1065  protonPDFPtr() { initNPDF(protonPDFPtrIn); }
1066 
1067  // Update parton densities.
1068  void xfUpdate(int id, double x, double Q2);
1069 
1070  // Update nuclear modifications.
1071  virtual void rUpdate(int, double, double) = 0;
1072 
1073  // Initialize the nPDF-related members.
1074  void initNPDF(PDFPtr protonPDFPtrIn = 0);
1075 
1076  // Return the number of protons and nucleons.
1077  int getA() {return a;}
1078  int getZ() {return z;}
1079 
1080  // Set (and reset) the ratio of protons to nucleons to study nuclear
1081  // modifications of protons (= 1.0) and neutrons (= 0.0). By default Z/A.
1082  void setMode(double zaIn) { za = zaIn; na = 1. - za; }
1083  void resetMode() { za = double(z)/double(a); na = double(a-z)/double(a); }
1084 
1085 protected:
1086 
1087  // The nuclear modifications for each flavour, modified by derived nPDF
1088  // classes.
1089  double ruv, rdv, ru, rd, rs, rc, rb, rg;
1090 
1091 private:
1092 
1093  // The nuclear mass number and number of protons (charge) and normalized
1094  // number of protons and neutrons.
1095  int a, z;
1096  double za, na;
1097 
1098  // Pointer to (free) proton PDF.
1099  PDFPtr protonPDFPtr;
1100 
1101 };
1102 
1103 //==========================================================================
1104 
1105 // Isospin modification with nuclear beam, i.e. no other modifications
1106 // but correct number of protons and neutrons.
1107 
1108 class Isospin : public nPDF {
1109 
1110 public:
1111 
1112  // Constructor.
1113  Isospin(int idBeamIn = 2212, PDFPtr protonPDFPtrIn = 0)
1114  : nPDF(idBeamIn, protonPDFPtrIn) {}
1115 
1116  // Only the Isospin effect so no need to do anything here.
1117  void rUpdate(int , double , double ) {}
1118 };
1119 
1120 //==========================================================================
1121 
1122 // Nuclear modifications from EPS09 fit.
1123 
1124 class EPS09 : public nPDF {
1125 
1126 public:
1127 
1128  // Constructor.
1129  EPS09(int idBeamIn = 2212, int iOrderIn = 1, int iSetIn = 1,
1130  string pdfdataPath = "../share/Pythia8/pdfdata/",
1131  PDFPtr protonPDFPtrIn = 0, Info* infoPtrIn = 0)
1132  : nPDF(idBeamIn, protonPDFPtrIn), iSet(), iOrder(), grid(),
1133  infoPtr(infoPtrIn) { init(iOrderIn, iSetIn, pdfdataPath);}
1134 
1135  // Update parton densities.
1136  void rUpdate(int id, double x, double Q2);
1137 
1138  // Use other than central set to study uncertainties.
1139  void setErrorSet(int iSetIn) {iSet = iSetIn;}
1140 
1141 private:
1142 
1143  // Parameters related to the fit.
1144  static const double Q2MIN, Q2MAX, XMIN, XMAX, XCUT;
1145  static const int Q2STEPS, XSTEPS;
1146 
1147  // Set parameters and the grid.
1148  int iSet, iOrder;
1149  double grid[31][51][51][8];
1150 
1151  // Pointer to info for possible error messages.
1152  Info* infoPtr;
1153 
1154  // Initialize with given inputs.
1155  void init(int iOrderIn, int iSetIn, string pdfdataPath);
1156 
1157  // Interpolation algorithm.
1158  double polInt(double* fi, double* xi, int n, double x);
1159 };
1160 
1161 //==========================================================================
1162 
1163 // Nuclear modifications from EPPS16 fit.
1164 
1165 class EPPS16 : public nPDF {
1166 
1167 public:
1168 
1169  // Constructor.
1170  EPPS16(int idBeamIn = 2212, int iSetIn = 1,
1171  string pdfdataPath = "../share/Pythia8/pdfdata/",
1172  PDFPtr protonPDFPtrIn = 0, Info* infoPtrIn = 0)
1173  : nPDF(idBeamIn, protonPDFPtrIn), iSet(), grid(), logQ2min(),
1174  loglogQ2maxmin(), logX2min(), infoPtr(infoPtrIn)
1175  { init(iSetIn, pdfdataPath); }
1176 
1177  // Update parton densities.
1178  void rUpdate(int id, double x, double Q2);
1179 
1180  // Use other than central set to study uncertainties.
1181  void setErrorSet(int iSetIn) {iSet = iSetIn;}
1182 
1183 private:
1184 
1185  // Parameters related to the fit.
1186  static const double Q2MIN, Q2MAX, XMIN, XMAX, XCUT;
1187  static const int Q2STEPS, XSTEPS, NINTQ2, NINTX, NSETS;
1188 
1189  // Set parameters and the grid.
1190  int iSet;
1191  double grid[41][31][80][8];
1192  double logQ2min, loglogQ2maxmin, logX2min;
1193 
1194  // Pointer to info for possible error messages.
1195  Info* infoPtr;
1196 
1197  // Initialize with given inputs.
1198  void init(int iSetIn, string pdfdataPath);
1199 
1200  // Interpolation algorithm.
1201  double polInt(double* fi, double* xi, int n, double x);
1202 };
1203 
1204 //==========================================================================
1205 
1206 } // end namespace Pythia8
1207 
1208 #endif // Pythia8_PartonDistributions_H
Definition: rb.hh:21