cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
LpairHandler.cpp
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2013-2024 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 <fstream>
20
#include <memory>
21
22
#include "
CepGen/Cards/Handler.h
"
23
#include "
CepGen/Core/Exception.h
"
24
#include "
CepGen/Core/RunParameters.h
"
25
#include "
CepGen/EventFilter/EventExporter.h
"
26
#include "
CepGen/EventFilter/EventModifier.h
"
27
#include "
CepGen/Generator.h
"
// for library loading
28
#include "
CepGen/Modules/CardsHandlerFactory.h
"
29
#include "
CepGen/Modules/EventExporterFactory.h
"
30
#include "
CepGen/Modules/EventModifierFactory.h
"
31
#include "
CepGen/Modules/ProcessFactory.h
"
32
#include "
CepGen/Modules/StructureFunctionsFactory.h
"
33
#include "
CepGen/Physics/GluonGrid.h
"
34
#include "
CepGen/Physics/MCDFileParser.h
"
35
#include "
CepGen/Physics/PDG.h
"
36
#include "
CepGen/Process/Process.h
"
37
#include "
CepGen/Utils/Filesystem.h
"
38
#include "
CepGen/Utils/String.h
"
39
#include "
CepGen/Utils/TimeKeeper.h
"
40
41
using
std::string;
42
43
static
constexpr
int
kInvalidInt
= -999999;
44
static
constexpr
double
kInvalidDbl
= 999.999;
45
static
constexpr
const
char
*
kInvalidStr
=
"(null)"
;
46
47
#define REGISTER_LPAIR_CONTENT_TYPE \
48
__TYPE_ENUM(int, p_ints_, -kInvalidInt) \
49
__TYPE_ENUM(double, p_doubles_, -kInvalidDbl) \
50
__TYPE_ENUM(std::string, p_strings_, kInvalidStr)
51
52
namespace
cepgen
{
53
class
ParametersList;
54
namespace
card {
56
class
LpairHandler
final :
public
Handler
{
57
public
:
59
explicit
LpairHandler
(
const
ParametersList
& params) :
Handler
(params) {}
60
61
static
ParametersDescription
description
() {
62
auto
desc =
Handler::description
();
63
desc.setDescription(
"LPAIR-like cards parser"
);
64
return
desc;
65
}
66
67
inline
LpairHandler
&
parseFile
(
const
std::string& filename)
override
{
68
if
(!
utils::fileExists
(filename))
69
throw
CG_FATAL
(
"LpairHandler:parseFile"
) <<
"Unable to locate steering card \""
<< filename <<
"\"."
;
70
if
(
const
auto
file_content =
utils::split
(
utils::readFile
(filename),
'\n'
); !file_content.empty())
71
return
parseCommands
(file_content);
72
CG_WARNING
(
"LpairHandler:parseFile"
) <<
"Empty steering card."
;
73
return
*
this
;
74
}
75
76
inline
LpairHandler
&
parseCommands
(
const
std::vector<std::string>& commands)
override
{
77
std::ostringstream os;
78
init();
79
for
(
auto
line : commands) {
80
if
(line =
utils::trim
(line); line.empty() || line[0] ==
'#'
)
// skip comments
81
continue
;
82
const
auto
fields =
utils::split
(line,
' '
,
true
);
// parse all fields
83
84
if
(fields.size() < 2) {
// skip all invalid lines
85
CG_WARNING
(
"LpairHandler:parseCommands"
) <<
"Invalid command read: '"
<< line <<
"'."
;
86
continue
;
87
}
88
const
auto
key = fields.at(0), value = fields.at(1);
89
setParameter(key, value);
90
if
(
const
auto
descr = describe(key); descr !=
kInvalidStr
)
91
os <<
utils::format
(
"\n\t>> %-8s %-25s (%s)"
, key.data(), parameter(key).data(), descr.data());
92
}
93
94
CG_INFO
(
"LpairHandler:parseCommands"
)
95
<<
"LPAIR configuration successfully loaded! Now parsing the following parameters:"
<< os.str() <<
"."
;
96
parse();
97
return
*
this
;
98
}
99
101
inline
void
write
(
const
std::string& filename)
const override
{
102
std::ofstream file(filename, std::fstream::out | std::fstream::trunc);
103
if
(!file.is_open())
104
throw
CG_ERROR
(
"LpairHandler"
) <<
"Failed to open file '"
<< filename <<
"' for writing."
;
105
for
(
const
auto
& it : p_strings_)
106
if
(it.second.value && !it.second.value->empty())
107
file <<
utils::format
(
108
"%-8s %-20s ! %s\n"
, it.first.data(), it.second.value->data(), it.second.description.data());
109
for
(
const
auto
& it : p_ints_)
110
if
(it.second.value && *it.second.value !=
kInvalidInt
)
111
file <<
utils::format
(
"%-8s %-20d ! %s\n"
, it.first.data(), *it.second.value, it.second.description.data());
112
for
(
const
auto
& it : p_doubles_)
113
if
(it.second.value && *it.second.value !=
Limits::INVALID
)
114
file <<
utils::format
(
"%-8s %-20e ! %s\n"
, it.first.data(), *it.second.value, it.second.description.data());
115
file.close();
116
}
117
118
private
:
119
LpairHandler
& setRunParameters(
const
RunParameters
*)
override
;
120
121
void
init();
122
inline
void
parse() {
123
for
(
const
auto
& lib : utils::split(addons_list_,
','
))
124
loadLibrary
(lib);
125
126
//--- parse the PDG library
127
if
(!pdg_input_path_.empty())
128
pdg::MCDFileParser::parse
(pdg_input_path_);
129
if
(!kmr_grid_path_.empty())
130
kmr::GluonGrid::get
(
ParametersList
().set<std::string>(
"path"
, kmr_grid_path_));
131
132
//--- build the ticker if required
133
if
(timer_)
134
runParameters
()->
setTimeKeeper
(
new
utils::TimeKeeper
);
135
utils::Logger::get
().
setLevel
((
utils::Logger::Level
)log_level_);
136
utils::Logger::get
().
setExtended
(ext_log_);
137
138
{
//--- parse the structure functions code
139
auto
& kin_params = proc_params_.operator[]<
ParametersList
>(
"kinematics"
);
140
bool
beam1_elastic{
true
}, beam2_elastic{
true
};
141
if
(pmod_ ==
"1"
)
142
kin_params.
set
<
int
>(
"beam1id"
,
PDG::electron
);
143
else
{
144
kin_params.
set
<
int
>(
"beam1id"
,
PDG::proton
);
145
if
(pmod_ !=
"2"
) {
146
beam1_elastic =
false
;
147
auto
sf_params = StructureFunctionsFactory::get().describeParameters(pmod_).parameters();
148
sf_params.
set
<ParametersList>(
"sigmaRatio"
,
149
SigmaRatiosFactory::get().describeParameters(sr_type_).parameters());
150
if
(pmod_ ==
"205"
/* MSTWgrid */
&& !mstw_grid_path_.empty())
151
sf_params.
set
<std::string>(
"gridPath"
, mstw_grid_path_);
152
kin_params.
set
(
"structureFunctions"
, sf_params);
153
}
154
}
155
if
(emod_ ==
"1"
)
156
kin_params.
set
<
int
>(
"beam2id"
,
PDG::electron
);
157
else
{
158
kin_params.
set
<
int
>(
"beam2id"
,
PDG::proton
);
159
if
(emod_ !=
"2"
) {
160
beam2_elastic =
false
;
161
if
(emod_ != pmod_)
162
CG_WARNING
(
"LpairHandler"
)
163
<<
"Incoming particles' modes are inconsistent: PMOD="
<< pmod_ <<
", EMOD="
<< emod_ <<
"."
;
164
}
165
}
166
auto
& mode = kin_params.operator[]<
int
>(
"mode"
);
167
mode =
static_cast<
int
>
(
168
beam1_elastic
169
? (beam2_elastic ?
mode::Kinematics::ElasticElastic
:
mode::Kinematics::ElasticInelastic
)
170
: (beam2_elastic ? mode::
Kinematics
::
InelasticElastic
: mode::
Kinematics
::
InelasticInelastic
));
171
}
172
173
//--- parse the process name
174
if
(!proc_name_.empty() || !proc_params_.
empty
()) {
175
if
(!
runParameters
()->hasProcess() && proc_name_.empty())
176
throw
CG_FATAL
(
"LpairHandler"
) <<
"Process name not specified!"
;
177
if
(
runParameters
()->hasProcess() &&
runParameters
()->
process
().
name
() == proc_name_)
178
proc_params_ =
runParameters
()->
process
().
parameters
() + proc_params_;
179
if
(proc_name_ ==
"pptoff"
&& lepton_id_ != 0)
// backward-compatibility for PPtoLL cards
180
proc_params_.
set
<
int
>(
"pair"
,
PDG::electron
+ (lepton_id_ - 1) * 2);
181
runParameters
()->
setProcess
(ProcessFactory::get().build(proc_name_, proc_params_));
182
}
183
184
if
(!int_params_.
name
().empty())
185
runParameters
()->
integrator
() += int_params_;
186
runParameters
()->
generation
().
setParameters
(gen_params_);
187
188
//--- parse the hadronisation algorithm name
189
if
(!evt_mod_name_.empty())
190
for
(
const
auto
& mod : utils::
split
(evt_mod_name_,
','
))
191
runParameters
()->addModifier(EventModifierFactory::get().build(mod, ParametersList()));
192
193
//--- parse the output module name
194
if
(!out_mod_name_.empty()) {
195
const
auto
& out_files =
utils::split
(out_file_name_,
','
);
196
size_t
i = 0;
197
for
(
const
auto
& mod : utils::
split
(out_mod_name_,
','
)) {
198
ParametersList outm;
199
if
(out_files.size() > i && !out_files.at(i).empty())
200
outm.set<std::string>(
"filename"
, out_files.at(i));
201
runParameters
()->
addEventExporter
(EventExporterFactory::get().build(mod, outm));
202
++i;
203
}
204
}
205
}
206
209
template
<
typename
T>
210
struct
Parameter {
211
std::string key, description;
212
T* value{
nullptr
};
213
};
215
template
<
typename
T>
216
void
registerParameter(
const
std::string&
/*key*/
,
const
std::string&
/*description*/
, T*
/*def*/
) {}
217
template
<
typename
T>
218
void
registerProcessParameter(
const
std::string& key,
219
const
std::string&
description
,
220
const
std::string& proc_key) {
221
registerParameter<T>(key,
description
, &proc_params_.operator[]<T>(proc_key));
222
}
224
template
<
typename
T>
225
void
registerKinematicsParameter(
const
std::string& key,
226
const
std::string&
description
,
227
const
std::string& kin_key) {
228
registerParameter<T>(
229
key,
description
, &proc_params_.operator[]<ParametersList>(
"kinematics"
).operator[]<T>(kin_key));
230
}
231
template
<
typename
T>
232
void
registerGenerationParameter(
const
std::string& key,
233
const
std::string&
description
,
234
const
std::string& gen_key) {
235
registerParameter<T>(key,
description
, &gen_params_.operator[]<T>(gen_key));
236
}
237
template
<
typename
T>
238
void
registerIntegratorParameter(
const
std::string& key,
239
const
std::string&
description
,
240
const
std::string& int_key) {
241
registerParameter<T>(key,
description
, &int_params_.operator[]<T>(int_key));
242
}
244
template
<
typename
T>
245
inline
void
set(
const
std::string&
/*key*/
,
const
T&
/*value*/
) {}
247
template
<
typename
T>
248
inline
T get(
const
std::string&
/*key*/
)
const
{
249
return
T();
250
}
251
252
void
setParameter(
const
std::string& key,
const
std::string& value);
253
std::string parameter(
const
std::string& key)
const
;
254
inline
std::string describe(
const
std::string& key)
const
{
255
#define __TYPE_ENUM(type, map, default_val) \
256
if (map.count(key)) \
257
return map.at(key).description;
258
REGISTER_LPAIR_CONTENT_TYPE
259
#undef __TYPE_ENUM
260
return
kInvalidStr
;
261
}
262
263
ParametersList proc_params_, gen_params_, int_params_;
264
int
timer_{0}, iend_{1}, log_level_{(int)
utils::Logger::get
().
level
()}, ext_log_{0};
265
std::string emod_{
"2"
}, pmod_{
"2"
};
266
int
sr_type_{1}, lepton_id_{0};
267
std::string proc_name_, evt_mod_name_, out_mod_name_;
268
std::string out_file_name_, addons_list_;
269
std::string kmr_grid_path_, mstw_grid_path_, pdg_input_path_;
270
271
#define __TYPE_ENUM(type, map_name, default_val) std::map<std::string, Parameter<type> > map_name;
272
REGISTER_LPAIR_CONTENT_TYPE
273
#undef __TYPE_ENUM
274
};
275
276
//----- specialised registerers
277
#define __TYPE_ENUM(type, map, default_val) \
278
template <> \
279
inline void LpairHandler::registerParameter<type>( \
280
const std::string& key, const std::string& description, type* def) { \
281
map[key] = Parameter<type>{key, description, def}; \
282
} \
283
template <> \
284
inline void LpairHandler::set<type>(const std::string& key, const type& value) { \
285
if (map.count(key)) \
286
*map.at(key).value = value; \
287
} \
288
template <> \
289
inline type LpairHandler::get(const std::string& key) const { \
290
if (map.count(key)) \
291
return *map.at(key).value; \
292
return default_val; \
293
}
294
REGISTER_LPAIR_CONTENT_TYPE
295
#undef __TYPE_ENUM
296
297
std::string LpairHandler::parameter(
const
std::string& key)
const
{
298
#define __TYPE_ENUM(type, map, default_val) \
299
if (auto var = get<type>(key); var != default_val) \
300
return utils::toString(var);
301
REGISTER_LPAIR_CONTENT_TYPE
302
#undef __TYPE_ENUM
303
CG_ERROR
(
"LpairHandler:parameter"
) <<
"Failed to retrieve a parameter with key '"
<< key <<
"'."
;
304
return
kInvalidStr
;
305
}
306
307
void
LpairHandler::init() {
308
//-------------------------------------------------------------------------------------------
309
// Process/integration/hadronisation parameters
310
registerParameter<std::string>(
"PROC"
,
"Process name to simulate"
, &proc_name_);
311
registerParameter<std::string>(
"HADR"
,
"Hadronisation algorithm"
, &evt_mod_name_);
312
registerParameter<std::string>(
"EVMD"
,
"Events modification algorithms"
, &evt_mod_name_);
313
registerParameter<std::string>(
"OUTP"
,
"Output module"
, &out_mod_name_);
314
registerParameter<std::string>(
"OUTF"
,
"Output file name"
, &out_file_name_);
315
registerParameter<std::string>(
"ADDN"
,
"Additional libraries to load"
, &addons_list_);
316
registerIntegratorParameter<std::string>(
"ITYP"
,
"Integration algorithm"
,
MODULE_NAME
);
317
registerIntegratorParameter<int>(
"NTRT"
,
"Smoothen the integrand"
,
"treat"
);
318
registerIntegratorParameter<int>(
"NCVG"
,
"Number of function calls"
,
"numFunctionCalls"
);
319
registerIntegratorParameter<int>(
"ITVG"
,
"Number of integration iterations"
,
"iterations"
);
320
registerIntegratorParameter<int>(
"SEED"
,
"Random generator seed"
,
"seed"
);
321
322
//-------------------------------------------------------------------------------------------
323
// General parameters
324
registerParameter<int>(
"TIMR"
,
"Enable the time ticker"
, &timer_);
325
registerParameter<int>(
"IEND"
,
"Generation type"
, &iend_);
326
registerParameter<int>(
"DEBG"
,
"Debugging verbosity"
, &log_level_);
327
registerParameter<int>(
"LOGE"
,
"Extended logging"
, &ext_log_);
328
registerGenerationParameter<int>(
"NTHR"
,
"Number of threads to use for events generation"
,
"numThreads"
);
329
registerGenerationParameter<int>(
"NCSG"
,
"Number of points to probe"
,
"numPoints"
);
330
registerGenerationParameter<int>(
"NGEN"
,
"Number of events to generate"
,
"maxgen"
);
331
registerGenerationParameter<int>(
"NPRN"
,
"Number of events before printout"
,
"printEvery"
);
332
333
//-------------------------------------------------------------------------------------------
334
// Process-specific parameters
335
registerProcessParameter<int>(
"METH"
,
"Computation method (kT-factorisation)"
,
"method"
);
336
registerProcessParameter<int>(
"IPOL"
,
"Polarisation states to consider"
,
"polarisationStates"
);
337
338
//-------------------------------------------------------------------------------------------
339
// Process kinematics parameters
340
registerParameter<std::string>(
"KMRG"
,
"KMR grid interpolation path"
, &kmr_grid_path_);
341
registerParameter<std::string>(
"MGRD"
,
"MSTW grid interpolation path"
, &mstw_grid_path_);
342
registerParameter<std::string>(
"PDGI"
,
"Input file for PDG information"
, &pdg_input_path_);
343
registerParameter<std::string>(
"PMOD"
,
"Outgoing primary particles' mode"
, &pmod_);
344
registerParameter<std::string>(
"EMOD"
,
"Outgoing primary particles' mode"
, &emod_);
345
registerParameter<int>(
"RTYP"
,
"R-ratio computation type"
, &sr_type_);
346
registerProcessParameter<int>(
"PAIR"
,
"Outgoing particles' PDG id"
,
"pair"
);
347
registerKinematicsParameter<std::string>(
"FFAC"
,
"Form factors for the incoming beams"
,
"formFactors"
);
348
registerKinematicsParameter<int>(
"MODE"
,
"Subprocess' mode"
,
"mode"
);
349
registerKinematicsParameter<int>(
"INA1"
,
"Heavy ion atomic weight (1st incoming beam)"
,
"beam1A"
);
350
registerKinematicsParameter<int>(
"INZ1"
,
"Heavy ion atomic number (1st incoming beam)"
,
"beam1Z"
);
351
registerKinematicsParameter<int>(
"INA2"
,
"Heavy ion atomic weight (2nd incoming beam)"
,
"beam2A"
);
352
registerKinematicsParameter<int>(
"INZ2"
,
"Heavy ion atomic number (2nd incoming beam)"
,
"beam2Z"
);
353
registerKinematicsParameter<double>(
"INP1"
,
"Momentum (1st primary particle)"
,
"beam1pz"
);
354
registerKinematicsParameter<double>(
"INP2"
,
"Momentum (2nd primary particle)"
,
"beam2pz"
);
355
registerKinematicsParameter<double>(
"INPP"
,
"Momentum (1st primary particle)"
,
"beam1pz"
);
356
registerKinematicsParameter<double>(
"INPE"
,
"Momentum (2nd primary particle)"
,
"beam2pz"
);
357
registerKinematicsParameter<double>(
358
"PTCT"
,
"Minimal transverse momentum (single central outgoing particle)"
,
"ptmin"
);
359
registerKinematicsParameter<double>(
360
"PTMX"
,
"Maximal transverse momentum (single central outgoing particle)"
,
"ptmax"
);
361
registerKinematicsParameter<double>(
"MSCT"
,
"Minimal central system mass"
,
"invmassmin"
);
362
registerKinematicsParameter<double>(
"MSMX"
,
"Maximal central system mass"
,
"invmassmax"
);
363
registerKinematicsParameter<double>(
"ECUT"
,
"Minimal energy (single central outgoing particle)"
,
"energysummin"
);
364
registerKinematicsParameter<double>(
"ETMN"
,
"Minimal pseudo-rapidity (central outgoing particles)"
,
"etamin"
);
365
registerKinematicsParameter<double>(
"ETMX"
,
"Maximal pseudo-rapidity (central outgoing particles)"
,
"etamax"
);
366
registerKinematicsParameter<double>(
"YMIN"
,
"Minimal rapidity (central outgoing particles)"
,
"rapiditymin"
);
367
registerKinematicsParameter<double>(
"YMAX"
,
"Maximal rapidity (central outgoing particles)"
,
"rapiditymax"
);
368
registerKinematicsParameter<double>(
369
"PDMN"
,
"Minimal transverse momentum difference (central outgoing particles)"
,
"ptdiffmin"
);
370
registerKinematicsParameter<double>(
371
"PDMX"
,
"Maximal transverse momentum difference (central outgoing particles)"
,
"ptdiffmax"
);
372
registerKinematicsParameter<double>(
"Q2MN"
,
"Minimal Q^2 = -q^2 (exchanged parton)"
,
"q2min"
);
373
registerKinematicsParameter<double>(
"Q2MX"
,
"Maximal Q^2 = -q^2 (exchanged parton)"
,
"q2max"
);
374
registerKinematicsParameter<double>(
"QTMN"
,
"Minimal Q_T (exchanged parton)"
,
"qtmin"
);
375
registerKinematicsParameter<double>(
"QTMX"
,
"Maximal Q_T (exchanged parton)"
,
"qtmax"
);
376
registerKinematicsParameter<double>(
"MXMN"
,
"Minimal invariant mass of proton remnants"
,
"mxmin"
);
377
registerKinematicsParameter<double>(
"MXMX"
,
"Maximal invariant mass of proton remnants"
,
"mxmax"
);
378
registerKinematicsParameter<double>(
"XIMN"
,
"Minimal fractional momentum loss of outgoing proton (xi)"
,
"ximin"
);
379
registerKinematicsParameter<double>(
"XIMX"
,
"Maximal fractional momentum loss of outgoing proton (xi)"
,
"ximax"
);
380
registerKinematicsParameter<double>(
"YJMN"
,
"Minimal remnant jet rapidity"
,
"yjmin"
);
381
registerKinematicsParameter<double>(
"YJMX"
,
"Maximal remnant jet rapidity"
,
"yjmax"
);
382
383
//-------------------------------------------------------------------------------------------
384
// PPtoLL cards backward compatibility
385
registerIntegratorParameter<int>(
"NTREAT"
,
"Smoothen the integrand"
,
"treat"
);
386
registerIntegratorParameter<int>(
"ITMX"
,
"Number of integration iterations"
,
"iterations"
);
387
registerIntegratorParameter<int>(
"NCVG"
,
"Number of function calls to perform"
,
"numFunctionCalls"
);
388
registerProcessParameter<int>(
"METHOD"
,
"Computation method (kT-factorisation)"
,
"method"
);
389
registerParameter<int>(
"LEPTON"
,
"Outgoing leptons' flavour"
, &lepton_id_);
390
registerKinematicsParameter<double>(
391
"PTMIN"
,
"Minimal transverse momentum (single central outgoing particle)"
,
"ptmin"
);
392
registerKinematicsParameter<double>(
393
"PTMAX"
,
"Maximal transverse momentum (single central outgoing particle)"
,
"ptmax"
);
394
registerKinematicsParameter<double>(
"Q1TMIN"
,
"Minimal Q_T (exchanged parton)"
,
"qtmin"
);
395
registerKinematicsParameter<double>(
"Q1TMAX"
,
"Maximal Q_T (exchanged parton)"
,
"qtmax"
);
396
registerKinematicsParameter<double>(
"Q2TMIN"
,
"Minimal Q_T (exchanged parton)"
,
"qtmin"
);
397
registerKinematicsParameter<double>(
"Q2TMAX"
,
"Maximal Q_T (exchanged parton)"
,
"qtmax"
);
398
registerKinematicsParameter<double>(
"MXMIN"
,
"Minimal invariant mass of proton remnants"
,
"mxmin"
);
399
registerKinematicsParameter<double>(
"MXMAX"
,
"Maximal invariant mass of proton remnants"
,
"mxmax"
);
400
}
401
402
LpairHandler
& LpairHandler::setRunParameters(
const
RunParameters* params) {
403
Handler::setRunParameters
(params);
404
const
auto
beam_mode =
runParameters
()->
kinematics
().
incomingBeams
().
mode
();
405
pmod_ = (beam_mode ==
mode::Kinematics::InelasticElastic
|| beam_mode ==
mode::Kinematics::InelasticInelastic
)
406
?
runParameters
()->
kinematics
().
incomingBeams
().
structureFunctions
().
name
()
407
: (std::abs(
runParameters
()->kinematics().incomingBeams().
positive
().integerPdgId()) ==
PDG::electron
408
?
"1"
409
:
"2"
);
410
emod_ = (beam_mode ==
mode::Kinematics::ElasticInelastic
|| beam_mode ==
mode::Kinematics::InelasticInelastic
)
411
?
runParameters
()->
kinematics
().
incomingBeams
().
structureFunctions
().
name
()
412
: (std::abs(
runParameters
()->kinematics().incomingBeams().negative().integerPdgId()) ==
PDG::electron
413
?
"1"
414
:
"2"
);
415
sr_type_ =
runParameters
()->
kinematics
().
incomingBeams
().
structureFunctions
().
get
<
int
>(
"sigmaRatio"
);
416
//kmr_grid_path_ = kmr::GluonGrid::get().path();
417
//mstw_grid_path_ =
418
//pdg_input_path_ =
419
iend_ = (int)
runParameters
()->
generation
().
enabled
();
420
log_level_ = (int)
utils::Logger::get
().
level
();
421
ext_log_ =
utils::Logger::get
().
extended
();
422
proc_name_ =
runParameters
()->
processName
();
423
proc_params_ +=
runParameters
()->
process
().
parameters
();
424
if
(proc_params_.has<ParticleProperties>(
"pair"
))
425
proc_params_.
set
<
int
>(
"pair"
, proc_params_.get<ParticleProperties>(
"pair"
).pdgid);
426
if
(proc_name_ ==
"pptoff"
|| proc_name_ ==
"pptoll"
/* legacy */
)
427
lepton_id_ = (
runParameters
()->
process
().
parameters
().
get
<
int
>(
"pair"
) -
PDG::electron
) / 2. + 1;
428
{
429
std::vector<std::string> evt_mod;
430
std::transform(
runParameters
()->eventModifiersSequence().begin(),
431
runParameters
()->eventModifiersSequence().end(),
432
std::back_inserter(evt_mod),
433
[](
const
auto
& mod) {
return
mod->name(); });
434
evt_mod_name_ =
utils::merge
(evt_mod,
","
);
435
}
436
{
437
std::vector<std::string> out_mod, out_mod_file;
438
for
(
const
auto
& out :
runParameters
()->eventExportersSequence()) {
439
out_mod.emplace_back(out->name());
440
out_mod_file.emplace_back(out->parameters().get<std::string>(
"filename"
));
441
}
442
out_mod_name_ =
utils::merge
(out_mod,
","
);
443
out_file_name_ =
utils::merge
(out_mod_file,
","
);
444
}
445
timer_ = (
runParameters
()->
timeKeeper
() !=
nullptr
);
446
447
int_params_ +=
runParameters
()->
integrator
();
448
gen_params_ +=
runParameters
()->
generation
().
parameters
();
449
init();
450
return
*
this
;
451
}
452
453
void
LpairHandler::setParameter(
const
std::string& key,
const
std::string& value) {
454
// particular case for the double as we cannot rely on casting exceptions
455
if
(value.find(
'.'
) != std::string::npos)
456
try
{
457
set<double>(key, std::stod(value));
458
return
;
459
}
catch
(
const
std::logic_error&) {
460
for
(
const
auto
& let : value)
461
if (isalpha(let) && let !=
'E'
&& let !=
'e'
) {
462
set<std::string>(key, value);
463
return
;
464
}
465
throw
CG_FATAL
(
"LpairHandler:setParameter"
)
466
<<
"Failed to parse a floating-point parameter \""
<< key <<
"\" → \""
<< value <<
"\"!"
;
467
}
468
try
{
469
set<int>(key, std::stoi(value));
470
}
catch
(
const
std::logic_error&) {
471
try
{
472
set<std::string>(key, value);
473
}
catch
(
const
std::logic_error&) {
474
throw
CG_FATAL
(
"LpairHandler:setParameter"
)
475
<<
"Failed to add the parameter \""
<< key <<
"\" → \""
<< value <<
"\"!"
;
476
}
477
}
478
}
479
}
// namespace card
480
}
// namespace cepgen
481
using
cepgen::card::LpairHandler
;
482
REGISTER_CARD_HANDLER
(
".card"
,
LpairHandler
);
CardsHandlerFactory.h
REGISTER_CARD_HANDLER
#define REGISTER_CARD_HANDLER(name, obj)
Add a cards handler definition to the list of handled parsers.
Definition
CardsHandlerFactory.h:25
EventExporterFactory.h
EventExporter.h
EventModifierFactory.h
EventModifier.h
Exception.h
CG_FATAL
#define CG_FATAL(mod)
Definition
Exception.h:61
CG_ERROR
#define CG_ERROR(mod)
Definition
Exception.h:60
Filesystem.h
Generator.h
GluonGrid.h
Handler.h
kInvalidStr
static constexpr const char * kInvalidStr
Definition
LpairHandler.cpp:45
REGISTER_LPAIR_CONTENT_TYPE
#define REGISTER_LPAIR_CONTENT_TYPE
Definition
LpairHandler.cpp:47
kInvalidDbl
static constexpr double kInvalidDbl
Definition
LpairHandler.cpp:44
kInvalidInt
static constexpr int kInvalidInt
Definition
LpairHandler.cpp:43
MCDFileParser.h
CG_WARNING
#define CG_WARNING(mod)
Definition
Message.h:228
CG_INFO
#define CG_INFO(mod)
Definition
Message.h:216
PDG.h
ProcessFactory.h
Process.h
RunParameters.h
String.h
StructureFunctionsFactory.h
TimeKeeper.h
cepgen::IncomingBeams::structureFunctions
const ParametersList & structureFunctions() const
Structure functions parameters.
Definition
IncomingBeams.h:43
cepgen::IncomingBeams::mode
mode::Kinematics mode() const
Type of kinematics to consider for the phase space.
Definition
IncomingBeams.cpp:204
cepgen::Kinematics::incomingBeams
IncomingBeams & incomingBeams()
Beam/primary particle kinematics.
Definition
Kinematics.h:36
cepgen::Limits::INVALID
static constexpr double INVALID
Invalid value placeholder (single-edged or invalid limits)
Definition
Limits.h:86
cepgen::NamedModule< Handler >::name
const std::string & name() const
Module unique indexing name.
Definition
NamedModule.h:42
cepgen::PDG::electron
@ electron
Definition
PDG.h:37
cepgen::PDG::proton
@ proton
Definition
PDG.h:50
cepgen::ParametersDescription
A description object for parameters collection.
Definition
ParametersDescription.h:26
cepgen::ParametersList
Definition
ParametersList.h:52
cepgen::ParametersList::name
std::string name(const std::string &def="") const
Retrieve the module name if any.
Definition
ParametersList.cpp:294
cepgen::ParametersList::empty
bool empty() const
Is the list empty?
Definition
ParametersList.cpp:249
cepgen::ParametersList::get
T get(const std::string &key, const T &def=default_arg< T >::get()) const
Get a parameter value.
Definition
ParametersList.cpp:391
cepgen::ParametersList::set
ParametersList & set(const std::string &, const T &)
Set a parameter value Set a recast parameter value.
Definition
ParametersList.cpp:401
cepgen::RunParameters::Generation::enabled
bool enabled() const
Are we generating events?
Definition
RunParameters.h:92
cepgen::RunParameters
List of parameters used to start and run the simulation job.
Definition
RunParameters.h:41
cepgen::RunParameters::kinematics
const Kinematics & kinematics() const
Events kinematics for phase space definition.
Definition
RunParameters.cpp:125
cepgen::RunParameters::process
proc::Process & process()
Process object for cross-section computation/events generation.
Definition
RunParameters.cpp:105
cepgen::RunParameters::timeKeeper
utils::TimeKeeper * timeKeeper()
Pointer to a timekeeper instance.
Definition
RunParameters.h:55
cepgen::RunParameters::setProcess
void setProcess(std::unique_ptr< proc::Process >)
Set a process configuration.
Definition
RunParameters.cpp:117
cepgen::RunParameters::processName
std::string processName() const
Name of the process considered.
Definition
RunParameters.cpp:109
cepgen::RunParameters::integrator
ParametersList & integrator()
Integrator specific user-defined parameters.
Definition
RunParameters.h:60
cepgen::RunParameters::addEventExporter
void addEventExporter(std::unique_ptr< EventExporter >)
Set a new output module definition.
Definition
RunParameters.cpp:145
cepgen::RunParameters::setTimeKeeper
void setTimeKeeper(utils::TimeKeeper *)
Initialise the timekeeper instance.
Definition
RunParameters.cpp:98
cepgen::RunParameters::generation
Generation & generation()
Event generation parameters.
Definition
RunParameters.h:108
cepgen::SteeredObject::setParameters
virtual void setParameters(const ParametersList ¶ms) override
Set module parameters.
Definition
SteeredObject.h:62
cepgen::SteeredObject::parameters
const ParametersList & parameters() const override
Module user-defined parameters.
Definition
SteeredObject.h:54
cepgen::card::Handler
Base steering card module.
Definition
Handler.h:31
cepgen::card::Handler::setRunParameters
virtual Handler & setRunParameters(const RunParameters *)
Specify runtime parameters.
Definition
Handler.cpp:31
cepgen::card::Handler::runParameters
const RunParameters * runParameters() const
Parsed runtime parameters.
Definition
Handler.h:45
cepgen::card::Handler::description
static ParametersDescription description()
Definition
Handler.cpp:36
cepgen::card::LpairHandler
LPAIR-like steering cards parser and writer.
Definition
LpairHandler.cpp:56
cepgen::card::LpairHandler::write
void write(const std::string &filename) const override
Store a configuration into a LPAIR steering card.
Definition
LpairHandler.cpp:101
cepgen::card::LpairHandler::parseCommands
LpairHandler & parseCommands(const std::vector< std::string > &commands) override
Read configuration from command strings.
Definition
LpairHandler.cpp:76
cepgen::card::LpairHandler::description
static ParametersDescription description()
Definition
LpairHandler.cpp:61
cepgen::card::LpairHandler::parseFile
LpairHandler & parseFile(const std::string &filename) override
Read configuration from steering card.
Definition
LpairHandler.cpp:67
cepgen::card::LpairHandler::LpairHandler
LpairHandler(const ParametersList ¶ms)
Read a LPAIR steering card.
Definition
LpairHandler.cpp:59
cepgen::utils::Logger::Level
Level
Logging threshold for the output stream.
Definition
Logger.h:44
cepgen::utils::Logger::get
static Logger & get(std::ostream *=nullptr)
Retrieve the running instance of the logger.
Definition
Logger.cpp:31
cepgen::utils::Logger::extended
bool extended() const
Also show extended information?
Definition
Logger.h:54
cepgen::utils::Logger::setLevel
void setLevel(Level level)
Set the logging threshold.
Definition
Logger.h:52
cepgen::utils::Logger::level
Level level() const
Logging threshold.
Definition
Logger.h:50
cepgen::utils::Logger::setExtended
void setExtended(bool ext=true)
Set the extended information flag.
Definition
Logger.h:56
cepgen::utils::TimeKeeper
Collection of clocks to benchmark execution blocks.
Definition
TimeKeeper.h:35
kmr::GluonGrid::get
static GluonGrid & get(const cepgen::ParametersList ¶ms={})
Retrieve the grid interpolator (singleton)
Definition
GluonGrid.cpp:27
pdg::MCDFileParser::parse
static void parse(const std::string &path)
Parse an external MCD file and retrieve all particles definition.
Definition
MCDFileParser.cpp:32
cepgen::mode::Kinematics
Kinematics
Type of scattering.
Definition
Modes.h:28
cepgen::mode::Kinematics::ElasticElastic
@ ElasticElastic
proton-proton elastic case
cepgen::mode::Kinematics::InelasticElastic
@ InelasticElastic
proton-proton single-dissociative (or elastic-inelastic) case
cepgen::mode::Kinematics::InelasticInelastic
@ InelasticInelastic
proton-proton double-dissociative case
cepgen::mode::Kinematics::ElasticInelastic
@ ElasticInelastic
proton-proton single-dissociative (or inelastic-elastic) case
cepgen::utils::format
std::string format(const std::string &fmt, Args... args)
Format a string using a printf style format descriptor.
Definition
String.h:61
cepgen::utils::trim
std::string trim(const std::string &str)
Trim leading and trailing spaces.
Definition
String.h:174
cepgen::utils::readFile
std::string readFile(const std::string &filename)
Read the content of a file into a string buffer.
Definition
Filesystem.cpp:31
cepgen::utils::positive
bool positive(const T &val)
Check if a number is positive and finite.
Definition
Math.cpp:26
cepgen::utils::fileExists
bool fileExists(const std::string &path)
Check if the file exists.
Definition
Filesystem.cpp:27
cepgen::utils::merge
std::string merge(const std::vector< T > &vec, const std::string &delim)
Merge a collection of a printable type in a single string.
Definition
String.cpp:248
cepgen::utils::split
std::vector< std::string > split(const std::string &str, char delim, bool trim)
Split a string according to a separation character.
Definition
String.cpp:233
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
cepgen::loadLibrary
bool loadLibrary(const std::string &path, bool match)
Import a shared library in RTE Launch the initialisation procedure.
Definition
GlobalFunctions.cpp:42
cepgen::MODULE_NAME
const char *const MODULE_NAME
Indexing key for the module name Parameters container.
Definition
ParametersList.h:50
python.Config.collinearProcess_cfi.process
process
Definition
collinearProcess_cfi.py:13
CepGen
Cards
LpairHandler.cpp
Generated on Mon Jul 29 2024 for CepGen by
1.9.7