EvtGen 2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Loading...
Searching...
No Matches
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
22
24
25#ifdef EVTGEN_PYTHIA
27#endif
28
29#ifdef EVTGEN_TAUOLA
31#endif
32
33#include <iostream>
34using std::endl;
35
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
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
69void EvtExternalGenFactory::definePythiaGenerator( std::string, bool, bool )
70{
71}
72#endif
73
74#ifdef EVTGEN_TAUOLA
76 bool seedTauolaFortran )
77{
78 EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Defining EvtTauolaEngine." << endl;
79
81 std::make_unique<EvtTauolaEngine>( useEvtGenRandom, seedTauolaFortran );
82}
83#else
85{
86}
87#endif
88
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
107{
108 for ( auto& [id, theGenerator] : m_extGenMap ) {
109 if ( theGenerator ) {
110 theGenerator->initialise();
111 }
112 }
113}
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition EvtReport.cpp:32
@ EVTGEN_INFO
Definition EvtReport.hh:52
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
static EvtExternalGenFactory & getInstance()
EvtExternalGenFactory()=default
EvtAbsExternalGen * getGenerator(const GenId genId)
void defineTauolaGenerator(bool useEvtGenRandom=true, bool seedTauolaFortran=true)
void definePythiaGenerator(std::string xmlDir, bool convertPhysCodes, bool useEvtGenRandom=true)