lhapdf is hosted by Hepforge, IPPP Durham
LHAPDF 6.5.5
Loading...
Searching...
No Matches
Paths.h
1// -*- C++ -*-
2//
3// This file is part of LHAPDF
4// Copyright (C) 2012-2024 The LHAPDF collaboration (see AUTHORS for details)
5//
6#pragma once
7#ifndef LHAPDF_Paths_H
8#define LHAPDF_Paths_H
9
10#include "LHAPDF/Utils.h"
11
12namespace LHAPDF {
13
14
15 /// @defgroup search Searching for PDF data
16 ///@{
17
18
19 /// @name Search path handling functions
20 ///@{
21
22 /// @brief Get the ordered list of search paths, from $LHAPDF_DATA_PATH and the install location
23 /// @note The install prefix will be appended *unless* $LHAPDF_DATA_PATH ends with a double colon, i.e. '::'
25
26 /// Set the search paths list as a colon-separated string
27 void setPaths(const std::string& pathstr);
28 /// Set the search paths list
29 inline void setPaths(std::vector<string> paths) {
30 setPaths(join(paths, ":"));
31 }
32
33
34 /// Prepend to the search paths list
35 inline void pathsPrepend(const std::string& p) {
36 vector<string> ps = paths();
37 ps.insert(ps.begin(), p);
38 //ps.pop_back(); //< Discard the auto-added fallback path to the installed data prefix
39 setPaths(ps);
40 }
41
42
43 /// Append to the search paths list
44 inline void pathsAppend(const std::string& p) {
45 vector<string> ps = paths();
46 //ps.pop_back(); //< Discard the auto-added fallback path to the installed data prefix
47 ps.push_back(p);
48 setPaths(ps);
49 }
50
51
52 /// Return the first location in which a file is found
53 ///
54 /// If no matching file is found, return an empty path.
55 std::string findFile(const std::string& target);
56
57 /// Return all locations in which a file is found
58 std::vector<std::string> findFiles(const std::string& target);
59
60 ///@}
61
62
63 /// @name PDF-specific path functions
64 ///@{
65
66 /// Get the standard path-end elements expected for a PDF member data-file
67 inline std::string pdfmempath(const std::string& setname, int member) {
68 const string memname = setname + "_" + to_str_zeropad(member) + ".dat";
69 const string mempath = setname / memname;
70 return mempath;
71 }
72
73 /// Search for the data-path of a PDF member
74 inline std::string findpdfmempath(const std::string& setname, int member) {
75 return findFile(pdfmempath(setname, member));
76 }
77
78 /// Get the standard path-end elements expected for a PDF set's info-file
79 inline std::string pdfsetinfopath(const std::string& setname) {
80 const string infoname = setname + ".info";
81 const string setinfo = setname / infoname;
82 return setinfo;
83 }
84
85 /// Search for the info-path of a PDF set
86 inline std::string findpdfsetinfopath(const std::string& setname) {
87 /// @todo Check that set info and mem=0 file are in same dir?
88 return findFile(pdfsetinfopath(setname));
89 }
90
91
92 /// @brief Get the names of all available PDF sets in the search path
93 ///
94 /// @note Taken from scanning the directories in the search path
95 /// (i.e. LHAPDF_DATA_PATH) for viable PDF sets.
96 ///
97 /// @note The result is cached when first called, to avoid repeated filesystem
98 /// walking. It's assumed that new PDFs will not appear on the filesystem
99 /// during a run: please let the authors know if that's not a good assumption!
101
102 ///@}
103
104
105}
106
107#endif
const std::vector< std::string > & availablePDFSets()
Get the names of all available PDF sets in the search path.
std::string findpdfmempath(const std::string &setname, int member)
Search for the data-path of a PDF member.
Definition Paths.h:74
void pathsAppend(const std::string &p)
Append to the search paths list.
Definition Paths.h:44
std::string pdfmempath(const std::string &setname, int member)
Get the standard path-end elements expected for a PDF member data-file.
Definition Paths.h:67
std::vector< std::string > findFiles(const std::string &target)
Return all locations in which a file is found.
std::string findFile(const std::string &target)
void pathsPrepend(const std::string &p)
Prepend to the search paths list.
Definition Paths.h:35
std::vector< std::string > paths()
Get the ordered list of search paths, from $LHAPDF_DATA_PATH and the install location.
std::string findpdfsetinfopath(const std::string &setname)
Search for the info-path of a PDF set.
Definition Paths.h:86
void setPaths(const std::string &pathstr)
Set the search paths list as a colon-separated string.
std::string pdfsetinfopath(const std::string &setname)
Get the standard path-end elements expected for a PDF set's info-file.
Definition Paths.h:79
void setPaths(std::vector< string > paths)
Set the search paths list.
Definition Paths.h:29
Namespace for all LHAPDF functions and classes.
Definition AlphaS.h:14