LHAPDF6.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab
9 */
10 //____________________________________________________________________________
11 
12 #include <cassert>
13 #include <cstdlib>
14 
15 #include <TSystem.h>
16 #include <TMath.h>
17 
21 
22 #ifdef __GENIE_LHAPDF6_ENABLED__
23 #include "LHAPDF/LHAPDF.h"
24 #endif
25 
26 using namespace genie;
27 
28 //____________________________________________________________________________
30 PDFModelI("genie::LHAPDF6")
31 {
32  fSetName = "";
33  fMemberID = 0;
34 
35 #ifdef __GENIE_LHAPDF6_ENABLED__
36  fLHAPDF = 0;
37 #endif
38 }
39 //____________________________________________________________________________
41 PDFModelI("genie::LHAPDF6", config)
42 {
43  fSetName = "";
44  fMemberID = 0;
45 
46 #ifdef __GENIE_LHAPDF6_ENABLED__
47  fLHAPDF = 0;
48 #endif
49 }
50 //____________________________________________________________________________
52 {
53 //#ifdef __GENIE_LHAPDF6_ENABLED__
54 // if(fLHAPDF) delete fLHAPDF;
55 //#endif
56 }
57 //____________________________________________________________________________
58 double LHAPDF6::UpValence(double x, double Q2) const
59 {
60  return AllPDFs(x,Q2).uval;
61 }
62 //____________________________________________________________________________
63 double LHAPDF6::DownValence(double x, double Q2) const
64 {
65  return AllPDFs(x,Q2).dval;
66 }
67 //____________________________________________________________________________
68 double LHAPDF6::UpSea(double x, double Q2) const
69 {
70  return AllPDFs(x,Q2).usea;
71 }
72 //____________________________________________________________________________
73 double LHAPDF6::DownSea(double x, double Q2) const
74 {
75  return AllPDFs(x,Q2).dsea;
76 }
77 //____________________________________________________________________________
78 double LHAPDF6::Strange(double x, double Q2) const
79 {
80  return AllPDFs(x,Q2).str;
81 }
82 //____________________________________________________________________________
83 double LHAPDF6::Charm(double x, double Q2) const
84 {
85  return AllPDFs(x,Q2).chm;
86 }
87 //____________________________________________________________________________
88 double LHAPDF6::Bottom(double x, double Q2) const
89 {
90  return AllPDFs(x,Q2).bot;
91 }
92 //____________________________________________________________________________
93 double LHAPDF6::Top(double x, double Q2) const
94 {
95  return AllPDFs(x,Q2).top;
96 }
97 //____________________________________________________________________________
98 double LHAPDF6::Gluon(double x, double Q2) const
99 {
100  return AllPDFs(x,Q2).gl;
101 }
102 //____________________________________________________________________________
103 #ifdef __GENIE_LHAPDF6_ENABLED__
104 PDF_t LHAPDF6::AllPDFs(double x, double Q2) const
105 {
106  PDF_t pdf;
107  vector<double> pdfvec;
108  fLHAPDF->xfxQ2(x,Q2,pdfvec);
109  pdf.uval = pdfvec[8] - pdfvec[4];
110  pdf.dval = pdfvec[7] - pdfvec[5];
111  pdf.usea = pdfvec[4];
112  pdf.dsea = pdfvec[5];
113  pdf.str = pdfvec[9];
114  pdf.chm = pdfvec[10];
115  pdf.bot = pdfvec[11];
116  pdf.top = pdfvec[12];
117  pdf.gl = pdfvec[6];
118  return pdf;
119 }
120 #else
121 PDF_t LHAPDF6::AllPDFs(double, double) const
122 {
123  LOG("LHAPDF6",pFATAL) << "LHAPDF6 not enabled.";
124  exit(-1);
125 }
126 #endif
127 //____________________________________________________________________________
129 {
130  Algorithm::Configure(config);
131  this->LoadConfig();
132  fAllowReconfig=false;
133 }
134 //____________________________________________________________________________
136 {
137  Algorithm::Configure(config);
138  this->LoadConfig();
139  fAllowReconfig=false;
140 }
141 //____________________________________________________________________________
143 {
144  this->GetParam("SetName", fSetName );
145  this->GetParam("MemberID", fMemberID);
146 
147 #ifdef __GENIE_LHAPDF6_ENABLED__
148  fLHAPDF = LHAPDF::mkPDF(fSetName, fMemberID);
149  if(!fLHAPDF) {
150  LOG("LHAPDF6",pFATAL)
151  << "Couldn't retrieve LHADPF6 pdf set: "
152  << fSetName << ", member id: " << fMemberID;
153  exit(1);
154  }
155 #endif
156 }
157 //____________________________________________________________________________
158 
void LoadConfig(void)
Definition: LHAPDF6.cxx:142
void Configure(const Registry &config)
Definition: LHAPDF6.cxx:128
double Bottom(double x, double Q2) const
Definition: LHAPDF6.cxx:88
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:991
#define pFATAL
Definition: Messenger.h:57
double Strange(double x, double Q2) const
Definition: LHAPDF6.cxx:78
double Charm(double x, double Q2) const
Definition: LHAPDF6.cxx:83
Definition: config.py:1
double Top(double x, double Q2) const
Definition: LHAPDF6.cxx:93
double UpSea(double x, double Q2) const
Definition: LHAPDF6.cxx:68
Pure abstract base class. Defines the PDFModelI interface to be implemented by wrapper classes to exi...
Definition: PDFModelI.h:29
PDF_t AllPDFs(double x, double Q2) const
Definition: LHAPDF6.cxx:121
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
string fSetName
Definition: LHAPDF6.h:63
double UpValence(double x, double Q2) const
Definition: LHAPDF6.cxx:58
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:70
LHAPDF::PDF * fLHAPDF
Definition: LHAPDF6.h:66
A struct to hold PDF set data.
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:66
double DownSea(double x, double Q2) const
Definition: LHAPDF6.cxx:73
exit(0)
virtual ~LHAPDF6()
Definition: LHAPDF6.cxx:51
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
int fMemberID
Definition: LHAPDF6.h:64
double DownValence(double x, double Q2) const
Definition: LHAPDF6.cxx:63
double Gluon(double x, double Q2) const
Definition: LHAPDF6.cxx:98