gtestPDFLIB.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \program gtestPDFLIB
5 
6 \brief Test interface to LHAPDF library
7 
8 \author Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
9  University of Liverpool & STFC Rutherford Appleton Laboratory
10 
11 \created May 4, 2004
12 
13 \cpright Copyright (c) 2003-2020, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15 
16 */
17 //____________________________________________________________________________
18 
19 #include <TNtuple.h>
20 #include <TFile.h>
21 #include <TMath.h>
22 
28 
29 using namespace genie;
30 
31 //___________________________________________________________________
32 int main(int /*argc*/, char ** /*argv*/)
33 {
34  // x, Q2 range
35  const int nQ2 = 3;
36  const int nx = 300;
37  double Q2arr[nQ2] = { 1.0, 2.0, 4.0 };
38  const double xmin_idx = -2;
39  const double xmax_idx = 0;
40  const double dx_idx = (xmax_idx-xmin_idx)/(nx-1);
41 
42  // Output ntuple
43  TNtuple * nt = new TNtuple("nt","pdfs","uv:dv:us:ds:s:g:x:Q2");
44 
45  // PDF model
47  const PDFModelI * pdfmodel =
48  dynamic_cast<const PDFModelI *> (
49  algf->GetAlgorithm("genie::LHAPDF5","GRVLO"));
50 
51  PDF pdf;
52  pdf.SetModel(pdfmodel);
53 
54  // Extract PDFs
55  for(int iq2 = 0; iq2 < nQ2; iq2++) {
56  for(int ix = 0; ix < nx; ix++) {
57 
58  double Q2 = Q2arr[iq2];
59  double x = TMath::Power(10, xmin_idx + ix * dx_idx);
60 
61  pdf.Calculate(x, Q2);
62  LOG("test", pINFO) << "PDFs:\n" << pdf;
63 
64  nt->Fill(pdf.UpValence(),
65  pdf.DownValence(),
66  pdf.UpSea(),
67  pdf.DownSea(),
68  pdf.Strange(),
69  pdf.Gluon(),
70  x, Q2);
71  }
72  }
73  TFile f("./genie-pdfs.root","recreate");
74  nt->Write("pdfs");
75 
76  f.Close();
77  delete nt;
78 
79  return 0;
80 }
81 //___________________________________________________________________
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
double Gluon(void) const
Definition: PDF.h:58
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:1064
double DownValence(void) const
Definition: PDF.h:51
A class to store PDFs.
Definition: PDF.h:37
double UpSea(void) const
Definition: PDF.h:52
Pure abstract base class. Defines the PDFModelI interface to be implemented by wrapper classes to exi...
Definition: PDFModelI.h:28
double DownSea(void) const
Definition: PDF.h:53
double Strange(void) const
Definition: PDF.h:54
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
int main(int, char **)
Definition: gtestPDFLIB.cxx:32
void SetModel(const PDFModelI *model)
Definition: PDF.cxx:42
const Algorithm * GetAlgorithm(const AlgId &algid)
Definition: AlgFactory.cxx:75
#define pINFO
Definition: Messenger.h:62
void Calculate(double x, double q2)
Definition: PDF.cxx:49
double UpValence(void) const
Definition: PDF.h:50
static AlgFactory * Instance()
Definition: AlgFactory.cxx:64
list x
Definition: train.py:276
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39