1 //--------------------------------------------------------------------------
4 // This software is part of the EvtGen package. If you use all or part
5 // of it, please give an appropriate acknowledgement.
7 // Copyright Information: See EvtGen/COPYRIGHT
8 // Copyright (C) 2011 University of Warwick, UK
10 // Module: EvtExternalGenFactory
12 // Description: A factory type method to create engines for external physics
13 // generators like Pythia.
15 // Modification history:
17 // John Back April 2011 Module created
19 //------------------------------------------------------------------------------
22 #include "EvtGenBase/EvtPatches.hh"
23 #include "EvtGenBase/EvtReport.hh"
24 #include "EvtGenExternal/EvtExternalGenFactory.hh"
27 #include "EvtGenExternal/EvtPythiaEngine.hh"
31 #include "EvtGenExternal/EvtPhotosEngine.hh"
35 #include "EvtGenExternal/EvtTauolaEngine.hh"
41 EvtExternalGenFactory::EvtExternalGenFactory() {
47 EvtExternalGenFactory::~EvtExternalGenFactory() {
49 ExtGenMap::iterator iter;
50 for (iter = _extGenMap.begin(); iter != _extGenMap.end(); ++iter) {
52 EvtAbsExternalGen* theGenerator = iter->second;
61 EvtExternalGenFactory* EvtExternalGenFactory::getInstance() {
63 static EvtExternalGenFactory* theFactory = 0;
65 if (theFactory == 0) {
66 theFactory = new EvtExternalGenFactory();
73 void EvtExternalGenFactory::definePythiaGenerator(std::string xmlDir,
74 bool convertPhysCodes,
75 bool useEvtGenRandom) {
77 // Only define the generator if we have the external ifdef variable set
80 int genId = EvtExternalGenFactory::PythiaGenId;
82 report(INFO,"EvtGen")<<"Defining EvtPythiaEngine: data tables defined in "
85 if (convertPhysCodes == true) {
86 report(INFO,"EvtGen")<<"Pythia 6 codes in decay files will be converted to Pythia 8 codes"<<endl;
88 report(INFO,"EvtGen")<<"Pythia 8 codes need to be used in decay files"<<endl;
91 if (useEvtGenRandom == true) {
92 report(INFO,"EvtGen")<<"Using EvtGen random engine for Pythia 8 as well"<<endl;
95 EvtAbsExternalGen* pythiaGenerator = new EvtPythiaEngine(xmlDir, convertPhysCodes, useEvtGenRandom);
96 _extGenMap[genId] = pythiaGenerator;
102 void EvtExternalGenFactory::definePhotosGenerator(std::string photonType, bool useEvtGenRandom) {
106 int genId = EvtExternalGenFactory::PhotosGenId;
107 report(INFO,"EvtGen")<<"Defining EvtPhotosEngine using photonType = "<<photonType<<endl;
108 EvtAbsExternalGen* photosGenerator = new EvtPhotosEngine(photonType, useEvtGenRandom);
109 _extGenMap[genId] = photosGenerator;
115 void EvtExternalGenFactory::defineTauolaGenerator(bool useEvtGenRandom) {
119 int genId = EvtExternalGenFactory::TauolaGenId;
120 report(INFO,"EvtGen")<<"Defining EvtTauolaEngine."<<endl;
121 EvtAbsExternalGen* tauolaGenerator = new EvtTauolaEngine(useEvtGenRandom);
122 _extGenMap[genId] = tauolaGenerator;
128 EvtAbsExternalGen* EvtExternalGenFactory::getGenerator(int genId) {
130 EvtAbsExternalGen* theGenerator(0);
132 ExtGenMap::iterator iter;
134 if ((iter = _extGenMap.find(genId)) != _extGenMap.end()) {
136 // Retrieve the external generator engine
137 theGenerator = iter->second;
145 void EvtExternalGenFactory::initialiseAllGenerators() {
147 ExtGenMap::iterator iter;
148 for (iter = _extGenMap.begin(); iter != _extGenMap.end(); ++iter) {
150 EvtAbsExternalGen* theGenerator = iter->second;
151 if (theGenerator != 0) {
152 theGenerator->initialise();