Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:28

0001 // -*- C++ -*-
0002 //
0003 // LHAPDF6.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 2014-2019 Leif Lonnblad, David Grellscheid
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef THEPEG_LHAPDF6_H
0010 #define THEPEG_LHAPDF6_H
0011 //
0012 // This is the declaration of the LHAPDF class.
0013 //
0014 
0015 #include "ThePEG/PDF/PDFBase.h"
0016 
0017 namespace LHAPDF {
0018     class PDF;
0019 }
0020 
0021 namespace ThePEG {
0022 
0023 /**
0024  * The LHAPDF class inherits from PDFBase and implements an interface
0025  * to the LHAPDF library of parton density function
0026  * parameterizations. This class is available even if LHAPDF was not
0027  * properly installed when ThePEG was installed, but will then produce
0028  * an error in the initialization.
0029  *
0030  * Note that the valence densities from the xfvx() and xfvl() function
0031  * will only work properly for nucleons. All other particles will have
0032  * zero valence densities.
0033  *
0034  * @see \ref LHAPDFInterfaces "The interfaces"
0035  * defined for LHAPDF.
0036  */
0037 class LHAPDF: public PDFBase {
0038 
0039 public:
0040 
0041   /** @name Standard constructors and destructors. */
0042   //@{
0043   /**
0044    * The default constructor.
0045    */
0046   LHAPDF();
0047 
0048   /**
0049    * The copy constructor.
0050    */
0051   LHAPDF(const LHAPDF &);
0052   //@}
0053 
0054 public:
0055 
0056   /** @name Virtual functions to be overridden by sub-classes. */
0057   //@{
0058   /**
0059    * Return true if this PDF can handle the extraction of partons from
0060    * the given \a particle.
0061    */
0062   virtual bool canHandleParticle(tcPDPtr particle) const;
0063 
0064   /**
0065    * Return the partons which this PDF may extract from the given
0066    * \a particle.
0067    */
0068   virtual cPDVector partons(tcPDPtr particle) const;
0069 
0070   /**
0071    * The density. Return the pdf for the given \a parton inside the
0072    * given \a particle for the virtuality \a partonScale and momentum
0073    * fraction \a x (with x = 1-\a eps). The \a particle is assumed to
0074    * have a virtuality \a particleScale.
0075    */
0076   virtual double xfx(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale,
0077              double x, double eps = 0.0,
0078              Energy2 particleScale = ZERO) const;
0079 
0080   /**
0081    * The valence density. Return the pdf for the given cvalence \a
0082    * parton inside the given \a particle for the virtuality \a
0083    * partonScale and logarithmic momentum fraction \a l. The \a
0084    * particle is assumed to have a virtuality \a particleScale. This
0085    * will only work properly for nucleons. All other particles will
0086    * have zero valence densities
0087    */
0088   virtual double xfvl(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale,
0089               double l, Energy2 particleScale = ZERO) const;
0090 
0091   /**
0092    * The valence density. Return the pdf for the given cvalence \a
0093    * parton inside the given \a particle for the virtuality \a
0094    * partonScale and momentum fraction \a x (with x = 1-\a eps). The
0095    * \a particle is assumed to have a virtuality \a
0096    * particleScale. This will only work properly for nucleons. All
0097    * other particles will have zero valence densities
0098    */
0099   virtual double xfvx(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale,
0100               double x, double eps = 0.0,
0101               Energy2 particleScale = ZERO) const;
0102 
0103   /**
0104    * The sea density. Return the pdf for the given cvalence \a
0105    * parton inside the given \a particle for the virtuality \a
0106    * partonScale and momentum fraction \a x. The \a particle is
0107    * assumed to have a virtuality \a particleScale. If not overidden
0108    * by a sub class this implementation will assume that the
0109    * difference between a quark and anti-quark distribution is due do
0110    * valense quarks.
0111    */
0112   virtual double xfsx(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale,
0113               double x, double eps = 0.0,
0114               Energy2 particleScale = ZERO) const;
0115   //@}
0116 
0117 
0118   /** @name Simple access function. */
0119   //@{
0120   /**
0121    * The name if the PDF set to be used. The full name including the
0122    * <code>.LHpdf</code> or <code>.LHgrid</code> suffix.
0123    */
0124   const string & PDFName() const { return thePDFName; }
0125  
0126   /**
0127    * The chosen member of the selected PDF set.
0128    */
0129   int member() const { return theMember; }
0130 
0131   /**
0132    * The maximum number of flavours for which non-zero densities are
0133    * reported. The actual number of flavours may be less depending on
0134    * the chosen PDF set.
0135    */
0136   int maxFlav() const { return theMaxFlav; }
0137   //@}
0138 
0139 protected:
0140 
0141   /** @name Internal helper functions. */
0142   //@{
0143   /**
0144    * Initialize the LHAPDF library for the chosen PDF set if it has
0145    * not been done before.
0146    */
0147   void initPDFptr();
0148 
0149   /**
0150    * Used by the interface to select a set according to a file name.
0151    */
0152   void setPDFName(string name);
0153 
0154   /**
0155    * Used by the interface to select a member in the current set.
0156    */
0157   void setPDFMember(int n);
0158 
0159   /**
0160    * Interface for simple tests.
0161    */
0162   string doTest(string input);
0163   //@}
0164 
0165 public:
0166 
0167   /** @name Functions used by the persistent I/O system. */
0168   //@{
0169   /**
0170    * Function used to write out object persistently.
0171    * @param os the persistent output stream written to.
0172    */
0173   void persistentOutput(PersistentOStream & os) const;
0174 
0175   /**
0176    * Function used to read in object persistently.
0177    * @param is the persistent input stream read from.
0178    * @param version the version number of the object when written.
0179    */
0180   void persistentInput(PersistentIStream & is, int version);
0181   //@}
0182 
0183   /**
0184    * The standard Init function used to initialize the interfaces.
0185    * Called exactly once for each class by the class description system
0186    * before the main function starts or
0187    * when this class is dynamically loaded.
0188    */
0189   static void Init();
0190 
0191 protected:
0192 
0193   /** @name Clone Methods. */
0194   //@{
0195   /**
0196    * Make a simple clone of this object.
0197    * @return a pointer to the new object.
0198    */
0199   virtual IBPtr clone() const;
0200 
0201   /** Make a clone of this object, possibly modifying the cloned object
0202    * to make it sane.
0203    * @return a pointer to the new object.
0204    */
0205   virtual IBPtr fullclone() const;
0206   //@}
0207 
0208 public:
0209 
0210   /** @cond EXCEPTIONCLASSES */
0211   /** Exception class used if the LHAPDF library was not installed. */
0212   class NotInstalled: public InterfaceException {};
0213 
0214   /** @endcond */
0215 
0216 // If needed, insert declarations of virtual function defined in the
0217 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
0218 
0219 protected:
0220 
0221   /** @name Standard Interfaced functions. */
0222   //@{
0223   /**
0224    * Initialize this object after the setup phase before saving an
0225    * EventGenerator to disk.
0226    * @throws InitException if object could not be initialized properly.
0227    */
0228   virtual void doinit();
0229 
0230   /**
0231    * Initialize this object. Called in the run phase just before
0232    * a run begins.
0233    */
0234   virtual void doinitrun();
0235 
0236   /**
0237    * Finalize this object. Called in the run phase just after a
0238    * run has ended. Used eg. to write out statistics.
0239    */
0240   virtual void dofinish();
0241   //@}
0242 
0243 private:
0244 
0245   /**
0246    * LHAPDF member object
0247    */
0248   ::LHAPDF::PDF * thePDF;
0249 
0250   /**
0251    * The name of the selected PDF set.
0252    */
0253   string thePDFName;
0254 
0255   /**
0256    * The chosen member of the selected PDF set.
0257    */
0258   int theMember;
0259 
0260   /**
0261    * The maximum number of flavours for which non-zero densities are
0262    * reported. The actual number of flavours may be less depending on
0263    * the chosen PDF set.
0264    */
0265   int theMaxFlav;
0266 
0267   /**
0268    * The minimum \f$x\f$-value for the current PDF set.
0269    */
0270   double xMin;
0271 
0272   /**
0273    * The maximum \f$x\f$-value for the current PDF set.
0274    */
0275   double xMax;
0276 
0277   /**
0278    * The minimum \f$Q^2\f$-value for the current PDF set.
0279    */
0280   Energy2 Q2Min;
0281 
0282   /**
0283    * The maximum \f$Q^2\f$-value for the current PDF set.
0284    */
0285   Energy2 Q2Max;
0286 
0287 private:
0288 
0289   /**
0290    * The assignment operator is private and must never be called.
0291    * In fact, it should not even be implemented.
0292    */
0293   LHAPDF & operator=(const LHAPDF &) = delete;
0294 
0295 };
0296 
0297 }
0298 
0299 #endif /* THEPEG_LHAPDF6_H */