LHAPDF is hosted by Hepforge, IPPP Durham
LHAPDF  6.2.1
PDFSet.h
1 // -*- C++ -*-
2 //
3 // This file is part of LHAPDF
4 // Copyright (C) 2012-2016 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 
19  // Forward declaration
20  class PDF;
21 
22 
24  struct PDFUncertainty {
26  PDFUncertainty(double cent=0, double eplus=0, double eminus=0, double esymm=0, double scalefactor=1,
27  double eplus_pdf=0, double eminus_pdf=0, double esymm_pdf=0, double e_par=0)
28  : central(cent), errplus(eplus), errminus(eminus), errsymm(esymm), scale(scalefactor),
29  errplus_pdf(eplus_pdf), errminus_pdf(eminus_pdf), errsymm_pdf(esymm_pdf), err_par(e_par)
30  { }
32  double central, errplus, errminus, errsymm, scale;
34  double errplus_pdf, errminus_pdf, errsymm_pdf, err_par;
35  };
36 
37 
39  class PDFSet : public Info {
40  public:
41 
43 
44 
47  PDFSet() { }
48 
51  PDFSet(const std::string& setname);
52 
54 
55 
57 
58 
62  std::string name() const {
63  return _setname;
64  }
65 
67  std::string description() const {
68  return get_entry("SetDesc");
69  }
70 
72  int lhapdfID() const {
73  return get_entry_as<int>("SetIndex", -1);
74  }
75 
77  int dataversion() const {
78  return get_entry_as<int>("DataVersion", -1);
79  }
80 
82  std::string errorType() const {
83  return to_lower(get_entry("ErrorType", "UNKNOWN"));
84  }
85 
90  double errorConfLevel() const;
91 
93  // int numMembers() const {
94  // return get_entry_as<int>("NumMembers");
95  // }
96  size_t size() const {
97  return get_entry_as<unsigned int>("NumMembers");
98  }
99 
101 
102 
104  void print(std::ostream& os=std::cout, int verbosity=1) const;
105 
106 
108 
109 
115  PDF* mkPDF(int member) const {
116  return LHAPDF::mkPDF(name(), member);
117  }
118 
119 
140  //
142  template <typename PTR>
143  void mkPDFs(std::vector<PTR>& pdfs) const {
144  const int v = verbosity();
145  if (v > 0) {
146  std::cout << "LHAPDF " << version() << " loading all " << size() << " PDFs in set " << name() << std::endl;
147  this->print(std::cout, v);
148  if (this->has_key("Note")) std::cout << get_entry("Note") << std::endl;
149  }
150  pdfs.clear();
151  pdfs.reserve(size());
152  if (v < 2) setVerbosity(0); //< Disable every-member printout unless verbosity level is high
153  for (size_t i = 0; i < size(); ++i) {
155  pdfs.push_back( PTR(mkPDF(i)) );
156  }
157  setVerbosity(v);
158  }
159 
165  std::vector<PDF*> mkPDFs() const {
166  std::vector<PDF*> rtn;
167  mkPDFs(rtn);
168  return rtn;
169  }
170 
172  // template <typename PTR=PDF*>
173  template <typename PTR>
174  std::vector<PTR> mkPDFs() const {
175  std::vector<PTR> rtn;
176  mkPDFs(rtn);
177  return rtn;
178  }
179 
181 
182 
184 
185 
187 
188 
190  bool has_key(const std::string& key) const {
191  return has_key_local(key) || getConfig().has_key(key);
192  }
193 
195  const std::string& get_entry(const std::string& key) const {
196  if (has_key_local(key)) return get_entry_local(key); //< value is defined locally
197  return getConfig().get_entry(key); //< fall back to the global config
198  }
199 
201  const std::string& get_entry(const std::string& key, const std::string& fallback) const {
202  return Info::get_entry(key, fallback);
203  }
204 
206 
207 
209 
210 
236  PDFUncertainty uncertainty(const std::vector<double>& values,
237  double cl=100*erf(1/sqrt(2)), bool alternative=false) const;
238 
242  const std::vector<double>& values,
243  double cl=100*erf(1/sqrt(2)), bool alternative=false) const {
244  rtn = uncertainty(values, cl, alternative);
245  }
246 
253  double correlation(const std::vector<double>& valuesA, const std::vector<double>& valuesB) const;
254 
277  double randomValueFromHessian(const std::vector<double>& values, const std::vector<double>& randoms, bool symmetrise=true) const;
278 
279 
284  void _checkPdfType(const std::vector<string>& pdftypes) const;
285 
287 
288 
289  private:
290 
292  std::string _setname;
293 
294  };
295 
296 
297 }
298 #endif
double errplus_pdf
Add extra variables for separate PDF and parameter variation errors with combined sets...
Definition: PDFSet.h:34
std::string version()
Get the LHAPDF library version code (as a string)
Definition: Version.h:33
std::string description() const
Description of the set.
Definition: PDFSet.h:67
PDF is the general interface for access to parton density information.
Definition: PDF.h:26
double central
Variables for the central value, +ve, -ve & symmetrised errors, and a CL scalefactor.
Definition: PDFSet.h:32
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:201
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:190
std::string _setname
Name of this set.
Definition: PDFSet.h:292
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 e_par=0)
Constructor.
Definition: PDFSet.h:26
PDF * mkPDF(const std::string &setname, int member)
void uncertainty(PDFUncertainty &rtn, const std::vector< double > &values, double cl=100 *erf(1/sqrt(2)), bool alternative=false) const
Definition: PDFSet.h:241
virtual bool has_key(const std::string &key) const
Definition: Info.h:89
PDF * mkPDF(int member) const
Definition: PDFSet.h:115
Info & getConfig()
virtual const std::string & get_entry(const std::string &key) const
Definition: Info.h:108
int dataversion() const
Version of this PDF set&#39;s data files.
Definition: PDFSet.h:77
PDFSet()
Definition: PDFSet.h:47
void mkPDFs(const std::string &setname, std::vector< PDF *> &pdfs)
Get all PDFs in a named set (return by filling the supplied vector).
std::string to_lower(const std::string &s)
Convert a string to lower-case (not in-place)
Definition: Utils.h:137
const std::string & get_entry(const std::string &key) const
Retrieve a metadata string by key name.
Definition: PDFSet.h:195
Class for PDF set metadata and manipulation.
Definition: PDFSet.h:39
int verbosity()
Definition: Config.h:65
Namespace for all LHAPDF functions and classes.
Definition: AlphaS.h:14
std::string errorType() const
Get the type of PDF errors in this set (replicas, symmhessian, hessian, custom, etc.)
Definition: PDFSet.h:82
void setVerbosity(int v)
Definition: Config.h:72
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:259
size_t size() const
Number of members in this set.
Definition: PDFSet.h:96
Metadata base class for PDFs, PDF sets, or global configuration.
Definition: Info.h:30
std::vector< PTR > mkPDFs() const
Definition: PDFSet.h:174
Structure for storage of uncertainty info calculated over a PDF error set.
Definition: PDFSet.h:24
int lhapdfID() const
First LHAPDF global index in this PDF set.
Definition: PDFSet.h:72
std::vector< PDF * > mkPDFs() const
Definition: PDFSet.h:165
void mkPDFs(std::vector< PTR > &pdfs) const
Definition: PDFSet.h:143
std::string name() const
PDF set name.
Definition: PDFSet.h:62