8 #ifndef Pythia8_LHAPDF5_H
9 #define Pythia8_LHAPDF5_H
11 #include "Pythia8/PartonDistributions.h"
25 extern void initpdfsetm_(
int&,
const char*,
int);
27 extern void initpdfsetbynamem_(
int&,
const char*,
int);
29 extern void initpdfm_(
int&,
int&);
31 extern void evolvepdfm_(
int&,
double&,
double&,
double*);
33 extern void evolvepdfpm_(
int&,
double&,
double&,
double&,
double&,
double*);
35 extern void evolvepdfphotonm_(
int&,
double&,
double&,
double*,
double&);
37 extern void setlhaparm_(
const char*,
int);
39 extern void getxminm_(
int &,
int &,
double &);
41 extern void getxmaxm_(
int &,
int &,
double &);
43 extern void getq2minm_(
int &,
int &,
double &);
45 extern void getq2maxm_(
int &,
int &,
double &);
53 namespace LHAPDF5Interface {
56 void initPDFsetM(
int& nSet,
string name) {
57 const char* cName = name.c_str();
int lenName = name.length();
58 initpdfsetm_( nSet, cName, lenName);
62 void initPDFsetByNameM(
int& nSet,
string name) {
63 const char* cName = name.c_str();
int lenName = name.length();
64 initpdfsetbynamem_( nSet, cName, lenName);
68 void initPDFM(
int& nSet,
int member) {
69 initpdfm_(nSet, member);
73 void evolvePDFM(
int& nSet,
double x,
double Q,
double* xfArray) {
74 evolvepdfm_( nSet, x, Q, xfArray);
78 void evolvePDFpM(
int& nSet,
double x,
double Q,
double P2,
double IP2,
80 evolvepdfpm_( nSet, x, Q, P2, IP2, xfArray);
84 void evolvePDFPHOTONM(
int& nSet,
double x,
double Q,
double* xfArray,
86 evolvepdfphotonm_( nSet, x, Q, xfArray, xPhoton);
90 void setPDFparm(
string name) {
91 const char* cName = name.c_str();
int lenName = name.length();
92 setlhaparm_( cName, lenName);
103 map<int, LHAPDFInfo> initializedSets;
107 int findNSet(
string setName,
int member) {
108 for (map<int, LHAPDFInfo>::const_iterator i = initializedSets.begin();
109 i != initializedSets.end(); ++i) {
111 string iName = i->second.name;
112 int iMember = i->second.member;
113 if (iName == setName && iMember == member)
return iSet;
120 for (
int iSet = 1; iSet <= int(initializedSets.size()); ++iSet) {
121 if (initializedSets.find(iSet) == initializedSets.end())
124 return initializedSets.size() + 1;
142 LHAPDF5(
int idBeamIn,
string setName,
int member,
int nSetIn = -1,
143 Info* infoPtr = 0) :
PDF(idBeamIn), doExtraPol(
false), nSet(nSetIn)
144 { init(setName, member, infoPtr);
145 isPhoton = (idBeamIn == 22) ?
true :
false; }
148 void setExtrapolate(
bool extrapol);
153 void init(
string setName,
int member,
Info* infoPtr);
156 void xfUpdate(
int ,
double x,
double Q2);
162 bool hasPhoton, isPhoton;
171 void LHAPDF5::init(
string setName,
int member,
Info*) {
175 LHAPDF5Interface::initializedSets[nSet];
176 string initializedSetName = initializedInfo.name;
177 int initializedMember = initializedInfo.member;
178 hasPhoton = initializedInfo.photon;
179 if (setName == initializedSetName && member == initializedMember)
return;
183 if (setName[0] ==
'/') LHAPDF5Interface::initPDFsetM( nSet, setName);
184 else LHAPDF5Interface::initPDFsetByNameM( nSet, setName);
188 LHAPDF5Interface::initPDFM(nSet, member);
191 LHAPDF5Interface::setPDFparm(
"NOSTAT" );
192 LHAPDF5Interface::setPDFparm(
"LOWKEY" );
196 LHAPDF5Interface::evolvePDFPHOTONM(nSet, 0.01, 1, xfArray, xPhoton);
197 hasPhoton = xPhoton != 0;
200 initializedInfo.name = setName;
201 initializedInfo.member = member;
202 initializedInfo.photon = hasPhoton;
203 if (nSet > 0) LHAPDF5Interface::initializedSets[nSet] = initializedInfo;
211 void LHAPDF5::setExtrapolate(
bool extrapol) {
213 doExtraPol = extrapol;
214 LHAPDF5Interface::setPDFparm( (extrapol) ?
"EXTRAPOLATE" :
"18" );
222 void LHAPDF5::xfUpdate(
int,
double x,
double Q2) {
225 int member = LHAPDF5Interface::initializedSets[nSet].member;
226 double xMin, xMax, q2Min, q2Max;
227 getxminm_( nSet, member, xMin);
228 getxmaxm_( nSet, member, xMax);
229 getq2minm_(nSet, member, q2Min);
230 getq2maxm_(nSet, member, q2Max);
231 if (x < xMin && !doExtraPol) x = xMin;
232 if (x > xMax) x = xMax;
233 if (Q2 < q2Min) Q2 = q2Min;
234 if (Q2 > q2Max) Q2 = q2Max;
235 double Q = sqrt( max( 0., Q2));
239 LHAPDF5Interface::evolvePDFPHOTONM( nSet, x, Q, xfArray, xPhoton);
244 LHAPDF5Interface::evolvePDFpM( nSet, x, Q, 0., 0., xfArray);
249 LHAPDF5Interface::evolvePDFM( nSet, x, Q, xfArray);
282 LHAPDF5* newLHAPDF(
int idBeamIn,
string setName,
int member,
284 int nSet = LHAPDF5Interface::findNSet(setName, member);
285 if (nSet == -1) nSet = LHAPDF5Interface::freeNSet();
286 return new LHAPDF5(idBeamIn, setName, member, nSet, infoPtr);
289 void deleteLHAPDF(LHAPDF5* pdf) {
299 #endif // end Pythia8_LHAPDF5_H