8 #ifndef Pythia8_LHAPDF6_H 9 #define Pythia8_LHAPDF6_H 11 #include "Pythia8/PartonDistributions.h" 12 #include "Pythia8/Plugins.h" 13 #include "LHAPDF/LHAPDF.h" 32 PdfSets(
string setName) :
info(::LHAPDF::PDFSet(setName)),
33 pdfs(vector< ::LHAPDF::PDF* >(
info.size(), 0)) {;}
38 lock_guard<mutex> lck (mtx);
39 pdfs[member] =
info.mkPDF(member);
45 int size() {
return pdfs.size();}
49 vector< ::LHAPDF::PDF* > pdfs;
66 PDF(), pdf(nullptr), extrapol(false) {
67 if (settingsPtr ==
nullptr)
return;
68 sSymmetric(settingsPtr->
flag(
"LHAPDF:sSymmetric"));
69 cSymmetric(settingsPtr->
flag(
"LHAPDF:cSymmetric"));
70 bSymmetric(settingsPtr->
flag(
"LHAPDF:bSymmetric"));
74 bool init(
int idBeamIn,
string setName,
int member,
Logger* loggerPtr)
85 ::LHAPDF::Extrapolator *ext;
89 void xfUpdate(
int id,
double x,
double Q2);
92 bool insideBounds(
double x,
double Q2) {
93 return (x > xMin && x < xMax && Q2 > q2Min && Q2 < q2Max);}
96 double alphaS(
double Q2) {
return pdf->alphasQ2(Q2); }
99 double muPDFSave, mdPDFSave, mcPDFSave, msPDFSave, mbPDFSave,
100 xMin, xMax, q2Min, q2Max;
101 double mQuarkPDF(
int id) {
103 case 1:
return mdPDFSave;
104 case 2:
return muPDFSave;
105 case 3:
return msPDFSave;
106 case 4:
return mcPDFSave;
107 case 5:
return mbPDFSave;
113 void calcPDFEnvelope(
int,
double,
double,
int);
114 void calcPDFEnvelope(pair<int,int>, pair<double,double>,
double,
int);
117 static const double PDFMINVALUE;
120 int nMembers() {
return nMembersSave; }
128 const double LHAPDF6::PDFMINVALUE = 1e-10;
137 idBeamAbs = abs(idBeamIn);
145 }
catch (
const std::exception &e) {
146 loggerPtr->ERROR_MSG(
"unknown PDF " + setName);
151 if (pdfs.size() == 0) {
152 loggerPtr->ERROR_MSG(
"could not initialize PDF " + setName);
154 }
else if (member >= pdfs.size()) {
155 loggerPtr->ERROR_MSG(setName +
" does not contain requested member");
164 q2Max = pdf->q2Max();
165 q2Min = pdf->q2Min();
168 muPDFSave = pdf->info().get_entry_as<
double>(
"MUp");
169 mdPDFSave = pdf->info().get_entry_as<
double>(
"MDown");
170 mcPDFSave = pdf->info().get_entry_as<
double>(
"MCharm");
171 msPDFSave = pdf->info().get_entry_as<
double>(
"MStrange");
172 mbPDFSave = pdf->info().get_entry_as<
double>(
"MBottom");
173 nMembersSave = pdf->info().get_entry_as<
int>(
"NumMembers");
182 void LHAPDF6::xfUpdate(
int,
double x,
double Q2) {
186 if (x < xMin && !extrapol) x = xMin;
187 if (x > xMax) x = xMax;
188 if (Q2 < q2Min) Q2 = q2Min;
189 if (Q2 > q2Max) Q2 = q2Max;
192 xg = pdf->xfxQ2(21, x, Q2);
193 xd = pdf->xfxQ2(1, x, Q2);
194 xu = pdf->xfxQ2(2, x, Q2);
195 xdbar = pdf->xfxQ2(-1, x, Q2);
196 xubar = pdf->xfxQ2(-2, x, Q2);
197 xs = pdf->xfxQ2(3, x, Q2);
198 xc = pdf->xfxQ2(4, x, Q2);
199 xb = pdf->xfxQ2(5, x, Q2);
200 xsbar = sSymmetricSave ? xs : pdf->xfxQ2(-3, x, Q2);
201 xcbar = cSymmetricSave ? xc : pdf->xfxQ2(-4, x, Q2);
202 xbbar = bSymmetricSave ? xb : pdf->xfxQ2(-5, x, Q2);
203 xgamma = pdf->xfxQ2(22, x, Q2);
214 void LHAPDF6::calcPDFEnvelope(
int idNow,
double xNow,
double Q2NowIn,
219 double x1 = (xNow < xMin && !extrapol) ? xMin : xNow;
220 if (x1 > xMax) x1 = xMax;
221 double Q2Now = (Q2NowIn < q2Min) ? q2Min : Q2NowIn;
222 if (Q2Now > q2Max) Q2Now = q2Max;
225 vector<double> xfCalc(pdfs.size());
226 for(
int iMem = 0; iMem < pdfs.size(); ++iMem) {
227 if (valSea==0 || (idNow != 1 && idNow != 2)) {
228 xfCalc[iMem] = pdfs[iMem]->xfxQ2(idNow, x1, Q2Now);
229 }
else if (valSea==1 && (idNow == 1 || idNow == 2 )) {
230 xfCalc[iMem] = pdfs[iMem]->xfxQ2(idNow, x1, Q2Now) -
231 pdfs[iMem]->xfxQ2(-idNow, x1, Q2Now);
232 }
else if (valSea==2 && (idNow == 1 || idNow == 2 )) {
233 xfCalc[iMem] = pdfs[iMem]->xfxQ2(-idNow, x1, Q2Now);
238 ::LHAPDF::PDFUncertainty xfErr = pdfs.info.uncertainty(xfCalc);
239 pdfEnvelope.centralPDF = xfErr.central;
240 pdfEnvelope.errplusPDF = xfErr.errplus;
241 pdfEnvelope.errminusPDF = xfErr.errminus;
242 pdfEnvelope.errsymmPDF = xfErr.errsymm;
243 pdfEnvelope.scalePDF = xfErr.scale;
250 void LHAPDF6::calcPDFEnvelope(pair<int,int> idNows, pair<double,double> xNows,
251 double Q2NowIn,
int valSea) {
255 double x1 = (xNows.first < xMin && !extrapol) ? xMin : xNows.first;
256 if (x1 > xMax) x1 = xMax;
257 double x2 = (xNows.second < xMin && !extrapol) ? xMin : xNows.second;
258 if (x2 > xMax) x2 = xMax;
259 double Q2Now = (Q2NowIn < q2Min) ? q2Min : Q2NowIn;
260 if (Q2Now > q2Max) Q2Now = q2Max;
263 vector<double> xfCalc(pdfs.size());
264 pdfEnvelope.pdfMemberVars.resize(pdfs.size());
265 for(
int iMem = 0; iMem < pdfs.size(); ++iMem) {
266 if (valSea == 0 || (idNows.first != 1 && idNows.first != 2 ) ) {
267 xfCalc[iMem] = pdfs[iMem]->xfxQ2(idNows.first, x1, Q2Now);
268 }
else if (valSea == 1 && (idNows.first == 1 || idNows.first == 2)) {
269 xfCalc[iMem] = pdfs[iMem]->xfxQ2(idNows.first, x1, Q2Now)
270 - pdfs[iMem]->xfxQ2(-idNows.first, x1, Q2Now);
271 }
else if (valSea == 2 && (idNows.first == 1 || idNows.first == 2 )) {
272 xfCalc[iMem] = pdfs[iMem]->xfxQ2(-idNows.first, x1, Q2Now);
274 xfCalc[iMem] = max(0.0, xfCalc[iMem]);
275 if (valSea == 0 || (idNows.second != 1 && idNows.second != 2)) {
277 (PDFMINVALUE, pdfs[iMem]->xfxQ2(idNows.second, x2, Q2Now));
278 }
else if (valSea == 1 && (idNows.second == 1 || idNows.second == 2 )) {
280 (pdfs[iMem]->xfxQ2(idNows.second, x2, Q2Now) - pdfs[iMem]->xfxQ2
281 (-idNows.second, x2, Q2Now), PDFMINVALUE);
282 }
else if (valSea == 2 && (idNows.second == 1 || idNows.second == 2 )) {
284 (pdfs[iMem]->xfxQ2(-idNows.second, x2, Q2Now), PDFMINVALUE);
286 pdfEnvelope.pdfMemberVars[iMem] = xfCalc[iMem];
290 ::LHAPDF::PDFUncertainty xfErr = pdfs.info.uncertainty(xfCalc);
291 pdfEnvelope.centralPDF = xfErr.central;
292 pdfEnvelope.errplusPDF = xfErr.errplus;
293 pdfEnvelope.errminusPDF = xfErr.errminus;
294 pdfEnvelope.errsymmPDF = xfErr.errsymm;
295 pdfEnvelope.scalePDF = xfErr.scale;
303 PYTHIA8_PLUGIN_CLASS(
PDF,
LHAPDF6,
false,
false,
false)
304 PYTHIA8_PLUGIN_VERSIONS(PYTHIA_VERSION_INTEGER)
Containers for PDF sets.
Definition: LHAPDF6.h:26
void setExtrapolate(bool extrapolIn)
Allow extrapolation beyond boundaries (not implemented).
Definition: LHAPDF6.h:78
bool flag(string keyIn)
Give back current value, with check that key exists.
Definition: Settings.cc:1478
::LHAPDF::PDFSet info
PDF sets and info.
Definition: LHAPDF6.h:48
LHAPDF6(Pythia *, Settings *settingsPtr, Logger *)
Constructor.
Definition: LHAPDF6.h:65
Provide interface to the LHAPDF6 library of parton densities.
Definition: LHAPDF6.h:60
Error envelope from PDF uncertainty.
Definition: PartonDistributions.h:102
PdfSets()
Constructors.
Definition: LHAPDF6.h:31
::LHAPDF::PDF * operator[](unsigned int member)
Access a PDF set.
Definition: LHAPDF6.h:36
int size()
Get number of PDF sets.
Definition: LHAPDF6.h:45
Base class for parton distribution functions.
Definition: PartonDistributions.h:49
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
The Pythia class contains the top-level routines to generate an event.
Definition: Pythia.h:71
bool init(int idBeamIn, string setName, int member, Logger *loggerPtr) override
Initialization of PDF set.
Definition: LHAPDF6.h:134
Definition: Settings.h:195