30 #include <Math/IFunction.h>
31 #include <Math/Integrator.h>
37 #ifdef __GENIE_APFEL_ENABLED__
38 #include "APFEL/APFEL.h"
40 #include "LHAPDF/LHAPDF.h"
41 #ifdef __GENIE_LHAPDF6_ENABLED__
42 const LHAPDF::PDF* pdf_cache;
47 using namespace genie;
48 using namespace genie::constants;
52 #ifdef __GENIE_APFEL_ENABLED__
53 class PhotonConv:
public ROOT::Math::IBaseFunctionOneDim
56 PhotonConv(
double x,
double q) : ROOT::Math::IBaseFunctionOneDim(),xmin(x),Qin(q){};
58 ROOT::Math::IBaseFunctionOneDim * Clone (
void)
const {
return new PhotonConv(xmin,Qin); }
59 unsigned int NDim (
void)
const {
return 1; }
60 double DoEval (
double y)
const {
return 2. * ( TMath::Power(xmin/y,2)+TMath::Power( 1.-xmin/y, 2) ) * pdf_cache->xfxQ(22, y, Qin); }
61 void SetPar (
double x,
double q) { xmin=x; Qin=q; }
67 extern "C" void externalsetapfellept_(
double* x,
double* q,
int* irep,
double* xl,
double* xf);
71 void externalsetapfellept_(
double* x,
double* q,
int* irep,
double* xl,
double* xf){
72 if (*x >= 1 || *x < 0) {
73 for (
int i=0; i<13; i++ ) xf[i] = 0.;
74 for (
int i=0; i<7; i++ ) xl[i] = 0.;
78 for (
int i=0; i<13; i++ ) {
79 xf[i] = pdf_cache->xfxQ(i-6, *x, *q);
81 if ( i==4 ) xf[i] = pdf_cache->xfxQ(-1, *x, *q);
82 else if( i==5 ) xf[i] = pdf_cache->xfxQ(-2, *x, *q);
83 else if( i==7 ) xf[i] = pdf_cache->xfxQ( 2, *x, *q);
84 else if( i==8 ) xf[i] = pdf_cache->xfxQ( 1, *x, *q);
87 for (
int i=0; i<7; i++ ) {
89 if (i==0 || i==6) xl[i] = 0.;
90 else if (i==3 ) xl[i] = pdf_cache->xfxQ(22, *x, *q);
95 ROOT::Math::IBaseFunctionOneDim *
func =
new PhotonConv(*x,*q);
96 ROOT::Math::IntegrationOneDim::Type ig_type = ROOT::Math::IntegrationOneDim::kADAPTIVE;
97 ROOT::Math::Integrator ig(*func,ig_type,1,0.01,100000);
98 double res = ig.Integral(*x,1.);
99 xl[i] = APFEL::AlphaQED(*q)/2./
kPi*TMath::Log( *q/mlep ) * res;
111 int main(
int argc,
char ** argv)
115 if ( gSystem->Getenv(
"PHOTON_SF_DATA_PATH")==NULL ) basedir =
string(gSystem->Getenv(
"GENIE")) +
"/data/evgen/photon-sf";
116 else basedir = string(gSystem->Getenv(
"PHOTON_SF_DATA_PATH"));
117 LOG(
"gmkphotonsf",
pERROR) <<
"Base directory: " << basedir;
119 if ( gSystem->AccessPathName( basedir.c_str(), kWritePermission ) ) {
120 LOG(
"gmkphotonsf",
pFATAL) <<
"Base directory doesnt exist or you dont have write permission.";
121 LOG(
"gmkphotonsf",
pFATAL) <<
"Remember!!!";
122 LOG(
"gmkphotonsf",
pFATAL) <<
"Path to base directory is defined with the enviroment variable PHOTON_SF_DATA_PATH.";
123 LOG(
"gmkphotonsf",
pFATAL) <<
"If not defined, default location is $GENIE/data/evgen/photon-sf";
127 const int nx = 1000.;
132 #ifdef __GENIE_APFEL_ENABLED__
133 for (
int k=0; k<2; k++) {
138 LOG(
"gmkphotonsf",
pINFO) <<
"Initialising APFEL..." ;
143 const LHAPDF::PDFSet set(pdfset);
144 pdf_cache = LHAPDF::mkPDF(pdfset,0);
147 stringstream( set.get_entry(
"MCharm") ) >> mc;
148 stringstream( set.get_entry(
"MBottom") ) >> mb;
149 stringstream( set.get_entry(
"MTop") ) >> mt;
150 stringstream( set.get_entry(
"QMin") ) >> QPDFmin;
151 stringstream( set.get_entry(
"QMax") ) >> QPDFmax;
152 stringstream( set.get_entry(
"XMin") ) >> xPDFmin;
154 LOG(
"gmkphotonsf",
pINFO) <<
"QPDFmin = " << QPDFmin;
155 LOG(
"gmkphotonsf",
pINFO) <<
"QPDFmax = " << QPDFmax;
156 LOG(
"gmkphotonsf",
pINFO) <<
"mc = " << mc;
158 LOG(
"gmkphotonsf",
pINFO) <<
"mt = " << mt;
162 APFEL::SetPDFSet(pdfset);
163 APFEL::SetReplica(0);
164 APFEL::SetPerturbativeOrder(2);
165 APFEL::SetQLimits(QPDFmin,QPDFmax);
166 APFEL::SetMaxFlavourPDFs(6);
167 APFEL::SetMaxFlavourAlpha(6);
168 APFEL::SetNumberOfGrids(3);
169 APFEL::SetGridParameters(1,100,5,1
e-9);
170 APFEL::SetGridParameters(2,40,3,1
e-1);
171 APFEL::SetGridParameters(3,60,3,8
e-1);
172 APFEL::SetGFermi(
kGF);
173 APFEL::SetPoleMasses(mc,mb,mt);
174 APFEL::SetTheory(
"QUniD");
175 APFEL::EnableLeptonEvolution(
true);
176 APFEL::SetFastEvolution(
true);
177 APFEL::SetPDFSet(
"leptexternal");
178 APFEL::InitializeAPFEL();
180 LOG(
"gmkphotonsf",
pWARN) <<
"Init EvolveAPFEL";
181 APFEL::EvolveAPFEL(QPDFmin,
kMw);
182 LOG(
"gmkphotonsf",
pWARN) <<
"End EvolveAPFEL";
187 for (
int i=0; i<nx; i++ ) x[i] = TMath::Power( 10, TMath::Log10(xPDFmin) + i*(TMath::Log10(1.)-TMath::Log10(xPDFmin))/(1000.-1) );
189 for(
int j=0; j<6; j++) {
191 string SFname = basedir +
"/PhotonSF_hitnuc"+to_string(
fNucPdg)+
"_hitlep"+to_string(pdgs[j])+
".dat";
192 std::ofstream sf_stream(SFname);
193 for (
int i=0; i<nx; i++ ) {
195 if (
pdg::IsNuE (pdgs[j]) ) tmp = APFEL::xLepton( 1,x[i]);
196 else if (
pdg::IsAntiNuE (pdgs[j]) ) tmp = APFEL::xLepton(-1,x[i]);
197 else if (
pdg::IsNuMu (pdgs[j]) ) tmp = APFEL::xLepton( 2,x[i]);
199 else if (
pdg::IsNuTau (pdgs[j]) ) tmp = APFEL::xLepton( 3,x[i]);
201 LOG(
"gmkphotonsf",
pWARN) <<
"SF " << pdgs[j] <<
" [x=" << x[i] <<
"] = " << tmp;
202 sf_stream << x[i] <<
" " << tmp << endl;
bool IsAntiNuTau(int pdgc)
static const double kElectronMass
int main(int argc, char **argv)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
static constexpr double mb
double func(double x, double y)
bool IsAntiNuMu(int pdgc)
static const double kMuonMass
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...