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