LHAPDF5.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
8 */
9 //____________________________________________________________________________
10 
11 #include <cstdlib>
12 
13 #include <TSystem.h>
14 #include <TMath.h>
15 
16 #include "Framework/Conventions/GBuild.h"
19 
20 #ifdef __GENIE_LHAPDF5_ENABLED__
21 #include "LHAPDF/LHAPDF.h"
22 #endif
23 
24 using namespace genie;
25 
26 //____________________________________________________________________________
28 PDFModelI("genie::LHAPDF5")
29 {
30  this->Initialize();
31 }
32 //____________________________________________________________________________
34 PDFModelI("genie::LHAPDF5", config)
35 {
36  LOG("LHAPDF5", pDEBUG) << "LHAPDF5 configuration:\n " << this->GetConfig();
37 
38  this->Initialize();
39 }
40 //____________________________________________________________________________
42 {
43 
44 }
45 //____________________________________________________________________________
46 void LHAPDF5::Initialize(void) const
47 {
48 #ifdef __GENIE_LHAPDF5_ENABLED__
49  bool lhapath_ok = true;
50  const char * lhapath = gSystem->Getenv("LHAPATH");
51  if(!lhapath) lhapath_ok = false;
52  else {
53  void *dirp = gSystem->OpenDirectory(lhapath);
54  if (dirp) gSystem->FreeDirectory(dirp);
55  else lhapath_ok = false;
56  }
57  if(!lhapath_ok) {
58  LOG("LHAPDF5", pFATAL)
59  << "\n"
60  << "** LHAPDF won't be able to read-in the PDF data. \n"
61  << "** The LHAPATH env. variable is not properly (or at all) defined. \n"
62  << "** Please, set LHAPATH to <lhapdf_top_dir>/PDFsets/ \n"
63  << "** See http://projects.hepforge.org/lhapdf/ for more details. \n\n";
64  gAbortingInErr = true;
65  exit(1);
66  }
67 #endif
68 }
69 //____________________________________________________________________________
71 {
72 // Get PDF spec (particle type, pdf group/set) from configuration registry.
73 // For definitions, have a look at PDFLIB and LHAPDF manuals
74 
75 #ifdef __GENIE_LHAPDF5_ENABLED__
76  string name = "";
77  int type = 0;
78  int memset = 0;
79 
80  this->GetParam("name_lhapdf", name);
81  this->GetParam("type_lhapdf", type);
82  this->GetParam("memset_lhapdf", memset);
83 
84  LHAPDF::SetType stype = (type==0) ? LHAPDF::LHPDF : LHAPDF::LHGRID;
85 
86  LHAPDF::initPDFByName(name, stype, memset);
87  LHAPDF::extrapolate(false);
88 #endif
89 }
90 //____________________________________________________________________________
91 double LHAPDF5::UpValence(double x, double Q2) const
92 {
93  return AllPDFs(x,Q2).uval;
94 }
95 //____________________________________________________________________________
96 double LHAPDF5::DownValence(double x, double Q2) const
97 {
98  return AllPDFs(x,Q2).dval;
99 }
100 //____________________________________________________________________________
101 double LHAPDF5::UpSea(double x, double Q2) const
102 {
103  return AllPDFs(x,Q2).usea;
104 }
105 //____________________________________________________________________________
106 double LHAPDF5::DownSea(double x, double Q2) const
107 {
108  return AllPDFs(x,Q2).dsea;
109 }
110 //____________________________________________________________________________
111 double LHAPDF5::Strange(double x, double Q2) const
112 {
113  return AllPDFs(x,Q2).str;
114 }
115 //____________________________________________________________________________
116 double LHAPDF5::Charm(double x, double Q2) const
117 {
118  return AllPDFs(x,Q2).chm;
119 }
120 //____________________________________________________________________________
121 double LHAPDF5::Bottom(double x, double Q2) const
122 {
123  return AllPDFs(x,Q2).bot;
124 }
125 //____________________________________________________________________________
126 double LHAPDF5::Top(double x, double Q2) const
127 {
128  return AllPDFs(x,Q2).top;
129 }
130 //____________________________________________________________________________
131 double LHAPDF5::Gluon(double x, double Q2) const
132 {
133  return AllPDFs(x,Q2).gl;
134 }
135 //____________________________________________________________________________
137 #ifdef __GENIE_LHAPDF5_ENABLED__
138  double x, double Q2
139 #else
140  double, double
141 #endif
142 ) const
143 {
144  PDF_t pdf;
145 
146 #ifdef __GENIE_LHAPDF5_ENABLED__
147  // QCD scale
148  double Q = TMath::Sqrt( TMath::Abs(Q2) );
149 
150  vector<double> pdfs = LHAPDF::xfx(x, Q);
151  pdf.uval = pdfs[8] - pdfs[4];
152  pdf.dval = pdfs[7] - pdfs[5];
153  pdf.usea = pdfs[4];
154  pdf.dsea = pdfs[5];
155  pdf.str = pdfs[9];
156  pdf.chm = pdfs[10];
157  pdf.bot = pdfs[11];
158  pdf.top = pdfs[12];
159  pdf.gl = pdfs[6];;
160 #endif
161 
162  return pdf;
163 }
164 //____________________________________________________________________________
166 {
167  Algorithm::Configure(config);
168 
169  this->Initialize();
170  this->SetPDFSetFromConfig();
171 
172  fAllowReconfig=false;
173 }
174 //____________________________________________________________________________
176 {
177  Algorithm::Configure(config);
178 
179  this->Initialize();
180  this->SetPDFSetFromConfig();
181 
182  fAllowReconfig=false;
183 }
184 //____________________________________________________________________________
static QCString name
Definition: declinfo.cpp:673
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
double Gluon(double x, double Q2) const
Definition: LHAPDF5.cxx:131
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:1064
#define pFATAL
Definition: Messenger.h:56
double Charm(double x, double Q2) const
Definition: LHAPDF5.cxx:116
void Initialize(void) const
Definition: LHAPDF5.cxx:46
double Bottom(double x, double Q2) const
Definition: LHAPDF5.cxx:121
double DownSea(double x, double Q2) const
Definition: LHAPDF5.cxx:106
Pure abstract base class. Defines the PDFModelI interface to be implemented by wrapper classes to exi...
Definition: PDFModelI.h:28
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
void SetPDFSetFromConfig(void) const
Definition: LHAPDF5.cxx:70
double UpSea(double x, double Q2) const
Definition: LHAPDF5.cxx:101
double Top(double x, double Q2) const
Definition: LHAPDF5.cxx:126
double DownValence(double x, double Q2) const
Definition: LHAPDF5.cxx:96
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static Config * config
Definition: config.cpp:1054
virtual ~LHAPDF5()
Definition: LHAPDF5.cxx:41
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void Configure(const Registry &config)
Definition: LHAPDF5.cxx:165
A struct to hold PDF set data.
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
double UpValence(double x, double Q2) const
Definition: LHAPDF5.cxx:91
double Strange(double x, double Q2) const
Definition: LHAPDF5.cxx:111
PDF_t AllPDFs(double x, double Q2) const
Definition: LHAPDF5.cxx:136
list x
Definition: train.py:276
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
bool gAbortingInErr
Definition: Messenger.cxx:34
#define pDEBUG
Definition: Messenger.h:63