#include <random>
using namespace std;
void printUncs(
const LHAPDF::PDFSet& set,
const vector<double>& vals,
double cl,
const string& varname,
bool alt=
false) {
cout <<
"PDF uncertainties on " << varname <<
" computed with " << set.
name() <<
" at CL=" << cl <<
"%" << endl;
if (cl >= 0) cout <<
"Scaled PDF uncertainties using scale = " << err.
scale << endl;
cout.precision(5);
cout << varname <<
" = " << err.
central <<
" +" << err.
errplus <<
" -" << err.
errminus <<
" (+-" << err.
errsymm <<
")" << endl;
for (
size_t i = 0; i < errinfo.
qparts.size(); ++i) {
cout <<
" " << setw(12) << err.
errparts[i].first << setw(12) << err.
errparts[i].second <<
" " << errinfo.
qpartName(i) << endl;
}
}
int main(int argc, char* argv[]) {
if (argc < 2) {
cerr << "You must specify a PDF set: ./testpdfunc setname" << endl;
return 1;
}
const string setname = argv[1];
const size_t nmem = set.size()-1;
double x = 0.1;
double Q = 100.0;
const vector<LHAPDF::PDF*> pdfs = set.mkPDFs();
vector<double> xgAll, xuAll;
vector<string> pdftypes;
for (size_t imem = 0; imem <= nmem; imem++) {
xgAll.push_back(pdfs[imem]->xfxQ(21,x,Q));
xuAll.push_back(pdfs[imem]->xfxQ(2,x,Q));
pdftypes.push_back(pdfs[imem]->type());
}
cout << endl;
cout <<
"ErrorType: " << errinfo.
errtype << endl;
cout <<
"ErrorConfLevel: " << errinfo.
conflevel << endl;
const size_t npar = errinfo.
nmemPar();
if (npar > 0) cout << "Last " << npar << " members are parameter variations" << endl;
cout << endl;
set._checkPdfType(pdftypes);
cout << "Gluon distribution at Q = " << Q << " GeV (normal uncertainties)" << endl;
printUncs(set, xgAll, -1, "xg");
cout << endl;
cout << "Up-quark distribution at Q = " << Q << " GeV (normal uncertainties)" << endl;
printUncs(set, xuAll, -1, "xu");
cout << endl;
const double autocorr = set.correlation(xgAll, xgAll);
cout << "Self-correlation of xg = " << autocorr << endl;
cout << endl;
const double corr = set.correlation(xgAll, xuAll);
cout << "Correlation between xg and xu = " << corr << endl;
cout << endl;
cout << "Gluon distribution at Q = " << Q << " GeV (scaled uncertainties)" << endl;
printUncs(set, xgAll, 90, "xg");
cout << endl;
cout << "Up-quark distribution at Q = " << Q << " GeV (scaled uncertainties)" << endl;
printUncs(set, xuAll, 0, "xu");
cout << endl;
cout << "Gluon distribution at Q = " << Q << " GeV (median and 90% C.L.)" << endl;
printUncs(set, xgAll, 90, "xg", true);
cout << endl;
cout << "Up-quark distribution at Q = " << Q << " GeV (median and 68% C.L.)" << endl;
printUncs(set, xuAll, 68, "xu", true);
cout << endl;
const int neigen = (
LHAPDF::startswith(set.errorType(),
"hessian")) ? npdfmem/2 : npdfmem;
const unsigned seed = 1234;
default_random_engine generator(seed);
normal_distribution<double> distribution;
const int nrand = 5;
for (int irand = 1; irand <= nrand; irand++) {
vector<double> randoms;
for (int ieigen=1; ieigen <= neigen; ieigen++) {
double r = distribution(generator);
randoms.push_back(r);
}
const bool symmetrise = true;
double xgrand = set.randomValueFromHessian(xgAll, randoms, symmetrise);
double xurand = set.randomValueFromHessian(xuAll, randoms, symmetrise);
cout << "Random " << irand << ": xg = " << xgrand << ", xu = " << xurand << endl;
}
cout << endl;
}
return 0;
}
Class for PDF-set metadata and manipulation.
Definition: PDFSet.h:105
PDFErrInfo errorInfo() const
Get the structured decomposition of the error-type string.
PDFUncertainty uncertainty(const std::vector< double > &values, double cl=CL1SIGMA, bool alternative=false) const
Calculate the central value and PDF uncertainty on an observable.
Definition: PDFSet.h:330
std::string name() const
PDF set name.
Definition: PDFSet.h:123
bool startswith(const std::string &s, const std::string &sub)
Does a string s start with the sub substring?
Definition: Utils.h:115
const double CL1SIGMA
CL percentage for a Gaussian 1-sigma.
Definition: PDFSet.h:20
Structure encoding the structure of the PDF error-set.
Definition: PDFSet.h:63
QuadParts qparts
Error-set quadrature parts.
Definition: PDFSet.h:77
size_t nmemCore() const
Number of core-set members.
double conflevel
Default confidence-level.
Definition: PDFSet.h:80
size_t nmemPar() const
Number of par-set members.
std::string errtype
Error-type annotation.
Definition: PDFSet.h:83
std::string qpartName(size_t iq) const
Calculated name of a quadrature part.
Structure for storage of uncertainty info calculated over a PDF error set.
Definition: PDFSet.h:36
double central
Variables for the central value, +ve, -ve & symmetrised errors, and a CL scalefactor.
Definition: PDFSet.h:49
ErrPairs errparts
Full error-breakdown of all quadrature uncertainty components, as (+,-) pairs.
Definition: PDFSet.h:57