C++ tutorial
PDFSet for set-level calculations and uncertainty analysis. Use factories or custom template components when you need a single member or specialized numerical behavior.Before compiling
Make sure that PDFxTMDLib is installed and that the parent directory of each data set is listed in config.yaml. The examples use:
MSHT20nlo_as120for collinear calculations.PB-LO-HERAI+II-2020-set2for TMD calculations.xas a dimensionless momentum fraction.mu2andkt2as squared scales in GeV2.
Collinear calculation with PDFSet
PDFSet<CollinearPDFTag> manages every member in a collinear set. Member 0 is used as the central member in this example.
#include <PDFxTMDLib/PDFSet.h>
#include <iostream>
int main() {
PDFxTMD::PDFSet<PDFxTMD::CollinearPDFTag> set("MSHT20nlo_as120");
auto central = set[0];
const double x = 0.1;
const double mu2 = 10000.0;
const double gluon = central->pdf(PDFxTMD::PartonFlavor::g, x, mu2);
std::cout << "Gluon value: " << gluon << '\n';
}
TMD calculation with PDFSet
Specialize the same interface with TMDPDFTag and supply kT2 to tmd:
#include <PDFxTMDLib/PDFSet.h>
#include <iostream>
int main() {
PDFxTMD::PDFSet<PDFxTMD::TMDPDFTag> set(
"PB-LO-HERAI+II-2020-set2"
);
auto central = set[0];
const double x = 0.001;
const double kt2 = 10.0;
const double mu2 = 100.0;
const double gluon = central->tmd(
PDFxTMD::PartonFlavor::g, x, kt2, mu2
);
std::cout << "Gluon TMD value: " << gluon << '\n';
}
Uncertainty and correlation
The set-level interface uses the set metadata to combine its members:
PDFxTMD::PDFSet<PDFxTMD::CollinearPDFTag> set("MSHT20nlo_as120");
const double x = 0.1;
const double mu2 = 10000.0;
const auto uncertainty = set.Uncertainty(
PDFxTMD::PartonFlavor::g, x, mu2
);
std::cout << "central = " << uncertainty.central << '\n'
<< "+error = " << uncertainty.errplus << '\n'
<< "-error = " << uncertainty.errminus << '\n';
const double correlation = set.Correlation(
PDFxTMD::PartonFlavor::g, x, mu2,
PDFxTMD::PartonFlavor::u, x, mu2
);
std::cout << "correlation(g, u) = " << correlation << '\n';
An explicit confidence level can be supplied as the final argument when required by the set and analysis:
const auto uncertainty90 = set.Uncertainty(
PDFxTMD::PartonFlavor::g, x, mu2, 90.0
);
Metadata
Use the structured metadata objects when you need common fields:
const auto standard_info = set.getStdPDFInfo();
const auto error_info = set.getPDFErrorInfo();
std::cout << "Description: " << standard_info.SetDesc << '\n';
std::cout << "Members: " << standard_info.NumMembers << '\n';
std::cout << "Error type: " << error_info.ErrorType << '\n';
For less common keys, use the set’s general configuration interface exposed by info().
Single-member factory interface
Factories avoid constructing a complete set when an application only needs one member:
#include <PDFxTMDLib/Factory.h>
#include <iostream>
int main() {
auto cpdf_factory = PDFxTMD::GenericCPDFFactory();
auto cpdf = cpdf_factory.mkCPDF("MMHT2014lo68cl", 0);
const double value = cpdf.pdf(
PDFxTMD::PartonFlavor::g, 0.001, 100.0
);
std::cout << value << '\n';
}
The corresponding TMD factory is GenericTMDFactory, and individual TMD members are created with mkTMD.
Strong coupling
Calculate αs(μ2) from the loaded set or through a coupling factory:
#include <PDFxTMDLib/Factory.h>
#include <PDFxTMDLib/PDFSet.h>
PDFxTMD::PDFSet<PDFxTMD::CollinearPDFTag> set("MSHT20nlo_as120");
const double alpha_from_set = set.alphasQ2(10000.0);
auto coupling_factory = PDFxTMD::CouplingFactory();
auto coupling = coupling_factory.mkCoupling("MMHT2014lo68cl");
const double alpha_from_factory = coupling.AlphaQCDMu2(10000.0);
Custom implementations
Advanced users can combine a reader, interpolator, and extrapolator through GenericPDF:
#include <PDFxTMDLib/GenericPDF.h>
#include <PDFxTMDLib/Implementation/Extrapolator/Collinear/CErrExtrapolator.h>
#include <PDFxTMDLib/Implementation/Interpolator/Collinear/CLHAPDFBilinearInterpolator.h>
#include <PDFxTMDLib/Implementation/Reader/Collinear/CDefaultLHAPDFFileReader.h>
using Reader = PDFxTMD::CDefaultLHAPDFFileReader;
using Interpolator = PDFxTMD::CLHAPDFBilinearInterpolator<Reader>;
using Extrapolator = PDFxTMD::CErrExtrapolator;
using CustomPDF = PDFxTMD::GenericPDF<
PDFxTMD::CollinearPDFTag,
Reader,
Interpolator,
Extrapolator
>;
CustomPDF pdf("MMHT2014lo68cl", 0);
const double value = pdf.pdf(PDFxTMD::PartonFlavor::g, 0.001, 100.0);
The interpolator is parameterized by the reader type; omitting that template argument produces an invalid type.
Compile an example
When PDFxTMDLib is installed in a standard prefix:
g++ -std=c++17 example.cpp -lPDFxTMDLib -o example
./example
For reproducible projects, prefer the CMake target shown in the installation guide.