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