LHAPDF is hosted by Hepforge, IPPP Durham
LHAPDF  6.2.1
LHAPDF::PDFSet Class Reference

Class for PDF set metadata and manipulation. More...

#include <PDFSet.h>

Inheritance diagram for LHAPDF::PDFSet:
LHAPDF::Info

Public Member Functions

void print (std::ostream &os=std::cout, int verbosity=1) const
 Summary printout.
 
Creation and deletion
 PDFSet ()
 
 PDFSet (const std::string &setname)
 
PDF set metadata specialisations
std::string name () const
 PDF set name. More...
 
std::string description () const
 Description of the set.
 
int lhapdfID () const
 First LHAPDF global index in this PDF set.
 
int dataversion () const
 Version of this PDF set's data files.
 
std::string errorType () const
 Get the type of PDF errors in this set (replicas, symmhessian, hessian, custom, etc.)
 
double errorConfLevel () const
 Get the confidence level of the Hessian eigenvectors, in percent. More...
 
size_t size () const
 Number of members in this set.
 
Creating PDF members
PDFmkPDF (int member) const
 
template<typename PTR >
void mkPDFs (std::vector< PTR > &pdfs) const
 
std::vector< PDF * > mkPDFs () const
 
template<typename PTR >
std::vector< PTR > mkPDFs () const
 
Generic metadata cascading mechanism
Todo:
Add AlphaS getter for set-level alphaS?
bool has_key (const std::string &key) const
 Can this Info object return a value for the given key? (it may be defined non-locally)
 
const std::string & get_entry (const std::string &key) const
 Retrieve a metadata string by key name.
 
const std::string & get_entry (const std::string &key, const std::string &fallback) const
 Retrieve a metadata string by key name, with a fallback.
 
PDF set uncertainty functions
PDFUncertainty uncertainty (const std::vector< double > &values, double cl=100 *erf(1/sqrt(2)), bool alternative=false) const
 Calculate central value and error from vector values with appropriate formulae for this set. More...
 
void uncertainty (PDFUncertainty &rtn, const std::vector< double > &values, double cl=100 *erf(1/sqrt(2)), bool alternative=false) const
 
double correlation (const std::vector< double > &valuesA, const std::vector< double > &valuesB) const
 Calculate the PDF correlation between valuesA and valuesB using appropriate formulae for this set. More...
 
double randomValueFromHessian (const std::vector< double > &values, const std::vector< double > &randoms, bool symmetrise=true) const
 Generate a random value from Hessian values and Gaussian random numbers. More...
 
void _checkPdfType (const std::vector< string > &pdftypes) const
 
- Public Member Functions inherited from LHAPDF::Info
 Info ()
 Default constructor.
 
 Info (const std::string &path)
 Constructor.
 
virtual ~Info ()
 Virtual destructor to allow inheritance.
 
void load (const std::string &filepath)
 
bool has_key_local (const std::string &key) const
 Is a value defined for the given key on this specific object?
 
const std::string & get_entry_local (const std::string &key) const
 Retrieve a metadata string by key name, as defined on this specific object.
 
template<typename T >
get_entry_as (const std::string &key) const
 
template<typename T >
get_entry_as (const std::string &key, const T &fallback) const
 Retrieve a metadata entry by key name, with an inline type cast and default fallback.
 
template<typename T >
void set_entry (const std::string &key, const T &val)
 Set a keyed value entry.
 
template<>
bool get_entry_as (const std::string &key) const
 
template<>
std::vector< std::string > get_entry_as (const std::string &key) const
 
template<>
std::vector< int > get_entry_as (const std::string &key) const
 
template<>
std::vector< double > get_entry_as (const std::string &key) const
 

Private Attributes

std::string _setname
 Name of this set.
 

Additional Inherited Members

- Protected Attributes inherited from LHAPDF::Info
std::map< std::string, std::string > _metadict
 The string -> string native metadata storage container.
 

Detailed Description

Class for PDF set metadata and manipulation.

Examples:
/examples/testpdfunc.cc, and /tests/testinfo.cc.

Constructor & Destructor Documentation

◆ PDFSet() [1/2]

LHAPDF::PDFSet::PDFSet ( )
inline

Default constructor (for container compatibility)

Todo:
Remove?

◆ PDFSet() [2/2]

LHAPDF::PDFSet::PDFSet ( const std::string &  setname)

Constructor from a set name

Todo:
Remove?

Member Function Documentation

◆ _checkPdfType()

void LHAPDF::PDFSet::_checkPdfType ( const std::vector< string > &  pdftypes) const

Check that the PdfType of each member matches the ErrorType of the set.

Todo:
We need to make the signature clearer – what is the arg? Why not automatically check the members? Why not a plural name? Why not on PDF? "Hiding" the name for now with the leading underscore.

◆ correlation()

double LHAPDF::PDFSet::correlation ( const std::vector< double > &  valuesA,
const std::vector< double > &  valuesB 
) const

Calculate the PDF correlation between valuesA and valuesB using appropriate formulae for this set.

The correlation can vary between -1 and +1 where values close to {-1,0,+1} mean that the two quantities A and B are {anticorrelated,uncorrelated,correlated}, respectively.

For a combined set, the parameter variations are not included in the calculation of the correlation.

◆ errorConfLevel()

double LHAPDF::PDFSet::errorConfLevel ( ) const

Get the confidence level of the Hessian eigenvectors, in percent.

If not defined, assume 1-sigma = erf(1/sqrt(2)) =~ 68.268949% by default, unless this is a replica set for which return -1.

◆ mkPDF()

PDF* LHAPDF::PDFSet::mkPDF ( int  member) const
inline

Make the nth PDF member in this set, returned by pointer

Note
As with the mkPDF factory method, the PDF pointer returned by this method is heap allocated and its memory management is now the responsibility of the caller.

◆ mkPDFs() [1/3]

template<typename PTR >
void LHAPDF::PDFSet::mkPDFs ( std::vector< PTR > &  pdfs) const
inline

Make all the PDFs in this set, filling a supplied vector with PDF pointers

This version may be preferred in many circumstances, since it can avoid the overhead of creating a new temporary vector.

A vector of smart pointers can be used, for any smart pointer type which supports construction from a raw pointer argument, e.g. unique_ptr<PDF>(PDF*).

Note
The supplied vector will be cleared before filling!
As with the mkPDF method and factory function, the PDF pointers returned by this method are heap allocated and their memory management is now the responsibility of the caller, either manually for raw pointers or automatically if smart pointers are used.
Use an appropriate smart pointer, of course! This depends in detail on how you will use the PDF objects (do you want shared or unique pointers?), but they also need to be compatible with storage in STL containers, e.g. std::unique_ptr or std::shared_ptr but not the deprecated std::auto_ptr.
Todo:
Needs to be implemented in the header since the arg type is templated.
Todo:
Need to use an std::move here, or write differently, for unique_ptr to work?

◆ mkPDFs() [2/3]

std::vector<PDF*> LHAPDF::PDFSet::mkPDFs ( ) const
inline

Make all the PDFs in this set, returning as a vector of PDF pointers

Note
As with the mkPDF method and factory function, the PDF pointers returned by this method are heap allocated and their memory management is now the responsibility of the caller.

◆ mkPDFs() [3/3]

template<typename PTR >
std::vector<PTR> LHAPDF::PDFSet::mkPDFs ( ) const
inline
Todo:
Use the following with default function template args if C++11 is being used

◆ name()

std::string LHAPDF::PDFSet::name ( ) const
inline

PDF set name.

Note
Not taken from the .info metadata file.

◆ randomValueFromHessian()

double LHAPDF::PDFSet::randomValueFromHessian ( const std::vector< double > &  values,
const std::vector< double > &  randoms,
bool  symmetrise = true 
) const

Generate a random value from Hessian values and Gaussian random numbers.

Note
This routine is intended for advanced users!

See Section 6 of G. Watt and R.S. Thorne, JHEP 1208 (2012) 052 [arXiv:1205.4024 [hep-ph]].

Pass a vector values containing a value for each member of the Hessian PDF set. Pass a vector randoms containing neigen random numbers, where neigen is the number of distinct eigenvectors.

Option symmetrise equal to true will symmetrise the random values (in the case of an asymmetric Hessian set) using a corrected Eq. (6.5) of arXiv:1205.4024v2, so that the average tends to the best-fit for a large number of replicas.

Option symmetrise equal to false will use Eq. (6.4) of arXiv:1205.4024v2 (for an asymmetric Hessian set), then the average differs from the best-fit. Option symmetrise has no effect for a symmetric Hessian set.

Random values generated in this way can subsequently be used for applications such as Bayesian reweighting or combining predictions from different groups (as an alternative to taking the envelope). See, for example, supplementary material at http://mstwpdf.hepforge.org/random/.

Use of this routine with a non-Hessian PDF set will throw a UserError.

For a combined set, the parameter variations are not included in the generation of the random value.

◆ uncertainty() [1/2]

PDFUncertainty LHAPDF::PDFSet::uncertainty ( const std::vector< double > &  values,
double  cl = 100 *erf(1/sqrt(2)),
bool  alternative = false 
) const

Calculate central value and error from vector values with appropriate formulae for this set.

In the Hessian approach, the central value is the best-fit "values[0]" and the uncertainty is given by either the symmetric or asymmetric formula using eigenvector PDF sets.

If the PDF set is given in the form of replicas, by default, the central value is given by the mean and is not necessarily "values[0]" for quantities with a non-linear dependence on PDFs, while the uncertainty is given by the standard deviation.

Optional argument clpct is used to rescale uncertainties to a particular confidence level (in percent); a negative number will rescale to the default CL for this set.

Note
If cl is omitted, automatically rescale to normal 1-sigma ~ 68.268949% uncertainties.

If the PDF set is given in the form of replicas, then optional argument alternative equal to true (default: false) will construct a confidence interval from the probability distribution of replicas, with the central value given by the median.

For a combined set, a breakdown of the separate PDF and parameter variation uncertainties is available. The parameter variation uncertainties are computed from the last 2*n members of the set, with n the number of parameters.

◆ uncertainty() [2/2]

void LHAPDF::PDFSet::uncertainty ( PDFUncertainty rtn,
const std::vector< double > &  values,
double  cl = 100*erf(1/sqrt(2)),
bool  alternative = false 
) const
inline

Calculate PDF uncertainties (as above), with efficient no-copy return to the rtn argument.

Todo:
For real efficiency, the chaining of these functions should be the other way around

The documentation for this class was generated from the following file: