GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
gtestPDFLIB.cxx File Reference
#include <TNtuple.h>
#include <TFile.h>
#include <TMath.h>
#include "Framework/Algorithm/AlgFactory.h"
#include "Framework/Messenger/Messenger.h"
#include "Physics/PartonDistributions/PDFModelI.h"
#include "Physics/PartonDistributions/LHAPDF5.h"
#include "Physics/PartonDistributions/PDF.h"
Include dependency graph for gtestPDFLIB.cxx:

Go to the source code of this file.

Functions

int main (int, char **)
 

Function Documentation

int main ( int  ,
char **   
)

Definition at line 32 of file gtestPDFLIB.cxx.

References genie::PDF::Calculate(), genie::PDF::DownSea(), genie::PDF::DownValence(), genie::AlgFactory::GetAlgorithm(), genie::PDF::Gluon(), genie::AlgFactory::Instance(), LOG, pINFO, genie::utils::kinematics::Q2(), genie::PDF::SetModel(), genie::PDF::Strange(), genie::PDF::UpSea(), and genie::PDF::UpValence().

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
46  AlgFactory * algf = AlgFactory::Instance();
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 }
double Gluon(void) const
Definition: PDF.h:58
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:1077
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
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
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39