12 #include "Pythia8/PartonDistributions.h"
24 void PDF::setValenceContent() {
27 if ((idBeamAbs < 100 || idBeamAbs > 1000) && idBeamAbs != 22)
return;
28 int idTmp1 = idBeamAbs/100;
29 int idTmp2 = (idBeamAbs/10)%10;
45 if (idBeamAbs == 990) {
51 if (idBeamAbs == 22) {
62 double PDF::xf(
int id,
double x,
double Q2) {
67 if ( (abs(idSav) != abs(
id) && idSav != 9) || x != xSav || Q2 != Q2Sav)
68 {idSav = id; xfUpdate(
id, x, Q2); xSav = x; Q2Sav = Q2;}
71 if (idBeamAbs == 2212) {
72 int idNow = (idBeam > 0) ?
id : -
id;
74 if (idNow == 0 || idAbs == 21)
return max(0., xg);
75 if (idNow == 1)
return max(0., xd);
76 if (idNow == -1)
return max(0., xdbar);
77 if (idNow == 2)
return max(0., xu);
78 if (idNow == -2)
return max(0., xubar);
79 if (idNow == 3)
return max(0., xs);
80 if (idNow == -3)
return max(0., xsbar);
81 if (idAbs == 4)
return max(0., xc);
82 if (idAbs == 5)
return max(0., xb);
83 if (idAbs == 22)
return max(0., xgamma);
87 }
else if (idBeamAbs == 2112) {
88 int idNow = (idBeam > 0) ?
id : -
id;
90 if (idNow == 0 || idAbs == 21)
return max(0., xg);
91 if (idNow == 1)
return max(0., xu);
92 if (idNow == -1)
return max(0., xubar);
93 if (idNow == 2)
return max(0., xd);
94 if (idNow == -2)
return max(0., xdbar);
95 if (idNow == 3)
return max(0., xs);
96 if (idNow == -3)
return max(0., xsbar);
97 if (idAbs == 4)
return max(0., xc);
98 if (idAbs == 5)
return max(0., xb);
99 if (idAbs == 22)
return max(0., xgamma);
104 }
else if (idBeamAbs == 211) {
105 int idNow = (idBeam > 0) ?
id : -
id;
107 if (idNow == 0 || idAbs == 21)
return max(0., xg);
108 if (idNow == 1)
return max(0., xubar );
109 if (idNow == -1)
return max(0., xu );
110 if (idNow == 2)
return max(0., xu);
111 if (idNow == -2)
return max(0., xubar);
112 if (idNow == 3)
return max(0., xs);
113 if (idNow == -3)
return max(0., xsbar);
114 if (idAbs == 4)
return max(0., xc);
115 if (idAbs == 5)
return max(0., xb);
116 if (idAbs == 22)
return max(0., xgamma);
120 }
else if (idBeam == 111 || idBeam == 990) {
122 if (
id == 0 || idAbs == 21)
return max(0., xg);
123 if (
id == idVal1 ||
id == idVal2)
return max(0., xu);
124 if (idAbs <= 2)
return max(0., xubar);
125 if (idAbs == 3)
return max(0., xs);
126 if (idAbs == 4)
return max(0., xc);
127 if (idAbs == 5)
return max(0., xb);
128 if (idAbs == 22)
return max(0., xgamma);
132 }
else if (idBeam == 22) {
134 if (
id == 0 || idAbs == 21)
return max(0., xg);
135 if (
id == 1)
return max(0., xd);
136 if (
id == -1)
return max(0., xdbar);
137 if (
id == 2)
return max(0., xu);
138 if (
id == -2)
return max(0., xubar);
139 if (
id == 3)
return max(0., xs);
140 if (
id == -3)
return max(0., xsbar);
141 if (idAbs == 4)
return max(0., xc);
142 if (idAbs == 5)
return max(0., xb);
143 if (idAbs == 22)
return max(0., xgamma);
147 }
else if ( ( idBeamAbs == 11 || idBeamAbs == 13 || idBeamAbs == 15 )
148 && hasGammaInLepton ) {
150 if (idAbs == 0 || idAbs == 21)
return max(0., xg);
151 if (idAbs == 1)
return max(0., xd);
152 if (idAbs == 2)
return max(0., xu);
153 if (idAbs == 3)
return max(0., xs);
154 if (idAbs == 4)
return max(0., xc);
155 if (idAbs == 5)
return max(0., xb);
156 if (idAbs == 22)
return max(0., xgamma);
160 }
else if ( idBeamAbs > 100000000 ) {
162 if (idAbs == 0 || idAbs == 21)
return max(0., xg);
163 if (
id == 1)
return max(0., xd);
164 if (
id == -1)
return max(0., xdbar);
165 if (
id == 2)
return max(0., xu);
166 if (
id == -2)
return max(0., xubar);
167 if (
id == 3)
return max(0., xs);
168 if (
id == -3)
return max(0., xsbar);
169 if (idAbs == 4)
return max(0., xc);
170 if (idAbs == 5)
return max(0., xb);
171 if (idAbs == 22)
return max(0., xgamma);
176 if (
id == idBeam )
return max(0., xlepton);
177 if (abs(
id) == 22)
return max(0., xgamma);
187 double PDF::xfVal(
int id,
double x,
double Q2) {
192 if ( (abs(idSav) != abs(
id) && idSav != 9) || x != xSav || Q2 != Q2Sav)
193 {idSav = id; xfUpdate(
id, x, Q2); xSav = x; Q2Sav = Q2;}
196 if (idBeamAbs == 2212) {
197 int idNow = (idBeam > 0) ?
id : -
id;
198 if (idNow == 1)
return max(0., xdVal);
199 if (idNow == 2)
return max(0., xuVal);
201 }
else if (idBeamAbs == 2112) {
202 int idNow = (idBeam > 0) ?
id : -
id;
203 if (idNow == 1)
return max(0., xuVal);
204 if (idNow == 2)
return max(0., xdVal);
206 }
else if (idBeamAbs == 211) {
207 int idNow = (idBeam > 0) ?
id : -
id;
208 if (idNow == 2 || idNow == -1)
return max(0., xuVal);
212 }
else if (idBeam == 111 || idBeam == 990) {
213 if (
id == idVal1 ||
id == idVal2)
return max(0., xuVal);
217 }
else if (idBeam == 22) {
219 if (
id == idVal1 ||
id == idVal2) {
220 if (idAbs == 1)
return max(0., xdVal);
221 if (idAbs == 2)
return max(0., xuVal);
222 if (idAbs == 3)
return max(0., xsVal);
223 if (idAbs == 4)
return max(0., xcVal);
224 if (idAbs == 5)
return max(0., xbVal);
230 if (
id == idBeam)
return max(0., xlepton);
240 double PDF::xfSea(
int id,
double x,
double Q2) {
245 if ( (abs(idSav) != abs(
id) && idSav != 9) || x != xSav || Q2 != Q2Sav)
246 {idSav = id; xfUpdate(
id, x, Q2); xSav = x; Q2Sav = Q2;}
249 if (idBeamAbs > 100) {
250 int idNow = (idBeam > 0) ?
id : -
id;
252 if (idNow == 0 || idAbs == 21)
return max(0., xg);
253 if (idBeamAbs == 2212) {
254 if (idNow == 1)
return max(0., xdSea);
255 if (idNow == -1)
return max(0., xdbar);
256 if (idNow == 2)
return max(0., xuSea);
257 if (idNow == -2)
return max(0., xubar);
258 }
else if (idBeamAbs == 2112) {
259 if (idNow == 1)
return max(0., xuSea);
260 if (idNow == -1)
return max(0., xubar);
261 if (idNow == 2)
return max(0., xdSea);
262 if (idNow == -2)
return max(0., xdbar);
264 if (idAbs <= 2)
return max(0., xuSea);
266 if (idNow == 3)
return max(0., xs);
267 if (idNow == -3)
return max(0., xsbar);
268 if (idAbs == 4)
return max(0., xc);
269 if (idAbs == 5)
return max(0., xb);
270 if (idAbs == 22)
return max(0., xgamma);
274 }
else if (idBeamAbs == 22) {
276 if (
id == 0 || idAbs == 21 )
return max(0., xg);
277 if ( idAbs == 22 )
return max(0., xgamma);
281 if (
id == idVal1 ||
id == idVal2 ) {
282 if (idAbs == 1)
return max(0., xdSea);
283 if (idAbs == 2)
return max(0., xuSea);
284 if (idAbs == 3)
return max(0., xsSea);
285 if (idAbs == 4)
return max(0., xcSea);
286 if (idAbs == 5)
return max(0., xbSea);
288 if (idAbs == 1)
return max(0., xd);
289 if (idAbs == 2)
return max(0., xu);
290 if (idAbs == 3)
return max(0., xs);
291 if (idAbs == 4)
return max(0., xc);
292 if (idAbs == 5)
return max(0., xb);
298 if (abs(
id) == 22)
return max(0., xgamma);
312 LHAPDF::LHAPDF(
int idIn,
string pSet, Info* infoPtrIn) :
313 pdfPtr(nullptr), infoPtr(infoPtrIn), libPtr(nullptr) {
317 if (pSet.size() < 8) {
318 printErr(
"Error in LHAPDF::LHAPDF: invalid pSet " + pSet, infoPtr);
321 name = pSet.substr(0, 7);
322 if (name !=
"LHAPDF5" && name !=
"LHAPDF6") {
323 printErr(
"Error in LHAPDF::LHAPDF: invalid pSet " + pSet, infoPtr);
326 name =
"libpythia8lhapdf" + name.substr(6) +
".so";
327 if (infoPtr !=
nullptr) libPtr = infoPtr->plugin(name);
328 else libPtr = make_shared<Plugin>(name);
329 if (!libPtr->isLoaded())
return;
332 string set = pSet.substr(8);
334 size_t pos = set.find_last_of(
"/");
335 if (pos != string::npos) {
336 istringstream memStream(set.substr(pos + 1));
339 set = set.substr(0, pos);
342 NewPDF* newPDF = (NewPDF*)libPtr->symbol(
"newPDF");
344 pdfPtr = newPDF(idIn, set, mem, infoPtr);
354 if (pdfPtr ==
nullptr || !libPtr->isLoaded())
return;
357 DeletePDF* deletePDF = (DeletePDF*)libPtr->symbol(
"deletePDF");
358 if (deletePDF) deletePDF(pdfPtr);
373 void LHAGrid1::init(
string pdfWord,
string pdfdataPath, Info* infoPtr) {
376 if (pdfWord.length() > 9 && toLower(pdfWord).substr(0,9) ==
"lhagrid1:")
377 pdfWord = pdfWord.substr(9, pdfWord.length() - 9);
378 istringstream pdfStream(pdfWord);
383 string dataFile =
"";
384 if ( pdfdataPath[ pdfdataPath.length() - 1 ] !=
'/') pdfdataPath +=
"/";
385 if (pdfWord[0] ==
'/') dataFile = pdfWord;
386 else if (pdfSet == 0) dataFile = pdfdataPath + pdfWord;
390 else if (pdfSet == 13) dataFile = pdfdataPath
391 +
"NNPDF23_lo_as_0130_qed_0000.dat";
392 else if (pdfSet == 14) dataFile = pdfdataPath
393 +
"NNPDF23_lo_as_0119_qed_0000.dat";
394 else if (pdfSet == 15) dataFile = pdfdataPath
395 +
"NNPDF23_nlo_as_0119_qed_0000.dat";
396 else if (pdfSet == 16) dataFile = pdfdataPath
397 +
"NNPDF23_nnlo_as_0119_qed_0000.dat";
398 else if (pdfSet == 17) dataFile = pdfdataPath
399 +
"NNPDF31_lo_as_0130_0000.dat";
400 else if (pdfSet == 18) dataFile = pdfdataPath
401 +
"NNPDF31_lo_as_0118_0000.dat";
402 else if (pdfSet == 19) dataFile = pdfdataPath
403 +
"NNPDF31_nlo_as_0118_luxqed_0000.dat";
404 else if (pdfSet == 20) dataFile = pdfdataPath
405 +
"NNPDF31_nnlo_as_0118_luxqed_0000.dat";
406 else if (pdfSet == 21) dataFile = pdfdataPath
407 +
"NNPDF31sx_nlonllx_as_0118_LHCb_luxqed_0000.dat";
408 else if (pdfSet == 22) dataFile = pdfdataPath
409 +
"NNPDF31sx_nnlonllx_as_0118_LHCb_luxqed_0000.dat";
412 else if (pdfSet == 112) dataFile = pdfdataPath
413 +
"GKG18_DPDF_FitA_LO_0000.dat";
414 else if (pdfSet == 113) dataFile = pdfdataPath
415 +
"GKG18_DPDF_FitB_LO_0000.dat";
416 else if (pdfSet == 114) dataFile = pdfdataPath
417 +
"GKG18_DPDF_FitA_NLO_0000.dat";
418 else if (pdfSet == 115) dataFile = pdfdataPath
419 +
"GKG18_DPDF_FitB_NLO_0000.dat";
422 ifstream is( dataFile.c_str() );
424 printErr(
"Error in LHAGrid1::init: did not find data file", infoPtr);
439 void LHAGrid1::init(istream& is, Info* infoPtr) {
443 printErr(
"Error in LHAGrid1::init: cannot read from stream", infoPtr);
450 vector<string> idlines, pdflines;
451 int nqNow, idNow, idNowMap;
452 double xNow, qNow, pdfNow;
456 do getline( is, line);
457 while (line.find(
"---") == string::npos);
459 printErr(
"Error in LHAGrid1::init: could not read data file", infoPtr);
463 while (getline( is, line)) {
467 istringstream isx(line);
469 while (isx >> xNow) {
470 xGrid.push_back( xNow);
471 lnxGrid.push_back( log(xNow));
474 xMin = xGrid.front();
479 if ( abs(log(xNow) - lnxGrid[++ixc]) > 1e-5) {
480 printErr(
"Error in LHAGrid1::init: mismatched subgrid x spacing",
489 istringstream isq(line);
491 while (isq >> qNow) {
493 qGrid.push_back( qNow);
494 lnqGrid.push_back( log(qNow));
497 if (abs(qGrid[nq] / qGrid[nq-1] - 1.) > 1e-5) {
498 printErr(
"Error in LHAGrid1::init: mismatched subgrid Q borders",
503 qGrid[nq-1] = 0.5 * (qGrid[nq-1] + qGrid[nq]);
504 qGrid[nq] = qGrid[nq-1];
507 qMin = qGrid.front();
510 qDiv.push_back(qMax);
514 idlines.push_back( line);
515 for (
int ixq = 0; ixq < nx * nqNow; ++ixq) {
517 pdflines.push_back( line);
523 for (
int iid = 0; iid < 12; ++iid) {
524 pdfGrid[iid] =
new double*[nq];
525 for (
int iq = 0; iq < nq; ++iq) {
526 pdfGrid[iid][iq] =
new double[nx];
527 for (
int ix = 0; ix < nx; ++ix) pdfGrid[iid][iq][ix] = 0.;
533 for (
int iqSub = 0; iqSub < nqSub; ++iqSub) {
534 vector<int> idGridMap;
537 istringstream isid( idlines[iqSub] );
538 while (isid >> idNow) {
540 if (idNow == 21 || idNow == 0) idNowMap = 0;
541 if (idNow > 0 && idNow < 6) idNowMap = idNow;
542 if (idNow < 0 && idNow > -6) idNowMap = 5 - idNow;
543 if (idNow == 22) idNowMap = 11;
544 idGridMap.push_back( idNowMap);
546 int nid = idGridMap.size();
549 int iq0 = (iqSub == 0) ? 0 : nqSum[iqSub - 1];
550 for (
int ix = 0; ix < nx; ++ix)
551 for (
int iq = iq0; iq < nqSum[iqSub]; ++iq) {
552 istringstream ispdf( pdflines[++iln] );
553 for (
int iid = 0; iid < nid; ++iid) {
555 if (idGridMap[iid] >= 0) pdfGrid[idGridMap[iid]][iq][ix] = pdfNow;
561 pdfSlope =
new double*[12];
562 for (
int iid = 0; iid < 12; ++iid) {
563 pdfSlope[iid] =
new double[nq];
564 for (
int iq = 0; iq < nq; ++iq) { pdfSlope[iid][iq] =
565 ( min( pdfGrid[iid][iq][0], pdfGrid[iid][iq][1]) > 1e-5
566 && abs(lnxGrid[1] - lnxGrid[0]) > 1e-5)
567 ? ( log(pdfGrid[iid][iq][1]) - log(pdfGrid[iid][iq][0]) )
568 / (lnxGrid[1] - lnxGrid[0]) : 0.;
576 void LHAGrid1::xfUpdate(
int ,
double x,
double Q2) {
580 xg = xu = xd = xubar = xdbar = xs = xsbar = xc = xb = xgamma
581 = xuVal = xuSea = xdVal = xdSea = 0.;
596 xc = 0.5 * (pdfVal[4] + pdfVal[9]);
597 xb = 0.5 * (pdfVal[5] + pdfVal[10]);
613 void LHAGrid1::xfxevolve(
double x,
double Q2) {
617 int inx = (x <= xMin) ? -1 : ((x >= xMax) ? 1 : 0);
618 int inq = (q <= qMin) ? -1 : ((q >= qMax) ? 1 : 0);
624 double wx[4] = {1., 1., 1., 1.};
629 while (maxx - minx > 1) {
630 midx = (minx + maxx) / 2;
631 if (x < xGrid[midx]) maxx = midx;
637 if (minx == 0) m3x = 0;
638 else if (maxx == nx - 1) m3x = nx - 4;
640 for (
int i3 = 0; i3 < 4; ++i3)
641 for (
int j = 0; j < 4; ++j)
if (j != i3)
642 wx[i3] *= (lnx - lnxGrid[m3x+j]) / (lnxGrid[m3x+i3] - lnxGrid[m3x+j]);
647 for (
int iqSub = 1; iqSub < nqSub; ++iqSub)
648 if (q > qDiv[iqSub - 1]) iqDiv = iqSub;
649 int minS = (iqDiv == 0) ? 0 : nqSum[iqDiv - 1];
650 int maxS = nqSum[iqDiv] - 1;
655 double wq[4] = {1., 1., 1., 1.};
660 while (maxq - minq > 1) {
661 midq = (minq + maxq) / 2;
662 if (q < qGrid[midq]) maxq = midq;
668 if (maxS - minS < 3) {
671 wq[1] = (lnq - lnqGrid[minq]) / (lnqGrid[maxq] - lnqGrid[minq]);
674 if (minq == minS) m3q = minS;
675 else if (maxq == maxS) m3q = maxS - 3;
677 for (
int i3 = 0; i3 < 4; ++i3)
678 for (
int j = 0; j < 4; ++j)
if (j != i3)
679 wq[i3] *= (lnq - lnqGrid[m3q+j]) / (lnqGrid[m3q+i3] - lnqGrid[m3q+j]);
685 if (inq == 1) m3q = nq - 1;
690 for (
int iid = 0; iid < 12; ++iid) {
691 double **ppdf = pdfGrid[iid] + m3q;
693 for (
int i3q = 0; i3q < n3q; ++i3q) {
694 double *pdf = ppdf[i3q] + m3x;
695 sum0 += wq[i3q] * (wx[0] * pdf[0] + wx[1] * pdf[1] + wx[2] * pdf[2]
702 }
else if (inx == -1) {
703 for (
int iid = 0; iid < 12; ++iid) {
705 for (
int i3q = 0; i3q < n3q; ++i3q)
706 pdfVal[iid] += wq[i3q] * pdfGrid[iid][m3q+i3q][0]
707 * (doExtraPol ? pow( x / xMin, pdfSlope[iid][m3q+i3q]) : 1.);
719 void GRV94L::xfUpdate(
int ,
double x,
double Q2) {
723 double lam2 = 0.2322 * 0.2322;
724 double s = (Q2 > mu2) ? log( log(Q2/lam2) / log(mu2/lam2) ) : 0.;
730 double nu = 2.284 + 0.802 * s + 0.055 * s2;
731 double aku = 0.590 - 0.024 * s;
732 double bku = 0.131 + 0.063 * s;
733 double au = -0.449 - 0.138 * s - 0.076 * s2;
734 double bu = 0.213 + 2.669 * s - 0.728 * s2;
735 double cu = 8.854 - 9.135 * s + 1.979 * s2;
736 double du = 2.997 + 0.753 * s - 0.076 * s2;
737 double uv = grvv (x, nu, aku, bku, au, bu, cu, du);
740 double nd = 0.371 + 0.083 * s + 0.039 * s2;
742 double bkd = 0.486 + 0.062 * s;
743 double ad = -0.509 + 3.310 * s - 1.248 * s2;
744 double bd = 12.41 - 10.52 * s + 2.267 * s2;
745 double cd = 6.373 - 6.208 * s + 1.418 * s2;
746 double dd = 3.691 + 0.799 * s - 0.071 * s2;
747 double dv = grvv (x, nd, akd, bkd, ad, bd, cd, dd);
752 double akx = 0.410 - 0.232 * s;
753 double bkx = 0.534 - 0.457 * s;
754 double agx = 0.890 - 0.140 * s;
756 double cx = 0.320 + 0.683 * s;
757 double dx = 4.752 + 1.164 * s + 0.286 * s2;
758 double ex = 4.119 + 1.713 * s;
759 double esx = 0.682 + 2.978 * s;
760 double udb = grvw (x, s, alx, bex, akx, bkx, agx, bgx, cx,
764 double ne = 0.082 + 0.014 * s + 0.008 * s2;
765 double ake = 0.409 - 0.005 * s;
766 double bke = 0.799 + 0.071 * s;
767 double ae = -38.07 + 36.13 * s - 0.656 * s2;
768 double be = 90.31 - 74.15 * s + 7.645 * s2;
770 double de = 7.486 + 1.217 * s - 0.159 * s2;
771 double del = grvv (x, ne, ake, bke, ae, be, ce, de);
777 double aks = 1.798 - 0.596 * s;
778 double as = -5.548 + 3.669 * ds - 0.616 * s;
779 double bs = 18.92 - 16.73 * ds + 5.168 * s;
780 double dst = 6.379 - 0.350 * s + 0.142 * s2;
781 double est = 3.981 + 1.638 * s;
783 double sb = grvs (x, s, sts, als, bes, aks, as, bs, dst, est, ess);
791 double bc = 4.24 - 0.804 * s;
792 double dct = 3.46 - 1.076 * s;
793 double ect = 4.61 + 1.49 * s;
794 double esc = 2.555 + 1.961 * s;
795 double chm = grvs (x, s, stc, alc, bec, akc, ac, bc, dct, ect, esc);
804 double dbt = 2.929 + 1.396 * s;
805 double ebt = 4.71 + 1.514 * s;
806 double esb = 4.02 + 1.239 * s;
807 double bot = grvs (x, s, stb, alb, beb, akb, ab, bb, dbt, ebt, esb);
812 double akg = 1.742 - 0.930 * s;
813 double bkg = - 0.399 * s2;
814 double ag = 7.486 - 2.185 * s;
815 double bg = 16.69 - 22.74 * s + 5.779 * s2;
816 double cg = -25.59 + 29.71 * s - 7.296 * s2;
817 double dg = 2.792 + 2.215 * s + 0.422 * s2 - 0.104 * s3;
818 double eg = 0.807 + 2.005 * s;
819 double esg = 3.841 + 0.316 * s;
820 double gl = grvw (x, s, alg, beg, akg, bkg, ag, bg, cg,
825 xu = uv + 0.5*(udb - del);
826 xd = dv + 0.5*(udb + del);
827 xubar = 0.5*(udb - del);
828 xdbar = 0.5*(udb + del);
847 double GRV94L::grvv (
double x,
double n,
double ak,
double bk,
double a,
848 double b,
double c,
double d) {
851 return n * pow(x, ak) * (1. + a * pow(x, bk) + x * (b + c * dx)) *
858 double GRV94L::grvw (
double x,
double s,
double al,
double be,
double ak,
859 double bk,
double a,
double b,
double c,
double d,
double e,
double es) {
861 double lx = log(1./x);
862 return (pow(x, ak) * (a + x * (b + x * c)) * pow(lx, bk) + pow(s, al)
863 * exp(-e + sqrt(es * pow(s, be) * lx))) * pow(1. - x, d);
869 double GRV94L::grvs (
double x,
double s,
double sth,
double al,
double be,
870 double ak,
double ag,
double b,
double d,
double e,
double es) {
876 double lx = log(1./x);
877 return pow(s - sth, al) / pow(lx, ak) * (1. + ag * dx + b * x) *
878 pow(1. - x, d) * exp(-e + sqrt(es * pow(s, be) * lx));
893 void CTEQ5L::xfUpdate(
int ,
double x,
double Q2) {
896 double Q = sqrt( max( 1., min( 1e8, Q2) ) );
897 x = max( 1e-6, min( 1.-1e-10, x) );
901 double u = log( x / 0.00001);
903 double x1L = log(1. - x);
904 double sumUbarDbar = 0.;
907 const double Qmin[8] = { 0., 0., 0., 0., 0., 0., 1.3, 4.5};
908 const double alpha[8] = { 0.2987216, 0.3407552, 0.4491863, 0.2457668,
909 0.5293999, 0.3713141, 0.03712017, 0.004952010 };
910 const double ut1[8] = { 4.971265, 2.612618, -0.4656819, 3.862583,
911 0.1895615, 3.753257, 4.400772, 5.562568 };
912 const double ut2[8] = { -1.105128, -1.258304e5, -274.2390, -1.265969,
913 -3.069097, -1.113085, -1.356116, -1.801317 };
914 const double am[8][9][3] = {
916 { { 0.5292616E+01, -0.2751910E+01, -0.2488990E+01 },
917 { 0.9714424E+00, 0.1011827E-01, -0.1023660E-01 },
918 { -0.1651006E+02, 0.7959721E+01, 0.8810563E+01 },
919 { -0.1643394E+02, 0.5892854E+01, 0.9348874E+01 },
920 { 0.3067422E+02, 0.4235796E+01, -0.5112136E+00 },
921 { 0.2352526E+02, -0.5305168E+01, -0.1169174E+02 },
922 { -0.1095451E+02, 0.3006577E+01, 0.5638136E+01 },
923 { -0.1172251E+02, -0.2183624E+01, 0.4955794E+01 },
924 { 0.1662533E-01, 0.7622870E-02, -0.4895887E-03 } },
926 { { 0.9905300E+00, -0.4502235E+00, 0.1624441E+00 },
927 { 0.8867534E+00, 0.1630829E-01, -0.4049085E-01 },
928 { 0.8547974E+00, 0.3336301E+00, 0.1371388E+00 },
929 { 0.2941113E+00, -0.1527905E+01, 0.2331879E+00 },
930 { 0.3384235E+02, 0.3715315E+01, 0.8276930E+00 },
931 { 0.6230115E+01, 0.3134639E+01, -0.1729099E+01 },
932 { -0.1186928E+01, -0.3282460E+00, 0.1052020E+00 },
933 { -0.8545702E+01, -0.6247947E+01, 0.3692561E+01 },
934 { 0.1724598E-01, 0.7120465E-02, 0.4003646E-04 } },
936 { { 0.1193572E+03, -0.3886845E+01, -0.1133965E+01 },
937 { -0.9421449E+02, 0.3995885E+01, 0.1607363E+01 },
938 { 0.4206383E+01, 0.2485954E+00, 0.2497468E+00 },
939 { 0.1210557E+03, -0.3015765E+01, -0.1423651E+01 },
940 { -0.1013897E+03, -0.7113478E+00, 0.2621865E+00 },
941 { -0.1312404E+01, -0.9297691E+00, -0.1562531E+00 },
942 { 0.1627137E+01, 0.4954111E+00, -0.6387009E+00 },
943 { 0.1537698E+00, -0.2487878E+00, 0.8305947E+00 },
944 { 0.2496448E-01, 0.2457823E-02, 0.8234276E-03 } },
946 { { 0.2647441E+02, 0.1059277E+02, -0.9176654E+00 },
947 { 0.1990636E+01, 0.8558918E-01, 0.4248667E-01 },
948 { -0.1476095E+02, -0.3276255E+02, 0.1558110E+01 },
949 { -0.2966889E+01, -0.3649037E+02, 0.1195914E+01 },
950 { -0.1000519E+03, -0.2464635E+01, 0.1964849E+00 },
951 { 0.3718331E+02, 0.4700389E+02, -0.2772142E+01 },
952 { -0.1872722E+02, -0.2291189E+02, 0.1089052E+01 },
953 { -0.1628146E+02, -0.1823993E+02, 0.2537369E+01 },
954 { -0.1156300E+01, -0.1280495E+00, 0.5153245E-01 } },
956 { { -0.6556775E+00, 0.2490190E+00, 0.3966485E-01 },
957 { 0.1305102E+01, -0.1188925E+00, -0.4600870E-02 },
958 { -0.2371436E+01, 0.3566814E+00, -0.2834683E+00 },
959 { -0.6152826E+01, 0.8339877E+00, -0.7233230E+00 },
960 { -0.8346558E+01, 0.2892168E+01, 0.2137099E+00 },
961 { 0.1279530E+02, 0.1021114E+00, 0.5787439E+00 },
962 { 0.5858816E+00, -0.1940375E+01, -0.4029269E+00 },
963 { -0.2795725E+02, -0.5263392E+00, 0.1290229E+01 },
964 { 0.0000000E+00, 0.0000000E+00, 0.0000000E+00 } },
966 { { 0.1580931E+01, -0.2273826E+01, -0.1822245E+01 },
967 { 0.2702644E+01, 0.6763243E+00, 0.7231586E-02 },
968 { -0.1857924E+02, 0.3907500E+01, 0.5850109E+01 },
969 { -0.3044793E+02, 0.2639332E+01, 0.5566644E+01 },
970 { -0.4258011E+01, -0.5429244E+01, 0.4418946E+00 },
971 { 0.3465259E+02, -0.5532604E+01, -0.4904153E+01 },
972 { -0.1658858E+02, 0.2923275E+01, 0.2266286E+01 },
973 { -0.1149263E+02, 0.2877475E+01, -0.7999105E+00 },
974 { 0.0000000E+00, 0.0000000E+00, 0.0000000E+00 } },
976 { { -0.8293661E+00, -0.3982375E+01, -0.6494283E-01 },
977 { 0.2754618E+01, 0.8338636E+00, -0.6885160E-01 },
978 { -0.1657987E+02, 0.1439143E+02, -0.6887240E+00 },
979 { -0.2800703E+02, 0.1535966E+02, -0.7377693E+00 },
980 { -0.6460216E+01, -0.4783019E+01, 0.4913297E+00 },
981 { 0.3141830E+02, -0.3178031E+02, 0.7136013E+01 },
982 { -0.1802509E+02, 0.1862163E+02, -0.4632843E+01 },
983 { -0.1240412E+02, 0.2565386E+02, -0.1066570E+02 },
984 { 0.0000000E+00, 0.0000000E+00, 0.0000000E+00 } },
986 { { -0.6031237E+01, 0.1992727E+01, -0.1076331E+01 },
987 { 0.2933912E+01, 0.5839674E+00, 0.7509435E-01 },
988 { -0.8284919E+01, 0.1488593E+01, -0.8251678E+00 },
989 { -0.1925986E+02, 0.2805753E+01, -0.3015446E+01 },
990 { -0.9480483E+01, -0.9767837E+00, -0.1165544E+01 },
991 { 0.2193195E+02, -0.1788518E+02, 0.9460908E+01 },
992 { -0.1327377E+02, 0.1201754E+02, -0.6277844E+01 },
993 { 0.0000000E+00, 0.0000000E+00, 0.0000000E+00 },
994 { 0.0000000E+00, 0.0000000E+00, 0.0000000E+00 } } };
997 for (
int i = 0; i < 8; ++i) {
999 if (Q > max(Qmin[i], alpha[i])) {
1002 double tmp = log(Q / alpha[i]);
1003 double sb = log(tmp);
1004 double sb1 = sb - 1.2;
1005 double sb2 = sb1*sb1;
1007 for (
int j = 0; j < 9; ++j)
1008 af[j] = am[i][j][0] + sb1 * am[i][j][1] + sb2 * am[i][j][2];
1009 double part1 = af[1] * pow( y, 1. + 0.01 * af[4]) * (1. + af[8] * u);
1010 double part2 = af[0] * x1 + af[3] * x;
1011 double part3 = x * x1 * (af[5] + af[6] * x1 + af[7] * x * x1);
1012 double part4 = (ut2[i] < -100.) ? ut1[i] * x1L + af[2] * x1L
1013 : ut1[i] * x1L + af[2] * log(x1 + exp(ut2[i]));
1014 answer = x * exp( part1 + part2 + part3 + part4);
1015 answer *= 1. - Qmin[i] / Q;
1019 if (i == 0) xd = x * answer;
1020 else if (i == 1) xu = x * answer;
1021 else if (i == 2) xg = x * answer;
1022 else if (i == 3) sumUbarDbar = x * answer;
1023 else if (i == 4) { xubar = sumUbarDbar / (1. + answer);
1024 xdbar = sumUbarDbar * answer / (1. + answer); }
1025 else if (i == 5) {xs = x * answer; xsbar = xs;}
1026 else if (i == 6) xc = x * answer;
1027 else if (i == 7) xb = x * answer;
1055 const int MSTWpdf::np = 12;
1056 const int MSTWpdf::nx = 64;
1057 const int MSTWpdf::nq = 48;
1058 const int MSTWpdf::nqc0 = 4;
1059 const int MSTWpdf::nqb0 = 14;
1062 const double MSTWpdf::xmin = 1e-6;
1063 const double MSTWpdf::xmax = 1.0;
1064 const double MSTWpdf::qsqmin = 1.0;
1065 const double MSTWpdf::qsqmax = 1e9;
1068 const double MSTWpdf::xxInit[65] = {0., 1e-6, 2e-6, 4e-6, 6e-6, 8e-6,
1069 1e-5, 2e-5, 4e-5, 6e-5, 8e-5, 1e-4, 2e-4, 4e-4, 6e-4, 8e-4,
1070 1e-3, 2e-3, 4e-3, 6e-3, 8e-3, 1e-2, 1.4e-2, 2e-2, 3e-2, 4e-2, 6e-2,
1071 8e-2, 0.10, 0.125, 0.15, 0.175, 0.20, 0.225, 0.25, 0.275, 0.30,
1072 0.325, 0.35, 0.375, 0.40, 0.425, 0.45, 0.475, 0.50, 0.525, 0.55,
1073 0.575, 0.60, 0.625, 0.65, 0.675, 0.70, 0.725, 0.75, 0.775, 0.80,
1074 0.825, 0.85, 0.875, 0.90, 0.925, 0.95, 0.975, 1.0 };
1077 const double MSTWpdf::qqInit[49] = {0., 1.0, 1.25, 1.5, 0., 0., 2.5, 3.2,
1078 4.0, 5.0, 6.4, 8.0, 10., 12., 0., 0., 26.0, 40.0, 64.0, 1e2, 1.6e2,
1079 2.4e2, 4e2, 6.4e2, 1e3, 1.8e3, 3.2e3, 5.6e3, 1e4, 1.8e4, 3.2e4, 5.6e4,
1080 1e5, 1.8e5, 3.2e5, 5.6e5, 1e6, 1.8e6, 3.2e6, 5.6e6, 1e7, 1.8e7, 3.2e7,
1081 5.6e7, 1e8, 1.8e8, 3.2e8, 5.6e8, 1e9 };
1087 void MSTWpdf::init(
int iFitIn,
string pdfdataPath, Info* infoPtr) {
1093 if (pdfdataPath[ pdfdataPath.length() - 1 ] !=
'/') pdfdataPath +=
"/";
1094 string fileName =
" ";
1095 if (iFit == 1) fileName =
"mrstlostar.00.dat";
1096 if (iFit == 2) fileName =
"mrstlostarstar.00.dat";
1097 if (iFit == 3) fileName =
"mstw2008lo.00.dat";
1098 if (iFit == 4) fileName =
"mstw2008nlo.00.dat";
1101 ifstream data_file( (pdfdataPath + fileName).c_str() );
1102 if (!data_file.good()) {
1103 printErr(
"Error in MSTWpdf::init: did not find data file ", infoPtr);
1109 init(data_file, infoPtr);
1118 void MSTWpdf::init(istream& data_file, Info* infoPtr) {
1121 if (!data_file.good()) {
1122 printErr(
"Error in MSTWpdf::init: cannot read from stream", infoPtr);
1132 double f[np+1][nx+1][nq+1];
1133 double f1[np+1][nx+1][nq+1];
1134 double f2[np+1][nx+1][nq+1];
1135 double f12[np+1][nx+1][nq+1];
1136 double f21[np+1][nx+1][nq+1];
1137 int wt[16][16]={{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
1138 {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0},
1139 {-3,0,0,3,0,0,0,0,-2,0,0,-1,0,0,0,0},
1140 {2,0,0,-2,0,0,0,0,1,0,0,1,0,0,0,0},
1141 {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
1142 {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
1143 {0,0,0,0,-3,0,0,3,0,0,0,0,-2,0,0,-1},
1144 {0,0,0,0,2,0,0,-2,0,0,0,0,1,0,0,1},
1145 {-3,3,0,0,-2,-1,0,0,0,0,0,0,0,0,0,0},
1146 {0,0,0,0,0,0,0,0,-3,3,0,0,-2,-1,0,0},
1147 {9,-9,9,-9,6,3,-3,-6,6,-6,-3,3,4,2,1,2},
1148 {-6,6,-6,6,-4,-2,2,4,-3,3,3,-3,-2,-1,-1,-2},
1149 {2,-2,0,0,1,1,0,0,0,0,0,0,0,0,0,0},
1150 {0,0,0,0,0,0,0,0,2,-2,0,0,1,1,0,0},
1151 {-6,6,-6,6,-3,-3,3,3,-4,4,2,-2,-2,-2,-1,-1},
1152 {4,-4,4,-4,2,2,-2,-2,2,-2,-2,2,1,1,1,1}};
1153 double xxd,d1d2,cl[16],x[16],d1,d2,y[5],y1[5],y2[5],y12[5];
1154 double mc2,mb2,eps=1e-6;
1160 data_file.ignore(256,
'\n');
1161 data_file.ignore(256,
'\n');
1162 data_file.ignore(256,
'='); data_file >> distance >> tolerance;
1163 data_file.ignore(256,
'='); data_file >> mCharm;
1164 data_file.ignore(256,
'='); data_file >> mBottom;
1165 data_file.ignore(256,
'='); data_file >> alphaSQ0;
1166 data_file.ignore(256,
'='); data_file >> alphaSMZ;
1167 data_file.ignore(256,
'='); data_file >> alphaSorder >> comma >> alphaSnfmax;
1168 data_file.ignore(256,
'='); data_file >> nExtraFlavours;
1169 data_file.ignore(256,
'\n');
1170 data_file.ignore(256,
'\n');
1171 data_file.ignore(256,
'\n');
1174 for (
int iqq = 0; iqq < 49; ++iqq) qq[iqq] = qqInit[iqq];
1176 mb2=mBottom*mBottom;
1183 if (mc2 < qq[3] || mc2 > qq[6]) {
1184 printErr(
"Error in MSTWpdf::init: invalid mCharm", infoPtr);
1188 if (mb2 < qq[13] || mb2 > qq[16]) {
1189 printErr(
"Error in MSTWpdf::init: invalid mBottom", infoPtr);
1197 if (nExtraFlavours < 0 || nExtraFlavours > 1) {
1198 printErr(
"Error in MSTWpdf::init: invalid nExtraFlavours", infoPtr);
1204 for (n=1;n<=nx-1;n++)
1205 for (m=1;m<=nq;m++) {
1207 data_file >> f[i][n][m];
1208 if (alphaSorder==2) {
1209 data_file >> f[10][n][m];
1210 data_file >> f[11][n][m];
1216 if (nExtraFlavours>0)
1217 data_file >> f[12][n][m];
1220 if (data_file.eof()) {
1221 printErr(
"Error in MSTWpdf::init: could not read data stream",
1230 if (!data_file.eof()) {
1231 printErr(
"Error in MSTWpdf::init: could not read data stream", infoPtr);
1243 xx[i]=log10(xxInit[i]);
1248 for (i=1;i<=np;i++) {
1252 for (m=1;m<=nq;m++) {
1253 f1[i][1][m]=polderivative1(xx[1],xx[2],xx[3],f[i][1][m],f[i][2][m],
1257 f1[i][k][m]=polderivative2(xx[k-1],xx[k],xx[k+1],f[i][k-1][m],
1258 f[i][k][m],f[i][k+1][m]);
1260 f1[i][nx][m]=polderivative3(xx[nx-2],xx[nx-1],xx[nx],f[i][nx-2][m],
1261 f[i][nx-1][m],f[i][nx][m]);
1268 for (m=1;m<=nq;m++) {
1269 if (m==1 || m==nqc0+1 || m==nqb0+1) {
1271 f2[i][k][m]=polderivative1(qq[m],qq[m+1],qq[m+2],
1272 f[i][k][m],f[i][k][m+1],f[i][k][m+2]);
1274 else if (m==nq || m==nqc0 || m==nqb0) {
1276 f2[i][k][m]=polderivative3(qq[m-2],qq[m-1],qq[m],
1277 f[i][k][m-2],f[i][k][m-1],f[i][k][m]);
1282 f2[i][k][m]=polderivative2(qq[m-1],qq[m],qq[m+1],
1283 f[i][k][m-1],f[i][k][m],f[i][k][m+1]);
1294 f12[i][1][m]=polderivative1(xx[1],xx[2],xx[3],f2[i][1][m],
1295 f2[i][2][m],f2[i][3][m]);
1297 for (k=2;k<nx;k++) {
1299 f12[i][k][m]=polderivative2(xx[k-1],xx[k],xx[k+1],f2[i][k-1][m],
1300 f2[i][k][m],f2[i][k+1][m]);
1304 f12[i][nx][m]=polderivative3(xx[nx-2],xx[nx-1],xx[nx],
1305 f2[i][nx-2][m],f2[i][nx-1][m],f2[i][nx][m]);
1308 for (m=1;m<=nq;m++) {
1309 if (m==1 || m==nqc0+1 || m==nqb0+1) {
1311 f21[i][k][m]=polderivative1(qq[m],qq[m+1],qq[m+2],
1312 f1[i][k][m],f1[i][k][m+1],f1[i][k][m+2]);
1314 else if (m==nq || m==nqc0 || m==nqb0) {
1316 f21[i][k][m]=polderivative3(qq[m-2],qq[m-1],qq[m],
1317 f1[i][k][m-2],f1[i][k][m-1],f1[i][k][m]);
1322 f21[i][k][m]=polderivative2(qq[m-1],qq[m],qq[m+1],
1323 f1[i][k][m-1],f1[i][k][m],f1[i][k][m+1]);
1328 for (k=1;k<=nx;k++) {
1329 for (m=1;m<=nq;m++) {
1330 f12[i][k][m] = 0.5*(f12[i][k][m]+f21[i][k][m]);
1335 for (n=1;n<=nx-1;n++) {
1336 for (m=1;m<=nq-1;m++) {
1343 y[3]=f[i][n+1][m+1];
1347 y1[2]=f1[i][n+1][m];
1348 y1[3]=f1[i][n+1][m+1];
1349 y1[4]=f1[i][n][m+1];
1352 y2[2]=f2[i][n+1][m];
1353 y2[3]=f2[i][n+1][m+1];
1354 y2[4]=f2[i][n][m+1];
1356 y12[1]=f12[i][n][m];
1357 y12[2]=f12[i][n+1][m];
1358 y12[3]=f12[i][n+1][m+1];
1359 y12[4]=f12[i][n][m+1];
1361 for (k=1;k<=4;k++) {
1365 x[k+11]=y12[k]*d1d2;
1368 for (l=0;l<=15;l++) {
1370 for (k=0;k<=15;k++) xxd+= wt[l][k]*x[k];
1376 for (j=1;j<=4;j++) c[i][n][m][k][j]=cl[l++];
1387 void MSTWpdf::xfUpdate(
int ,
double x,
double Q2) {
1390 double q = sqrtpos(Q2);
1392 double dn = parton(1,x,q);
1393 double up = parton(2,x,q);
1394 double str = parton(3,x,q);
1395 double chm = parton(4,x,q);
1396 double bot = parton(5,x,q);
1398 double dnv = parton(7,x,q);
1399 double upv = parton(8,x,q);
1400 double sv = parton(9,x,q);
1401 double cv = parton(10,x,q);
1402 double bv = parton(11,x,q);
1404 double dsea = dn - dnv;
1405 double usea = up - upv;
1406 double sbar = str - sv;
1407 double cbar = chm - cv;
1408 double bbar = bot - bv;
1410 double glu = parton(0,x,q);
1412 double phot = parton(13,x,q);
1422 xc = 0.5 * (chm + cbar);
1423 xb = 0.5 * (bot + bbar);
1441 double MSTWpdf::parton(
int f,
double x,
double q) {
1446 double parton_pdf=0,parton_pdf1=0,anom;
1452 if (qsq>pow(10.,qq[nqc0]) && qsq<pow(10.,qq[nqc0+1])) {
1453 qsq = pow(10.,qq[nqc0+1]);
1457 if (qsq>pow(10.,qq[nqb0]) && qsq<pow(10.,qq[nqb0+1])) {
1458 qsq = pow(10.,qq[nqb0+1]);
1463 if (x<=0.)
return 0.;
1465 else if (x>xmax)
return 0.;
1469 if (q<=0.)
return 0.;
1471 else if (qsq>qsqmax) {
1476 else if (f>=1 && f<=5) ip=f+1;
1477 else if (f<=-1 && f>=-5) ip=-f+1;
1478 else if (f>=7 && f<=11) ip=f;
1479 else if (f==13) ip=12;
1480 else if (abs(f)==6 || f==12)
return 0.;
1487 if (interpolate==1) {
1488 parton_pdf=parton_interpolate(ip,xxx,qqq);
1490 parton_pdf -= parton_interpolate(ip+5,xxx,qqq);
1492 else if (interpolate==-1) {
1495 parton_pdf = parton_extrapolate(ip,xxx,log10(qsqmin));
1496 parton_pdf1 = parton_extrapolate(ip,xxx,log10(1.01*qsqmin));
1498 parton_pdf -= parton_extrapolate(ip+5,xxx,log10(qsqmin));
1499 parton_pdf1 -= parton_extrapolate(ip+5,xxx,log10(1.01*qsqmin));
1503 parton_pdf = parton_interpolate(ip,xxx,log10(qsqmin));
1504 parton_pdf1 = parton_interpolate(ip,xxx,log10(1.01*qsqmin));
1506 parton_pdf -= parton_interpolate(ip+5,xxx,log10(qsqmin));
1507 parton_pdf1 -= parton_interpolate(ip+5,xxx,log10(1.01*qsqmin));
1516 if (abs(parton_pdf) >= 1.e-5)
1517 anom = max(-2.5, (parton_pdf1-parton_pdf)/parton_pdf/0.01);
1519 parton_pdf = parton_pdf*pow(qsq/qsqmin,anom*qsq/qsqmin+1.-qsq/qsqmin);
1523 parton_pdf = parton_extrapolate(ip,xxx,qqq);
1525 parton_pdf -= parton_extrapolate(ip+5,xxx,qqq);
1535 double MSTWpdf::parton_interpolate(
int ip,
double xxx,
double qqq) {
1540 n=locate(xx,nx,xxx);
1541 m=locate(qq,nq,qqq);
1543 t=(xxx-xx[n])/(xx[n+1]-xx[n]);
1544 u=(qqq-qq[m])/(qq[m+1]-qq[m]);
1548 double g0=((c[ip][n][m][1][4]*u+c[ip][n][m][1][3])*u
1549 +c[ip][n][m][1][2])*u+c[ip][n][m][1][1];
1550 double g1=((c[ip][n-1][m][1][4]*u+c[ip][n-1][m][1][3])*u
1551 +c[ip][n-1][m][1][2])*u+c[ip][n-1][m][1][1];
1553 if (g0>0.0&&g1>0.0) p = log(g1/g0)/log((xx[n+1]-xx[n-1])/(xx[n+1]-xx[n]));
1555 g=g0*pow((xx[n+1]-xxx)/(xx[n+1]-xx[n]),p);
1561 for (l=4;l>=1;l--) {
1562 g=t*g+((c[ip][n][m][l][4]*u+c[ip][n][m][l][3])*u
1563 +c[ip][n][m][l][2])*u+c[ip][n][m][l][1];
1575 double MSTWpdf::parton_extrapolate(
int ip,
double xxx,
double qqq) {
1577 double parton_pdf=0.;
1580 n=locate(xx,nx,xxx);
1581 m=locate(qq,nq,qqq);
1583 if (n==0&&(m>0&&m<nq)) {
1586 f0=parton_interpolate(ip,xx[1],qqq);
1587 f1=parton_interpolate(ip,xx[2],qqq);
1588 if ( f0>1e-3 && f1>1e-3 ) {
1591 parton_pdf=exp(f0+(f1-f0)/(xx[2]-xx[1])*(xxx-xx[1]));
1593 parton_pdf=f0+(f1-f0)/(xx[2]-xx[1])*(xxx-xx[1]);
1595 }
else if (n>0&&m==nq) {
1598 f0=parton_interpolate(ip,xxx,qq[nq]);
1599 f1=parton_interpolate(ip,xxx,qq[nq-1]);
1600 if ( f0>1e-3 && f1>1e-3 ) {
1603 parton_pdf=exp(f0+(f0-f1)/(qq[nq]-qq[nq-1])*(qqq-qq[nq]));
1605 parton_pdf=f0+(f0-f1)/(qq[nq]-qq[nq-1])*(qqq-qq[nq]);
1607 }
else if (n==0&&m==nq) {
1610 f0=parton_extrapolate(ip,xx[1],qqq);
1611 f1=parton_extrapolate(ip,xx[2],qqq);
1612 if ( f0>1e-3 && f1>1e-3 ) {
1615 parton_pdf=exp(f0+(f1-f0)/(xx[2]-xx[1])*(xxx-xx[1]));
1617 parton_pdf=f0+(f1-f0)/(xx[2]-xx[1])*(xxx-xx[1]);
1630 int MSTWpdf::locate(
double xloc[],
int n,
double x) {
1640 if (x==xloc[1]) j=1;
1641 else if (x==xloc[n]) j=n-1;
1652 double MSTWpdf::polderivative1(
double x1,
double x2,
double x3,
double y1,
1653 double y2,
double y3) {
1655 return (x3*x3*(y1-y2)+2.0*x1*(x3*(-y1+y2)+x2*(y1-y3))+x2*x2*(-y1+y3)
1656 +x1*x1*(-y2+y3))/((x1-x2)*(x1-x3)*(x2-x3));
1665 double MSTWpdf::polderivative2(
double x1,
double x2,
double x3,
double y1,
1666 double y2,
double y3) {
1668 return (x3*x3*(y1-y2)-2.0*x2*(x3*(y1-y2)+x1*(y2-y3))+x2*x2*(y1-y3)
1669 +x1*x1*(y2-y3))/((x1-x2)*(x1-x3)*(x2-x3));
1678 double MSTWpdf::polderivative3(
double x1,
double x2,
double x3,
double y1,
1679 double y2,
double y3) {
1681 return (x3*x3*(-y1+y2)+2.0*x2*x3*(y1-y3)+x1*x1*(y2-y3)+x2*x2*(-y1+y3)
1682 +2.0*x1*x3*(-y2+y3))/((x1-x2)*(x1-x3)*(x2-x3));
1696 const double CTEQ6pdf::EPSILON = 1e-6;
1699 const double CTEQ6pdf::XPOWER = 0.3;
1705 void CTEQ6pdf::init(
int iFitIn,
string pdfdataPath, Info* infoPtr) {
1711 if (pdfdataPath[ pdfdataPath.length() - 1 ] !=
'/') pdfdataPath +=
"/";
1712 string fileName =
" ";
1713 if (iFit == 1) fileName =
"cteq6l.tbl";
1714 if (iFit == 2) fileName =
"cteq6l1.tbl";
1715 if (iFit == 3) fileName =
"ctq66.00.pds";
1716 if (iFit == 4) fileName =
"ct09mc1.pds";
1717 if (iFit == 5) fileName =
"ct09mc2.pds";
1718 if (iFit == 6) fileName =
"ct09mcs.pds";
1720 if (iFit == 11) fileName =
"pomactwb14.pds";
1721 if (iFit == 12) fileName =
"pomactwd14.pds";
1722 if (iFit == 13) fileName =
"pomactwsg14.pds";
1723 if (iFit == 14) fileName =
"pomactwd19.pds";
1724 bool isPdsGrid = (iFit > 2);
1727 ifstream pdfgrid( (pdfdataPath + fileName).c_str() );
1728 if (!pdfgrid.good()) {
1729 printErr(
"Error in CTEQ6pdf::init: did not find data file", infoPtr);
1735 init( pdfgrid, isPdsGrid, infoPtr);
1744 void CTEQ6pdf::init(istream& pdfgrid,
bool isPdsGrid, Info* infoPtr) {
1747 if (!pdfgrid.good()) {
1748 printErr(
"Error in CTEQ6pdf::init: cannot read from stream", infoPtr);
1755 double orderTmp, nQTmp, qTmp, rDum;
1757 getline( pdfgrid, line);
1758 getline( pdfgrid, line);
1759 getline( pdfgrid, line);
1760 istringstream is1(line);
1761 is1 >> orderTmp >> nQTmp >> lambda >> mQ[1] >> mQ[2] >> mQ[3]
1762 >> mQ[4] >> mQ[5] >> mQ[6];
1763 order = int(orderTmp + 0.5);
1764 nQuark = int(nQTmp + 0.5);
1765 getline( pdfgrid, line);
1769 getline( pdfgrid, line);
1770 istringstream is2(line);
1771 is2 >> iDum >> iDum >> iDum >> nfMx >> mxVal >> iDum;
1772 if (mxVal > 4) mxVal = 3;
1773 getline( pdfgrid, line);
1774 getline( pdfgrid, line);
1775 istringstream is3(line);
1776 is3 >> nX >> nT >> iDum >> nG >> iDum;
1777 for (
int i = 0; i < nG + 2; ++i) getline( pdfgrid, line);
1778 getline( pdfgrid, line);
1779 istringstream is4(line);
1780 is4 >> qIni >> qMax;
1781 for (
int iT = 0; iT <= nT; ++iT) {
1782 getline( pdfgrid, line);
1783 istringstream is5(line);
1785 tv[iT] = log( log( qTmp/lambda));
1787 getline( pdfgrid, line);
1788 getline( pdfgrid, line);
1789 istringstream is6(line);
1790 is6 >> xMin >> rDum;
1793 for (
int iXrng = 0; iXrng < int( (nX + nPackX - 1) / nPackX); ++iXrng) {
1794 getline( pdfgrid, line);
1795 istringstream is7(line);
1796 for (
int iX = nPackX * iXrng + 1; iX <= nPackX * (iXrng + 1); ++iX)
1797 if (iX <= nX) is7 >> xv[iX];
1804 getline( pdfgrid, line);
1805 istringstream is2(line);
1806 is2 >> nX >> nT >> nfMx;
1807 getline( pdfgrid, line);
1808 getline( pdfgrid, line);
1809 istringstream is3(line);
1810 is3 >> qIni >> qMax;
1812 for (
int iTrng = 0; iTrng < int( (nT + nPackT) / nPackT); ++iTrng) {
1813 getline( pdfgrid, line);
1814 istringstream is4(line);
1815 for (
int iT = nPackT * iTrng; iT < nPackT * (iTrng + 1); ++iT)
1818 tv[iT] = log( log( qTmp / lambda) );
1821 getline( pdfgrid, line);
1822 getline( pdfgrid, line);
1823 istringstream is5(line);
1826 for (
int iXrng = 0; iXrng < int( (nX + nPackX) / nPackX); ++iXrng) {
1827 getline( pdfgrid, line);
1828 istringstream is6(line);
1829 for (
int iX = nPackX * iXrng; iX < nPackX * (iXrng + 1); ++iX)
1830 if (iX <= nX) is6 >> xv[iX];
1835 getline( pdfgrid, line);
1836 int nBlk = (nX + 1) * (nT + 1);
1837 int nPts = nBlk * (nfMx + 1 + mxVal);
1838 int nPack = (isPdsGrid) ? 6 : 5;
1839 for (
int iRng = 0; iRng < int( (nPts + nPack - 1) / nPack); ++iRng) {
1840 getline( pdfgrid, line);
1841 istringstream is8(line);
1842 for (
int i = nPack * iRng + 1; i <= nPack * (iRng + 1); ++i)
1843 if (i <= nPts) is8 >> upd[i];
1848 for (
int iX = 1; iX <= nX; ++iX) xvpow[iX] = pow(xv[iX], XPOWER);
1851 xMinEps = xMin * (1. + EPSILON);
1852 xMaxEps = 1. - EPSILON;
1853 qMinEps = qIni * (1. + EPSILON);
1854 qMaxEps = qMax * (1. - EPSILON);
1866 void CTEQ6pdf::xfUpdate(
int ,
double x,
double Q2) {
1869 double xEps = doExtraPol ? x : max( xMinEps, x);
1870 double qEps = max( qMinEps, min( qMaxEps, sqrtpos(Q2) ) );
1873 double glu = xEps * parton6( 0, xEps, qEps);
1875 double bot = (iFit > 10) ? 0. : xEps * parton6( 5, xEps, qEps);
1876 double chm = (iFit > 10) ? 0. : xEps * parton6( 4, xEps, qEps);
1877 double str = xEps * parton6( 3, xEps, qEps);
1878 double usea = xEps * parton6(-1, xEps, qEps);
1879 double dsea = xEps * parton6(-2, xEps, qEps);
1881 double upv = xEps * parton6( 1, xEps, qEps) - usea;
1882 double dnv = xEps * parton6( 2, xEps, qEps) - dsea;
1885 if (iFit < 10) rescale = 1.;
1889 xu = rescale * (upv + usea);
1890 xd = rescale * (dnv + dsea);
1891 xubar = rescale * usea;
1892 xdbar = rescale * dsea;
1894 xsbar = rescale * str;
1900 xuVal = rescale * upv;
1901 xuSea = rescale * usea;
1902 xdVal = rescale * dnv;
1903 xdSea = rescale * dsea;
1914 double CTEQ6pdf::parton6(
int iParton,
double x,
double q) {
1917 if (x > xMaxEps)
return 0.;
1918 int iP = (iParton > mxVal) ? -iParton : iParton;
1919 double ss = pow( x, XPOWER);
1920 double tt = log( log(q / lambda) );
1923 if (x != xLast || q != qLast) {
1930 while (ju - iGridLX > 1 && jm >= 0) {
1931 jm = (ju + iGridLX) / 2;
1932 if (x >= xv[jm]) iGridLX = jm;
1937 if (iGridLX <= -1)
return 0.;
1938 else if (iGridLX == 0) iGridX = 0;
1939 else if (iGridLX <= nX - 2) iGridX = iGridLX - 1;
1940 else if (iGridLX == nX - 1) iGridX = iGridLX - 2;
1944 if (iGridLX > 1 && iGridLX < nX - 1) {
1945 double svec1 = xvpow[iGridX];
1946 double svec2 = xvpow[iGridX+1];
1947 double svec3 = xvpow[iGridX+2];
1948 double svec4 = xvpow[iGridX+3];
1949 double s12 = svec1 - svec2;
1950 double s13 = svec1 - svec3;
1951 xConst[8] = svec2 - svec3;
1952 double s24 = svec2 - svec4;
1953 double s34 = svec3 - svec4;
1954 xConst[6] = ss - svec2;
1955 xConst[7] = ss - svec3;
1956 xConst[0] = s13 / xConst[8];
1957 xConst[1] = s12 / xConst[8];
1958 xConst[2] = s34 / xConst[8];
1959 xConst[3] = s24 / xConst[8];
1960 double s1213 = s12 + s13;
1961 double s2434 = s24 + s34;
1962 double sdet = s12 * s34 - s1213 * s2434;
1963 double tmp = xConst[6] * xConst[7] / sdet;
1964 xConst[4] = (s34 * xConst[6] - s2434 * xConst[7]) * tmp / s12;
1965 xConst[5] = (s1213 * xConst[6] - s12 * xConst[7]) * tmp / s34;
1969 dlx = (iGridLX == 0 && doExtraPol)
1970 ? log(x / xv[1]) / log(xv[2] / xv[1]) : 1.;
1977 while (ju - iGridLQ > 1 && jm >= 0) {
1978 jm = (ju + iGridLQ) / 2;
1979 if (tt >= tv[jm]) iGridLQ = jm;
1982 if (iGridLQ == 0) iGridQ = 0;
1983 else if (iGridLQ <= nT - 2) iGridQ = iGridLQ - 1;
1984 else iGridQ = nT - 3;
1987 if (iGridLQ > 0 && iGridLQ < nT - 1) {
1988 double tvec1 = tv[iGridQ];
1989 double tvec2 = tv[iGridQ+1];
1990 double tvec3 = tv[iGridQ+2];
1991 double tvec4 = tv[iGridQ+3];
1992 double t12 = tvec1 - tvec2;
1993 double t13 = tvec1 - tvec3;
1994 tConst[8] = tvec2 - tvec3;
1995 double t24 = tvec2 - tvec4;
1996 double t34 = tvec3 - tvec4;
1997 tConst[6] = tt - tvec2;
1998 tConst[7] = tt - tvec3;
1999 double tmp1 = t12 + t13;
2000 double tmp2 = t24 + t34;
2001 double tdet = t12 * t34 - tmp1 * tmp2;
2002 tConst[0] = t13 / tConst[8];
2003 tConst[1] = t12 / tConst[8];
2004 tConst[2] = t34 / tConst[8];
2005 tConst[3] = t24 / tConst[8];
2006 tConst[4] = (t34 * tConst[6] - tmp2 * tConst[7]) / t12
2007 * tConst[6] * tConst[7] / tdet;
2008 tConst[5] = (tmp1 * tConst[6] - t12 * tConst[7]) / t34
2009 * tConst[6] * tConst[7] / tdet;
2018 int jtmp = ( (iP + nfMx) * (nT + 1) + (iGridQ - 1) ) * (nX + 1) + iGridX + 1;
2022 for(
int it = 1; it <= 4; ++it) {
2023 int j1 = jtmp + it * (nX + 1);
2024 if (iGridLX == 0 && doExtraPol) {
2025 fVec[it] = upd[j1+1] * pow( upd[j1+2] / upd[j1+1], dlx );
2026 }
else if (iGridX == 0) {
2029 fij[2] = upd[j1+1] * pow2(xv[1]);
2030 fij[3] = upd[j1+2] * pow2(xv[2]);
2031 fij[4] = upd[j1+3] * pow2(xv[3]);
2032 double fX = polint4F( &xvpow[0], &fij[1], ss);
2033 fVec[it] = (x > 0.) ? fX / pow2(x) : 0.;
2034 }
else if (iGridLX==nX-1) {
2035 fVec[it] = polint4F( &xvpow[nX-3], &upd[j1], ss);
2037 double sf2 = upd[j1+1];
2038 double sf3 = upd[j1+2];
2039 double g1 = sf2 * xConst[0] - sf3 * xConst[1];
2040 double g4 = -sf2 * xConst[2] + sf3 * xConst[3];
2041 fVec[it] = (xConst[4] * (upd[j1] - g1) + xConst[5] * (upd[j1+3] - g4)
2042 + sf2 * xConst[7] - sf3 * xConst[6]) / xConst[8];
2048 if( iGridLQ <= 0 ) {
2049 ff = polint4F( &tv[0], &fVec[1], tt);
2050 }
else if (iGridLQ >= nT - 1) {
2051 ff=polint4F( &tv[nT-3], &fVec[1], tt);
2053 double tf2 = fVec[2];
2054 double tf3 = fVec[3];
2055 double g1 = tf2 * tConst[0] - tf3 * tConst[1];
2056 double g4 = -tf2 * tConst[2] + tf3 * tConst[3];
2057 ff = (tConst[4] * (fVec[1] - g1) + tConst[5] * (fVec[4] - g4)
2058 + tf2 * tConst[7] - tf3 * tConst[6]) / tConst[8];
2071 double CTEQ6pdf::polint4F(
double xa[],
double ya[],
double x) {
2073 double y, h1, h2, h3, h4, w, den, d1, c1, d2, c2, d3, c3, cd1, cc1,
2082 den = w / (h1 - h2);
2087 den = w / (h2 - h3);
2092 den = w / (h3 - h4);
2097 den = w / (h1 - h3);
2102 den = w / (h2 - h4);
2107 den = w / (h1 - h4);
2111 if (h3 + h4 < 0.) y = ya[3] + d3 + cd2 + dd1;
2112 else if (h2 + h3 < 0.) y = ya[2] + d2 + cd1 + dc1;
2113 else if (h1 + h2 < 0.) y = ya[1] + c2 + cd1 + dc1;
2114 else y = ya[0] + c1 + cc1 + dc1;
2127 const double ProtonPoint::ALPHAEM = 0.00729735;
2128 const double ProtonPoint::Q2MAX = 2.0;
2129 const double ProtonPoint::Q20 = 0.71;
2130 const double ProtonPoint::A = 7.16;
2131 const double ProtonPoint::B = -3.96;
2132 const double ProtonPoint::C = 0.028;
2138 void ProtonPoint::xfUpdate(
int ,
double x,
double ) {
2141 double tmpQ2Min = 0.88 * pow2(x) / (1. - x);
2142 double phiMax = phiFunc(x, Q2MAX / Q20);
2143 double phiMin = phiFunc(x, tmpQ2Min / Q20);
2147 if (phiMax < phiMin) {
2148 printErr(
"Error in ProtonPoint::xfUpdate: phiMax - phiMin < 0!",
2152 fgm = (ALPHAEM / M_PI) * (1 - x) * (phiMax - phiMin);
2182 double ProtonPoint::phiFunc(
double x,
double Q) {
2184 double tmpV = 1. + Q;
2187 for (
int k=1; k<4; ++k) {
2188 tmpSum1 += 1. / (k * pow(tmpV, k));
2189 tmpSum2 += pow(B, k) / (k * pow(tmpV, k));
2192 double tmpY = pow2(x) / (1 - x);
2193 double funVal = (1 + A * tmpY) * (-1.*log(tmpV / Q) + tmpSum1)
2194 + (1 - B) * tmpY / (4 * Q * pow(tmpV, 3))
2195 + C * (1 + tmpY/4.)* (log((tmpV - B)/tmpV) + tmpSum2);
2209 const double Proton2gammaDZ::ALPHAEM = 0.00729735080;
2210 const double Proton2gammaDZ::Q20 = 0.71;
2217 void Proton2gammaDZ::xfUpdate(
int ,
double x,
double Q2 ) {
2220 double FQ4 = 1. / pow4( 1 + Q2 / Q20 );
2221 double fgm = 0.5 * ALPHAEM / M_PI * (1. + pow2(1. - x)) / Q2 * FQ4;
2255 const double Nucleus2gamma::ALPHAEM = 0.00729735080;
2259 void Nucleus2gamma::initNucleus() {
2262 a = (idBeam/10) % 1000;
2263 z = (idBeam/10000) % 1000;
2268 void Nucleus2gamma::xfUpdate(
int ,
double x,
double ) {
2271 double xi = x * mNucleon * bMin / HBARC;
2272 double bK0 = besselK0(xi);
2273 double bK1 = besselK1(xi);
2274 double intB = xi * bK1 * bK0 - 0.5 * pow2(xi) * ( pow2(bK1) - pow2(bK0) );
2275 xgamma = 2. * ALPHAEM * pow2(z) / M_PI * intB;
2306 void GRVpiL::xfUpdate(
int ,
double x,
double Q2) {
2310 double lam2 = 0.232 * 0.232;
2311 double s = (Q2 > mu2) ? log( log(Q2/lam2) / log(mu2/lam2) ) : 0.;
2314 double xL = -log(x);
2315 double xS = sqrt(x);
2318 double uv = (0.519 + 0.180 * s - 0.011 * s2) * pow(x, 0.499 - 0.027 * s)
2319 * (1. + (0.381 - 0.419 * s) * xS) * pow(x1, 0.367 + 0.563 * s);
2322 double gl = ( pow(x, 0.482 + 0.341 * sqrt(s))
2323 * ( (0.678 + 0.877 * s - 0.175 * s2) + (0.338 - 1.597 * s) * xS
2324 + (-0.233 * s + 0.406 * s2) * x) + pow(s, 0.599)
2325 * exp(-(0.618 + 2.070 * s) + sqrt(3.676 * pow(s, 1.263) * xL) ) )
2326 * pow(x1, 0.390 + 1.053 * s);
2329 double ub = pow(s, 0.55) * (1. - 0.748 * xS + (0.313 + 0.935 * s) * x)
2330 * pow(x1, 3.359) * exp(-(4.433 + 1.301 * s) + sqrt((9.30 - 0.887 * s)
2331 * pow(s, 0.56) * xL) ) / pow(xL, 2.538 - 0.763 * s);
2334 double chm = (s < 0.888) ? 0. : pow(s - 0.888, 1.02) * (1. + 1.008 * x)
2335 * pow(x1, 1.208 + 0.771 * s) * exp(-(4.40 + 1.493 * s)
2336 + sqrt( (2.032 + 1.901 * s) * pow(s, 0.39) * xL) );
2339 double bot = (s < 1.351) ? 0. : pow(s - 1.351, 1.03)
2340 * pow(x1, 0.697 + 0.855 * s) * exp(-(4.51 + 1.490 * s)
2341 + sqrt( (3.056 + 1.694 * s) * pow(s, 0.39) * xL) );
2345 xu = rescale * (uv + ub);
2347 xubar = rescale * ub;
2348 xdbar = rescale * (uv + ub);
2350 xsbar = rescale * ub;
2355 xuVal = rescale * uv;
2356 xuSea = rescale * ub;
2357 xdVal = rescale * uv;
2358 xdSea = rescale * ub;
2373 void PomFix::init() {
2375 normGluon = GammaReal(PomGluonA + PomGluonB + 2.)
2376 / (GammaReal(PomGluonA + 1.) * GammaReal(PomGluonB + 1.));
2377 normQuark = GammaReal(PomQuarkA + PomQuarkB + 2.)
2378 / (GammaReal(PomQuarkA + 1.) * GammaReal(PomQuarkB + 1.));
2386 void PomFix::xfUpdate(
int ,
double x,
double) {
2389 double gl = normGluon * pow(x, PomGluonA) * pow( (1. - x), PomGluonB);
2390 double qu = normQuark * pow(x, PomQuarkA) * pow( (1. - x), PomQuarkB);
2393 xg = (1. - PomQuarkFrac) * gl;
2394 xu = (PomQuarkFrac / (4. + 2. * PomStrangeSupp) ) * qu;
2398 xs = PomStrangeSupp * xu;
2422 void PomH1FitAB::init(
int iFit,
string pdfdataPath, Info* infoPtr) {
2425 if (pdfdataPath[ pdfdataPath.length() - 1 ] !=
'/') pdfdataPath +=
"/";
2426 string dataFile =
"pomH1FitBlo.data";
2427 if (iFit == 1) dataFile =
"pomH1FitA.data";
2428 if (iFit == 2) dataFile =
"pomH1FitB.data";
2429 ifstream is( (pdfdataPath + dataFile).c_str() );
2431 printErr(
"Error in PomH1FitAB::init: did not find data file", infoPtr);
2437 init( is, infoPtr );
2446 void PomH1FitAB::init( istream& is, Info* infoPtr) {
2450 printErr(
"Error in PomH1FitAB::init: cannot read from stream", infoPtr);
2459 dx = log(xupp / xlow) / (nx - 1.);
2463 dQ2 = log(Q2upp / Q2low) / (nQ2 - 1.);
2466 for (
int i = 0; i < nx; ++i)
2467 for (
int j = 0; j < nQ2; ++j)
2468 is >> quarkGrid[i][j];
2471 for (
int i = 0; i < nx; ++i)
2472 for (
int j = 0; j < nQ2; ++j)
2473 is >> gluonGrid[i][j];
2477 printErr(
"Error in PomH1FitAB::init: could not read data stream",
2491 void PomH1FitAB::xfUpdate(
int ,
double x,
double Q2) {
2494 double xt = min( xupp, max( xlow, x) );
2495 double Q2t = min( Q2upp, max( Q2low, Q2) );
2498 double dlx = log( xt / xlow) / dx;
2499 int i = min( nx - 2,
int(dlx) );
2501 double dlQ2 = log( Q2t / Q2low) / dQ2;
2502 int j = min( nQ2 - 2,
int(dlQ2) );
2507 if (x < xlow && doExtraPol) {
2508 dlx = log( x / xlow) / dx;
2509 qu = (1. - dlQ2) * quarkGrid[0][j]
2510 * pow( quarkGrid[1][j] / quarkGrid[0][j], dlx)
2511 + dlQ2 * quarkGrid[0][j + 1]
2512 * pow( quarkGrid[1][j + 1] / quarkGrid[0][j + 1], dlx);
2513 gl = (1. - dlQ2) * gluonGrid[0][j]
2514 * pow( gluonGrid[1][j] / gluonGrid[0][j], dlx)
2515 + dlQ2 * gluonGrid[0][j + 1]
2516 * pow( gluonGrid[1][j + 1] / gluonGrid[0][j + 1], dlx);
2520 qu = (1. - dlx) * (1. - dlQ2) * quarkGrid[i][j]
2521 + dlx * (1. - dlQ2) * quarkGrid[i + 1][j]
2522 + (1. - dlx) * dlQ2 * quarkGrid[i][j + 1]
2523 + dlx * dlQ2 * quarkGrid[i + 1][j + 1];
2526 gl = (1. - dlx) * (1. - dlQ2) * gluonGrid[i][j]
2527 + dlx * (1. - dlQ2) * gluonGrid[i + 1][j]
2528 + (1. - dlx) * dlQ2 * gluonGrid[i][j + 1]
2529 + dlx * dlQ2 * gluonGrid[i + 1][j + 1];
2562 void PomH1Jets::init(
int ,
string pdfdataPath, Info* infoPtr) {
2565 if (pdfdataPath[ pdfdataPath.length() - 1 ] !=
'/') pdfdataPath +=
"/";
2566 ifstream is( (pdfdataPath +
"pomH1Jets.data").c_str() );
2568 printErr(
"Error in PomH1Jets::init: did not find data file", infoPtr);
2583 void PomH1Jets::init( istream& is, Info* infoPtr) {
2587 printErr(
"Error in PomH1Jets::init: cannot read from stream", infoPtr);
2593 for (
int i = 0; i < 100; ++i) {
2594 is >> setw(13) >> xGrid[i];
2596 for (
int j = 0; j < 88; ++j) {
2597 is >> setw(13) >> Q2Grid[j];
2598 Q2Grid[j] = log( Q2Grid[j] );
2602 for (
int j = 0; j < 88; ++j) {
2603 for (
int i = 0; i < 100; ++i) {
2604 is >> setw(13) >> gluonGrid[i][j];
2609 for (
int j = 0; j < 88; ++j) {
2610 for (
int i = 0; i < 100; ++i) {
2611 is >> setw(13) >> singletGrid[i][j];
2616 for (
int j = 0; j < 88; ++j) {
2617 for (
int i = 0; i < 100; ++i) {
2618 is >> setw(13) >> charmGrid[i][j];
2624 printErr(
"Error in PomH1Jets::init: could not read data file", infoPtr);
2636 void PomH1Jets::xfUpdate(
int ,
double x,
double Q2) {
2639 double xLog = log(x);
2642 if (xLog <= xGrid[0]);
2643 else if (xLog >= xGrid[99]) {
2647 while (xLog > xGrid[i]) ++i;
2649 dx = (xLog - xGrid[i]) / (xGrid[i + 1] - xGrid[i]);
2653 double Q2Log = log(Q2);
2656 if (Q2Log <= Q2Grid[0]);
2657 else if (Q2Log >= Q2Grid[87]) {
2661 while (Q2Log > Q2Grid[j]) ++j;
2663 dQ2 = (Q2Log - Q2Grid[j]) / (Q2Grid[j + 1] - Q2Grid[j]);
2668 if (xLog < xGrid[0] && doExtraPol) {
2669 double dlx = (xLog - xGrid[0]) / (xGrid[1] - xGrid[0]) ;
2670 gl = (1. - dQ2) * gluonGrid[0][j]
2671 * pow( gluonGrid[1][j] / gluonGrid[0][j], dlx)
2672 + dQ2 * gluonGrid[0][j + 1]
2673 * pow( gluonGrid[1][j + 1] / gluonGrid[0][j + 1], dlx);
2674 sn = (1. - dQ2) * singletGrid[0][j]
2675 * pow( singletGrid[1][j] / singletGrid[0][j], dlx)
2676 + dQ2 * singletGrid[0][j + 1]
2677 * pow( singletGrid[1][j + 1] / singletGrid[0][j + 1], dlx);
2678 ch = (1. - dQ2) * charmGrid[0][j]
2679 * pow( charmGrid[1][j] / charmGrid[0][j], dlx)
2680 + dQ2 * charmGrid[0][j + 1]
2681 * pow( charmGrid[1][j + 1] / charmGrid[0][j + 1], dlx);
2685 gl = (1. - dx) * (1. - dQ2) * gluonGrid[i][j]
2686 + dx * (1. - dQ2) * gluonGrid[i + 1][j]
2687 + (1. - dx) * dQ2 * gluonGrid[i][j + 1]
2688 + dx * dQ2 * gluonGrid[i + 1][j + 1];
2691 sn = (1. - dx) * (1. - dQ2) * singletGrid[i][j]
2692 + dx * (1. - dQ2) * singletGrid[i + 1][j]
2693 + (1. - dx) * dQ2 * singletGrid[i][j + 1]
2694 + dx * dQ2 * singletGrid[i + 1][j + 1];
2697 ch = (1. - dx) * (1. - dQ2) * charmGrid[i][j]
2698 + dx * (1. - dQ2) * charmGrid[i + 1][j]
2699 + (1. - dx) * dQ2 * charmGrid[i][j + 1]
2700 + dx * dQ2 * charmGrid[i + 1][j + 1];
2705 xu = rescale * sn / 6.;
2711 xc = rescale * ch * 9./8.;
2729 void PomHISASD::xfUpdate(
int,
double x,
double Q2) {
2732 if ( xPomNow < 0.0 || xPomNow > 1.0 || !pPDFPtr )
2733 printErr(
"Error in PomHISASD::xfUpdate: no xPom available.", infoPtr);
2735 double xx = xPomNow * x;
2736 double fac = newfac * pow(1.0 - x, hixpow) / log(1.0 / xx);
2737 if ( fac == 0.0 ) fac = 1.0;
2739 xd = xdbar = fac * pPDFPtr->xfSea(1, xx, Q2);
2740 xu = xubar = fac * pPDFPtr->xfSea(2, xx, Q2);
2741 xs = xsbar = fac * pPDFPtr->xfSea(3, xx, Q2);
2742 xc = fac * pPDFPtr->xfSea(4, xx, Q2);
2743 xb = fac * pPDFPtr->xfSea(5, xx, Q2);
2744 xg = fac * pPDFPtr->xfSea(21, xx, Q2);
2745 xlepton = xgamma = 0.0;
2763 const double Lepton::ALPHAEM = 0.00729735;
2764 const double Lepton::ME = 0.0005109989;
2765 const double Lepton::MMU = 0.10566;
2766 const double Lepton::MTAU = 1.77699;
2768 void Lepton::xfUpdate(
int id,
double x,
double Q2) {
2773 if (abs(
id) == 13) mLep = MMU;
2774 if (abs(
id) == 15) mLep = MTAU;
2775 m2Lep = pow2( mLep );
2781 double xLog = log(max(1e-10,x));
2782 double xMinusLog = log( max(1e-10, 1. - x) );
2783 double Q2Log = log( max(3., Q2/m2Lep) );
2784 double beta = (ALPHAEM / M_PI) * (Q2Log - 1.);
2785 double delta = 1. + (ALPHAEM / M_PI) * (1.5 * Q2Log + 1.289868)
2786 + pow2(ALPHAEM / M_PI) * (-2.164868 * Q2Log*Q2Log
2787 + 9.840808 * Q2Log - 10.130464);
2788 double fPrel = beta * pow(1. - x, beta - 1.) * sqrtpos( delta )
2789 - 0.5 * beta * (1. + x) + 0.125 * beta*beta * ( (1. + x)
2790 * (-4. * xMinusLog + 3. * xLog) - 4. * xLog / (1. - x) - 5. - x);
2793 if (x > 1. - 1e-10) fPrel = 0.;
2794 else if (x > 1. - 1e-7) fPrel *= pow(1000.,beta) / (pow(1000.,beta) - 1.);
2795 xlepton = x * fPrel;
2798 double sCM = infoPtr->s();
2799 double m2s = 4 * m2Lep / sCM;
2800 double Q2minGamma = 2. * m2Lep * pow2(x)
2801 / ( 1. - x - m2s + sqrt(1. - m2s) * sqrt( pow2(1. - x) - m2s ) );
2802 xgamma = (0.5 * ALPHAEM / M_PI) * (1. + pow2(1. - x))
2803 * log( Q2maxGamma / Q2minGamma );
2819 const double CJKL::ALPHAEM = 0.007297353080;
2820 const double CJKL::Q02 = 0.25;
2821 const double CJKL::Q2MIN = 0.05;
2822 const double CJKL::Q2REF = 1.0;
2823 const double CJKL::LAMBDA = 0.221;
2824 const double CJKL::MC = 1.3;
2825 const double CJKL::MB = 4.3;
2829 void CJKL::xfUpdate(
int ,
double x,
double Q2) {
2832 double lambda2 = pow2(LAMBDA);
2837 bool belowRef = (Q2 < Q2REF);
2838 if ( belowRef) Q2 = Q2REF;
2841 double s = log( log(Q2/lambda2)/log(Q02/lambda2) );
2842 double plLog = 9.0/(4.0*M_PI)*log(Q2/lambda2);
2845 double plGluon = pointlikeG(x,s);
2846 double plUp = pointlikeU(x,s);
2847 double plDown = pointlikeD(x,s);
2848 double plStrange = plDown;
2851 double hlGluon = hadronlikeG(x,s);
2852 double hlVal = hadronlikeVal(x,s);
2853 double hlSea = hadronlikeSea(x,s);
2856 double xMaxC = 1 - 6.76/(6.76 + Q2);
2857 double xMaxB = 1 - 73.96/(73.96 + Q2);
2858 double plCharm = pointlikeC(x*xMaxC,s,Q2)*xMaxC;
2859 double plBottom = pointlikeB(x*xMaxB,s,Q2)*xMaxB;
2860 double hlCharm = hadronlikeC(x*xMaxC,s,Q2)*xMaxC;
2861 double hlBottom = hadronlikeB(x*xMaxB,s,Q2)*xMaxB;
2864 xg = ALPHAEM*( plLog*plGluon + hlGluon );
2865 xu = ALPHAEM*( plLog*plUp + 0.5*hlVal + hlSea );
2866 xd = ALPHAEM*( plLog*plDown + 0.5*hlVal + hlSea );
2869 xs = ALPHAEM*( plLog*plStrange + hlSea );
2871 xc = ALPHAEM*( plLog*plCharm + hlCharm );
2872 xb = ALPHAEM*( plLog*plBottom + hlBottom );
2876 xuVal = ALPHAEM*( plLog*plUp + 0.5*hlVal );
2877 xuSea = ALPHAEM*( hlSea );
2878 xdVal = ALPHAEM*( plLog*plDown + 0.5*hlVal );
2879 xdSea = ALPHAEM*( hlSea );
2880 xsVal = ALPHAEM*( plLog*plStrange );
2881 xsSea = ALPHAEM*( hlSea );
2882 xcVal = ALPHAEM*( plLog*plCharm );
2883 xcSea = ALPHAEM*( hlCharm );
2884 xbVal = ALPHAEM*( plLog*plBottom );
2885 xbSea = ALPHAEM*( hlBottom );
2891 double logApprox = max( log(Q2Save/Q2MIN) / log(Q2REF/Q2MIN ), 0.);
2926 double CJKL::gammaPDFxDependence(
int id,
double) {
2927 if (abs(
id) == 1)
return 0.013 * ALPHAEM;
2928 else if (abs(
id) == 2)
return 0.026 * ALPHAEM;
2929 else if (abs(
id) == 3)
return 0.010 * ALPHAEM;
2930 else if (abs(
id) == 4)
return 0.020 * ALPHAEM;
2931 else if (abs(
id) == 5)
return 0.010 * ALPHAEM;
2941 double CJKL::gammaPDFRefScale(
int id) {
2942 if (abs(
id) == 4)
return pow2(MC);
2943 else if (abs(
id) == 5)
return pow2(MB);
2951 int CJKL::sampleGammaValFlavor(
double Q2) {
2954 if(Q2 < Q02) Q2 = Q02;
2957 double lambda2 = pow2(LAMBDA);
2958 double s = log( log(Q2/lambda2)/log(Q02/lambda2) );
2959 double a = 1.0898 + 0.38087 * s;
2960 double b = 0.42654 - 1.2128 * s;
2961 double c = -1.6576 + 1.7075 * s;
2962 double d = 0.96155 + 1.8441 * s;
2963 double aa = 0.78391 - 0.06872 * s;
2964 double a1 = tgamma(1+aa)*tgamma(1+d)/tgamma(2+aa+d);
2965 double b1 = tgamma(1.5+aa)*tgamma(1+d)/tgamma(2.5+aa+d);
2966 double c1 = tgamma(2+aa)*tgamma(1+d)/tgamma(3+aa+d);
2967 double xfValHad = ALPHAEM*a*(a1 + b*b1 + c*c1);
2970 double mq2[5] = { Q02, Q02, Q02, pow2(MC), pow2(MB) };
2971 double eq2[5] = { 1.0/9.0, 4.0/9.0, 1.0/9.0, 4.0/9.0, 1.0/9.0 };
2974 double qEvo[5] = { xfValHad/2, xfValHad/2, 0, 0, 0 };
2978 double plNorm = 0.000936;
2981 for(
int i = 0;i < 5;++i) {
2982 qEvo[i] += plNorm*eq2[i]*max(0.0,log(Q2/mq2[i]));
2987 double qEvoRand = qEvoTot*rndmPtr->flat();
2988 for(
int i = 0; i < 5; ++i) {
2989 qEvoRand -= qEvo[i];
2990 if(qEvoRand <= 0.0) {
3005 double CJKL::xfIntegratedTotal(
double Q2) {
3008 if(Q2 < Q02) Q2 = Q02;
3014 double fq0[6] = { 0.0018, 0.0006, 0.0006, 0., 0., 0. };
3015 double mq2[6] = { Q02, Q02, Q02, Q02, pow2(MC), pow2(MB) };
3016 double eq2[6] = { 3.0/9.0, 1.0/9.0, 4.0/9.0, 1.0/9.0, 4.0/9.0, 1.0/9.0 };
3017 double a1 = 0.000981;
3021 double xIntegrated = 0;
3022 for(
int i = 0;i < 6;++i) {
3023 xIntegrated += fq0[i] + 2*a1*eq2[i]*max(0.0,log(Q2/mq2[i]));
3034 double CJKL::pointlikeG(
double x,
double s) {
3037 double alpha1 = -0.43865;
3038 double alpha2 = 2.7174;
3039 double beta = 0.36752;
3042 double a = 0.086893 - 0.34992 * s;
3043 double b = 0.010556 + 0.049525 * s;
3044 double c = -0.099005 + 0.34830 * s;
3045 double d = 1.0648 + 0.143421 * s;
3046 double e = 3.6717 + 2.5071 * s;
3047 double f = 2.1944 + 1.9358 * s;
3048 double aa = 0.23679 - 0.11849 * s;
3049 double bb = -0.19994 + 0.028124 * s;
3052 return max(0.0,( pow(s,alpha1)*pow(x,aa)*( a + b*sqrt(x) + c*pow(x,bb) )
3053 + pow(s,alpha2)*exp( -e + sqrt( f*pow(s,beta)*log(1.0/x) ) ) )
3061 double CJKL::pointlikeU(
double x,
double s) {
3064 double alpha1 = -1.0711;
3065 double alpha2 = 3.1320;
3066 double beta = 0.69243;
3069 double a = -0.058266 + 0.20506 * s;
3070 double b = 0.0097377 - 0.10617 * s;
3071 double c = -0.0068345 + 0.15211 * s;
3072 double d = 0.22297 + 0.013567 * s;
3073 double e = 6.4289 + 2.2802 * s;
3074 double f = 1.7302 + 0.76997 * s;
3075 double aa = 0.87940 - 0.110241 * s;
3076 double bb = 2.6878 - 0.040252 * s;
3079 return max(0.0, ( pow(s,alpha1)*pow(x,aa)*( a + b*sqrt(x) + c*pow(x,bb) )
3080 + pow(s,alpha2)*exp( -e + sqrt( f*pow(s,beta)*log(1.0/x) ) ) )
3088 double CJKL::pointlikeD(
double x,
double s) {
3091 double alpha1 = -1.1357;
3092 double alpha2 = 3.1187;
3093 double beta = 0.66290;
3096 double a = 0.098814 - 0.067300 * s;
3097 double b = -0.092892 + 0.049949 * s;
3098 double c = -0.0066140 + 0.020427 * s;
3099 double d = -0.31385 - 0.0037558 * s;
3100 double e = 6.4671 + 2.2834 * s;
3101 double f = 1.6996 + 0.84262 * s;
3102 double aa = 11.777 + 0.034760 * s;
3103 double bb = -11.124 - 0.20135 * s;
3106 if(x > 0.995) x = 0.995;
3109 return max( 0.0, ( pow(s,alpha1)*pow(x,aa)*( a + b*sqrt(x) + c*pow(x,bb) )
3110 + pow(s,alpha2)*exp( -e + sqrt( f*pow(s,beta)*log(1.0/x) ) ) )
3118 double CJKL::pointlikeC(
double x,
double s,
double Q2) {
3121 double y = x + 1 - Q2/(Q2 + 6.76);
3124 if (y >= 1.0)
return 0;
3127 double alpha1, alpha2, beta, a, b, c, d, e, f, aa, bb;
3138 a = -0.18826 + 0.13565 * s;
3139 b = 0.18508 - 0.11764 * s;
3140 c = -0.0014153 - 0.011510 * s;
3141 d = -0.48961 + 0.18810 * s;
3142 e = 0.20911 - 2.8544 * s + 14.256 *s*s;
3143 f = 2.7644 + 0.93717 * s;
3144 aa = -7.6307 + 5.6807 * s;
3145 bb = 394.58 - 541.82 * s + 200.82 *s*s;
3156 a = -0.54831 + 0.33412 * s;
3157 b = 0.19484 + 0.041562 * s;
3158 c = -0.39046 + 0.37194 * s;
3159 d = 0.12717 + 0.059280 * s;
3160 e = 8.7191 + 3.0194 * s;
3161 f = 4.2616 + 0.73993 * s;
3162 aa = -0.30307 + 0.29430 * s;
3163 bb = 7.2383 - 1.5995 * s;
3167 return max( 0.0, ( pow(s,alpha1)*pow(y,aa)*( a + b*sqrt(y) + c*pow(y,bb) )
3168 + pow(s,alpha2)*exp( -e + sqrt( f*pow(s,beta)*log(1.0/x) ) ) )
3176 double CJKL::pointlikeB(
double x,
double s,
double Q2) {
3179 double y = x + 1 - Q2/(Q2 + 73.96);
3182 if (y >= 1.0)
return 0;
3185 double alpha1, alpha2, beta, a, b, c, d, e, f, aa, bb;
3196 a = -0.26971 + 0.17942 * s;
3197 b = 0.27033 - 0.18358 * s + 0.0061059 *s*s;
3198 c = 0.0022862 - 0.0016837 * s;
3199 d = 0.30807 - 0.10490 * s;
3200 e = 14.812 - 1.2977 * s;
3201 f = 1.7148 + 2.3532 * s + 0.053734 *sqrt(s);
3202 aa = 3.8140 - 1.0514 * s;
3203 bb = 2.2292 + 20.194 * s;
3214 a = -0.72790 + 0.36549 * s;
3215 b = -0.62903 + 0.56817 * s;
3216 c = -2.4467 + 1.6783 * s;
3217 d = 0.56575 - 0.19120 * s;
3218 e = 1.4687 + 9.6071 * s;
3219 f = 1.1706 + 0.99674 * s;
3220 aa = -0.084651 - 0.083206 * s;
3221 bb = 9.6036 - 3.4864 * s;
3225 return max( 0.0, ( pow(s,alpha1)*pow(y,aa)*( a + b*sqrt(y) + c*pow(y,bb) )
3226 + pow(s,alpha2)*exp( -e + sqrt( f*pow(s,beta)*log(1.0/x) ) ) )
3234 double CJKL::hadronlikeG(
double x,
double s) {
3237 double alpha = 0.59945;
3238 double beta = 1.1285;
3241 double a = -0.19898 + 0.57414 * s;
3242 double b = 1.9942 - 1.8306 * s;
3243 double c = -1.9848 + 1.4136 * s;
3244 double d = 0.21294 + 2.7450 * s;
3245 double e = 1.2287 + 2.4447 * s;
3246 double f = 4.9230 + 0.18526 * s;
3247 double aa = -0.34948 + 0.47058 * s;
3250 return max( 0.0, pow(1-x,d)*( pow(x,aa)*( a + b*sqrt(x) + c*x )
3251 + pow(s,alpha)*exp( -e + sqrt( f*pow(s,beta)*log(1.0/x) ) ) ) );
3258 double CJKL::hadronlikeVal(
double x,
double s) {
3261 double a = 1.0898 + 0.38087 * s;
3262 double b = 0.42654 - 1.2128 * s;
3263 double c = -1.6576 + 1.7075 * s;
3264 double d = 0.96155 + 1.8441 * s;
3265 double aa = 0.78391 - 0.068720 * s;
3268 return max( 0.0, pow(1-x,d)*pow(x,aa)*a*( 1 + b*sqrt(x) + c*x ) );
3275 double CJKL::hadronlikeSea(
double x,
double s) {
3278 double alpha = 0.71660;
3279 double beta = 1.0497;
3282 double a = 0.60478 + 0.036160 * s;
3283 double b = 4.2106 - 0.85835 * s;
3284 double d = 4.1494 + 0.34866 * s;
3285 double e = 4.5179 + 1.9219 * s;
3286 double f = 5.2812 - 0.15200 * s;
3287 double aa = 0.72289 - 0.21562 * s;
3290 double logx = log(1.0/x);
3293 return max( 0.0, pow(1-x,d)*pow(s,alpha)*( 1 + a*sqrt(x) + b*x )
3294 * exp( -e + sqrt( f*pow(s,beta)*logx ) )*pow(logx,-aa) );
3301 double CJKL::hadronlikeC(
double x,
double s,
double Q2) {
3304 double y = x + 1 - Q2/(Q2 + 6.76);
3307 if (y >= 1.0)
return 0;
3310 double logx = log(1.0/x);
3313 double alpha, beta, a, b, d, e, f, aa;
3323 a = -2586.4 + 1910.1 * s;
3324 b = 2695.0 - 1688.2 * s;
3325 d = 1.5146 + 3.1028 * s;
3326 e = -3.9185 + 11.738 * s;
3327 f = 3.6126 - 1.0291 * s;
3328 aa = 1.6248 - 0.70433 * s;
3338 a = -2.0561 + 0.75576 * s;
3339 b = 2.1266 + 0.66383 * s;
3340 d = 3.0301 - 1.7499 * s + 1.6466 *s*s;
3341 e = 4.1282 + 1.6929 * s - 0.26292 *s*s;
3342 f = 0.89599 + 1.2761 * s - 0.15061 *s*s;
3343 aa = -0.78809 + 0.90278 * s;
3348 return max( 0.0, pow(1-y,d)*pow(s,alpha)*( 1 + a*sqrt(y) + b*y )
3349 * exp( -e + f*sqrt( pow(s,beta)*logx ) )*pow(logx,-aa) );
3356 double CJKL::hadronlikeB(
double x,
double s,
double Q2) {
3359 double y = x + 1 - Q2/(Q2 + 73.96);
3362 if (y >= 1.0)
return 0;
3365 double logx = log(1.0/x);
3368 double alpha, beta, a, b, d, e, f, aa;
3378 a = -99.613 + 171.25 * s;
3379 b = 492.61 - 420.45 * s;
3380 d = 3.3917 + 0.084256 * s;
3381 e = 5.6829 - 0.23571 * s;
3382 f = -2.0137 + 4.6955 * s;
3383 aa = 0.82278 + 0.081818 * s;
3393 a = -2.1109 + 1.2711 * s;
3394 b = 9.0196 - 3.6082 * s;
3395 d = 3.6455 - 4.1353 * s + 2.3615 *s*s;
3396 e = 4.6196 + 2.4212 * s;
3397 f = 0.66454 + 1.1109 * s;
3398 aa = -0.98933 + 0.42366 * s + 0.15817 *s*s;
3402 return max( 0.0, pow(1-y,d)*pow(s,alpha)*( 1 + a*sqrt(y) + b*y )
3403 * exp( -e + f*sqrt( pow(s,beta)*logx ) )*pow(logx,-aa) );
3415 const double Lepton2gamma::ALPHAEM = 0.007297353080;
3416 const double Lepton2gamma::Q2MIN = 1.;
3422 void Lepton2gamma::xfUpdate(
int ,
double x,
double Q2) {
3425 double sCM = infoPtr->s();
3426 double xGamMax = ( 2. - 2. * Q2max / sCM - 8. * m2lepton / sCM )
3427 / ( 1. + sqrt( (1. + 4. * m2lepton / Q2max) * (1. - 4. * m2lepton/sCM) ) );
3430 if ( x > xGamMax ) {
3445 double log2x = pow2( log( Q2max / (m2lepton * pow2(x)) ) );
3446 double log2xMax = pow2( log( Q2max / (m2lepton * pow2(xGamMax)) ) );
3449 if ( sampleXgamma) {
3450 xGm = sqrt( (Q2max / m2lepton)
3451 * exp( -sqrt( log2x + rndmPtr->flat() * (log2xMax - log2x) ) ) );
3455 double xInGamma = x/xGm;
3456 double xgGm = gammaPDFPtr->xf(21, xInGamma, Q2);
3457 double xdGm = gammaPDFPtr->xf(1 , xInGamma, Q2);
3458 double xuGm = gammaPDFPtr->xf(2 , xInGamma, Q2);
3459 double xsGm = gammaPDFPtr->xf(3 , xInGamma, Q2);
3460 double xcGm = gammaPDFPtr->xf(4 , xInGamma, Q2);
3461 double xbGm = gammaPDFPtr->xf(5 , xInGamma, Q2);
3464 double m2s = 4. * m2lepton / sCM;
3465 double Q2min = 2. * m2lepton * pow2(xGm)
3466 / ( 1. - xGm - m2s + sqrt(1. - m2s) * sqrt( pow2(1. - xGm) - m2s ) );
3469 double alphaLog = (ALPHAEM / (2. * M_PI)) * (1. + pow2(1. - xGm) )
3470 * 0.25 * (log2x - log2xMax) * log(Q2max / Q2min)
3471 / log( Q2max / ( m2lepton * pow2(xGm) ) );
3474 xg = alphaLog * xgGm;
3475 xd = alphaLog * xdGm;
3476 xu = alphaLog * xuGm;
3477 xs = alphaLog * xsGm;
3478 xc = alphaLog * xcGm;
3479 xb = alphaLog * xbGm;
3497 double Lepton2gamma::xfMax(
int id,
double x,
double Q2) {
3500 double sCM = infoPtr->s();
3501 double xGamMax = ( 2. - 2. * Q2max / sCM - 8. * m2lepton / sCM )
3502 / ( 1. + sqrt( (1. + 4. * m2lepton / Q2max) * (1. - 4. * m2lepton/sCM) ) );
3505 if ( x > xGamMax )
return 0;
3508 double log2x = pow2( log( Q2max / (m2lepton * pow2(x)) ) );
3509 double log2xMax = pow2( log( Q2max / (m2lepton * pow2(xGamMax)) ) );
3512 double xApprox = 0.;
3513 int idAbs = abs(
id);
3514 if (idAbs == 21 || idAbs == 0) xApprox = 2.35;
3515 else if (idAbs == 1) xApprox = (pow(x, 0.2) + pow(1. - x, -0.15)) * 0.8;
3516 else if (idAbs == 2) xApprox = (pow(x, 1.0) + pow(1. - x, -0.4)) * 0.4;
3517 else if (idAbs == 3) xApprox = (pow(x, 0.2) + pow(1. - x, -0.5)) * 0.5;
3518 else if (idAbs == 4) xApprox = (pow(x, 1.0) + pow(1. - x, -0.4)) * 0.7;
3519 else if (idAbs == 5) xApprox = (pow(x, 0.2) + pow(1. -x, -0.5)) * 0.5;
3523 if ( idAbs == 22 )
return 0;
3526 return (ALPHAEM / (2. * M_PI)) * (log2x - log2xMax) * 0.5
3527 * gammaPDFPtr->xf(
id, x, Q2) / xApprox;
3535 double Lepton2gamma::xfSame(
int id,
double x,
double Q2) {
3536 sampleXgamma =
false;
3537 xfUpdate(
id, x, Q2);
3538 double xfNow = xf(
id, x, Q2);
3539 sampleXgamma =
true;
3547 const double EPAexternal::ALPHAEM = 0.007297353080;
3551 void EPAexternal::init() {
3554 double sCM = pow2(infoPtr->eCM());
3555 double m2s = 4. * m2 / sCM;
3558 xMin = pow2(settingsPtr->parm(
"Photon:Wmin")) / sCM;
3562 approxMode = settingsPtr->mode(
"PDF:beam2gammaApprox");
3565 if (approxMode == 1) {
3568 Q2min = 2. * m2 * pow2(xMin) / ( 1. - xMin - m2s
3569 + sqrt(1. - m2s) * sqrt( pow2(1. - xMin) - m2s) );
3570 Q2max = settingsPtr->parm(
"Photon:Q2max");
3571 xMax = 2. * ( 1. - Q2max / sCM - m2s )
3572 / ( 1. + sqrt( (1. + 4. * m2 / Q2max) * (1. - m2s) ) );
3573 bool sampleQ2 = settingsPtr->flag(
"Photon:sampleQ2");
3576 double ratio, ratioMax = 0.0;
3581 for (
int i = 0; i < 10; ++i) {
3582 double xi = xMin + (xMax - xMin)*i/(10.);
3586 for (
int j = 0; j < 10; ++j) {
3587 double Q2j = Q2min * exp( log(Q2max/Q2min)*j/(10. - 1.0));
3588 ratio = xfFlux(22,xi,Q2j) / xfApprox(22,xi,Q2j);
3589 if (ratio > ratioMax) ratioMax = ratio;
3594 ratio = xfFlux(22,xi) / xf(22,xi,1.);
3595 if (ratio > ratioMax) ratioMax = ratio;
3604 }
else if (approxMode == 2) {
3607 double mBeam = settingsPtr->parm(
"PDF:gammaFluxApprox2bMin");
3608 double bMin = settingsPtr->parm(
"PDF:gammaFluxApprox2mBeam");
3609 xPow = settingsPtr->parm(
"PDF:gammaFluxApprox2xPow");
3610 xCut = settingsPtr->parm(
"PDF:gammaFluxApprox2xCut");
3611 bmhbarc = bMin * mBeam / HBARC;
3614 norm1 = xMin < xCut ? pow(xMin, -1. + xPow) * xfFlux(22,xMin) : 0.0;
3615 norm2 = xMin < xCut ? exp( 2. * bmhbarc * xCut) * xfFlux(22,xCut) / xCut
3616 : exp( 2. * bmhbarc * xMin) * xfFlux(22,xMin) / xMin;
3619 integral1 = xMin < xCut ? norm1 / (1. - xPow)
3620 * ( pow(xCut, 1. - xPow) - pow(xMin, 1. - xPow) ) : 0.;
3621 integral2 = xMin < xCut ? norm2 * 0.5 / bmhbarc
3622 * ( exp(-2. * bmhbarc * xCut) - exp(-2. * bmhbarc) )
3623 : norm2 * 0.5 / bmhbarc
3624 * ( exp(-2. * bmhbarc * xMin) - exp(-2. * bmhbarc) );
3635 void EPAexternal::xfUpdate(
int ,
double x,
double Q2) {
3638 double alphaLog = (approxMode == 1) ?
3639 norm * ALPHAEM / M_PI * log (Q2max/Q2min) : 1.;
3642 if (approxMode == 1) {
3644 }
else if (approxMode == 2) {
3645 if (x < xCut) xgamma = norm1 * pow(x, 1. - xPow);
3646 else xgamma = norm2 * x * exp(-2. * bmhbarc * x);
3650 if (gammaPDFPtr != 0) {
3654 double alphaLogX = 0.;
3657 if (approxMode == 1) {
3658 alphaLogX = alphaLog * log (xMax / xHadr);
3659 }
else if (approxMode == 2) {
3660 double integral1tmp = xHadr < xCut ? norm1 / (1. - xPow)
3661 * ( pow(xCut, 1. - xPow) - pow(xHadr, 1. - xPow) ) : 0.;
3662 double xMinTmp = xHadr < xCut ? xCut : xHadr;
3663 double integral2tmp = norm2 * 0.5 / bmhbarc
3664 * ( exp(-2. * bmhbarc * xMinTmp) - exp(-2. * bmhbarc) );
3665 alphaLogX = integral1tmp + integral2tmp;
3669 xg = alphaLogX * gammaPDFPtr->xf(21, x, Q2);
3670 xd = alphaLogX * gammaPDFPtr->xf( 1, x, Q2);
3671 xu = alphaLogX * gammaPDFPtr->xf( 2, x, Q2);
3672 xs = alphaLogX * gammaPDFPtr->xf( 3, x, Q2);
3673 xc = alphaLogX * gammaPDFPtr->xf( 4, x, Q2);
3674 xb = alphaLogX * gammaPDFPtr->xf( 5, x, Q2);
3689 double EPAexternal::xfApprox(
int ,
double x,
double Q2) {
3692 if (approxMode == 1) {
3693 return norm * ALPHAEM / M_PI / Q2;
3696 }
else if (approxMode == 2) {
3697 if (x < xCut)
return norm1 * pow(x, 1. - xPow);
3698 else return norm2 * x * exp(-2. * bmhbarc * x);
3708 double EPAexternal::xfFlux(
int id,
double x,
double Q2) {
3711 if ( gammaFluxPtr != 0 )
return gammaFluxPtr->xf(
id, x, Q2);
3719 double EPAexternal::xfGamma(
int id,
double x,
double Q2) {
3722 if ( gammaPDFPtr != 0 )
return gammaPDFPtr->xf(
id, x, Q2);
3730 double EPAexternal::sampleXgamma(
double xMinIn) {
3733 double xMinSample = (xMinIn < 0.) ? xMin : xMinIn;
3734 if (approxMode == 1) {
3735 return xMinSample * pow(xMax / xMinSample, rndmPtr->flat());
3738 }
else if (approxMode == 2) {
3741 double integral1tmp = xMinSample < xCut ? norm1 / (1. - xPow)
3742 * ( pow(xCut, 1. - xPow) - pow(xMinSample, 1. - xPow) ) : 0.;
3743 double integral2tmp = norm2 * 0.5 / bmhbarc
3744 * ( exp(-2. * bmhbarc * xMinSample) - exp(-2. * bmhbarc) );
3745 double integral1Frac = integral1tmp / (integral1tmp + integral2tmp);
3748 int samplingRegion = 1;
3749 if ( xMinSample > xCut || integral1Frac < rndmPtr->flat() )
3753 double xGm = (samplingRegion == 1)
3754 ? pow( pow(xMinSample,1. - xPow) + rndmPtr->flat()
3755 * ( pow(xCut, 1. - xPow) - pow(xMinSample, 1. - xPow) ), 1./(1. - xPow))
3756 : -0.5 / bmhbarc * log( exp(-2. * bmhbarc * xMinSample) - rndmPtr->flat()
3757 * ( exp(-2. * bmhbarc * xMinSample) - exp(-2. * bmhbarc) ) );
3771 double EPAexternal::intFluxApprox() {
3774 if ( approxMode == 1 )
3775 return ALPHAEM / M_PI * norm * log (xMax/xMin) * log(Q2max/Q2min);
3776 else if (approxMode == 2)
return integral1 + integral2;
3785 void nPDF::initNPDF(PDFPtr protonPDFPtrIn) {
3788 a = (idBeam/10) % 1000;
3789 z = (idBeam/10000) % 1000;
3795 protonPDFPtr = protonPDFPtrIn;
3812 void nPDF::xfUpdate(
int id,
double x,
double Q2) {
3814 if (protonPDFPtr == 0) {
3815 printErr(
"Error in nPDF: No free proton PDF pointer set.");
3820 this->rUpdate(
id, x, Q2);
3823 double xfd = protonPDFPtr->xf( 1, x, Q2);
3824 double xfu = protonPDFPtr->xf( 2, x, Q2);
3825 double xfdb = protonPDFPtr->xf(-1, x, Q2);
3826 double xfub = protonPDFPtr->xf(-2, x, Q2);
3829 xd = za * (rdv * (xfd - xfdb) +
rd * xfdb)
3830 + na * (ruv * (xfu - xfub) + ru * xfub);
3831 xu = za * (ruv * (xfu - xfub) + ru * xfub)
3832 + na * (rdv * (xfd - xfdb) +
rd * xfdb);
3833 xdbar = za * xfdb *
rd + na * xfub * ru;
3834 xubar = za * xfub * ru + na * xfdb *
rd;
3835 xs = rs * protonPDFPtr->xf( 3, x, Q2);
3836 xsbar = rs * protonPDFPtr->xf(-3, x, Q2);
3837 xc = rc * protonPDFPtr->xf( 4, x, Q2);
3838 xb =
rb * protonPDFPtr->xf( 5, x, Q2);
3839 xg = rg * protonPDFPtr->xf(21, x, Q2);
3855 const double EPS09::Q2MIN = 1.69;
3856 const double EPS09::Q2MAX = 1000000.;
3857 const double EPS09::XMIN = 0.000001;
3858 const double EPS09::XMAX = 1.;
3859 const double EPS09::XCUT = 0.1;
3860 const int EPS09::XSTEPS = 50;
3861 const int EPS09::Q2STEPS = 50;
3867 void EPS09::init(
int iOrderIn,
int iSetIn,
string pdfdataPath) {
3874 if (pdfdataPath[ pdfdataPath.length() - 1 ] !=
'/') pdfdataPath +=
"/";
3875 stringstream fileSS;
3877 if (iOrder == 1) fileSS << pdfdataPath <<
"EPS09LOR_" << getA();
3878 if (iOrder == 2) fileSS << pdfdataPath <<
"EPS09NLOR_" << getA();
3879 string gridFile = fileSS.str();
3882 ifstream fileStream( gridFile.c_str() );
3883 if (!fileStream.good()) {
3884 printErr(
"Error in EPS09::init: did not find grid file " + gridFile,
3894 for (
int i = 0;i < 31; ++i) {
3895 for (
int j = 0;j < 51; ++j) {
3896 fileStream >> dummy;
3897 for (
int k = 0;k < 51; ++k) {
3898 for (
int l = 0;l < 8; ++l) fileStream >> grid[i][j][k][l];
3910 void EPS09::rUpdate(
int ,
double x,
double Q2) {
3913 if( x < XMIN ) x = XMIN;
3914 if( x > XMAX ) x = XMAX;
3915 if( Q2 < Q2MIN ) Q2 = Q2MIN;
3916 if( Q2 > Q2MAX ) Q2 = Q2MAX;
3919 double dQ2 = Q2STEPS * log( log(Q2) / log(Q2MIN) )
3920 / log( log(Q2MAX) / log(Q2MIN) );
3924 if ( iQ2 < 1 ) iQ2 = 1;
3925 else if ( iQ2 > Q2STEPS - 1 ) iQ2 = Q2STEPS - 1;
3929 Q2Near[0] = iQ2 - 1;
3930 Q2Near[1] = iQ2 + 0;
3931 Q2Near[2] = iQ2 + 1;
3934 for (
int iFlavour = 0; iFlavour < 8; ++iFlavour) {
3938 int nxlog = XSTEPS/2;
3939 int nxlin = XSTEPS - nxlog;
3940 if ( x <= XCUT ) ix = int( nxlog * log(x / XMIN) / log( XCUT / XMIN ) );
3941 else ix = int( ( x - XCUT ) * nxlin / ( XMAX - XCUT ) + nxlog );
3944 if ( ix < 1 ) ix = 1;
3947 if ( iFlavour == 0 || iFlavour == 1 || iFlavour == 7)
3948 if ( ix >= XSTEPS - 4 ) ix = XSTEPS - 4;
3949 if ( iFlavour > 1 && iFlavour < 7 )
3950 if ( ix >= XSTEPS - 7 ) ix = XSTEPS - 7;
3954 for(
int i = 0;i < 4;i++) {
3955 if ( ix - 1 + i < nxlog ) {
3956 xNear[i] = XMIN * exp( (
double( ix - 1 + i ) / nxlog )
3957 * log( XCUT / XMIN ) );
3959 xNear[i] = ( double( ix - 1 + i - nxlog) / nxlin )
3960 * ( XMAX - XCUT ) + XCUT;
3969 for (
int j = 0; j < 3; ++j) {
3970 xGrid[0] = grid[iSet - 1][iQ2 - 1 + j][ix - 1][iFlavour];
3971 xGrid[1] = grid[iSet - 1][iQ2 - 1 + j][ix][iFlavour];
3972 xGrid[2] = grid[iSet - 1][iQ2 - 1 + j][ix + 1][iFlavour];
3973 xGrid[3] = grid[iSet - 1][iQ2 - 1 + j][ix + 2][iFlavour];
3974 Q2Grid[j] = polInt(xGrid, xNear, 4, x);
3978 double result = polInt(Q2Grid, Q2Near, 3, dQ2);
3981 if (iFlavour == 0) ruv = max(result, 0.);
3982 if (iFlavour == 1) rdv = max(result, 0.);
3983 if (iFlavour == 2) ru = max(result, 0.);
3984 if (iFlavour == 3) rd = max(result, 0.);
3985 if (iFlavour == 4) rs = max(result, 0.);
3986 if (iFlavour == 5) rc = max(result, 0.);
3987 if (iFlavour == 6)
rb = max(result, 0.);
3988 if (iFlavour == 7) rg = max(result, 0.);
3998 double EPS09::polInt(
double* fi,
double* xi,
int n,
double x) {
4000 for(
int i = 1;i < n;i++) {
4001 for(
int j = n-1;j > i - 1;j--) {
4002 fi[j] = (fi[j] - fi[j-1])/(xi[j] - xi[j-i]);
4006 for(
int i = n-2;i > -1;i--) {
4007 f = (x - xi[i])*f + fi[i];
4024 const double EPPS16::Q2MIN = 1.69;
4025 const double EPPS16::Q2MAX = 100000000.;
4026 const double EPPS16::XMIN = 0.0000001;
4027 const double EPPS16::XMAX = 1.;
4028 const int EPPS16::XSTEPS = 80;
4029 const int EPPS16::Q2STEPS = 30;
4030 const int EPPS16::NINTQ2 = 4;
4031 const int EPPS16::NINTX = 4;
4032 const int EPPS16::NSETS = 41;
4038 void EPPS16::init(
int iSetIn,
string pdfdataPath) {
4042 logQ2min = log(Q2MIN);
4043 loglogQ2maxmin = log( log(Q2MAX)/logQ2min );
4044 logX2min = log(XMIN) - 2. * (1. - XMIN);
4047 if (pdfdataPath[ pdfdataPath.length() - 1 ] !=
'/') pdfdataPath +=
"/";
4048 stringstream fileSS;
4049 fileSS << pdfdataPath <<
"EPPS16NLOR_" << getA();
4050 string gridFile = fileSS.str();
4053 ifstream fileStream( gridFile.c_str() );
4054 if (!fileStream.good()) {
4055 printErr(
"Error in EPPS16::init: did not find grid file " + gridFile,
4065 for (
int i = 0;i < NSETS; ++i) {
4066 for (
int j = 0;j < Q2STEPS+1; ++j) {
4067 fileStream >> dummy;
4068 for (
int k = 0;k < XSTEPS; ++k) {
4069 for (
int l = 0;l < 8; ++l) fileStream >> grid[i][j][k][l];
4081 void EPPS16::rUpdate(
int ,
double x,
double Q2) {
4084 if( x < XMIN ) x = XMIN;
4085 if( x > XMAX ) x = XMAX;
4086 if( Q2 < Q2MIN ) Q2 = Q2MIN;
4087 if( Q2 > Q2MAX ) Q2 = Q2MAX;
4094 double dQ2 = Q2STEPS * log( log(Q2) / logQ2min ) / loglogQ2maxmin;
4098 if ( iQ2 < 1 ) iQ2 = 1;
4099 else if ( iQ2 > Q2STEPS - 3 ) iQ2 = Q2STEPS - 2;
4102 double dx = XSTEPS * ( 1. - (log(x) - 2. * (1. - x) ) / logX2min );
4106 if ( ix < 1 ) ix = 1;
4109 for (
int iFlavour = 0; iFlavour < 8; ++iFlavour) {
4112 if ( (iFlavour > 1) && (iFlavour < 7) ) {
4113 if ( ix > XSTEPS - 6 ) ix = XSTEPS - 6;
4115 if ( ix > XSTEPS - 4 ) ix = XSTEPS - 4;
4120 for(
int i = 0;i < 4;i++) xNear[i] = ix - 1 + i;
4123 if ( (iFlavour == 5) && (iQ2 == 1) ) {
4129 if ( (iFlavour == 6) && (iQ2 < 17) && (iQ2 > 1) ) {
4136 for(
int i = 0;i < 4;i++) Q2Near[i] = iQ2 - 1 + i;
4143 for (
int j = 0; j < 4; ++j) {
4144 xGrid[0] = grid[iSet - 1][iQ2 - 1 + j][ix - 1][iFlavour];
4145 xGrid[1] = grid[iSet - 1][iQ2 - 1 + j][ix][iFlavour];
4146 xGrid[2] = grid[iSet - 1][iQ2 - 1 + j][ix + 1][iFlavour];
4147 xGrid[3] = grid[iSet - 1][iQ2 - 1 + j][ix + 2][iFlavour];
4148 Q2Grid[j] = polInt(xGrid, xNear, NINTX, dx);
4152 double result = polInt(Q2Grid, Q2Near, NINTQ2, dQ2);
4155 if (iFlavour == 0) ruv = result;
4156 if (iFlavour == 1) rdv = result;
4157 if (iFlavour == 2) ru = result;
4158 if (iFlavour == 3) rd = result;
4159 if (iFlavour == 4) rs = result;
4160 if (iFlavour == 5) rc = result;
4161 if (iFlavour == 6)
rb = ( sqrt(Q2) < 4.75 ) ? 0. : result;
4162 if (iFlavour == 7) rg = result;
4165 if (cThreshold > 0) {
4168 }
else if (bThreshold > 0) {
4181 double EPPS16::polInt(
double* fi,
double* xi,
int n,
double x) {
4183 for(
int i = 1;i < n;i++) {
4184 for(
int j = n-1;j > i - 1;j--) {
4185 fi[j] = (fi[j] - fi[j-1])/(xi[j] - xi[j-i]);
4189 for(
int i = n-2;i > -1;i--) {
4190 f = (x - xi[i])*f + fi[i];
void rd(int hits=0, bool clear=false)
This function redraws all hits and/or tracks from the current event.
void ae(int tracks=-1, int hits=-1)
This function is to search for the next non-empty event and draw it by looping over StBFChain (readin...