EvtGen
2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Toggle main menu visibility
Loading...
Searching...
No Matches
src
EvtGenExternal
EvtExternalGenFactory.cpp
Go to the documentation of this file.
1
2
/***********************************************************************
3
* Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4
* *
5
* This file is part of EvtGen. *
6
* *
7
* EvtGen is free software: you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation, either version 3 of the License, or *
10
* (at your option) any later version. *
11
* *
12
* EvtGen is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19
***********************************************************************/
20
21
#include "
EvtGenExternal/EvtExternalGenFactory.hh
"
22
23
#include "
EvtGenBase/EvtReport.hh
"
24
25
#ifdef EVTGEN_PYTHIA
26
#include "
EvtGenExternal/EvtPythiaEngine.hh
"
27
#endif
28
29
#ifdef EVTGEN_TAUOLA
30
#include "
EvtGenExternal/EvtTauolaEngine.hh
"
31
#endif
32
33
#include <iostream>
34
using
std::endl;
35
36
EvtExternalGenFactory
&
EvtExternalGenFactory::getInstance
()
37
{
38
static
thread_local
EvtExternalGenFactory
theFactory;
39
40
return
theFactory;
41
}
42
43
// Only define the generator if we have the external ifdef variable set
44
#ifdef EVTGEN_PYTHIA
45
void
EvtExternalGenFactory::definePythiaGenerator
( std::string xmlDir,
46
bool
convertPhysCodes,
47
bool
useEvtGenRandom )
48
{
49
EvtGenReport
(
EVTGEN_INFO
,
"EvtGen"
)
50
<<
"Defining EvtPythiaEngine: data tables defined in "
<< xmlDir << endl;
51
if
( convertPhysCodes ==
true
) {
52
EvtGenReport
(
EVTGEN_INFO
,
"EvtGen"
)
53
<<
"Pythia 6 codes in decay files will be converted to Pythia 8 codes"
54
<< endl;
55
}
else
{
56
EvtGenReport
(
EVTGEN_INFO
,
"EvtGen"
)
57
<<
"Pythia 8 codes need to be used in decay files"
<< endl;
58
}
59
60
if
( useEvtGenRandom ==
true
) {
61
EvtGenReport
(
EVTGEN_INFO
,
"EvtGen"
)
62
<<
"Using EvtGen random engine for Pythia 8 as well"
<< endl;
63
}
64
65
m_extGenMap
[
GenId::PythiaGenId
] = std::make_unique<EvtPythiaEngine>(
66
xmlDir, convertPhysCodes, useEvtGenRandom );
67
}
68
#else
69
void
EvtExternalGenFactory::definePythiaGenerator
( std::string,
bool
,
bool
)
70
{
71
}
72
#endif
73
74
#ifdef EVTGEN_TAUOLA
75
void
EvtExternalGenFactory::defineTauolaGenerator
(
bool
useEvtGenRandom,
76
bool
seedTauolaFortran )
77
{
78
EvtGenReport
(
EVTGEN_INFO
,
"EvtGen"
) <<
"Defining EvtTauolaEngine."
<< endl;
79
80
m_extGenMap
[
GenId::TauolaGenId
] =
81
std::make_unique<EvtTauolaEngine>( useEvtGenRandom, seedTauolaFortran );
82
}
83
#else
84
void
EvtExternalGenFactory::defineTauolaGenerator
(
bool
,
bool
)
85
{
86
}
87
#endif
88
89
EvtAbsExternalGen
*
EvtExternalGenFactory::getGenerator
(
const
GenId
genId )
90
{
91
ExtGenMap::iterator
iter
=
m_extGenMap
.find( genId );
92
93
if
(
iter
==
m_extGenMap
.end() ) {
94
EvtGenReport
(
EVTGEN_INFO
,
"EvtGen"
)
95
<<
"EvtAbsExternalGen::getGenerator: could not find generator for genId = "
96
//FIXME C++23 use std::to_underlying
97
<<
static_cast<
std::underlying_type_t<GenId>
>
( genId ) << endl;
98
return
nullptr
;
99
}
100
101
// Retrieve the external generator engine
102
auto
& theGenerator =
iter
->second;
103
return
theGenerator.get();
104
}
105
106
void
EvtExternalGenFactory::initialiseAllGenerators
()
107
{
108
for
(
auto
& [
id
, theGenerator] :
m_extGenMap
) {
109
if
( theGenerator ) {
110
theGenerator->initialise();
111
}
112
}
113
}
EvtExternalGenFactory.hh
EvtPythiaEngine.hh
EvtReport.hh
EvtGenReport
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition
EvtReport.cpp:32
EVTGEN_INFO
@ EVTGEN_INFO
Definition
EvtReport.hh:52
iter
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
Definition
EvtStreamInputIterator.hh:109
EvtTauolaEngine.hh
EvtAbsExternalGen
Definition
EvtAbsExternalGen.hh:28
EvtExternalGenFactory::getInstance
static EvtExternalGenFactory & getInstance()
Definition
EvtExternalGenFactory.cpp:36
EvtExternalGenFactory::EvtExternalGenFactory
EvtExternalGenFactory()=default
EvtExternalGenFactory::getGenerator
EvtAbsExternalGen * getGenerator(const GenId genId)
Definition
EvtExternalGenFactory.cpp:89
EvtExternalGenFactory::initialiseAllGenerators
void initialiseAllGenerators()
Definition
EvtExternalGenFactory.cpp:106
EvtExternalGenFactory::defineTauolaGenerator
void defineTauolaGenerator(bool useEvtGenRandom=true, bool seedTauolaFortran=true)
Definition
EvtExternalGenFactory.cpp:75
EvtExternalGenFactory::GenId
GenId
Definition
EvtExternalGenFactory.hh:35
EvtExternalGenFactory::GenId::TauolaGenId
@ TauolaGenId
Definition
EvtExternalGenFactory.hh:37
EvtExternalGenFactory::GenId::PythiaGenId
@ PythiaGenId
Definition
EvtExternalGenFactory.hh:36
EvtExternalGenFactory::m_extGenMap
ExtGenMap m_extGenMap
Definition
EvtExternalGenFactory.hh:66
EvtExternalGenFactory::definePythiaGenerator
void definePythiaGenerator(std::string xmlDir, bool convertPhysCodes, bool useEvtGenRandom=true)
Definition
EvtExternalGenFactory.cpp:45
Generated by
1.17.0