GENIEGenerator
Loading...
Searching...
No Matches
GRV98LO.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, 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 University of Liverpool
8*/
9//____________________________________________________________________________
10
11#include <sstream>
12#include <fstream>
13#include <cstdlib>
14
15#include <TSystem.h>
16#include <TMath.h>
17
20
21using namespace std;
22using namespace genie;
23
24//____________________________________________________________________________
26PDFModelI("genie::GRV98LO")
27{
28 this->Initialize();
29}
30//____________________________________________________________________________
31GRV98LO::GRV98LO(string config) :
32PDFModelI("genie::GRV98LO", config)
33{
34 LOG("GRV98LO", pDEBUG) << "GRV98LO configuration:\n " << GetConfig() ;
35
36 this->Initialize();
37}
38//____________________________________________________________________________
41//____________________________________________________________________________
42double GRV98LO::UpValence(double x, double Q2) const
43{
44 return AllPDFs(x,Q2).uval;
45}
46//____________________________________________________________________________
47double GRV98LO::DownValence(double x, double Q2) const
48{
49 return AllPDFs(x,Q2).dval;
50}
51//____________________________________________________________________________
52double GRV98LO::UpSea(double x, double Q2) const
53{
54 return AllPDFs(x,Q2).usea;
55}
56//____________________________________________________________________________
57double GRV98LO::DownSea(double x, double Q2) const
58{
59 return AllPDFs(x,Q2).dsea;
60}
61//____________________________________________________________________________
62double GRV98LO::Strange(double x, double Q2) const
63{
64 return AllPDFs(x,Q2).str;
65}
66//____________________________________________________________________________
67double GRV98LO::Charm(double x, double Q2) const
68{
69 return AllPDFs(x,Q2).chm;
70}
71//____________________________________________________________________________
72double GRV98LO::Bottom(double x, double Q2) const
73{
74 return AllPDFs(x,Q2).bot;
75}
76//____________________________________________________________________________
77double GRV98LO::Top(double x, double Q2) const
78{
79 return AllPDFs(x,Q2).top;
80}
81//____________________________________________________________________________
82double GRV98LO::Gluon(double x, double Q2) const
83{
84 return AllPDFs(x,Q2).gl;
85}
86//____________________________________________________________________________
87PDF_t GRV98LO::AllPDFs(double x, double Q2) const
88{
89 PDF_t pdf;
90
91 if(!fInitialized) {
92 LOG("GRV98LO", pWARN)
93 << "GRV98LO algorithm was not initialized succesfully";
94 pdf.uval = 0.;
95 pdf.dval = 0.;
96 pdf.usea = 0.;
97 pdf.dsea = 0.;
98 pdf.str = 0.;
99 pdf.chm = 0.;
100 pdf.bot = 0.;
101 pdf.top = 0.;
102 pdf.gl = 0.;
103 return pdf;
104 }
105
106 LOG("GRV98LO", pDEBUG)
107 << "Inputs x = " << x << ", Q2 = " << Q2;
108
109 // apply kinematical limits
110//Q2 = TMath::Max(Q2, fGridQ2[0]);
111 if(Q2 <= 0.8) Q2 = 0.80001;
112 Q2 = std::min(Q2, fGridQ2[kNQ2-1]);
113 x = std::max(x, fGridXbj[0]);
114 x = std::min(x, fGridXbj[kNXbj-1]);
115
116 double logx = std::log(x);
117 double logQ2 = std::log(Q2);
118 double x1 = 1-x;
119 double xv = std::sqrt(x);
120 double xs = std::pow(x, -0.2);
121 double x1p3 = x1*x1*x1;
122 double x1p4 = x1*x1p3;
123 double x1p5 = x1*x1p4;
124 double x1p7 = x1p3*x1p4;
125
126 double uv = fXUVF->Eval(logx,logQ2) * x1p3 * xv;
127 double dv = fXDVF->Eval(logx,logQ2) * x1p4 * xv;
128 double de = fXDEF->Eval(logx,logQ2) * x1p7 * xv;
129 double ud = fXUDF->Eval(logx,logQ2) * x1p7 * xs;
130 double us = 0.5 * (ud - de);
131 double ds = 0.5 * (ud + de);
132 double ss = fXSF->Eval(logx,logQ2) * x1p7 * xs;
133 double gl = fXGF->Eval(logx,logQ2) * x1p5 * xs;
134
135 pdf.uval = uv;
136 pdf.dval = dv;
137 pdf.usea = us;
138 pdf.dsea = ds;
139 pdf.str = ss;
140 pdf.chm = 0.;
141 pdf.bot = 0.;
142 pdf.top = 0.;
143 pdf.gl = gl;
144
145 return pdf;
146}
147//____________________________________________________________________________
148void GRV98LO::Configure(const Registry & config)
149{
150 Algorithm::Configure(config);
151 this->Initialize();
152}
153//____________________________________________________________________________
154void GRV98LO::Configure(string config)
155{
156 Algorithm::Configure(config);
157 this->Initialize();
158}
159//____________________________________________________________________________
161{
162 fInitialized = false;
163
164 const char * genie_dir = gSystem->Getenv("GENIE");
165 if(!genie_dir) return;
166
167 string grid_file_name =
168 string(gSystem->Getenv("GENIE")) + string("/data/evgen/pdfs/GRV98lo_patched.LHgrid");
169
170 LOG("GRV98LO", pNOTICE)
171 << "Reading grid file from:\n " << grid_file_name;
172
173 ifstream grid_file;
174 grid_file.open (grid_file_name.c_str());
175
176 char rubbish[1000];
177
178 const int nskip = 21;
179 for(int i=0; i<nskip; i++) {
180 grid_file.getline(rubbish,1000);
181 LOG("GRV98LO", pDEBUG) << "Skipping: " << rubbish;
182 }
183
184 // x's
185 //
186
187 LOG("GRV98LO", pDEBUG) << "Reading x_bj grid values";
188 for(int j=0; j < kNXbj; j++) {
189 double xbj = -1;
190 grid_file >> xbj;
191 // check against known limits
192 // ...
193 fGridXbj[j] = xbj;
194 fGridLogXbj[j] = TMath::Log(xbj);
195 }
196 ostringstream grid_values;
197 grid_values << "(";
198 for(int j=0; j < kNXbj; j++) {
199 grid_values << fGridXbj[j];
200 if(j == kNXbj - 1) { grid_values << ")"; }
201 else { grid_values << ", "; }
202 }
203 LOG("GRV98LO", pDEBUG)
204 << "x_bj grid values: " << grid_values.str();
205
206 // Q^2s
207 //
208
209 LOG("GRV98LO", pDEBUG) << "Reading Q^2 grid values.";
210 for(int i=0; i < kNQ2; i++) {
211 double Q2 = -1;
212 grid_file >> Q2;
213 // check against known limits
214 // ...
215 fGridQ2[i] = Q2;
216 fGridLogQ2[i] = TMath::Log(Q2);
217 }
218 grid_values.str("");
219 grid_values << "(";
220 for(int i=0; i < kNQ2; i++) {
221 grid_values << fGridQ2[i];
222 if(i == kNQ2 - 1) { grid_values << ")"; }
223 else { grid_values << ", "; }
224 }
225 LOG("GRV98LO", pDEBUG)
226 << "Q^2 grid values: " << grid_values.str() << "GeV^2";
227
228 // skip again
229 grid_file.getline(rubbish,1000);
230 LOG("GRV98LO", pDEBUG) << "Skipping: " << rubbish;
231 grid_file.getline(rubbish,1000);
232 LOG("GRV98LO", pDEBUG) << "Skipping: " << rubbish;
233
234 // pdf values on grid points
235 //
236
237 LOG("GRV98LO", pDEBUG) << "Reading PDF values on grid points";
238
239 int k=0;
240 for(int j=0; j < kNXbj-1; j++) {
241 for(int i=0; i < kNQ2; i++) {
242 double p0 = 0;
243 double p1 = 0;
244 double p2 = 0;
245 double p3 = 0;
246 double p4 = 0;
247 double p5 = 0;
248 grid_file >> p0 >> p1 >> p2 >> p3 >> p4 >> p5;
249 LOG("GRV98LO", pDEBUG)
250 << "Row: " << k << ", grid point: (" << i << ", " << j << ") ->"
251 << " p0 = " << p0
252 << ", p1 = " << p1
253 << ", p2 = " << p2
254 << ", p3 = " << p3
255 << ", p4 = " << p4
256 << ", p5 = " << p5;
257 fParton [0][i][j] = p0;
258 fParton [1][i][j] = p1;
259 fParton [2][i][j] = p2;
260 fParton [3][i][j] = p3;
261 fParton [4][i][j] = p4;
262 fParton [5][i][j] = p5;
263 k++;
264 }
265 }
266
267 grid_file.close();
268
269 // arrays for interpolation routines
270 //
271
272 vector<double> gridLogQ2 (kNQ2);
273 vector<double> gridLogXbj(kNXbj);
274 vector<double> knotsXUVF(kNQ2*kNXbj);
275 vector<double> knotsXDVF(kNQ2*kNXbj);
276 vector<double> knotsXDEF(kNQ2*kNXbj);
277 vector<double> knotsXUDF(kNQ2*kNXbj);
278 vector<double> knotsXSF (kNQ2*kNXbj);
279 vector<double> knotsXGF (kNQ2*kNXbj);
280
281 k=0;
282 for(int i=0; i < kNQ2; i++) {
283 double logQ2 = std::log(fGridQ2[i]);
284 gridLogQ2[i] = logQ2;
285 for(int j=0; j < kNXbj - 1; j++) {
286 double logx = std::log(fGridXbj[j]);
287 gridLogXbj[j] = logx;
288 double xb0v = std::sqrt(fGridXbj[j]);
289 double xb0s = std::pow(fGridXbj[j], -0.2);
290 double xb1 = 1 - fGridXbj[j];
291 double xb1p3 = std::pow(xb1, 3.);
292 double xb1p4 = std::pow(xb1, 4.);
293 double xb1p5 = std::pow(xb1, 5.);
294 double xb1p7 = std::pow(xb1, 7.);
295 knotsXUVF[k] = fParton[0][i][j] / (xb1p3 * xb0v);
296 knotsXDVF[k] = fParton[1][i][j] / (xb1p4 * xb0v);
297 knotsXDEF[k] = fParton[2][i][j] / (xb1p7 * xb0v);
298 knotsXUDF[k] = fParton[3][i][j] / (xb1p7 * xb0s);
299 knotsXSF [k] = fParton[4][i][j] / (xb1p7 * xb0s);
300 knotsXGF [k] = fParton[5][i][j] / (xb1p5 * xb0s);
301 k++;
302 }
303 double logxmax = TMath::Log(fGridXbj[kNXbj-1]);
304 gridLogXbj[kNXbj-1] = logxmax;
305 knotsXUVF[k] = 0;
306 knotsXDVF[k] = 0;
307 knotsXDEF[k] = 0;
308 knotsXUDF[k] = 0;
309 knotsXSF [k] = 0;
310 knotsXGF [k] = 0;
311 k++;
312 }
313
314 fXUVF = std::make_unique<Interpolator2D>(gridLogXbj.size(),&gridLogXbj[0],gridLogQ2.size(),&gridLogQ2[0],&knotsXUVF[0]);
315 fXDVF = std::make_unique<Interpolator2D>(gridLogXbj.size(),&gridLogXbj[0],gridLogQ2.size(),&gridLogQ2[0],&knotsXDVF[0]);
316 fXDEF = std::make_unique<Interpolator2D>(gridLogXbj.size(),&gridLogXbj[0],gridLogQ2.size(),&gridLogQ2[0],&knotsXDEF[0]);
317 fXUDF = std::make_unique<Interpolator2D>(gridLogXbj.size(),&gridLogXbj[0],gridLogQ2.size(),&gridLogQ2[0],&knotsXUDF[0]);
318 fXSF = std::make_unique<Interpolator2D>(gridLogXbj.size(),&gridLogXbj[0],gridLogQ2.size(),&gridLogQ2[0],&knotsXSF [0]);
319 fXGF = std::make_unique<Interpolator2D>(gridLogXbj.size(),&gridLogXbj[0],gridLogQ2.size(),&gridLogQ2[0],&knotsXGF [0]);
320
321 fInitialized = true;
322}
323//____________________________________________________________________________
string genie_dir(std::getenv("GENIE"))
#define pNOTICE
Definition Messenger.h:61
#define pDEBUG
Definition Messenger.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
#define pWARN
Definition Messenger.h:60
virtual const Registry & GetConfig(void) const
virtual void Configure(const Registry &config)
Definition Algorithm.cxx:62
std::unique_ptr< Interpolator2D > fXUDF
Definition GRV98LO.h:92
void Initialize(void)
Definition GRV98LO.cxx:160
double Charm(double x, double Q2) const
Definition GRV98LO.cxx:67
double Strange(double x, double Q2) const
Definition GRV98LO.cxx:62
double UpSea(double x, double Q2) const
Definition GRV98LO.cxx:52
PDF_t AllPDFs(double x, double Q2) const
Definition GRV98LO.cxx:87
double fParton[kNParton][kNQ2][kNXbj-1]
Definition GRV98LO.h:85
std::unique_ptr< Interpolator2D > fXDVF
Definition GRV98LO.h:90
double DownSea(double x, double Q2) const
Definition GRV98LO.cxx:57
std::unique_ptr< Interpolator2D > fXDEF
Definition GRV98LO.h:91
bool fInitialized
Definition GRV98LO.h:69
double fGridXbj[kNXbj]
Definition GRV98LO.h:83
std::unique_ptr< Interpolator2D > fXSF
Definition GRV98LO.h:93
std::unique_ptr< Interpolator2D > fXGF
Definition GRV98LO.h:94
double Gluon(double x, double Q2) const
Definition GRV98LO.cxx:82
static const int kNXbj
Definition GRV98LO.h:74
double Bottom(double x, double Q2) const
Definition GRV98LO.cxx:72
double fGridLogXbj[kNXbj]
Definition GRV98LO.h:84
double fGridLogQ2[kNQ2]
Definition GRV98LO.h:82
double DownValence(double x, double Q2) const
Definition GRV98LO.cxx:47
double fGridQ2[kNQ2]
Definition GRV98LO.h:81
std::unique_ptr< Interpolator2D > fXUVF
Definition GRV98LO.h:89
double UpValence(double x, double Q2) const
Definition GRV98LO.cxx:42
static const int kNQ2
Definition GRV98LO.h:73
double Top(double x, double Q2) const
Definition GRV98LO.cxx:77
void Configure(const Registry &config)
Definition GRV98LO.cxx:148
A registry. Provides the container for algorithm configuration parameters.
Definition Registry.h:65
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
struct genie::EPDF PDF_t
double str
Definition PDFt.h:29
double bot
Definition PDFt.h:31
double dsea
Definition PDFt.h:28
double uval
Definition PDFt.h:25
double top
Definition PDFt.h:32
double gl
Definition PDFt.h:33
double usea
Definition PDFt.h:27
double chm
Definition PDFt.h:30
double dval
Definition PDFt.h:26