10 #include "LHAPDF/PDFInfo.h"
11 #include "LHAPDF/PDFIndex.h"
12 #include "LHAPDF/Factories.h"
13 #include "LHAPDF/AlphaS.h"
14 #include "LHAPDF/Utils.h"
15 #include "LHAPDF/Paths.h"
16 #include "LHAPDF/Exceptions.h"
17 #include "LHAPDF/Version.h"
18 #include "LHAPDF/Config.h"
48 void _loadInfo(
const std::string& mempath);
50 void _loadInfo(
const std::string& setname,
int member) {
51 const string searchpath = findpdfmempath(setname, member);
52 if (searchpath.empty())
53 throw UserError(
"Can't find a valid PDF " + setname +
"/" +
to_str(member));
54 _loadInfo(searchpath);
57 void _loadInfo(
int lhaid) {
58 const pair<string,int> setname_memid =
lookupPDF(lhaid);
59 if (setname_memid.second == -1)
60 throw IndexError(
"Can't find a PDF with LHAPDF ID = " +
to_str(lhaid));
61 _loadInfo(setname_memid.first, setname_memid.second);
81 double xfxQ2(
int id,
double x,
double q2)
const;
94 double xfxQ(
int id,
double x,
double q)
const {
95 return xfxQ2(
id, x, q*q);
107 void xfxQ2(
double x,
double q2, std::map<int, double>& rtn)
const;
118 void xfxQ(
double x,
double q, std::map<int, double>& rtn)
const {
135 void xfxQ2(
double x,
double q2, std::vector<double>& rtn)
const;
149 void xfxQ(
double x,
double q, std::vector<double>& rtn)
const {
162 std::map<int, double>
xfxQ2(
double x,
double q2)
const;
176 std::map<int, double>
xfxQ(
double x,
double q)
const {
177 return xfxQ2(x, q*q);
195 virtual double _xfxQ2(
int id,
double x,
double q2)
const = 0;
209 return numeric_limits<double>::epsilon();
239 return (
info().
has_key(
"QMax")) ?
sqr(
info().get_entry_as<double>(
"QMax")) : numeric_limits<double>::max();
264 return x >= 0.0 && x <= 1.0;
358 assert(memname.length() > 5);
359 const int memid = lexical_cast<int>(memname.substr(memname.length()-4));
401 virtual const std::vector<int>&
flavors()
const {
std::string type() const
Get the type of PDF member that this object represents (central, error)
Definition: PDF.h:379
N sqr(const N &x)
Convenience function for squaring (of any type)
Definition: Utils.h:208
std::string _mempath
Member data file path.
Definition: PDF.h:515
void print(std::ostream &os=std::cout, int verbosity=1) const
Summary printout.
Generic unspecialised LHAPDF runtime error.
Definition: Exceptions.h:22
PDFSet & set() const
Get the PDF set of which this is a member.
Definition: PDF.h:343
virtual double xMin()
Minimum valid x value for this PDF.
Definition: PDF.h:206
int _forcePos
Cached flag for whether to return only positive (or positive definite) PDF values.
Definition: PDF.h:531
double quarkThreshold(int id) const
Get a flavor scale threshold in GeV by PDG code (|PID| = 1-6 only) Convenience interface to the Mass*...
const AlphaS & alphaS() const
Retrieve the AlphaS object for this PDF (const)
Definition: PDF.h:479
virtual double xMax()
Maximum valid x value for this PDF.
Definition: PDF.h:213
virtual ~PDF()
Virtual destructor, to allow unfettered inheritance.
Definition: PDF.h:39
bool hasAlphaS() const
Check if an AlphaS calculator is set.
Definition: PDF.h:469
void xfxQ2(double x, double q2, std::vector< double > &rtn) const
Get the PDF xf(x) value at (x,q2) for "standard" PIDs.
void xfxQ2(double x, double q2, std::map< int, double > &rtn) const
Get the PDF xf(x) value at (x,q2) for all supported PIDs.
bool inPhysicalRangeX(double x) const
Check whether the given x is physically valid.
Definition: PDF.h:263
Metadata class for PDF members.
Definition: PDFInfo.h:18
double xfxQ(int id, double x, double q) const
Get the PDF xf(x) value at (x,q) for the given PID.
Definition: PDF.h:94
virtual double _xfxQ2(int id, double x, double q2) const =0
Calculate the PDF xf(x) value at (x,q2) for the given PID.
int forcePositive() const
Check whether the PDF is set to only return positive (definite) values or not.
Definition: PDF.h:248
const std::string & get_entry(const std::string &key) const
Retrieve a metadata string by key name.
unique_ptr< AlphaS > AlphaSPtr
Internal convenience typedef for the AlphaS object handle.
Definition: PDF.h:30
bool inPhysicalRangeXQ2(double x, double q2) const
Check whether the given (x,Q2) is physically valid.
Definition: PDF.h:282
double quarkMass(int id) const
Get a quark mass in GeV by PDG code (|PID| = 1-6 only)
bool inRangeXQ2(double x, double q2) const
Combined range check for x and Q2.
Definition: PDF.h:324
int qcdOrder() const
Definition: PDF.h:431
std::pair< std::string, int > lookupPDF(int lhaid)
AlphaS & alphaS()
Retrieve the AlphaS object for this PDF.
Definition: PDF.h:474
void setAlphaS(AlphaSPtr alphas)
Set the AlphaS calculator by smart pointer.
Definition: PDF.h:464
bool inPhysicalRangeXQ(double x, double q) const
Check whether the given (x,Q) is physically valid.
Definition: PDF.h:287
virtual bool inRangeQ(double q) const
Grid range check for Q.
Definition: PDF.h:298
bool inPhysicalRangeQ(double q) const
Check whether the given Q is physically valid.
Definition: PDF.h:277
void xfxQ(double x, double q, std::map< int, double > &rtn) const
Get the PDF xf(x) value at (x,q) for all supported PIDs.
Definition: PDF.h:118
T get_entry_as(const std::string &key) const
Definition: Info.h:122
virtual double qMin()
Definition: PDF.h:221
const PDFInfo & info() const
Get the info class that actually stores and handles the metadata (const version)
Definition: PDF.h:338
double alphasQ(double q) const
Value of alpha_s(Q2) used by this PDF.
Definition: PDF.h:487
std::string _setname() const
Get the set name from the member data file path (for internal use only)
Definition: PDF.h:510
virtual double q2Min()
Minimum valid Q2 value for this PDF (in GeV2).
Definition: PDF.h:232
std::map< int, double > xfxQ(double x, double q) const
Get the PDF xf(x) value at (x,q) for all supported PIDs.
Definition: PDF.h:176
PDFSet & getPDFSet(const std::string &setname)
PDFInfo _info
Metadata container.
Definition: PDF.h:518
void setFlavors(std::vector< int > const &flavors)
Manually set/override the list of flavours defined by this PDF set.
Definition: PDF.h:412
virtual const std::vector< int > & flavors() const
List of flavours defined by this PDF set.
Definition: PDF.h:401
std::string dirname(const std::string &p)
Get the dirname (i.e. path to the penultimate directory) from a path p.
Definition: Utils.h:181
bool has_key(const std::map< K, T > &container, const K &key)
Does the map<K,T> container have a key K key?
Definition: Utils.h:251
std::string to_lower(const std::string &s)
Convert a string to lower-case (not in-place)
Definition: Utils.h:138
int lhapdfID() const
PDF member global LHAPDF ID number.
bool inPhysicalRangeQ2(double q2) const
Check whether the given Q2 is physically valid.
Definition: PDF.h:270
AlphaSPtr _alphas
Optionally loaded AlphaS object (mutable for laziness/caching)
Definition: PDF.h:524
std::string basename(const std::string &p)
Get the basename (i.e. terminal file name) from a path p.
Definition: Utils.h:175
Class for PDF set metadata and manipulation.
Definition: PDFSet.h:48
int orderQCD() const
Order of QCD at which this PDF has been constructed.
Definition: PDF.h:427
double alphasQ2(double q2) const
Value of alpha_s(Q2) used by this PDF.
Definition: PDF.h:495
PDFInfo & info()
Get the info class that actually stores and handles the metadata.
Definition: PDF.h:335
std::map< int, double > xfxQ2(double x, double q2) const
Get the PDF xf(x) value at (x,q2) for all supported PIDs.
PDF is the general interface for access to parton density information.
Definition: PDF.h:26
int dataversion() const
Version of this PDF's data file.
Definition: PDF.h:374
virtual bool inRangeX(double x) const =0
Grid range check for x.
virtual double q2Max()
Maximum valid Q2 value for this PDF (in GeV2).
Definition: PDF.h:237
int memberID() const
PDF member local ID number.
Definition: PDF.h:356
void xfxQ(double x, double q, std::vector< double > &rtn) const
Get the PDF xf(x) value at (x,q) for "standard" PIDs.
Definition: PDF.h:149
std::string to_str(const T &val)
Make a string representation of val.
Definition: Utils.h:61
PDF()
Force initialization of the only non-class member.
Definition: PDF.h:33
virtual bool inRangeXQ(double x, double q) const
Combined range check for x and Q.
Definition: PDF.h:319
void setForcePositive(int mode)
Set whether the PDF will only return positive (definite) values or not.
Definition: PDF.h:254
vector< int > _flavors
Locally cached list of supported PIDs (mutable for laziness/caching)
Definition: PDF.h:521
Namespace for all LHAPDF functions and classes.
Definition: AlphaS.h:14
AlphaS * mkAlphaS(const Info &info)
Make an AlphaS object from an Info object.
virtual double qMax()
Maximum valid Q value for this PDF (in GeV).
Definition: PDF.h:227
Problem exists between keyboard and chair.
Definition: Exceptions.h:110
virtual bool inRangeQ2(double q2) const =0
Grid range check for Q2.
bool hasFlavor(int id) const
Checks whether id is a valid parton for this PDF.
void setAlphaS(AlphaS *alphas)
Set the AlphaS calculator by pointer.
Definition: PDF.h:459
std::string file_stem(const std::string &f)
Get the stem (i.e. part without a file extension) from a filename f.
Definition: Utils.h:187
Calculator interface for computing alpha_s(Q2) in various ways.
Definition: AlphaS.h:24
int verbosity()
Definition: Config.h:54
std::string description() const
Description of this PDF member.
Definition: PDF.h:369
double xfxQ2(int id, double x, double q2) const
Get the PDF xf(x) value at (x,q2) for the given PID.