ATLAS Offline Software
EvtExternalGenFactory.cxx
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2022 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 "EvtGen_i/EvtGenExternal/EvtExternalGenFactory.hh"
22 
23 #include "EvtGenBase/EvtPatches.hh"
24 #include "EvtGenBase/EvtReport.hh"
25 
26 #include "EvtGen_i/EvtGenExternal/EvtPythiaEngine.hh"
27 
28 #include "EvtGen_i/EvtGenExternal/EvtPhotosEngine.hh"
29 
30 #include "EvtGen_i/EvtGenExternal/EvtTauolaEngine.hh"
31 
32 #include <iostream>
33 using std::endl;
34 
35 EvtExternalGenFactory::EvtExternalGenFactory()
36 {
37  m_extGenMap.clear();
38 }
39 
40 EvtExternalGenFactory::~EvtExternalGenFactory()
41 {
43  for ( iter = m_extGenMap.begin(); iter != m_extGenMap.end(); ++iter ) {
44  EvtAbsExternalGen* theGenerator = iter->second;
45  delete theGenerator;
46  }
47 
48  m_extGenMap.clear();
49 }
50 
51 const EvtExternalGenFactory* EvtExternalGenFactory::getInstance()
52 {
53  static const EvtExternalGenFactory theFactory;
54  return &theFactory;
55 }
56 
57 EvtExternalGenFactory* EvtExternalGenFactory::getInstance_mutable ATLAS_NOT_THREAD_SAFE ()
58 {
59  return const_cast<EvtExternalGenFactory*>(getInstance());
60 }
61 
62 void EvtExternalGenFactory::definePythiaGenerator( std::string xmlDir,
63  bool convertPhysCodes,
64  bool useEvtGenRandom )
65 {
66  int genId = EvtExternalGenFactory::PythiaGenId;
67 
68  EvtGenReport( EVTGEN_INFO, "EvtGen" )
69  << "Defining EvtPythiaEngine: data tables defined in " << xmlDir << endl;
70  if ( convertPhysCodes == true ) {
71  EvtGenReport( EVTGEN_INFO, "EvtGen" )
72  << "Pythia 6 codes in decay files will be converted to Pythia 8 codes"
73  << endl;
74  } else {
75  EvtGenReport( EVTGEN_INFO, "EvtGen" )
76  << "Pythia 8 codes need to be used in decay files" << endl;
77  }
78 
79  if ( useEvtGenRandom == true ) {
80  EvtGenReport( EVTGEN_INFO, "EvtGen" )
81  << "Using EvtGen random engine for Pythia 8 as well" << endl;
82  }
83 
84  EvtAbsExternalGen* pythiaGenerator =
85  new EvtPythiaEngine( xmlDir, convertPhysCodes, useEvtGenRandom );
86  m_extGenMap[genId] = pythiaGenerator;
87 }
88 
89 void EvtExternalGenFactory::definePhotosGenerator( std::string photonType,
90  bool useEvtGenRandom )
91 {
92  int genId = EvtExternalGenFactory::PhotosGenId;
93 
94  EvtGenReport( EVTGEN_INFO, "EvtGen" )
95  << "Defining EvtPhotosEngine using photonType = " << photonType << endl;
96 
97  EvtAbsExternalGen* photosGenerator = new EvtPhotosEngine( photonType,
98  useEvtGenRandom );
99  m_extGenMap[genId] = photosGenerator;
100 }
101 
102 
103 void EvtExternalGenFactory::defineTauolaGenerator( bool useEvtGenRandom )
104 {
105  int genId = EvtExternalGenFactory::TauolaGenId;
106 
107  EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Defining EvtTauolaEngine." << endl;
108 
109  EvtAbsExternalGen* tauolaGenerator = new EvtTauolaEngine( useEvtGenRandom );
110  m_extGenMap[genId] = tauolaGenerator;
111 }
112 
113 EvtAbsExternalGen* EvtExternalGenFactory::getGenerator( int genId ) const
114 {
115  EvtAbsExternalGen* theGenerator( 0 );
116 
117  ExtGenMap::const_iterator iter;
118 
119  if ( ( iter = m_extGenMap.find( genId ) ) != m_extGenMap.end() ) {
120  // Retrieve the external generator engine
121  theGenerator = iter->second;
122 
123  } else {
124  EvtGenReport( EVTGEN_INFO, "EvtGen" )
125  << "EvtAbsExternalGen::getGenerator: could not find generator for genId = "
126  << genId << endl;
127  }
128 
129  return theGenerator;
130 }
131 
132 void EvtExternalGenFactory::initialiseAllGenerators()
133 {
134  ExtGenMap::iterator iter;
135  for ( iter = m_extGenMap.begin(); iter != m_extGenMap.end(); ++iter ) {
136  EvtAbsExternalGen* theGenerator = iter->second;
137  if ( theGenerator != 0 ) {
138  theGenerator->initialise();
139  }
140  }
141 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
ATLAS_NOT_THREAD_SAFE
EvtExternalGenFactory *EvtExternalGenFactory::getInstance_mutable ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: EvtExternalGenFactory.cxx:57