APFEL 4.8.0
A PDF evolution library in C++
Loading...
Searching...
No Matches
mkpdf.h
Go to the documentation of this file.
1//
2// APFEL++ 2017
3//
4// Author: Valerio Bertone: valerio.bertone@cern.ch
5//
6
7#pragma once
8
9#include "apfel/config.h"
10
11#if WITH_LHAPDF == 1
12
14
15#include <LHAPDF/LHAPDF.h>
16#include <LHAPDF/GridPDF.h>
17
25LHAPDF::PDF* mkPDF(apfel::InitialiseEvolution const& ev)
26{
27 // Get knot array from APFEL
28 const std::map<double, std::map<int, apfel::LHKnotArray>> ka = ev.KnotArray();
29
30 // Knot array to be fed to LHAPDF
31 LHAPDF::KnotArray data;
32
33 // Loop over Q subgrids to accumulate x-grid, q2-grid, and flavour
34 // IDs.
35 for (auto const& sg : ka)
36 {
37 // Get x-grid from first flavour of the first subgrid
38 if (data.xs().empty())
39 data.setxknots() = sg.second.begin()->second.xs;
40
41 // Accumulate q2 grid using the first flavour
42 data.setq2knots().insert(data.setq2knots().end(), sg.second.begin()->second.q2s.begin(), sg.second.begin()->second.q2s.end());
43
44 // Fill in the flavour ID vector (use 21 for the gluon)
45 if (data.setPids().empty())
46 for (auto const& id : sg.second)
47 data.setPids().push_back((id.first == 0 ? 21 : id.first));
48 }
49
50 // Set up the knots of the Knotarray
51 data.setShape() = std::vector<size_t> {data.xs().size(), data.q2s().size(), data.setPids().size()};
52 data.fillLogKnots();
53 data.initPidLookup();
54
55 // Set size of data vector
56 data.setGrid().resize(data.shape(0) * data.shape(1) * data.shape(2), 0.);
57
58 // Loop over Q subgrids to accumulate data
59 int nqprev = 0;
60 for (auto const& sg : ka)
61 {
62 // Initialise flavour index
63 int ifl = 0;
64
65 // Get q2-subgrid size
66 const int q2size = (int) sg.second.begin()->second.xfs.size() / data.shape(0);
67
68 // Loop over flavours
69 for (auto const& id : sg.second)
70 {
71 // Get vector of distributions
72 const std::vector<double> f = id.second.xfs;
73
74 // Loop over x-grid
75 for (int ix = 0; ix < (int) data.shape(0); ix++)
76 {
77 int iq = nqprev;
78 // Loop over q2-sugrid
79 for (int iqs = 0; iqs < q2size; iqs++)
80 data.setGrid()[ix * data.shape(2) * data.shape(1) + iq++ * data.shape(2) + ifl] = f[ix * q2size + iqs];
81 }
82 ifl++;
83 }
84 nqprev += q2size;
85 }
86
87 // Fill in alpha_s vector
88 std::vector<double> als;
89 for (auto const& q2 : data.q2s())
90 als.push_back(ev.Alphas(sqrt(q2)));
91
92 // Construct alpha_s object
93 LHAPDF::AlphaS_Ipol* as = new LHAPDF::AlphaS_Ipol{};
94 as->setQ2Values(data.q2s());
95 as->setAlphaSValues(als);
96
97 // Define an LHAPDF GridPDF object
98 LHAPDF::GridPDF* dist = new LHAPDF::GridPDF{};
99
100 // Pass knot arrays to LHAPDF
101 dist->Data() = data;
102
103 // Set interpolator
104 dist->setInterpolator((std::string) "logcubic");
105
106 // Set extrapolator
107 dist->setExtrapolator((std::string) "continuation");
108
109 // Set flavours
110 dist->setFlavors(data.setPids());
111
112 // Set alpha_s
113 dist->setAlphaS(as);
114
115 // Set scale bounds
116 dist->info().set_entry("QMin", sqrt(data.q2s().front()));
117 dist->info().set_entry("QMax", sqrt(data.q2s().back()));
118
119 // Set x bounds
120 dist->info().set_entry("XMin", data.xs().front());
121 dist->info().set_entry("XMax", data.xs().back());
122
123 // Set quark masses and thresholds
124 const std::vector<std::string> Qnames{"Down", "Up", "Strange", "Charm", "Bottom", "Top"};
125 const std::vector<double> trhs = ev.GetEvolutionSetup().Thresholds;
126 for (int iq = 0; iq < (int) Qnames.size(); iq++)
127 {
128 dist->info().set_entry("M" + Qnames[iq], (iq < (int) trhs.size() ? trhs[iq] : 1e8 + iq));
129 dist->info().set_entry("Threshold" + Qnames[iq], (iq < (int) trhs.size() ? trhs[iq] : 1e8 + iq));
130 }
131
132 // Return object
133 return dist;
134}
135
136#endif
The InitialiseEvolution performs all the operations to initialise a DGLAP evolution using an Evolutio...
Definition initialiseevolution.h:37
std::map< double, std::map< int, LHKnotArray > > KnotArray() const
Function that returns the full set of distributions tabulated on the (x,Q2) grid.
Definition initialiseevolution.h:114
EvolutionSetup GetEvolutionSetup() const
Function that returns the EvolutionSetup object.
Definition initialiseevolution.h:127
std::vector< double > Thresholds
Heavy-quark thresholds.
Definition evolutionsetup.h:84