ThePEG  1.8.0
LHAPDF.h
1 // -*- C++ -*-
2 //
3 // LHAPDF.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef THEPEG_LHAPDF_H
10 #define THEPEG_LHAPDF_H
11 //
12 // This is the declaration of the LHAPDF class.
13 //
14 
15 #include "ThePEG/PDF/PDFBase.h"
16 
17 namespace ThePEG {
18 
33 class LHAPDF: public PDFBase {
34 
35 public:
36 
38  enum PType { nucleonType = 1,
39  pionType = 2,
40  photonType = 3
41  };
42 
43 public:
44 
50  LHAPDF();
51 
55  LHAPDF(const LHAPDF &);
57 
58 public:
59 
66  virtual bool canHandleParticle(tcPDPtr particle) const;
67 
72  virtual cPDVector partons(tcPDPtr particle) const;
73 
80  virtual double xfx(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale,
81  double x, double eps = 0.0,
82  Energy2 particleScale = ZERO) const;
83 
92  virtual double xfvl(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale,
93  double l, Energy2 particleScale = ZERO) const;
94 
103  virtual double xfvx(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale,
104  double x, double eps = 0.0,
105  Energy2 particleScale = ZERO) const;
106 
116  virtual double xfsx(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale,
117  double x, double eps = 0.0,
118  Energy2 particleScale = ZERO) const;
120 
121 
129  PType ptype() const { return thePType; }
130 
135  const string & PDFName() const { return thePDFName; }
136 
140  int member() const { return theMember; }
141 
147  int maxFlav() const { return theMaxFlav; }
149 
150 protected:
151 
157  bool indexLine(istream & is, int & set, int & mem, string & file,
158  int & pdftyp, int & pdfgup, int & pdfsup,
159  double & xmin, double & xmax,
160  double & q2min, double & q2max) const;
161 
165  void initpdfsetm() const;
166 
170  void initpdfm() const;
171 
175  void lastReset() const;
176 
180  void setnset() const;
181 
185  int getMaxMember() const;
186 
190  int getMaxFlav() const;
191 
196  void checkInit() const;
197 
202  void checkUpdate(double x, Energy2 Q2, Energy2 P2) const;
203 
210  void setMaxNSet(int);
211 
216  int getMaxNSet() const;
217 
222  void setMinMax();
223 
227  void setPDFNumber(int n);
228 
233  int getPDFNumber() const;
234 
239  void setPDFLIBNumbers(int group, int num);
240 
245  string setPDFLIBNumbers(string);
246 
251  pair<int,int> getPDFLIBNumbers() const;
252 
256  void setPDFName(string name);
257 
261  void setPDFMember(int n);
262 
266  static std::string getIndexPath();
267 
271  static bool openLHAIndex(ifstream & is);
272 
276  string doTest(string input);
278 
279 public:
280 
287  void persistentOutput(PersistentOStream & os) const;
288 
294  void persistentInput(PersistentIStream & is, int version);
296 
303  static void Init();
304 
305 protected:
306 
313  virtual IBPtr clone() const;
314 
319  virtual IBPtr fullclone() const;
321 
322 public:
323 
326  class NotInstalled: public Exception {};
327 
329  static void throwNotInstalled();
330 
333 // If needed, insert declarations of virtual function defined in the
334 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
335 
336 protected:
337 
345  virtual void doinit();
346 
351  virtual void doinitrun();
352 
357  virtual void dofinish();
359 
360 private:
361 
368 
373  string thePDFName;
374 
379 
385 
390 
395 
402 
407  mutable int nset;
408 
412  mutable Energy2 lastQ2;
413 
417  mutable double lastX;
418 
423  mutable Energy2 lastP2;
424 
428  mutable vector<double> lastXF;
429 
436  static int MaxNSet;
437 
441  static int lastNSet;
442 
446  static vector<string> lastNames;
447 
451  static vector<int> lastMem;
452 
456  double xMin;
457 
461  double xMax;
462 
466  Energy2 Q2Min;
467 
471  Energy2 Q2Max;
472 
473 private:
474 
480 
485  LHAPDF & operator=(const LHAPDF &);
486 
487 };
488 
489 }
490 
491 #include "ThePEG/Utilities/ClassTraits.h"
492 
493 namespace ThePEG {
494 
499 template <>
500 struct BaseClassTrait<LHAPDF,1> {
502  typedef PDFBase NthBase;
503 };
504 
507 template <>
508 struct ClassTraits<LHAPDF>
509  : public ClassTraitsBase<LHAPDF> {
511  static string className() { return "ThePEG::LHAPDF"; }
515  static string library() { return "ThePEGLHAPDF.so"; }
516 };
517 
520 }
521 
522 #endif /* THEPEG_LHAPDF_H */
const string & PDFName() const
The name if the PDF set to be used.
Definition: LHAPDF.h:135
void setnset() const
Acquire a new nset number.
PersistentIStream is used to read persistent objects from a stream where they were previously written...
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
pair< int, int > getPDFLIBNumbers() const
Used by the interface to select a get the old PDFLIB numbers of the currently chosen set and member...
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
bool enablePartonicGamma
If this PDF allows partonic photons inside a hadron, enable this.
Definition: LHAPDF.h:389
void setPDFName(string name)
Used by the interface to select a set according to a file name.
LHAPDF()
The default constructor.
virtual cPDVector partons(tcPDPtr particle) const
Return the partons which this PDF may extract from the given particle.
int getPDFNumber() const
Used by the interface to select a get the index number of the currently chosen set and member...
void setMaxNSet(int)
Set the maximum number of simultaneous pdfs that can be used in LHAPDF.
static ClassDescription< LHAPDF > initLHAPDF
The static object used to initialize the description of this class.
Definition: LHAPDF.h:479
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
double xMax
The maximum -value for the current PDF set.
Definition: LHAPDF.h:461
virtual bool canHandleParticle(tcPDPtr particle) const
Return true if this PDF can handle the extraction of partons from the given particle.
string name() const
Returns the name of this object, without the path.
Energy2 Q2Min
The minimum -value for the current PDF set.
Definition: LHAPDF.h:466
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
virtual double xfvl(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale, double l, Energy2 particleScale=ZERO) const
The valence density.
void setPDFMember(int n)
Used by the interface to select a member in the current set.
Energy2 Q2Max
The maximum -value for the current PDF set.
Definition: LHAPDF.h:471
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
Definition: RCPtr.h:681
double lastX
Save the last value used to avoid recalculation.
Definition: LHAPDF.h:417
PType ptype() const
The particle type.
Definition: LHAPDF.h:129
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
void setPDFLIBNumbers(int group, int num)
Used by the interface to select a set and member according to the old PDFLIB numbers.
int member() const
The chosen member of the selected PDF set.
Definition: LHAPDF.h:140
static int lastNSet
The last nset number used by an LHAPDF object.
Definition: LHAPDF.h:441
virtual double xfsx(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale, double x, double eps=0.0, Energy2 particleScale=ZERO) const
The sea density.
virtual double xfx(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale, double x, double eps=0.0, Energy2 particleScale=ZERO) const
The density.
virtual double xfvx(tcPDPtr particle, tcPDPtr parton, Energy2 partonScale, double x, double eps=0.0, Energy2 particleScale=ZERO) const
The valence density.
int theVerboseLevel
The verbosity of the output from the LHAPDF library.
Definition: LHAPDF.h:394
int maxFlav() const
The maximum number of flavours for which non-zero densities are reported.
Definition: LHAPDF.h:147
int nset
The LHAPDF nset number (minus one) to be used by this object.
Definition: LHAPDF.h:407
static bool openLHAIndex(ifstream &is)
Try to find a LHAPDF index file, open it in the given file stream.
vector< double > lastXF
Save the last function values returned from the LHAPDF library.
Definition: LHAPDF.h:428
virtual IBPtr clone() const
Make a simple clone of this object.
string thePDFName
The name if the PDF set to be used.
Definition: LHAPDF.h:373
(Anti-) proton or neutron.
Definition: LHAPDF.h:38
void checkInit() const
Initialize the LHAPDF library for the chosen PDF set if it has not been done before.
static string library()
The name of a file containing the dynamic library where the class T is implemented.
Definition: ClassTraits.h:85
The LHAPDF class inherits from PDFBase and implements an interface to the LHAPDF library of parton de...
Definition: LHAPDF.h:33
virtual void doinit()
Initialize this object after the setup phase before saving an EventGenerator to disk.
static int MaxNSet
The maximum number of simultaneous pdfs that can be used in LHAPDF.
Definition: LHAPDF.h:436
Energy2 lastQ2
Save the last value used to avoid recalculation.
Definition: LHAPDF.h:412
static vector< int > lastMem
The last mem used in the initialization of a given nset number.
Definition: LHAPDF.h:451
string doTest(string input)
Interface for simple tests.
int theMember
The chosen member of the selected PDF set.
Definition: LHAPDF.h:378
PDFBase is the base class for implementing parton density functions for particles with sub-structure...
Definition: PDFBase.h:40
Energy2 lastP2
Save the last value used for off-shell photon to avoid recalculation.
Definition: LHAPDF.h:423
LHAPDF & operator=(const LHAPDF &)
The assignment operator is private and must never be called.
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
vector< cPDPtr > cPDVector
A vector of pointers to const ParticleData objects.
Definition: Containers.h:36
void lastReset() const
Reset the saved values from the last call to xfx(), etc.
const ZeroUnit ZERO
ZERO can be used as zero for any unitful quantity.
Definition: PhysicalQty.h:33
static void Init()
The standard Init function used to initialize the interfaces.
Exception is the base class for all exceptions to be used in ThePEG.
Definition: Exception.h:44
static std::string getIndexPath()
Try to determine the path to where the LHAPDF index file is located.
PType thePType
The particle type.
Definition: LHAPDF.h:367
double xMin
The minimum -value for the current PDF set.
Definition: LHAPDF.h:456
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
virtual void doinitrun()
Initialize this object.
void initpdfsetm() const
Call the Fortran InitPDFSetM function.
void setPDFNumber(int n)
Used by the interface to select a set and member according to a number.
void initpdfm() const
Call the Fortran InitPDFSetM function.
static string className()
Return the name of class T.
Definition: ClassTraits.h:66
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition: ClassTraits.h:161
PType
Enumerate the allowed particle types.
Definition: LHAPDF.h:38
void setMinMax()
Deduce the min/max values of and for the selected set.
void checkUpdate(double x, Energy2 Q2, Energy2 P2) const
Retrieve new PDF values for the given parameters if they were changed since the last call...
virtual void dofinish()
Finalize this object.
static vector< string > lastNames
The last names used in the initialization of a given nset number.
Definition: LHAPDF.h:446
int getMaxNSet() const
Get the maximum number of simultaneous pdfs that can be used in LHAPDF.
int theMaxFlav
The maximum number of flavours for which non-zero densities are reported.
Definition: LHAPDF.h:401
int getMaxMember() const
Retrieve the number of members in the chosen PDF.
bool indexLine(istream &is, int &set, int &mem, string &file, int &pdftyp, int &pdfgup, int &pdfsup, double &xmin, double &xmax, double &q2min, double &q2max) const
Read a line from the index file.
int getMaxFlav() const
Get the maximum number of flavours available in the chosen PDF.
int thePhotonOption
If this is a photon PDF, this describes the option for how to treat the anomalous component...
Definition: LHAPDF.h:384