lhapdf is hosted by Hepforge, IPPP Durham
LHAPDF 6.5.4
Loading...
Searching...
No Matches
/tests/testinfo.cc
// Example program for testing the info system
#include "LHAPDF/Info.h"
#include "LHAPDF/Config.h"
#include "LHAPDF/PDFInfo.h"
#include "LHAPDF/PDFSet.h"
#include "LHAPDF/Factories.h"
#include <iostream>
#ifdef HAVE_MPI
#include <mpi.h>
#endif
using namespace std;
int main(int argc, char* argv[]) {
#ifdef HAVE_MPI
MPI_Init(&argc, &argv);
#endif
// cout << "UndefFlavorAction: " << cfg.get_entry("UndefFlavorAction") << endl;
cout << "Verbosity: " << cfg.get_entry("Verbosity") << endl;
cfg.set_entry("Verbosity", 5);
cout << "New Verbosity from second Config: " << cfg2.get_entry("Verbosity") << endl;
const LHAPDF::PDFSet set("CT10nlo");
cout << "SetDesc: " << set.get_entry("SetDesc") << endl;
cout << "Verbosity from set: " << set.get_entry("Verbosity") << endl;
const LHAPDF::PDFInfo info("CT10nlo", 2);
if (info.has_key("PdfDesc")) cout << "PdfDesc: " << info.get_entry("PdfDesc") << endl;
cout << "PdfType: " << info.get_entry("PdfType") << endl;
cout << "Verbosity from PDF: " << info.get_entry("Verbosity") << endl;
vector<int> pids = info.get_entry_as< vector<int> >("Flavors");
cout << "PIDs (1): "; for (int f : pids) { cout << f << " "; } cout << endl;
cout << "PIDs (2): " << LHAPDF::to_str(pids) << endl;
// Now test loading of all central PDFs
for (const string& name : LHAPDF::availablePDFSets()) {
cout << "Testing PDFInfo for " << name << endl;
i->has_key("Foo"); // < Force loading of all info levels
delete i;
}
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return 0;
}
Metadata base class for PDFs, PDF sets, or global configuration.
Definition Info.h:29
virtual const std::string & get_entry(const std::string &key) const
Definition Info.h:119
void set_entry(const std::string &key, const T &val)
Set a keyed value entry.
Definition Info.h:158
T get_entry_as(const std::string &key) const
Definition Info.h:139
Metadata class for PDF members.
Definition PDFInfo.h:18
const std::string & get_entry(const std::string &key) const
Retrieve a metadata string by key name.
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)
Class for PDF-set metadata and manipulation.
Definition PDFSet.h:105
PDFInfo * mkPDFInfo(const std::string &setname, size_t member)
Info & getConfig()
const std::vector< std::string > & availablePDFSets()
Get the names of all available PDF sets in the search path.
std::string to_str(const T &val)
Make a string representation of val.
Definition Utils.h:61