/*
! Copyright (C) 2019-2022, respective authors of MCFM.
!
! This program is free software: you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the Free Software
! Foundation, either version 3 of the License, or (at your option) any later
! version.
!
! This program is distributed in the hope that it will be useful, but WITHOUT ANY
! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
! PARTICULAR PURPOSE. See the GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License along with
! this program. If not, see
*/
#include "LHAPDF/PDF.h"
#include "LHAPDF/PDFSet.h"
#include "LHAPDF/PDFIndex.h"
#include "LHAPDF/Factories.h"
#include "LHAPDF/Utils.h"
#include "LHAPDF/Paths.h"
#include "LHAPDF/Version.h"
#include "LHAPDF/GridPDF.h"
#include
using namespace std;
extern "C" {
void lhapdf_info()
{
std::vector sets = LHAPDF::availablePDFSets();
std::cout << "Available PDF sets in LHAPDF:" << std::endl;
for (int i=0; ixfxQ2(flav, x, q2);
}
int lhapdf_number(char name[])
{
std::string str(name);
return LHAPDF::PDFSet(str).size();
}
double lhapdf_alphas(LHAPDF::PDF* pdf, double q2)
{
return pdf->alphasQ2(q2);
}
int lhapdf_numFlavors(LHAPDF::PDF* pdf, double q)
{
return pdf->alphaS().numFlavorsQ(q);
}
double lhapdf_quarkThreshold(LHAPDF::PDF* pdf, int i)
{
return pdf->alphaS().quarkThreshold(i);
}
double lhapdf_quarkMass(LHAPDF::PDF* pdf, int i)
{
return pdf->alphaS().quarkMass(i);
}
int lhapdf_orderqcd(LHAPDF::PDF* pdf)
{
return pdf->orderQCD();
}
struct mypdfuncertainty
{
double central;
double errplus;
double errminus;
double errsymm;
};
struct mypdfuncertainty lhapdf_computeUncertainty(LHAPDF::PDF *pdf, double *values, int nval)
{
LHAPDF::PDFSet set = pdf->set();
LHAPDF::PDFUncertainty uncert;
mypdfuncertainty myuncert;
std::vector vals(&values[0], &values[nval]);
uncert = set.uncertainty(vals);
myuncert.central = uncert.central;
myuncert.errplus = uncert.errplus;
myuncert.errminus = uncert.errminus;
myuncert.errsymm = uncert.errsymm;
return myuncert;
}
void lhapdf_getconfig(LHAPDF::PDF *pdf, char key[], char* value, int vlen)
{
LHAPDF::PDFInfo info = pdf->info();
std::string skey(key);
strncpy(value, info.get_entry(skey).c_str(), vlen);
}
int lhapdf_numxKnots(LHAPDF::PDF *pdf)
{
const LHAPDF::GridPDF &gpdf = *dynamic_cast(pdf);
return gpdf.xKnots().size();
}
int lhapdf_numq2Knots(LHAPDF::PDF *pdf)
{
const LHAPDF::GridPDF &gpdf = *dynamic_cast(pdf);
return gpdf.q2Knots().size();
}
void lhapdf_getxKnots(LHAPDF::PDF *pdf, double *xknots)
{
const LHAPDF::GridPDF &gpdf = *dynamic_cast(pdf);
for (int i=0; i(pdf);
for (int i=0; i