Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:19:19

0001 // -*- C++ -*-
0002 //
0003 // This file is part of LHAPDF
0004 // Copyright (C) 2012-2024 The LHAPDF collaboration (see AUTHORS for details)
0005 //
0006 #pragma once
0007 #ifndef LHAPDF_Factories_H
0008 #define LHAPDF_Factories_H
0009 
0010 #include <string>
0011 
0012 namespace LHAPDF {
0013 
0014 
0015   // Forward declarations to avoid circular dependencies
0016   class PDF;
0017   class Info;
0018   class PDFSet;
0019   class PDFInfo;
0020   class Config;
0021   class Interpolator;
0022   class Extrapolator;
0023   class AlphaS;
0024 
0025 
0026   /// @defgroup factories Factory functions
0027   ///@{
0028 
0029   /// @defgroup factories_pdf Making single PDFs
0030   ///@{
0031 
0032   /// Create a new PDF with the given PDF set name and member ID.
0033   ///
0034   /// Returns a 'new'ed PDF by pointer.
0035   /// The caller is responsible for deletion of the created object.
0036   PDF* mkPDF(const std::string& setname, size_t member);
0037 
0038   /// Create a new PDF with the given LHAPDF ID code.
0039   ///
0040   /// Returns a 'new'ed PDF by pointer.
0041   /// The caller is responsible for deletion of the created object.
0042   PDF* mkPDF(int lhaid);
0043 
0044   /// Create a new PDF with the given PDF set name and member ID as a single string.
0045   ///
0046   /// The format of the @a setname_nmem string is <setname>/<nmem>
0047   /// where <nmem> must be parseable as a positive integer. The /
0048   /// character is not permitted in set names due to clashes with
0049   /// Unix filesystem path syntax.
0050   ///
0051   /// If no /<nmem> is given, member number 0 will be used.
0052   ///
0053   /// Returns a 'new'ed PDF by pointer.
0054   /// The caller is responsible for deletion of the created object.
0055   PDF* mkPDF(const std::string& setname_nmem);
0056 
0057   ///@}
0058 
0059 
0060   /// @defgroup factories_pdfs Making whole PDF sets
0061   ///@{
0062 
0063   /// Get the PDFSet with the given set name.
0064   ///
0065   /// Returns a PDFSet by reference. When this function is used for
0066   /// access, only one PDFSet object is made per set name... hence the
0067   /// 'get' rather than 'mk' function name.
0068   ///
0069   /// This function is intended particularly for use where it would be
0070   /// inefficient to have to repeatedly construct a PDFSet by name. The
0071   /// canonical use case is internal: the Info system uses this to ensure that
0072   /// cascading of config settings is efficient, and also allows the automatic
0073   /// application of set-level changes to all PDF member objects in that set.
0074   ///
0075   /// @note The LHAPDF system is responsible for deletion of the returned
0076   /// object. Do NOT delete it yourself! Hence the return by reference rather
0077   /// than pointer.
0078   PDFSet& getPDFSet(const std::string& setname);
0079 
0080   /// Get all PDFs in a named set (return by filling the supplied vector).
0081   void mkPDFs(const std::string& setname, std::vector<PDF*>& pdfs);
0082 
0083   /// Get all PDFs in a named set (return by a new vector).
0084   std::vector<PDF*> mkPDFs(const std::string& setname);
0085 
0086   /// Get all PDFs in a named set (return by filling the supplied vector).
0087   ///
0088   /// This is a templated version for returning a vector of smart ptrs
0089   template <typename PTR>
0090   void mkPDFs(const std::string& setname, std::vector<PTR>& pdfs) {
0091     std::vector<PDF*> rawptrs;
0092     mkPDFs(setname, rawptrs);
0093     pdfs.clear();
0094     pdfs.reserve(rawptrs.size());
0095     // for (const PDF* p : rawptrs) pdfs.push_back(PTR(p)); //< Reinstate when C++11 is guaranteed, without flags
0096     for (size_t i = 0; i < rawptrs.size(); ++i) pdfs.push_back(PTR(rawptrs[i]));
0097   }
0098 
0099   ///@}
0100 
0101 
0102   /// @defgroup factories_info Making metadata objects
0103   ///@{
0104 
0105   /// Get the global configuration object
0106   ///
0107   /// The global config is populated by reading from lhapdf.conf if it is found
0108   /// in the search paths. It is a singleton, hence the 'get' rather than 'mk'
0109   /// function name.
0110   ///
0111   /// @note The LHAPDF system is responsible for deletion of the returned
0112   /// object. Do NOT delete it yourself! Hence the return by reference rather
0113   /// than pointer.
0114   // Config& getConfig();
0115   Info& getConfig();
0116 
0117   /// Create a new Info object for the given set name and member number.
0118   ///
0119   /// Returns a 'new'ed Info by pointer.
0120   /// The caller is responsible for deletion of the created object.
0121   PDFInfo* mkPDFInfo(const std::string& setname, size_t member);
0122 
0123   /// Create a new Info object with the given LHAPDF ID code.
0124   ///
0125   /// Returns a 'new'ed Info by pointer.
0126   /// The caller is responsible for deletion of the created object.
0127   PDFInfo* mkPDFInfo(int lhaid);
0128 
0129   /// Create a new Info object for the given set name and member number as a single string.
0130   ///
0131   /// The format of the @a setname_nmem string is <setname>/<nmem>
0132   /// where <nmem> must be parseable as a positive integer. The /
0133   /// character is not permitted in set names due to clashes with
0134   /// Unix filesystem path syntax.
0135   ///
0136   /// If no /<nmem> is given, member number 0 will be used.
0137   ///
0138   /// Returns a 'new'ed Info by pointer.
0139   /// The caller is responsible for deletion of the created object.
0140   PDFInfo* mkPDFInfo(const std::string& setname_nmem);
0141 
0142   ///@}
0143 
0144 
0145   /// @defgroup factories_ipolxpol Making grid interpolators/extrapolators
0146   ///@{
0147 
0148   /// Interpolator factory
0149   ///
0150   /// Returns a 'new'ed Interpolator by pointer. Unless passed to a GridPDF,
0151   /// the caller is responsible for deletion of the created object.
0152   Interpolator* mkInterpolator(const std::string& name);
0153 
0154 
0155   /// Extrapolator factory
0156   ///
0157   /// Returns a 'new'ed Extrapolator by pointer. Unless passed to a GridPDF,
0158   /// the caller is responsible for deletion of the created object.
0159   Extrapolator* mkExtrapolator(const std::string& name);
0160 
0161   ///@}
0162 
0163 
0164   /// @defgroup factories_alphas Making AlphaS objects
0165   ///@{
0166 
0167   /// @brief Make an AlphaS object from an Info object
0168   ///
0169   /// The type and configuration of the returned AlphaS is chosen based on the
0170   /// PDF metadata Info object given as the argument.
0171   ///
0172   /// Returns a 'new'ed AlphaS by pointer. Unless attached to a PDF,
0173   /// the caller is responsible for deletion of the created object.
0174   AlphaS* mkAlphaS(const Info& info);
0175 
0176   /// @brief Make an AlphaS object for the specified PDF
0177   ///
0178   /// The type and configuration of the returned AlphaS is chosen based on the
0179   /// named PDFSet's nth member's metadata.
0180   ///
0181   /// Returns a 'new'ed AlphaS by pointer. Unless attached to a PDF,
0182   /// the caller is responsible for deletion of the created object.
0183   AlphaS* mkAlphaS(const std::string& setname, size_t member);
0184 
0185   /// @brief Make an AlphaS object for the specified PDF
0186   ///
0187   /// The type and configuration of the returned AlphaS is chosen based on the
0188   /// numbered PDF's metadata.
0189   ///
0190   /// Returns a 'new'ed AlphaS by pointer. Unless attached to a PDF,
0191   /// the caller is responsible for deletion of the created object.
0192   AlphaS* mkAlphaS(int lhaid);
0193 
0194   /// Create an AlphaS object for the given set name and member number as a single string
0195   ///
0196   /// The format of the @a setname_nmem string is <setname>/<nmem>
0197   /// where <nmem> must be parseable as a positive integer. The /
0198   /// character is not permitted in set names due to clashes with
0199   /// Unix filesystem path syntax.
0200   ///
0201   /// If no /<nmem> is given, the type and configuration of the returned AlphaS
0202   /// is chosen based on the named PDFSet's metadata, NOT the info of member
0203   /// number 0 as for similar methods. If there is a distinction and you specifically want
0204   /// the AlphaS for the central member rather than that specified for the set as a whole,
0205   /// make sure to include the "/0"!
0206   ///
0207   /// Returns a 'new'ed AlphaS by pointer. Unless attached to a PDF,
0208   /// the caller is responsible for deletion of the created object.
0209   AlphaS* mkAlphaS(const std::string& setname_nmem);
0210 
0211 
0212   /// @brief Make an AlphaS object of the requested type without a PDF reference
0213   ///
0214   /// No values are initialised and have to be configured by the caller.
0215   ///
0216   /// The caller is responsible for deletion of the created object.
0217   AlphaS* mkBareAlphaS(const std::string& type);
0218 
0219   ///@}
0220 
0221   ///@}
0222 
0223 }
0224 #endif