lhapdf
is hosted by
Hepforge
,
IPPP Durham
LHAPDF
6.5.4
Loading...
Searching...
No Matches
include
LHAPDF
PDFSet.h
1
// -*- C++ -*-
2
//
3
// This file is part of LHAPDF
4
// Copyright (C) 2012-2023 The LHAPDF collaboration (see AUTHORS for details)
5
//
6
#pragma once
7
#ifndef LHAPDF_PDFSet_H
8
#define LHAPDF_PDFSet_H
9
10
#include "LHAPDF/Info.h"
11
#include "LHAPDF/Factories.h"
12
#include "LHAPDF/Version.h"
13
#include "LHAPDF/Config.h"
14
#include "LHAPDF/Utils.h"
15
16
namespace
LHAPDF
{
17
18
20
const
double
CL1SIGMA
= 100*erf(1/sqrt(2));
21
22
23
// Forward declaration
24
class
PDF
;
25
26
31
32
36
struct
PDFUncertainty
{
37
using
ErrPairs = std::vector<std::pair<double,double>>;
38
40
PDFUncertainty
(
double
cent=0,
double
eplus=0,
double
eminus=0,
double
esymm=0,
double
scalefactor=1,
41
double
eplus_pdf=0,
double
eminus_pdf=0,
double
esymm_pdf=0,
42
double
eplus_par=0,
double
eminus_par=0,
double
esymm_par=0)
43
:
central
(cent), errplus(eplus), errminus(eminus), errsymm(esymm), scale(scalefactor),
44
errplus_pdf
(eplus_pdf), errminus_pdf(eminus_pdf), errsymm_pdf(esymm_pdf),
45
errplus_par(eplus_par), errminus_par(eminus_par), errsymm_par(esymm_par)
46
{ }
47
49
double
central
, errplus, errminus, errsymm, scale;
50
52
double
errplus_pdf
, errminus_pdf, errsymm_pdf;
53
double
errplus_par, errminus_par, errsymm_par;
54
double
err_par
;
55
57
ErrPairs
errparts
;
58
};
59
60
61
63
struct
PDFErrInfo
{
64
using
EnvPart = std::pair<std::string, size_t>;
65
using
EnvParts = std::vector<EnvPart>;
66
using
QuadParts = std::vector<EnvParts>;
67
69
PDFErrInfo
(QuadParts parts,
double
cl,
const
std::string& errtypestr=
""
)
70
:
qparts
(parts),
conflevel
(cl),
errtype
(errtypestr)
71
{ }
72
74
PDFErrInfo
() {}
75
77
QuadParts
qparts
;
78
80
double
conflevel
;
81
83
std::string
errtype
;
84
86
std::string
coreType
()
const
{
return
qpartName
(0); }
87
89
std::string
qpartName
(
size_t
iq)
const
;
91
std::vector<std::string>
qpartNames
()
const
;
92
94
size_t
nmemCore
()
const
;
96
size_t
nmemPar
()
const
;
97
98
};
99
101
102
103
105
class
PDFSet
:
public
Info
{
106
public
:
107
110
PDFSet
() { }
111
114
PDFSet
(
const
std::string& setname);
115
116
119
123
std::string
name
()
const
{
124
return
_setname
;
125
}
126
128
std::string
description
()
const
{
129
return
get_entry
(
"SetDesc"
);
130
}
131
133
int
lhapdfID
()
const
{
134
return
get_entry_as<int>
(
"SetIndex"
, -1);
135
}
136
138
int
dataversion
()
const
{
139
return
get_entry_as<int>
(
"DataVersion"
, -1);
140
}
141
143
std::string
errorType
()
const
{
144
return
to_lower
(
get_entry
(
"ErrorType"
,
"UNKNOWN"
));
145
}
146
148
PDFErrInfo
errorInfo
()
const
;
149
154
double
errorConfLevel
()
const
;
155
157
// int numMembers() const {
158
// return get_entry_as<int>("NumMembers");
159
// }
160
size_t
size
()
const
{
161
return
get_entry_as<unsigned int>
(
"NumMembers"
);
162
}
163
167
size_t
errorSize
()
const
{
168
return
size
()-1;
169
}
173
size_t
errSize
()
const
{
174
return
errorSize
();
175
}
176
178
179
181
void
print
(std::ostream& os=std::cout,
int
verbosity
=1)
const
;
182
183
186
192
PDF
*
mkPDF
(
size_t
member)
const
{
193
return
LHAPDF::mkPDF
(
name
(), member);
194
}
195
196
217
//
219
template
<
typename
PTR>
220
void
mkPDFs
(std::vector<PTR>& pdfs)
const
{
221
const
int
v =
verbosity
();
222
if
(v > 0) {
223
std::cout <<
"LHAPDF "
<<
version
() <<
" loading all "
<<
size
() <<
" PDFs in set "
<<
name
() << std::endl;
224
this->
print
(std::cout, v);
225
if
(this->
has_key
(
"Note"
)) std::cout <<
get_entry
(
"Note"
) << std::endl;
226
}
227
pdfs.clear();
228
pdfs.reserve(
size
());
229
if
(v < 2)
setVerbosity
(0);
//< Disable every-member printout unless verbosity level is high
230
for
(
size_t
i = 0; i <
size
(); ++i) {
232
pdfs.push_back( PTR(
mkPDF
(i)) );
233
}
234
setVerbosity
(v);
235
}
236
242
std::vector<PDF*>
mkPDFs
()
const
{
243
std::vector<PDF*> rtn;
244
mkPDFs
(rtn);
245
return
rtn;
246
}
247
249
// template <typename PTR=PDF*>
250
template
<
typename
PTR>
251
std::vector<PTR>
mkPDFs
()
const
{
252
std::vector<PTR> rtn;
253
mkPDFs
(rtn);
254
return
rtn;
255
}
256
258
259
261
262
265
267
std::vector<std::string>
keys
()
const
{
268
std::vector<std::string> rtn =
getConfig
().
keys
();
269
for
(
const
std::string& k :
keys_local
()) {
270
if
(!
contains
(rtn, k)) rtn.push_back(k);
271
}
272
return
rtn;
273
}
274
276
bool
has_key
(
const
std::string& key)
const
{
277
return
has_key_local
(key) ||
getConfig
().
has_key
(key);
278
}
279
281
const
std::string&
get_entry
(
const
std::string& key)
const
{
282
if
(
has_key_local
(key))
return
get_entry_local
(key);
//< value is defined locally
283
return
getConfig
().
get_entry
(key);
//< fall back to the global config
284
}
285
287
const
std::string&
get_entry
(
const
std::string& key,
const
std::string& fallback)
const
{
288
return
Info::get_entry
(key, fallback);
289
}
290
292
293
298
330
PDFUncertainty
uncertainty
(
const
std::vector<double>& values,
331
double
cl=
CL1SIGMA
,
bool
alternative=
false
)
const
{
332
PDFUncertainty
rtn;
333
uncertainty
(rtn, values, cl, alternative);
334
return
rtn;
335
}
336
337
338
// // Trick to ensure no calls with implicit type conversion
339
// template <typename T1, typename T2>
340
// void uncertainty(const std::vector<double>& values, T1, T2) const = delete;
341
342
// /// Alternative form allowing the alternative computation with default CL
343
// PDFUncertainty uncertainty(const std::vector<double>& values,
344
// bool alternative, double cl=CL1SIGMA) const {
345
// return uncertainty(values, cl, alternative);
346
// }
347
348
356
void
uncertainty
(
PDFUncertainty
& rtn,
357
const
std::vector<double>& values,
358
double
cl=
CL1SIGMA
,
bool
alternative=
false
)
const
;
359
360
// // Trick to ensure no calls with implicit type conversion
361
// template <typename T1, typename T2>
362
// void uncertainty(PDFUncertainty& rtn, const std::vector<double>& values, T1, T2) const = delete;
363
364
// /// Alternative form allowing the alternative computation with default CL
365
// void uncertainty(PDFUncertainty& rtn,
366
// const std::vector<double>& values,
367
// bool alternative, double cl=CL1SIGMA) const {
368
// uncertainty(rtn, values, cl, alternative);
369
// }
370
371
384
std::vector<PDFUncertainty>
uncertainties
(
const
std::vector<std::vector<double>>& observables_values,
385
double
cl=
CL1SIGMA
,
bool
alternative=
false
)
const
{
386
std::vector<PDFUncertainty> rtn;
387
uncertainties
(rtn, observables_values, cl, alternative);
388
return
rtn;
389
}
390
391
396
void
uncertainties
(std::vector<PDFUncertainty>& rtn,
397
const
std::vector<std::vector<double>>& observables_values,
398
double
cl=
CL1SIGMA
,
bool
alternative=
false
)
const
;
399
400
409
double
correlation
(
const
std::vector<double>& valuesA,
const
std::vector<double>& valuesB)
const
;
410
435
double
randomValueFromHessian
(
const
std::vector<double>& values,
const
std::vector<double>& randoms,
bool
symmetrise=
true
)
const
;
436
437
443
void
_checkPdfType
(
const
std::vector<string>& pdftypes)
const
;
444
446
447
448
private
:
449
451
std::string
_setname
;
452
454
mutable
PDFErrInfo
_errinfo
;
455
456
};
457
458
459
}
460
#endif
LHAPDF::Info
Metadata base class for PDFs, PDF sets, or global configuration.
Definition
Info.h:29
LHAPDF::Info::get_entry
virtual const std::string & get_entry(const std::string &key) const
Definition
Info.h:119
LHAPDF::Info::keys_local
std::vector< std::string > keys_local() const
Get the keys defined on this specific object.
Definition
Info.h:70
LHAPDF::Info::keys
std::vector< std::string > keys() const
Definition
Info.h:82
LHAPDF::Info::get_entry_local
const std::string & get_entry_local(const std::string &key) const
Retrieve a metadata string by key name, as defined on this specific object.
Definition
Info.h:106
LHAPDF::Info::has_key
virtual bool has_key(const std::string &key) const
Definition
Info.h:100
LHAPDF::Info::get_entry_as
T get_entry_as(const std::string &key) const
Definition
Info.h:139
LHAPDF::Info::has_key_local
bool has_key_local(const std::string &key) const
Is a value defined for the given key on this specific object?
Definition
Info.h:87
LHAPDF::PDFSet
Class for PDF-set metadata and manipulation.
Definition
PDFSet.h:105
LHAPDF::PDFSet::size
size_t size() const
Number of members in this set.
Definition
PDFSet.h:160
LHAPDF::PDFSet::errorInfo
PDFErrInfo errorInfo() const
Get the structured decomposition of the error-type string.
LHAPDF::PDFSet::uncertainty
void uncertainty(PDFUncertainty &rtn, const std::vector< double > &values, double cl=CL1SIGMA, bool alternative=false) const
Calculate the PDF uncertainty on an observable (as above), with efficient no-copy return to the rtn a...
LHAPDF::PDFSet::errorConfLevel
double errorConfLevel() const
Get the confidence level of the Hessian eigenvectors, in percent.
LHAPDF::PDFSet::PDFSet
PDFSet(const std::string &setname)
LHAPDF::PDFSet::mkPDFs
std::vector< PTR > mkPDFs() const
Definition
PDFSet.h:251
LHAPDF::PDFSet::has_key
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)
Definition
PDFSet.h:276
LHAPDF::PDFSet::mkPDFs
std::vector< PDF * > mkPDFs() const
Definition
PDFSet.h:242
LHAPDF::PDFSet::dataversion
int dataversion() const
Version of this PDF set's data files.
Definition
PDFSet.h:138
LHAPDF::PDFSet::print
void print(std::ostream &os=std::cout, int verbosity=1) const
Summary printout.
LHAPDF::PDFSet::randomValueFromHessian
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.
LHAPDF::PDFSet::errSize
size_t errSize() const
Definition
PDFSet.h:173
LHAPDF::PDFSet::mkPDF
PDF * mkPDF(size_t member) const
Definition
PDFSet.h:192
LHAPDF::PDFSet::_checkPdfType
void _checkPdfType(const std::vector< string > &pdftypes) const
LHAPDF::PDFSet::uncertainties
void uncertainties(std::vector< PDFUncertainty > &rtn, const std::vector< std::vector< double > > &observables_values, double cl=CL1SIGMA, bool alternative=false) const
Calculate multiple PDF uncertainties (as above), with efficient no-copy return to the rtn argument.
LHAPDF::PDFSet::lhapdfID
int lhapdfID() const
First LHAPDF global index in this PDF set.
Definition
PDFSet.h:133
LHAPDF::PDFSet::keys
std::vector< std::string > keys() const
Get the keys defined on this object or higher.
Definition
PDFSet.h:267
LHAPDF::PDFSet::correlation
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.
LHAPDF::PDFSet::_errinfo
PDFErrInfo _errinfo
Cached PDF error-info breakdown struct.
Definition
PDFSet.h:454
LHAPDF::PDFSet::uncertainty
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
LHAPDF::PDFSet::name
std::string name() const
PDF set name.
Definition
PDFSet.h:123
LHAPDF::PDFSet::errorType
std::string errorType() const
Get the type of PDF errors in this set (replicas, symmhessian, hessian, custom, etc....
Definition
PDFSet.h:143
LHAPDF::PDFSet::PDFSet
PDFSet()
Definition
PDFSet.h:110
LHAPDF::PDFSet::get_entry
const std::string & get_entry(const std::string &key) const
Retrieve a metadata string by key name.
Definition
PDFSet.h:281
LHAPDF::PDFSet::get_entry
const std::string & get_entry(const std::string &key, const std::string &fallback) const
Retrieve a metadata string by key name, with a fallback.
Definition
PDFSet.h:287
LHAPDF::PDFSet::uncertainties
std::vector< PDFUncertainty > uncertainties(const std::vector< std::vector< double > > &observables_values, double cl=CL1SIGMA, bool alternative=false) const
Calculate PDF uncertainties on multiple observables at once.
Definition
PDFSet.h:384
LHAPDF::PDFSet::description
std::string description() const
Description of the set.
Definition
PDFSet.h:128
LHAPDF::PDFSet::_setname
std::string _setname
Name of this set.
Definition
PDFSet.h:451
LHAPDF::PDFSet::errorSize
size_t errorSize() const
Definition
PDFSet.h:167
LHAPDF::PDFSet::mkPDFs
void mkPDFs(std::vector< PTR > &pdfs) const
Definition
PDFSet.h:220
LHAPDF::PDF
PDF is the general interface for access to parton density information.
Definition
PDF.h:40
LHAPDF::getConfig
Info & getConfig()
LHAPDF::mkPDF
PDF * mkPDF(const std::string &setname, size_t member)
LHAPDF::contains
bool contains(const std::string &s, const std::string &sub)
Does a string s contain the sub substring?
Definition
Utils.h:110
LHAPDF::to_lower
std::string to_lower(const std::string &s)
Convert a string to lower-case (not in-place)
Definition
Utils.h:138
LHAPDF::verbosity
int verbosity()
Definition
Config.h:56
LHAPDF::setVerbosity
void setVerbosity(int v)
Definition
Config.h:65
LHAPDF
Namespace for all LHAPDF functions and classes.
Definition
AlphaS.h:14
LHAPDF::CL1SIGMA
const double CL1SIGMA
CL percentage for a Gaussian 1-sigma.
Definition
PDFSet.h:20
LHAPDF::version
std::string version()
Get the LHAPDF library version code (as a string)
Definition
Version.h:33
LHAPDF::PDFErrInfo
Structure encoding the structure of the PDF error-set.
Definition
PDFSet.h:63
LHAPDF::PDFErrInfo::qparts
QuadParts qparts
Error-set quadrature parts.
Definition
PDFSet.h:77
LHAPDF::PDFErrInfo::coreType
std::string coreType() const
Calculated name of a quadrature part.
Definition
PDFSet.h:86
LHAPDF::PDFErrInfo::nmemCore
size_t nmemCore() const
Number of core-set members.
LHAPDF::PDFErrInfo::conflevel
double conflevel
Default confidence-level.
Definition
PDFSet.h:80
LHAPDF::PDFErrInfo::PDFErrInfo
PDFErrInfo(QuadParts parts, double cl, const std::string &errtypestr="")
Constructor.
Definition
PDFSet.h:69
LHAPDF::PDFErrInfo::nmemPar
size_t nmemPar() const
Number of par-set members.
LHAPDF::PDFErrInfo::errtype
std::string errtype
Error-type annotation.
Definition
PDFSet.h:83
LHAPDF::PDFErrInfo::PDFErrInfo
PDFErrInfo()
Default constructor (for STL, Cython, etc.)
Definition
PDFSet.h:74
LHAPDF::PDFErrInfo::qpartName
std::string qpartName(size_t iq) const
Calculated name of a quadrature part.
LHAPDF::PDFErrInfo::qpartNames
std::vector< std::string > qpartNames() const
Calculated names of all quadrature parts.
LHAPDF::PDFUncertainty
Structure for storage of uncertainty info calculated over a PDF error set.
Definition
PDFSet.h:36
LHAPDF::PDFUncertainty::PDFUncertainty
PDFUncertainty(double cent=0, double eplus=0, double eminus=0, double esymm=0, double scalefactor=1, double eplus_pdf=0, double eminus_pdf=0, double esymm_pdf=0, double eplus_par=0, double eminus_par=0, double esymm_par=0)
Constructor.
Definition
PDFSet.h:40
LHAPDF::PDFUncertainty::central
double central
Variables for the central value, +ve, -ve & symmetrised errors, and a CL scalefactor.
Definition
PDFSet.h:49
LHAPDF::PDFUncertainty::errplus_pdf
double errplus_pdf
Variables for separate PDF and parameter variation errors with combined sets.
Definition
PDFSet.h:52
LHAPDF::PDFUncertainty::errparts
ErrPairs errparts
Full error-breakdown of all quadrature uncertainty components, as (+,-) pairs.
Definition
PDFSet.h:57
LHAPDF::PDFUncertainty::err_par
double err_par
Definition
PDFSet.h:54
Generated on Thu Sep 26 2024 15:19:26 for LHAPDF by
1.12.0