cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
PartonicStructureFunctionsLHAPDF.cpp
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2013-2023 Laurent Forthomme
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#include <LHAPDF/LHAPDF.h>
20
21
#include <cmath>
22
23
#include "
CepGen/Core/Exception.h
"
24
#include "
CepGen/Modules/StructureFunctionsFactory.h
"
25
#include "
CepGen/StructureFunctions/PartonicParameterisation.h
"
26
#include "
CepGen/Utils/String.h
"
27
28
#if defined LHAPDF_MAJOR_VERSION && LHAPDF_MAJOR_VERSION == 6
29
#define LHAPDF_GE_6 1
30
#endif
31
32
namespace
cepgen
{
33
namespace
strfun {
35
class
LHAPDFPartonic
:
public
PartonicParameterisation
{
36
public
:
38
enum class
Mode
{
full
= 0,
valence
= 1,
sea
= 2 };
40
explicit
LHAPDFPartonic
(
const
ParametersList
& params)
41
:
PartonicParameterisation
(params),
42
pdf_set_(
steer
<std::string>(
"pdfSet"
)),
43
pdf_code_(
steer
<int>(
"pdfCode"
)),
44
pdf_member_(
steer
<int>(
"pdfMember"
)) {}
45
46
static
ParametersDescription
description
() {
47
auto
desc =
PartonicParameterisation::description
();
48
desc.setDescription(
"LHAPDF (partonic)"
);
49
desc.add<std::string>(
"pdfSet"
,
"cteq66"
).setDescription(
"PDF modelling to be considered"
);
50
desc.add<
int
>(
"pdfCode"
, 0);
51
desc.add<
int
>(
"pdfMember"
, 0);
52
return
desc;
53
}
54
55
private
:
56
void
initialise();
57
double
evalxQ2(
int
flavour,
double
xbj,
double
q2)
override
;
59
std::string pdf_set_;
61
int
pdf_code_;
63
int
pdf_member_;
64
bool
initialised_{
false
};
65
66
#ifdef LHAPDF_GE_6
67
LHAPDF::PDFSet lha_pdf_set_;
68
std::vector<std::unique_ptr<LHAPDF::PDF> > pdfs_;
69
#endif
70
};
71
72
void
LHAPDFPartonic::initialise() {
73
if
(initialised_)
74
return
;
75
std::string lhapdf_version, pdf_description, pdf_type;
76
#ifdef LHAPDF_GE_6
77
try
{
78
//--- check if PDF code is set
79
if
(pdf_code_ != 0) {
80
auto
pdf = LHAPDF::lookupPDF(pdf_code_);
81
if
(pdf.second != 0)
82
throw
CG_FATAL
(
"LHAPDFPartonic"
) <<
"Failed to retrieve PDFset with id="
<< pdf_code_ <<
"!"
;
83
if
(!pdf_set_.empty() && pdf_set_ != pdf.first)
84
CG_WARNING
(
"LHAPDFPartonic"
) <<
"PDF set name changed from \""
<< pdf_set_ <<
"\" to \""
<< pdf.first
85
<<
"\"."
;
86
pdf_set_ = pdf.first;
87
}
88
lha_pdf_set_ = LHAPDF::PDFSet(pdf_set_);
89
lha_pdf_set_.mkPDFs<std::unique_ptr<LHAPDF::PDF> >(pdfs_);
90
lhapdf_version = LHAPDF::version();
91
pdf_description =
utils::replaceAll
(lha_pdf_set_.description(), {{
"\\n"
,
"\n"
}, {
". "
,
".\n "
}});
92
pdf_type = pdfs_[pdf_member_]->type();
93
}
catch
(
const
LHAPDF::Exception& e) {
94
throw
CG_FATAL
(
"LHAPDFPartonic"
) <<
"Caught LHAPDF exception:\n\t"
<< e.what();
95
}
96
#else
97
if
(pdf_code_ != 0)
98
LHAPDF::initPDFSet(pdf_code_, pdf_member_);
99
else
100
LHAPDF::initPDFSet(pdf_set_, LHAPDF::LHGRID, pdf_member_);
101
lhapdf_version = LHAPDF::getVersion();
102
#endif
103
CG_INFO
(
"LHAPDFPartonic"
) <<
"Partonic structure functions evaluator successfully built.\n"
104
<<
" * LHAPDF version: "
<< lhapdf_version <<
"\n"
105
<<
" * number of flavours: "
<< num_flavours_ <<
"\n"
106
<<
" * quarks mode: "
<< mode_ <<
"\n"
107
<<
" * PDF set: "
<< pdf_set_ <<
"\n"
108
<<
" * PDF member: "
<< pdf_member_ << (pdf_type.empty() ?
""
:
" ("
+ pdf_type +
")"
)
109
<<
"\n"
110
<< (pdf_description.empty() ?
""
:
" "
+ pdf_description);
111
#ifndef LHAPDF_GE_6
112
LHAPDF::getDescription();
113
#endif
114
initialised_ =
true
;
115
}
116
117
double
LHAPDFPartonic::evalxQ2(
int
flavour,
double
xbj,
double
q2) {
118
if
(!initialised_)
119
initialise
();
120
#ifdef LHAPDF_GE_6
121
auto
& member = *pdfs_[pdf_member_];
122
if
(!member.inPhysicalRangeXQ2(xbj, q2)) {
123
CG_WARNING
(
"LHAPDFPartonic"
) <<
"(x="
<< xbj <<
", Q²="
<<
q2
<<
" GeV²) "
124
<<
"not in physical range for PDF member "
<< pdf_member_ <<
":\n\t"
125
<<
" min: (x="
<< member.xMin() <<
", Q²="
<< member.q2Min() <<
"),\n\t"
126
<<
" max: (x="
<< member.xMax() <<
", Q²="
<< member.q2Max() <<
")."
;
127
return
0.;
128
}
129
if
(!pdfs_[pdf_member_]->hasFlavor(flavour))
130
throw
CG_FATAL
(
"LHAPDFPartonic"
) <<
"Flavour "
<< flavour <<
" is unsupported!"
;
131
return
member.xfxQ2(flavour, xbj, q2);
132
#else
133
if
(q2 < LHAPDF::getQ2min(pdf_member_) || q2 > LHAPDF::getQ2max(pdf_member_) ||
134
xbj < LHAPDF::getXmin(pdf_member_) || xbj > LHAPDF::getXmax(pdf_member_)) {
135
CG_WARNING
(
"LHAPDFPartonic"
) <<
"(x="
<< xbj <<
"/Q²="
<<
q2
<<
" GeV²) "
136
<<
"not in physical range for PDF member "
<< pdf_member_ <<
":\n"
137
<<
" min: (x="
<< LHAPDF::getXmin(pdf_member_)
138
<<
"/Q²="
<< LHAPDF::getQ2min(pdf_member_) <<
"),\n"
139
<<
" max: (x="
<< LHAPDF::getXmax(pdf_member_)
140
<<
"/Q²="
<< LHAPDF::getQ2max(pdf_member_) <<
")."
;
141
return
0.;
142
}
143
return
LHAPDF::xfx(xbj, std::sqrt(q2), flavour);
144
#endif
145
}
146
}
// namespace strfun
147
}
// namespace cepgen
148
149
#ifdef LHAPDF_GE_6
150
#undef LHAPDF_GE_6
151
#endif
152
153
using
cepgen::strfun::LHAPDFPartonic
;
154
REGISTER_STRFUN
(
"lhapdf"
, 401,
LHAPDFPartonic
);
Exception.h
CG_FATAL
#define CG_FATAL(mod)
Definition
Exception.h:61
CG_WARNING
#define CG_WARNING(mod)
Definition
Message.h:228
CG_INFO
#define CG_INFO(mod)
Definition
Message.h:216
PartonicParameterisation.h
String.h
StructureFunctionsFactory.h
REGISTER_STRFUN
#define REGISTER_STRFUN(name, id, obj)
Add a structure functions definition to the list of handled parameterisation.
Definition
StructureFunctionsFactory.h:25
cepgen::ParametersDescription
A description object for parameters collection.
Definition
ParametersDescription.h:26
cepgen::ParametersList
Definition
ParametersList.h:52
cepgen::Steerable::steer
T steer(const std::string &key) const
Retrieve a parameters as previously steered.
Definition
Steerable.h:39
cepgen::strfun::LHAPDFPartonic
Generic partonic level perturbative structure functions built from an external PDFs grid.
Definition
PartonicStructureFunctionsLHAPDF.cpp:35
cepgen::strfun::LHAPDFPartonic::LHAPDFPartonic
LHAPDFPartonic(const ParametersList ¶ms)
Build a calculator from its Parameters object.
Definition
PartonicStructureFunctionsLHAPDF.cpp:40
cepgen::strfun::LHAPDFPartonic::Mode
Mode
Quarks types.
Definition
PartonicStructureFunctionsLHAPDF.cpp:38
cepgen::strfun::LHAPDFPartonic::Mode::valence
@ valence
cepgen::strfun::LHAPDFPartonic::Mode::sea
@ sea
cepgen::strfun::LHAPDFPartonic::Mode::full
@ full
cepgen::strfun::LHAPDFPartonic::description
static ParametersDescription description()
Definition
PartonicStructureFunctionsLHAPDF.cpp:46
cepgen::strfun::PartonicParameterisation
Generic partonic level perturbative structure functions built from an external PDFs grid.
Definition
PartonicParameterisation.h:26
cepgen::strfun::PartonicParameterisation::description
static ParametersDescription description()
Definition
PartonicParameterisation.cpp:32
cepgen::utils::q2
double q2(double xbj, double mp2, double mx2)
Compute the virtuality from Bjorken x/diffractive mass.
Definition
Utils.cpp:35
cepgen::utils::replaceAll
size_t replaceAll(std::string &str, const std::string &from, const std::string &to)
Replace all occurrences of a text by another.
Definition
String.cpp:118
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
cepgen::initialise
void initialise(bool safe_mode)
Definition
GlobalFunctions.cpp:91
CepGenAddOns
LHAPDFWrapper
PartonicStructureFunctionsLHAPDF.cpp
Generated on Mon Jul 29 2024 for CepGen by
1.9.7