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;
137 class LHAPDF5 :
public PDF {
142 LHAPDF5(
int idBeamIn,
string setName,
int member,
int nSetIn = -1) :
143 PDF(idBeamIn), doExtraPol(false), nSet(nSetIn)
144 { init(setName, member); isPhoton = (idBeamIn == 22) ?
true :
false; }
147 void setExtrapolate(
bool extrapol);
152 void init(
string setName,
int member);
155 void xfUpdate(
int ,
double x,
double Q2);
161 bool hasPhoton, isPhoton;
170 void LHAPDF5::init(
string setName,
int member) {
173 LHAPDF5Interface::LHAPDFInfo initializedInfo =
174 LHAPDF5Interface::initializedSets[nSet];
175 string initializedSetName = initializedInfo.name;
176 int initializedMember = initializedInfo.member;
177 hasPhoton = initializedInfo.photon;
178 if (setName == initializedSetName && member == initializedMember)
return;
182 if (setName[0] ==
'/') LHAPDF5Interface::initPDFsetM( nSet, setName);
183 else LHAPDF5Interface::initPDFsetByNameM( nSet, setName);
187 LHAPDF5Interface::initPDFM(nSet, member);
190 LHAPDF5Interface::setPDFparm(
"NOSTAT" );
191 LHAPDF5Interface::setPDFparm(
"LOWKEY" );
195 LHAPDF5Interface::evolvePDFPHOTONM(nSet, 0.01, 1, xfArray, xPhoton);
196 hasPhoton = xPhoton != 0;
199 initializedInfo.name = setName;
200 initializedInfo.member = member;
201 initializedInfo.photon = hasPhoton;
202 if (nSet > 0) LHAPDF5Interface::initializedSets[nSet] = initializedInfo;
210 void LHAPDF5::setExtrapolate(
bool extrapol) {
212 doExtraPol = extrapol;
213 LHAPDF5Interface::setPDFparm( (extrapol) ?
"EXTRAPOLATE" :
"18" );
221 void LHAPDF5::xfUpdate(
int,
double x,
double Q2) {
224 int member = LHAPDF5Interface::initializedSets[nSet].member;
225 double xMin, xMax, q2Min, q2Max;
226 getxminm_( nSet, member, xMin);
227 getxmaxm_( nSet, member, xMax);
228 getq2minm_(nSet, member, q2Min);
229 getq2maxm_(nSet, member, q2Max);
230 if (x < xMin && !doExtraPol) x = xMin;
231 if (x > xMax) x = xMax;
232 if (Q2 < q2Min) Q2 = q2Min;
233 if (Q2 > q2Max) Q2 = q2Max;
234 double Q = sqrt( max( 0., Q2));
238 LHAPDF5Interface::evolvePDFPHOTONM( nSet, x, Q, xfArray, xPhoton);
243 LHAPDF5Interface::evolvePDFpM( nSet, x, Q, 0., 0., xfArray);
248 LHAPDF5Interface::evolvePDFM( nSet, x, Q, xfArray);
281 LHAPDF5* newPDF(
int idBeamIn,
string setName,
int member) {
282 int nSet = LHAPDF5Interface::findNSet(setName, member);
283 if (nSet == -1) nSet = LHAPDF5Interface::freeNSet();
284 return new LHAPDF5(idBeamIn, setName, member, nSet);
287 void deletePDF(LHAPDF5* pdf) {
delete pdf;}
295 #endif // end Pythia8_LHAPDF5_H