Complete: 0


LHAPDF library is the collection of PDF (Parton Density Functions). CMSSW is built against one of its versions, so that all multi-purpose generators can be run using PDF from LHAPDF if user chooses this option (another option is to use generator's internal PDF). The examples below show how to switch between these options. Note that a major rewriting of lhapdf was performed around 2013. The new lhapdf versions, 6 series, are present in CMSSW as a separate package under the name lhapdf6. The corresponding tool in CMSSW is inactive until all tests are finished. More information below ("How to perform testing...").

Examples for Pythia6Interface modules: (Pythia6GeneratorFilter or Pythia6HadronizerFilter) one can manipulate the choice of (proton) structure function via Pythia6 cards MSTP(51) and MSTP(52), as shown in the example configuration Configuration/Generator/PythiaMinBias.cfg:

      'MSTP(51)=7     ! choice of proton parton-distribution set (D=7 and means CTEQ6L)',  - this can be obsolete info
      'MSTP(52)=1     ! choice of pdf library (D=1 and means internal pythia one',
      # the example below is to use of CT10 of lhapdf
      # for details, see pythia manual
      # 'MSTP(51)=10800     ! CT10 chosen',
      # 'MSTP(52)=2             ! tell pythia to use LHAPDF",

Pythia8Interface example: In order to use LHAPDF with pythia8 version 1XX add the following lines to the pythia8 parameters:

      'PDF:useLHAPDF = on',
      'PDF:LHAPDFset = MRST2004nlo.LHpdf' 

Pythia8Interface example for the pythia8 version 2XX: In order to use LHAPDF with pythia8 version 2XX add the following line to the pythia8 parameters (choose LHAPDF5 or LHAPDF6):

     'PDF:pSet = LHAPDF6:CT10' 

Please find more information on the PDF set numbers and names.


The size of the full set of PDF sets in LHAPDF6 is rather big. For this reason they are kept separately from the tool lhapdf itself on cvmfs. Only a few sets are available physically inside the tool, others are referenced using symbolic links. In CMS, the internal CMS versioning is introduced for the sets because new sets are released more often than the package lhapdf, for example 6.1.6a, 6.1.6b. A new version of sets is usually created by the CMS SW people on request from the generator conveners. In 2016 - 2017 the requests are to be sent to Bockjoo Kim. After this, the person responsible in CMS for the external lhapdf should perform the upgrade of sets as described below.

How to update LHAPDF6 version or a version of PDF sets

checkout (using git commands) cmsdist and open your branch
update LHAPDF and/or sets versions in lhapdf.spec (two upper lines)
run script with the sets version as an argument, like this:
lhapdf_makeScript.sh 6.1.5a
the above script will rewrite 2 files: lhapdf_makeLinks.file, lhapdf_pdfsetsindex.file
commit lhapdf*, push and make pull request

If you want to test a new version of pdf sets with the path PDFSETSNEWPATH without making the test install of all lhapdf you can do the following: setup some CMSSW release,

cd src
git cms-addpkg GeneratorInterface/Pythia8Interface
cd GeneratorInterface/Pythia8Interface/test
emacs pythia8ex2_cfg.py
cmsRun pythia8ex2_cfg.py
In the configuration file editing above you should use the set you want to test. Note that in setting the variable LHAPDF_DATA_PATH you should keep the old value of LHAPDF_DATA_PATH, otherwise the file lhapdf.conf will not be found

How to perform testing with LHAPDF6 (for CMSSW releases where it is not default)

scram project CMSSW CMSSW_X_X_X_X
scram tool remove lhapdf
scram setup lhapdf6
cd src
git cms-addpkg GeneratorInterface/Core
git cms-addpkg GeneratorInterface/LHEInterface
git cms-addpkg GeneratorInterface/Pythia8Interface
edit GeneratorInterface/Core/Buildfile and GeneratorInterface/LHEInterface/plugins/BuildFile to substitute lhapdf by lhapdf6
cd GeneratorInterface
scram b

It is important not to do cmsenv before removing lhapdf and setup lhapdf6. For your package substitute Pythia8Interface above by it. After the actions above try to run your package.

Using additional functionalities of LHAPDF library (old information, LHAPDF5 only)

[ Instructions from P. Tang ] To use the function in the LHAPDF package, you will need to define something like this at the beginning of your code or some header files:

extern "C" {
  void initpdfset_ (char *, int len);
  void initpdfsetm_(int &, char *);
  void initpdf_(int &);
  void evolvepdf_(double &, double &, double *);
  void numberpdf_(int &);
  • Here is how I do the initialization, and calculate some quantities related to the PDFs ( see also J. Alcaraz code ):

      int subset = 0; // for example
      const char *lhaPDFPath = getenv("LHAPATH");
      std::string pdfSet(lhaPDFPath); pdfSet.append("/MRST2004nlo.LHpdf");
     std::cout << "PDF set - " << pdfSet.data() << std::endl;
      initpdfset_((char *)pdfSet.data(), pdfSet.size());
    // then somewhere in my code to obtain xf(x)
      double Q = 80.4; // W mass
      double      xfx1[NUM_FLAVORS], xfx2[NUM_FLAVORS];
      evolvepdf_( x1, Q, xfx1);
      evolvepdf_( x2, Q, xfx2);
  • -- MikhailK - 15 Jun 2015

    Responsible: MikhailK

    Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | WYSIWYG | More topic actions
    Topic revision: r12 - 2021-07-08 - MikhailK
      • Cern Search Icon Cern Search
      • TWiki Search Icon TWiki Search
      • Google Search Icon Google Search

      CMSPublic All webs login

    This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
    or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback