LHAPDFreader

The package is meant as a simple parser of PDF/TMD grids to Mathematica. The main purpose is simple computation/plots.
If you have found a bug, send e-mail: vladimirov.aleksey@gmail.com

Loading package
You can install it using File/Install -> package, or specify the location

SetDirectory["/home/vla18041/LinkData2/WorkingFiles/TMD/MathCalc/LHAPDF"]

<<LHAPDFreader`

Provide the path to the grid-directory 
(the directory which directories of grids, e.g. LHAPDF/Installation/share/LHAPDF)

SetLibraryPath["/home/vla18041/LinkData2/LHAPDF/Installation/share/LHAPDF"]

Version history

1.0.0: Initial implementation. LHAPDF reader

1.0.1: Removed the automatic determination of LHAPDF path.

1.0.2: Update the info-reading routine. Now it reads all (my) library

1.0.3: Massive renaming of functions
------
1.1.0: Implementation of TMDLIB grids reading (“Pavia”)

Common parts (info-files, αs)

Provide the path to the grid-directory 
(the directory which directories of grids, e.g. LHAPDF/Installation/share/LHAPDF)

SetLibraryPath["/home/vla18041/LinkData2/LHAPDF/Installation/share/LHAPDF"]

Now you should be able to list avalible PDF-sets

ListGrids[]

The information on PDF-set is inside .info file it is read by

ReadInfo["NNPDF31_nnlo_as_0118"]

The result of info is accesed via ShowInfo
You can access individual fields by calling them (if found)

ShowInfo[]

ShowInfo["NumMembers"]

This command loads the values of alphaS
Comment 1: there is a default αs, which is loaded on the loading of the package it is from “NNPDF31_nnlo_as_0118”

Plot[AlphaS[Q],{Q,1,100}]

LHAPDF grids

SetLibraryPath["/home/vla18041/LinkData2/LHAPDF/Installation/share/LHAPDF"]

The LHAPDF is Loaded by 
Comment 1: the info-file is loaded automatically.
Comment 2: by default loads the num=0 set. (see alos lower)

Options: Silent ->False switches messages

LoadLHAPDFgrid["NNPDF31_nnlo_as_0118"]

xPDF[x,μ,f] gives you the PDF (times x)
Flavor enumeration according to the LHA convention
You can plot it!

LogLinearPlot[{xPDF[x,2.,1],xPDF[x,2.,2],xPDF[x,2.,3]},{x,(10^(-3)),1.},PlotStyle->{Red,Blue,Black},
PlotLegends->{"d-quark","u-quark","s-quark"}]

Uncertanty bands are inside of the replicas. For a moment they should be read separately.
Here is example of unceranty band for u-quark
Comment 1: the spaming of loading messages can be suppressed with option “Silent”->True

ShowInfo["NumMembers"]

xValues=Table[(10^j),{j,-3,0,0.05}]

tabNNPDF=Table[
LoadLHAPDFgrid["NNPDF31_nnlo_as_0118",i,"Silent"->True];
Table[xPDF[x,2.,2],{x,xValues}]
,{i,1,100}];

With[{tab=tabNNPDF},ListLogLinearPlot[
{Transpose[{xValues,Mean[tab]+StandardDeviation[tab]}],
Transpose[{xValues,Mean[tab]-StandardDeviation[tab]}],
Transpose[{xValues,Mean[tab]}]},Joined->True,PlotStyle->{LightRed,LightRed,Red},Filling->{1->{2}}]]

With[{tab=tabNNPDF},ListLogLinearPlot[
{Transpose[{xValues,((StandardDeviation[tab])/(Mean[tab]+(10^(-9))))}],
Transpose[{xValues,((-StandardDeviation[tab])/(Mean[tab]+(10^(-9))))}]},Joined->True,PlotStyle->{LightRed,LightRed,Red},Filling->{1->{2}}]]

TMDlib TMD-grids

For a moment (ver .1 .1 .0), the package read only grids in ``Pavia’’ format. Other formats could be added in the future.

SetLibraryPath["/home/vla18041/LinkData2/WorkingFiles/TMD/Fit_Notes/TMD-grids/Grids"]

Now you should be able to list avalible TMD-grids

ListGrids[]

The information on PDF-set is inside .info file it is read by

ReadInfo["BPV20_Sivers"]

The result of info is accesed via ShowInfo
You can access individual fields by calling them (if found)

ShowInfo[]

ShowInfo["NumMembers"]

The set is Loaded by 
Comment 0: For a moment only grids in ``Pavia19’’ format are used. There is a reserved Option “Format” for other cases, to be implemented in happy future.
Comment 1: the info-file is loaded automatically.
Comment 2: by default loads the num=0 set. 

Options: 	Silent ->False switches messages
		Format -> “Pavia”  for grids in different format (functionallity is not implemented)

Reading TMD grids takes time. Be patient...

Timing[LoadTMDLIBgrid["BPV20_Sivers"]]

xTMDPDF[x,qT, μ , f] gives you the TMDPDF.
Plot it!
Comment 1: Beyond the grid, values set to null..

LogLinearPlot[{xTMDPDF[x,0.5,2.,1],xTMDPDF[x,0.5,2.,2],xTMDPDF[x,0.5,2.,3]},{x,(10^(-2)),1.},PlotStyle->{Red,Blue,Black},
PlotLegends->{"d-quark","u-quark","s-quark"},PlotRange->All]

Plot[{xTMDPDF[0.1,qT,2.,1],xTMDPDF[0.1,qT,2.,2],xTMDPDF[0.1,qT,2.,3]},{qT,0,2},PlotStyle->{Red,Blue,Black},
PlotLegends->{"d-quark","u-quark","s-quark"},PlotRange->All]

Plot[{(0.9/qT)xTMDPDF[0.1,qT,2.,1],(0.9/qT)xTMDPDF[0.1,qT,10.,1],(0.9/qT)xTMDPDF[0.1,qT,25.,1]},{qT,0,2},PlotStyle->{Red,Blue,Black},
PlotLegends->{"2 GeV","10 GeV","25 GeV"},PlotRange->All]

Plot3D[(0.9/qT)xTMDPDF[(10^x),qT,2.,1],{x,-2,0},{qT,0,2},PlotRange->All]

Uncertanty bands are inside of the replicas. For a moment they should be read separately.
Here is example of unceranty band for u-quark In BPV20_Sivers extraction
Comment 1: the spaming of loading messages can be suppressed with option “Silent”->True

ShowInfo["SetDesc"]

ShowInfo["NumMembers"]

xValues=Table[(10^j),{j,-2,0,0.05}]

tabBSV=Table[
LoadTMDLIBgrid["BPV20_Sivers",i,"Silent"->True];
Table[xTMDPDF[x,0.5,4,2],{x,xValues}]
,{i,1,24}];

LoadTMDLIBgrid["BPV20_Sivers"]

var=With[{tt=Transpose[tabBSV]},
{
Table[{xValues[[i]],With[{t=xTMDPDF[xValues[[i]],0.5,4,2]},t+StandardDeviation@Select[tt[[i]]-t,#>=0&]]},{i,Length[xValues]}],
Table[{xValues[[i]],With[{t=xTMDPDF[xValues[[i]],0.5,4,2]},t-StandardDeviation@Abs[Select[tt[[i]]-t,#<=0&]]]},{i,Length[xValues]}],
Table[{xValues[[i]],With[{t=xTMDPDF[xValues[[i]],0.5,4,2]},t]},{i,Length[xValues]}]
}];

ListLogLinearPlot[var,Joined->True,PlotStyle->{LightRed,LightRed,Red},Filling->{1->{2}},PlotRange->All]