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) 2014 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, 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 
22 #ifndef Pythia8_PartonDistributions_H
23 #define Pythia8_PartonDistributions_H
24 
25 #include "Pythia8/Basics.h"
26 #include "Pythia8/Info.h"
27 #include "Pythia8/ParticleData.h"
28 #include "Pythia8/PythiaStdlib.h"
29 
30 namespace Pythia8 {
31 
32 //==========================================================================
33 
34 // Base class for parton distribution functions.
35 
36 class PDF {
37 
38 public:
39 
40  // Constructor.
41  PDF(int idBeamIn = 2212) {idBeam = idBeamIn; idBeamAbs = abs(idBeam);
42  setValenceContent(); idSav = 9; xSav = -1.; Q2Sav = -1.;
43  xu = 0.; xd = 0.; xs = 0.; xubar = 0.; xdbar = 0.; xsbar = 0.; xc = 0.;
44  xb = 0.; xg = 0.; xlepton = 0.; xgamma = 0.; xuVal = 0.; xuSea = 0.;
45  xdVal = 0.; xdSea = 0.; isSet = true; isInit = false;}
46 
47  // Destructor.
48  virtual ~PDF() {}
49 
50  // Confirm that PDF has been set up (important for LHAPDF and H1 Pomeron).
51  bool isSetup() {return isSet;}
52 
53  // Dynamic choice of meson valence flavours for pi0, K0S, K0L, Pomeron.
54  void newValenceContent(int idVal1In, int idVal2In) {
55  idVal1 = idVal1In; idVal2 = idVal2In;}
56 
57  // Allow extrapolation beyond boundaries. This is optional.
58  virtual void setExtrapolate(bool) {}
59 
60  // Read out parton density
61  double xf(int id, double x, double Q2);
62 
63  // Read out valence and sea part of parton densities.
64  double xfVal(int id, double x, double Q2);
65  double xfSea(int id, double x, double Q2);
66 
67 protected:
68 
69  // Store relevant quantities.
70  int idBeam, idBeamAbs, idSav, idVal1, idVal2;
71  double xSav, Q2Sav;
72  double xu, xd, xs, xubar, xdbar, xsbar, xc, xb, xg, xlepton, xgamma,
73  xuVal, xuSea, xdVal, xdSea;
74  bool isSet, isInit;
75 
76  // Resolve valence content for assumed meson. Possibly modified later.
77  void setValenceContent();
78 
79  // Update parton densities.
80  virtual void xfUpdate(int id, double x, double Q2) = 0;
81 
82 };
83 
84 //==========================================================================
85 
86 // Provide interface to the LHAPDF library of parton densities.
87 
88 class LHAPDF : public PDF {
89 
90 public:
91 
92  // Constructor.
93  LHAPDF(int idBeamIn, string setName, int member, int nSetIn = 1,
94  Info* infoPtr = 0) : PDF(idBeamIn), nSet(nSetIn)
95  {init( setName, member, infoPtr);}
96 
97  // Allow extrapolation beyond boundaries. This is optional.
98  void setExtrapolate(bool extrapol);
99 
100  // Find out the nSet number corresponding to a name and member.
101  // Returns -1 if no such LHAPDF set has been initialized.
102  static int findNSet(string setName, int member);
103 
104  // Return the lowest non-occupied nSet number.
105  static int freeNSet();
106 
107 private:
108 
109  // Initialization of PDF set.
110  void init(string setName, int member, Info* infoPtr);
111 
112  // Update all PDF values.
113  void xfUpdate(int , double x, double Q2);
114 
115  // Current set and pdf values.
116  int nSet;
117  double xfArray[13];
118  bool hasPhoton;
119  double xPhoton;
120 
121  // Keep track of what sets have been initialized in LHAPDFInterface.
122  // The key is the nSet index, the value is a pair (name, member number).
123  static map< int, pair<string, int> > initializedSets;
124 
125 };
126 
127 //==========================================================================
128 
129 // Gives the GRV 94L (leading order) parton distribution function set
130 // in parametrized form. Authors: M. Glueck, E. Reya and A. Vogt.
131 
132 class GRV94L : public PDF {
133 
134 public:
135 
136  // Constructor.
137  GRV94L(int idBeamIn = 2212) : PDF(idBeamIn) {}
138 
139 private:
140 
141  // Update PDF values.
142  void xfUpdate(int , double x, double Q2);
143 
144  // Auxiliary routines used during the updating.
145  double grvv (double x, double n, double ak, double bk, double a,
146  double b, double c, double d);
147  double grvw (double x, double s, double al, double be, double ak,
148  double bk, double a, double b, double c, double d, double e, double es);
149  double grvs (double x, double s, double sth, double al, double be,
150  double ak, double ag, double b, double d, double e, double es);
151 
152 };
153 
154 //==========================================================================
155 
156 // Gives the CTEQ 5L (leading order) parton distribution function set
157 // in parametrized form. Parametrization by J. Pumplin. Authors: CTEQ.
158 
159 class CTEQ5L : public PDF {
160 
161 public:
162 
163  // Constructor.
164  CTEQ5L(int idBeamIn = 2212) : PDF(idBeamIn) {}
165 
166 private:
167 
168  // Update PDF values.
169  void xfUpdate(int , double x, double Q2);
170 
171 };
172 
173 //==========================================================================
174 
175 // The MSTWpdf class.
176 // MRST LO*(*) and MSTW 2008 PDF's, specifically the LO one.
177 // Original C++ version by Jeppe Andersen.
178 // Modified by Graeme Watt <watt(at)hep.ucl.ac.uk>.
179 // Sets available:
180 // iFit = 1 : MRST LO* (2007).
181 // iFit = 2 : MRST LO** (2008).
182 // iFit = 3 : MSTW 2008 LO, central member.
183 // iFit = 4 : MSTW 2008 NLO, central member. (Warning!)
184 
185 class MSTWpdf : public PDF {
186 
187 public:
188 
189  // Constructor.
190  MSTWpdf(int idBeamIn = 2212, int iFitIn = 1, string xmlPath = "../xmldoc/",
191  Info* infoPtr = 0) : PDF(idBeamIn) {init( iFitIn, xmlPath, infoPtr);}
192 
193 private:
194 
195  // Constants: could only be changed in the code itself.
196  static const int np, nx, nq, nqc0, nqb0;
197  static const double xmin, xmax, qsqmin, qsqmax, xxInit[65], qqInit[49];
198 
199  // Data read in from grid file or set at initialization.
200  int iFit, alphaSorder, alphaSnfmax;
201  double mCharm, mBottom, alphaSQ0, alphaSMZ, distance, tolerance,
202  xx[65], qq[49], c[13][64][48][5][5];
203 
204  // Initialization of data array.
205  void init( int iFitIn, string xmlPath, Info* infoPtr);
206 
207  // Update PDF values.
208  void xfUpdate(int , double x, double Q2);
209 
210  // Evaluate PDF of one flavour species.
211  double parton(int flavour,double x,double q);
212  double parton_interpolate(int flavour,double xxx,double qqq);
213  double parton_extrapolate(int flavour,double xxx,double qqq);
214 
215  // Auxiliary routines for evaluation.
216  int locate(double xx[],int n,double x);
217  double polderivative1(double x1, double x2, double x3, double y1,
218  double y2, double y3);
219  double polderivative2(double x1, double x2, double x3, double y1,
220  double y2, double y3);
221  double polderivative3(double x1, double x2, double x3, double y1,
222  double y2, double y3);
223 
224 };
225 
226 //==========================================================================
227 
228 // The CTEQ6pdf class.
229 // Sets available:
230 // iFit = 1 : CTEQ6L
231 // iFit = 2 : CTEQ6L1
232 // iFit = 3 : CTEQ66.00 (NLO, central member)
233 // iFit = 4 : CT09MC1
234 // iFit = 5 : CT09MC2
235 // iFit = 6 : CT09MCS (not yet implemented)
236 
237 class CTEQ6pdf : public PDF {
238 
239 public:
240 
241  // Constructor.
242  CTEQ6pdf(int idBeamIn = 2212, int iFitIn = 1, string xmlPath = "../xmldoc/",
243  Info* infoPtr = 0) : PDF(idBeamIn) {init( iFitIn, xmlPath, infoPtr);}
244 
245 private:
246 
247  // Constants: could only be changed in the code itself.
248  static const double EPSILON, XPOWER;
249 
250  // Data read in from grid file or set at initialization.
251  int iFit, order, nQuark, nfMx, mxVal, nX, nT, nG,
252  iGridX, iGridQ, iGridLX, iGridLQ;
253  double lambda, mQ[7], qIni, qMax, tv[26], xMin, xv[202], upd[57773],
254  xvpow[202], xMinEps, xMaxEps, qMinEps, qMaxEps, fVec[5],
255  tConst[9], xConst[9], xLast, qLast;
256 
257  // Initialization of data array.
258  void init( int iFitIn, string xmlPath, Info* infoPtr);
259 
260  // Update PDF values.
261  void xfUpdate(int id, double x, double Q2);
262 
263  // Evaluate PDF of one flavour species.
264  double parton6(int iParton, double x, double q);
265 
266  // Interpolation in grid.
267  double polint4F(double xgrid[], double fgrid[], double xin);
268 
269 };
270 
271 //==========================================================================
272 
273 // SA Unresolved proton: equivalent photon spectrum from
274 // V.M. Budnev, I.F. Ginzburg, G.V. Meledin and V.G. Serbo,
275 // Phys. Rept. 15 (1974/1975) 181.
276 
277 class ProtonPoint : public PDF {
278 
279 public:
280 
281  // Constructor.
282  ProtonPoint(int idBeamIn = 2212, Info* infoPtrIn = 0) :
283  PDF(idBeamIn), m_infoPtr(infoPtrIn) {}
284 
285 private:
286 
287  // Stored value for PDF choice.
288  static const double ALPHAEM, Q2MAX, Q20, A, B, C;
289 
290  // Update PDF values.
291  void xfUpdate(int , double x, double Q2);
292 
293  // phi function from Q2 integration.
294  double phiFunc(double x, double Q);
295 
296  // Info and errors
297  Info* m_infoPtr;
298 
299 };
300 
301 //==========================================================================
302 
303 // Gives the GRV 1992 pi+ (leading order) parton distribution function set
304 // in parametrized form. Authors: Glueck, Reya and Vogt.
305 
306 class GRVpiL : public PDF {
307 
308 public:
309 
310  // Constructor.
311  GRVpiL(int idBeamIn = 221) : PDF(idBeamIn) {}
312 
313 private:
314 
315  // Update PDF values.
316  void xfUpdate(int , double x, double Q2);
317 
318 };
319 
320 //==========================================================================
321 
322 // Gives generic Q2-independent Pomeron PDF.
323 
324 class PomFix : public PDF {
325 
326 public:
327 
328  // Constructor.
329  PomFix(int idBeamIn = 990, double PomGluonAIn = 0.,
330  double PomGluonBIn = 0., double PomQuarkAIn = 0.,
331  double PomQuarkBIn = 0., double PomQuarkFracIn = 0.,
332  double PomStrangeSuppIn = 0.) : PDF(idBeamIn),
333  PomGluonA(PomGluonAIn), PomGluonB(PomGluonBIn),
334  PomQuarkA(PomQuarkAIn), PomQuarkB(PomQuarkBIn),
335  PomQuarkFrac(PomQuarkFracIn), PomStrangeSupp(PomStrangeSuppIn)
336  {init();}
337 
338 private:
339 
340  // Stored value for PDF choice.
341  double PomGluonA, PomGluonB, PomQuarkA, PomQuarkB, PomQuarkFrac,
342  PomStrangeSupp, normGluon, normQuark;
343 
344  // Initialization of some constants.
345  void init();
346 
347  // Update PDF values.
348  void xfUpdate(int , double x, double);
349 
350 };
351 
352 //==========================================================================
353 
354 // The H1 2006 Fit A and Fit B Pomeron parametrization.
355 // H1 Collaboration, A. Aktas et al., "Measurement and QCD Analysis of
356 // the Diffractive Deep-Inelastic Scattering Cross Section at HERA",
357 // DESY-06-049, Eur. Phys. J. C48 (2006) 715. e-Print: hep-ex/0606004.
358 
359 class PomH1FitAB : public PDF {
360 
361 public:
362 
363  // Constructor.
364  PomH1FitAB(int idBeamIn = 990, int iFit = 1, double rescaleIn = 1.,
365  string xmlPath = "../xmldoc/", Info* infoPtr = 0) : PDF(idBeamIn)
366  {rescale = rescaleIn; init( iFit, xmlPath, infoPtr);}
367 
368 private:
369 
370  // Limits for grid in x, in Q2, and data in (x, Q2).
371  int nx, nQ2;
372  double rescale, xlow, xupp, dx, Q2low, Q2upp, dQ2;
373  double gluonGrid[100][30];
374  double quarkGrid[100][30];
375 
376  // Initialization of data array.
377  void init( int iFit, string xmlPath, Info* infoPtr);
378 
379  // Update PDF values.
380  void xfUpdate(int , double x, double );
381 
382 };
383 
384 //==========================================================================
385 
386 // The H1 2007 Jets Pomeron parametrization..
387 // H1 Collaboration, A. Aktas et al., "Dijet Cross Sections and Parton
388 // Densities in Diffractive DIS at HERA", DESY-07-115, Aug 2007. 33pp.
389 // Published in JHEP 0710:042,2007. e-Print: arXiv:0708.3217 [hep-ex]
390 
391 class PomH1Jets : public PDF {
392 
393 public:
394 
395  // Constructor.
396  PomH1Jets(int idBeamIn = 990, double rescaleIn = 1.,
397  string xmlPath = "../xmldoc/", Info* infoPtr = 0) : PDF(idBeamIn)
398  {rescale = rescaleIn; init( xmlPath, infoPtr);}
399 
400 private:
401 
402  // Arrays for grid in x, in Q2, and data in (x, Q2).
403  double rescale;
404  double xGrid[100];
405  double Q2Grid[88];
406  double gluonGrid[100][88];
407  double singletGrid[100][88];
408  double charmGrid[100][88];
409 
410  // Initialization of data array.
411  void init( string xmlPath, Info* infoPtr);
412 
413  // Update PDF values.
414  void xfUpdate(int id, double x, double );
415 
416 };
417 
418 //==========================================================================
419 
420 // Gives electron (or muon, or tau) parton distribution.
421 
422 class Lepton : public PDF {
423 
424 public:
425 
426  // Constructor.
427  Lepton(int idBeamIn = 11) : PDF(idBeamIn) {}
428 
429 private:
430 
431  // Constants: could only be changed in the code itself.
432  static const double ALPHAEM, ME, MMU, MTAU;
433 
434  // Update PDF values.
435  void xfUpdate(int id, double x, double Q2);
436 
437  // The squared lepton mass, set at initialization.
438  double m2Lep;
439 
440 };
441 
442 //==========================================================================
443 
444 // Gives electron (or other lepton) parton distribution when unresolved.
445 
446 class LeptonPoint : public PDF {
447 
448 public:
449 
450  // Constructor.
451  LeptonPoint(int idBeamIn = 11) : PDF(idBeamIn) {}
452 
453 private:
454 
455  // Update PDF values in trivial way.
456  void xfUpdate(int , double , double ) {xlepton = 1; xgamma = 0.;}
457 
458 };
459 
460 //==========================================================================
461 
462 // Gives neutrino parton distribution when unresolved (only choice for now).
463 // Note factor of 2 since only lefthanded implies no spin averaging.
464 
465 class NeutrinoPoint : public PDF {
466 
467 public:
468 
469  // Constructor.
470  NeutrinoPoint(int idBeamIn = 12) : PDF(idBeamIn) {}
471 
472 private:
473 
474  // Update PDF values, with spin factor of 2.
475  void xfUpdate(int , double , double ) {xlepton = 2; xgamma = 0.;}
476 
477 };
478 
479 //==========================================================================
480 
481 // The NNPDF class.
482 // Sets available:
483 // Leading order QCD+QED Proton PDF sets
484 // iFit = 1 : NNPDF2.3 QCD+QED LO, alphas(MZ) = 0.130
485 // iFit = 2 : NNPDF2.3 QCD+QED LO, alphas(MZ) = 0.119
486 // (Next-to-)Next-to-Leading order QCD+QED Proton PDF sets
487 // iFit = 3 : NNPDF2.3 QCD+QED NLO, alphas(MZ) = 0.119
488 // iFit = 4 : NNPDF2.3 QCD+QED NNLO, alphas(MZ) = 0.119
489 // Code provided by Juan Rojo and Stefano Carrazza.
490 
491 class NNPDF : public PDF {
492 
493 public:
494 
495  // Constructor.
496  NNPDF(int idBeamIn = 2212, int iFitIn = 1, string xmlPath = "../xmldoc/",
497  Info* infoPtr = 0) : PDF(idBeamIn), fPDFGrid(NULL), fXGrid(NULL),
498  fLogXGrid(NULL), fQ2Grid(NULL), fLogQ2Grid(NULL), fRes(NULL) {
499  init( iFitIn, xmlPath, infoPtr); };
500 
501  // Destructor.
502  ~NNPDF() {
503  if (fPDFGrid) {
504  for (int i = 0; i < fNFL; i++) {
505  for (int j = 0; j < fNX; j++)
506  if (fPDFGrid[i][j]) delete[] fPDFGrid[i][j];
507  if (fPDFGrid[i]) delete[] fPDFGrid[i];
508  }
509  delete[] fPDFGrid;
510  }
511  if (fXGrid) delete[] fXGrid;
512  if (fLogXGrid) delete[] fLogXGrid;
513  if (fQ2Grid) delete[] fQ2Grid;
514  if (fLogQ2Grid) delete[] fLogQ2Grid;
515  if (fRes) delete[] fRes;
516  };
517 
518 private:
519 
520  // Constants: could only be changed in the code itself.
521  static const double fXMINGRID;
522 
523  // Number of flavors (including photon) and interpolation parameters.
524  static const int fNFL = 14;
525  static const int fM = 4;
526  static const int fN = 2;
527 
528  // Variables to be set during code initialization.
529  int iFit, fNX, fNQ2;
530  double ***fPDFGrid;
531  double *fXGrid;
532  double *fLogXGrid;
533  double *fQ2Grid;
534  double *fLogQ2Grid;
535  double *fRes;
536 
537  // Initialization of data array.
538  void init( int iFitIn, string xmlPath, Info* infoPtr);
539 
540  // Update PDF values.
541  void xfUpdate(int id, double x, double Q2);
542 
543  // Interpolation in the grid for a given PDF flavour.
544  void xfxevolve(double x, double Q2);
545 
546  // 1D and 2D polynomial interpolation.
547  void polint(double xa[], double ya[], int n, double x,
548  double& y, double& dy);
549  void polin2(double x1a[], double x2a[], double ya[][fN],
550  double x1, double x2, double& y, double& dy);
551 
552 };
553 
554 //==========================================================================
555 
556 } // end namespace Pythia8
557 
558 #endif // Pythia8_PartonDistributions_H