52 if (basedir==
"") basedir=
string(gSystem->Getenv(
"GENIE")) +
"/data/evgen/hedis-sf";
53 LOG(
"HEDISStrucFunc",
pERROR) <<
"Base diretory: " << basedir;
55 if ( gSystem->AccessPathName( basedir.c_str(), kWritePermission ) ) {
56 LOG(
"HEDISStrucFunc",
pERROR) <<
"Base diretory doesnt exist or you dont have write permission.";
64 LOG(
"HEDISStrucFunc",
pINFO) <<
"SF are (or will be) in following directory: " << SFname;
65 if ( gSystem->mkdir(SFname.c_str())==0 ) {
66 LOG(
"HEDISStrucFunc",
pWARN) <<
"Bad news! Directory doesnt exists.";
67 LOG(
"HEDISStrucFunc",
pWARN) <<
"HEDIS package requires computation of SF";
68 LOG(
"HEDISStrucFunc",
pWARN) <<
"This will be SLOW!!!!!";
69 LOG(
"HEDISStrucFunc",
pINFO) <<
"Creating Metafile with input information";
70 std::ofstream meta_stream((SFname+
"/Inputs.txt").c_str());
75 LOG(
"HEDISStrucFunc",
pWARN) <<
"Good news! Directory already exists.";
76 LOG(
"HEDISStrucFunc",
pWARN) <<
"Precomputed SF stored in that directory will be used";
77 LOG(
"HEDISStrucFunc",
pINFO) <<
"Comparing info from Metafile and selected Tune (CommonParam.xml)";
79 std::ifstream meta_stream((SFname+
"/Inputs.txt").c_str(), std::ios::in);
83 LOG(
"HEDISStrucFunc",
pINFO) <<
"Info from MetaFile and Tune match";
86 LOG(
"HEDISStrucFunc",
pERROR) <<
"Info from MetaFile and Tune doesnt match";
87 LOG(
"HEDISStrucFunc",
pERROR) <<
"MetaFile Path : " << SFname <<
"/Inputs.txt";
88 LOG(
"HEDISStrucFunc",
pERROR) <<
"From Tune : ";
90 LOG(
"HEDISStrucFunc",
pERROR) <<
"From MetaFile : ";
96 fSF.Sin2ThW = fSF.Rho==0. ? fSF.Sin2ThW : 1.-fSF.MassW*fSF.MassW/fSF.MassZ/fSF.MassZ/(1+fSF.Rho);
97 LOG(
"HEDISStrucFunc",
pINFO) <<
"Weingber angle computation:";
98 LOG(
"HEDISStrucFunc",
pINFO) <<
"Rho = " << fSF.Rho;
99 LOG(
"HEDISStrucFunc",
pINFO) <<
"Sin2ThW = " << fSF.Sin2ThW;
102 #ifdef __GENIE_LHAPDF6_ENABLED__ 103 LOG(
"HEDISStrucFunc",
pINFO) <<
"Initialising LHAPDF6...";
104 pdf = LHAPDF::mkPDF(fSF.LHAPDFset, fSF.LHAPDFmember);
108 LOG(
"HEDISStrucFunc",
pINFO) <<
"PDF info:";
109 LOG(
"HEDISStrucFunc",
pINFO) <<
"OrderQCD = " << pdf->orderQCD();
110 LOG(
"HEDISStrucFunc",
pINFO) <<
"FlavorScheme = " << pdf->info().get_entry(
"FlavorScheme");
111 LOG(
"HEDISStrucFunc",
pINFO) <<
"NumFlavors = " << pdf->info().get_entry(
"NumFlavors");
113 LOG(
"HEDISStrucFunc",
pINFO) <<
"MZ = " << pdf->info().get_entry(
"MZ");
114 for (
int i=1; i<7; i++) {
115 mPDFQrk[i] = pdf->quarkMass(i);
119 #ifdef __GENIE_LHAPDF5_ENABLED__ 120 LOG(
"HEDISStrucFunc",
pINFO) <<
"Initialising LHAPDF5...";
121 LHAPDF::initPDFByName(fSF.LHAPDFset, LHAPDF::LHGRID, fSF.LHAPDFmember);
124 Q2PDFmax = LHAPDF::getQ2max(0);
125 LOG(
"HEDISStrucFunc",
pINFO) <<
"PDF info:";
127 for (
int i=1; i<7; i++) {
128 mPDFQrk[i] = LHAPDF::getQMass(i);
134 if ( fSF.XGridMin <
xPDFmin ) {
135 LOG(
"HEDISStrucFunc",
pWARN) <<
"Lower boundary in X is smaller than input PDF";
137 LOG(
"HEDISStrucFunc",
pWARN) <<
"xGridMin = " << fSF.XGridMin;
138 LOG(
"HEDISStrucFunc",
pWARN) <<
"DANGER: An extrapolation will be done!!!!!";
140 else if ( fSF.Q2GridMin <
Q2PDFmin ) {
141 LOG(
"HEDISStrucFunc",
pWARN) <<
"Lower boundary in Q2 is smaller than input PDF";
143 LOG(
"HEDISStrucFunc",
pWARN) <<
"Q2GridMin = " << fSF.Q2GridMin;
144 LOG(
"HEDISStrucFunc",
pWARN) <<
"DANGER: An extrapolation will be done!!!!!";
146 else if ( fSF.Q2GridMax > Q2PDFmax ) {
147 LOG(
"HEDISStrucFunc",
pWARN) <<
"Upper boundary in Q2 is bigger than input PDF";
149 LOG(
"HEDISStrucFunc",
pWARN) <<
"Q2GridMax = " << fSF.Q2GridMax;
150 LOG(
"HEDISStrucFunc",
pWARN) <<
"DANGER: An extrapolation will be done!!!!!";
154 double dlogq2 = TMath::Abs( TMath::Log10(fSF.Q2GridMin)-TMath::Log10(fSF.Q2GridMax) ) / fSF.NGridQ2;
155 double dlogx = TMath::Abs( TMath::Log10(fSF.XGridMin)-TMath::Log10(1.) ) / fSF.NGridX;
156 LOG(
"HEDISStrucFunc",
pINFO) <<
"Grid x,Q2 :" << fSF.NGridX <<
" , " << fSF.NGridQ2;
157 for (
double logq2 = TMath::Log10(fSF.Q2GridMin); logq2<TMath::Log10(fSF.Q2GridMax); logq2+= dlogq2 ) {
158 double q2 = TMath::Power( 10, logq2 + 0.5*dlogq2 );
159 if (q2>fSF.Q2GridMax)
continue;
163 for (
double logx = TMath::Log10(fSF.XGridMin); logx<TMath::Log10(1.); logx+= dlogx ) {
164 double x = TMath::Power( 10, logx + 0.5*dlogx );
165 if ( x>1. )
continue;
177 for (
int j=0; j<ny; j++) y[j] =
sf_x_array[j];
179 vector<InteractionType_t> inttype;
182 vector<InitialState> init_state;
192 string sfFile = SFname +
"/QrkSF_LO_" +
QrkSFName(*in) +
".dat";
194 LOG(
"HEDISStrucFunc",
pINFO) <<
"Checking if file " << sfFile <<
" exists...";
195 if ( gSystem->AccessPathName( sfFile.c_str()) ) {
196 LOG(
"HEDISStrucFunc",
pWARN) <<
"File doesnt exist. SF table will be computed.";
199 else if ( atoi(gSystem->GetFromPipe((
"wc -w "+sfFile+
" | awk '{print $1}'").c_str()))!=
kSFT3*nx*ny ) {
200 LOG(
"HEDISStrucFunc",
pWARN) <<
"File does not contain all the need points. SF table will be recomputed.";
201 gSystem->Exec((
"rm "+sfFile).c_str());
204 std::ifstream sf_stream(sfFile.c_str(), std::ios::in);
208 for (
int ij=0; ij<nx*ny; ij++ ) sf_stream >> z[ij];
215 #ifdef __GENIE_APFEL_ENABLED__ 217 LOG(
"HEDISStrucFunc",
pINFO) <<
"Initialising APFEL..." ;
218 APFEL::SetPDFSet(fSF.LHAPDFset);
219 APFEL::SetReplica(fSF.LHAPDFmember);
220 if (fSF.Scheme==
"BGR") {
221 APFEL::SetMassScheme(
"FONLL-B");
224 else if (fSF.Scheme==
"CSMS") {
225 APFEL::SetMassScheme(
"ZM-VFNS");
229 LOG(
"HEDISStrucFunc",
pERROR) <<
"Mass Scheme is not set properly";
232 APFEL::SetQLimits(TMath::Sqrt(fSF.Q2GridMin),TMath::Sqrt(fSF.Q2GridMax));
233 APFEL::SetMaxFlavourPDFs(6);
234 APFEL::SetMaxFlavourAlpha(6);
235 APFEL::SetNumberOfGrids(3);
236 APFEL::SetGridParameters(1,90,3,fSF.XGridMin);
237 APFEL::SetGridParameters(2,50,5,1
e-1);
238 APFEL::SetGridParameters(3,40,5,8
e-1);
239 APFEL::SetPerturbativeOrder(1);
240 APFEL::SetAlphaQCDRef(pdf->alphasQ(fSF.MassZ),fSF.MassZ);
242 APFEL::SetWMass(fSF.MassW);
243 APFEL::SetZMass(fSF.MassZ);
244 APFEL::SetSin2ThetaW(fSF.Sin2ThW);
245 APFEL::SetCKM(fSF.Vud, fSF.Vus, fSF.Vub,
246 fSF.Vcd, fSF.Vcs, fSF.Vcb,
247 fSF.Vtd, fSF.Vts, fSF.Vtb);
257 string sfFile = SFname +
"/NucSF_NLO_" +
NucSFName(*in) +
".dat";
259 LOG(
"HEDISStrucFunc",
pINFO) <<
"Checking if file " << sfFile <<
" exists...";
260 if ( gSystem->AccessPathName( sfFile.c_str()) ) {
261 #ifdef __GENIE_APFEL_ENABLED__ 262 LOG(
"HEDISStrucFunc",
pWARN) <<
"File doesnt exist. SF table will be computed.";
265 LOG(
"HEDISStrucFunc",
pERROR) <<
"File doesnt exist. APFEL is needed for NLO SF";
269 else if ( atoi(gSystem->GetFromPipe((
"wc -w "+sfFile+
" | awk '{print $1}'").c_str()))!=
kSFT3*nx*ny ) {
270 #ifdef __GENIE_APFEL_ENABLED__ 271 LOG(
"HEDISStrucFunc",
pWARN) <<
"File does not contain all the need points. SF table will be recomputed.";
272 gSystem->Exec((
"rm "+sfFile).c_str());
275 LOG(
"HEDISStrucFunc",
pERROR) <<
"File does not contain all the need points. APFEL is needed for NLO SF";
279 std::ifstream sf_stream(sfFile.c_str(), std::ios::in);
283 for (
int ij=0; ij<nx*ny; ij++ ) sf_stream >> z[ij];
289 LOG(
"HEDISStrucFunc",
pDEBUG) <<
"Creating LO " << sfFile;
298 for (
int i=0; i<nx; i++) {
300 for (
int j=0; j<ny; j++) {
static constexpr double cm
TuneId * Tune(void) const
static HEDISStrucFunc * fgInstance
Concrete implementations of the InteractionListGeneratorI interface. Generate a list of all the Inter...
vector< double > sf_q2_array
map< int, HEDISStrucFuncTable > fQrkSFLOTables
std::map< int, double > mPDFQrk
int NucSFCode(const Interaction *in)
int QrkSFCode(const Interaction *in)
string QrkSFName(const Interaction *in)
enum genie::HEDISStrucFunc::StrucFuncType HEDISStrucFuncType_t
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
void CreateNucSF(const Interaction *in, string sfFile)
map< int, HEDISStrucFuncTable > fNucSFLOTables
InteractionList * CreateHEDISlist(vector< InitialState > vinit, vector< InteractionType_t > vinttype) const
map< int, HEDISStrucFuncTable > fNucSFNLOTables
static RunOpt * Instance(void)
void CreateQrkSF(const Interaction *in, string sfFile)
string NucSFName(const Interaction *in)
A vector of Interaction objects.
vector< double > sf_x_array
static const double kProtonMass
Initial State information.